babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561
  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. private static _ArrayBufferToBase64;
  1375. /**
  1376. * Loads an image as an HTMLImageElement.
  1377. * @param input url string, ArrayBuffer, or Blob to load
  1378. * @param onLoad callback called when the image successfully loads
  1379. * @param onError callback called when the image fails to load
  1380. * @param offlineProvider offline provider for caching
  1381. * @param mimeType optional mime type
  1382. * @returns the HTMLImageElement of the loaded image
  1383. */
  1384. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1385. /**
  1386. * Loads a file
  1387. * @param fileToLoad defines the file to load
  1388. * @param callback defines the callback to call when data is loaded
  1389. * @param progressCallBack defines the callback to call during loading process
  1390. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1391. * @returns a file request object
  1392. */
  1393. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1394. /**
  1395. * Loads a file
  1396. * @param url url string, ArrayBuffer, or Blob to load
  1397. * @param onSuccess callback called when the file successfully loads
  1398. * @param onProgress callback called while file is loading (if the server supports this mode)
  1399. * @param offlineProvider defines the offline provider for caching
  1400. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1401. * @param onError callback called when the file fails to load
  1402. * @returns a file request object
  1403. */
  1404. 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;
  1405. /**
  1406. * Checks if the loaded document was accessed via `file:`-Protocol.
  1407. * @returns boolean
  1408. */
  1409. static IsFileURL(): boolean;
  1410. }
  1411. }
  1412. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1413. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1414. /** @hidden */
  1415. export class ShaderProcessor {
  1416. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1417. private static _ProcessPrecision;
  1418. private static _ExtractOperation;
  1419. private static _BuildSubExpression;
  1420. private static _BuildExpression;
  1421. private static _MoveCursorWithinIf;
  1422. private static _MoveCursor;
  1423. private static _EvaluatePreProcessors;
  1424. private static _PreparePreProcessors;
  1425. private static _ProcessShaderConversion;
  1426. private static _ProcessIncludes;
  1427. }
  1428. }
  1429. declare module "babylonjs/Maths/math.like" {
  1430. import { float, int, DeepImmutable } from "babylonjs/types";
  1431. /**
  1432. * @hidden
  1433. */
  1434. export interface IColor4Like {
  1435. r: float;
  1436. g: float;
  1437. b: float;
  1438. a: float;
  1439. }
  1440. /**
  1441. * @hidden
  1442. */
  1443. export interface IColor3Like {
  1444. r: float;
  1445. g: float;
  1446. b: float;
  1447. }
  1448. /**
  1449. * @hidden
  1450. */
  1451. export interface IVector4Like {
  1452. x: float;
  1453. y: float;
  1454. z: float;
  1455. w: float;
  1456. }
  1457. /**
  1458. * @hidden
  1459. */
  1460. export interface IVector3Like {
  1461. x: float;
  1462. y: float;
  1463. z: float;
  1464. }
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IVector2Like {
  1469. x: float;
  1470. y: float;
  1471. }
  1472. /**
  1473. * @hidden
  1474. */
  1475. export interface IMatrixLike {
  1476. toArray(): DeepImmutable<Float32Array>;
  1477. updateFlag: int;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IViewportLike {
  1483. x: float;
  1484. y: float;
  1485. width: float;
  1486. height: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IPlaneLike {
  1492. normal: IVector3Like;
  1493. d: float;
  1494. normalize(): void;
  1495. }
  1496. }
  1497. declare module "babylonjs/Materials/iEffectFallbacks" {
  1498. import { Effect } from "babylonjs/Materials/effect";
  1499. /**
  1500. * Interface used to define common properties for effect fallbacks
  1501. */
  1502. export interface IEffectFallbacks {
  1503. /**
  1504. * Removes the defines that should be removed when falling back.
  1505. * @param currentDefines defines the current define statements for the shader.
  1506. * @param effect defines the current effect we try to compile
  1507. * @returns The resulting defines with defines of the current rank removed.
  1508. */
  1509. reduce(currentDefines: string, effect: Effect): string;
  1510. /**
  1511. * Removes the fallback from the bound mesh.
  1512. */
  1513. unBindMesh(): void;
  1514. /**
  1515. * Checks to see if more fallbacks are still availible.
  1516. */
  1517. hasMoreFallbacks: boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1521. /**
  1522. * Class used to evalaute queries containing `and` and `or` operators
  1523. */
  1524. export class AndOrNotEvaluator {
  1525. /**
  1526. * Evaluate a query
  1527. * @param query defines the query to evaluate
  1528. * @param evaluateCallback defines the callback used to filter result
  1529. * @returns true if the query matches
  1530. */
  1531. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1532. private static _HandleParenthesisContent;
  1533. private static _SimplifyNegation;
  1534. }
  1535. }
  1536. declare module "babylonjs/Misc/tags" {
  1537. /**
  1538. * Class used to store custom tags
  1539. */
  1540. export class Tags {
  1541. /**
  1542. * Adds support for tags on the given object
  1543. * @param obj defines the object to use
  1544. */
  1545. static EnableFor(obj: any): void;
  1546. /**
  1547. * Removes tags support
  1548. * @param obj defines the object to use
  1549. */
  1550. static DisableFor(obj: any): void;
  1551. /**
  1552. * Gets a boolean indicating if the given object has tags
  1553. * @param obj defines the object to use
  1554. * @returns a boolean
  1555. */
  1556. static HasTags(obj: any): boolean;
  1557. /**
  1558. * Gets the tags available on a given object
  1559. * @param obj defines the object to use
  1560. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1561. * @returns the tags
  1562. */
  1563. static GetTags(obj: any, asString?: boolean): any;
  1564. /**
  1565. * Adds tags to an object
  1566. * @param obj defines the object to use
  1567. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1568. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1569. */
  1570. static AddTagsTo(obj: any, tagsString: string): void;
  1571. /**
  1572. * @hidden
  1573. */
  1574. static _AddTagTo(obj: any, tag: string): void;
  1575. /**
  1576. * Removes specific tags from a specific object
  1577. * @param obj defines the object to use
  1578. * @param tagsString defines the tags to remove
  1579. */
  1580. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1581. /**
  1582. * @hidden
  1583. */
  1584. static _RemoveTagFrom(obj: any, tag: string): void;
  1585. /**
  1586. * Defines if tags hosted on an object match a given query
  1587. * @param obj defines the object to use
  1588. * @param tagsQuery defines the tag query
  1589. * @returns a boolean
  1590. */
  1591. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1592. }
  1593. }
  1594. declare module "babylonjs/Maths/math.scalar" {
  1595. /**
  1596. * Scalar computation library
  1597. */
  1598. export class Scalar {
  1599. /**
  1600. * Two pi constants convenient for computation.
  1601. */
  1602. static TwoPi: number;
  1603. /**
  1604. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1605. * @param a number
  1606. * @param b number
  1607. * @param epsilon (default = 1.401298E-45)
  1608. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1609. */
  1610. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1611. /**
  1612. * Returns a string : the upper case translation of the number i to hexadecimal.
  1613. * @param i number
  1614. * @returns the upper case translation of the number i to hexadecimal.
  1615. */
  1616. static ToHex(i: number): string;
  1617. /**
  1618. * Returns -1 if value is negative and +1 is value is positive.
  1619. * @param value the value
  1620. * @returns the value itself if it's equal to zero.
  1621. */
  1622. static Sign(value: number): number;
  1623. /**
  1624. * Returns the value itself if it's between min and max.
  1625. * Returns min if the value is lower than min.
  1626. * Returns max if the value is greater than max.
  1627. * @param value the value to clmap
  1628. * @param min the min value to clamp to (default: 0)
  1629. * @param max the max value to clamp to (default: 1)
  1630. * @returns the clamped value
  1631. */
  1632. static Clamp(value: number, min?: number, max?: number): number;
  1633. /**
  1634. * the log2 of value.
  1635. * @param value the value to compute log2 of
  1636. * @returns the log2 of value.
  1637. */
  1638. static Log2(value: number): number;
  1639. /**
  1640. * Loops the value, so that it is never larger than length and never smaller than 0.
  1641. *
  1642. * This is similar to the modulo operator but it works with floating point numbers.
  1643. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1644. * With t = 5 and length = 2.5, the result would be 0.0.
  1645. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1646. * @param value the value
  1647. * @param length the length
  1648. * @returns the looped value
  1649. */
  1650. static Repeat(value: number, length: number): number;
  1651. /**
  1652. * Normalize the value between 0.0 and 1.0 using min and max values
  1653. * @param value value to normalize
  1654. * @param min max to normalize between
  1655. * @param max min to normalize between
  1656. * @returns the normalized value
  1657. */
  1658. static Normalize(value: number, min: number, max: number): number;
  1659. /**
  1660. * Denormalize the value from 0.0 and 1.0 using min and max values
  1661. * @param normalized value to denormalize
  1662. * @param min max to denormalize between
  1663. * @param max min to denormalize between
  1664. * @returns the denormalized value
  1665. */
  1666. static Denormalize(normalized: number, min: number, max: number): number;
  1667. /**
  1668. * Calculates the shortest difference between two given angles given in degrees.
  1669. * @param current current angle in degrees
  1670. * @param target target angle in degrees
  1671. * @returns the delta
  1672. */
  1673. static DeltaAngle(current: number, target: number): number;
  1674. /**
  1675. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1676. * @param tx value
  1677. * @param length length
  1678. * @returns The returned value will move back and forth between 0 and length
  1679. */
  1680. static PingPong(tx: number, length: number): number;
  1681. /**
  1682. * Interpolates between min and max with smoothing at the limits.
  1683. *
  1684. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1685. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1686. * @param from from
  1687. * @param to to
  1688. * @param tx value
  1689. * @returns the smooth stepped value
  1690. */
  1691. static SmoothStep(from: number, to: number, tx: number): number;
  1692. /**
  1693. * Moves a value current towards target.
  1694. *
  1695. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1696. * Negative values of maxDelta pushes the value away from target.
  1697. * @param current current value
  1698. * @param target target value
  1699. * @param maxDelta max distance to move
  1700. * @returns resulting value
  1701. */
  1702. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1703. /**
  1704. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1705. *
  1706. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1707. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1708. * @param current current value
  1709. * @param target target value
  1710. * @param maxDelta max distance to move
  1711. * @returns resulting angle
  1712. */
  1713. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1714. /**
  1715. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1716. * @param start start value
  1717. * @param end target value
  1718. * @param amount amount to lerp between
  1719. * @returns the lerped value
  1720. */
  1721. static Lerp(start: number, end: number, amount: number): number;
  1722. /**
  1723. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1724. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1725. * @param start start value
  1726. * @param end target value
  1727. * @param amount amount to lerp between
  1728. * @returns the lerped value
  1729. */
  1730. static LerpAngle(start: number, end: number, amount: number): number;
  1731. /**
  1732. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1733. * @param a start value
  1734. * @param b target value
  1735. * @param value value between a and b
  1736. * @returns the inverseLerp value
  1737. */
  1738. static InverseLerp(a: number, b: number, value: number): number;
  1739. /**
  1740. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1741. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1742. * @param value1 spline value
  1743. * @param tangent1 spline value
  1744. * @param value2 spline value
  1745. * @param tangent2 spline value
  1746. * @param amount input value
  1747. * @returns hermite result
  1748. */
  1749. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1750. /**
  1751. * Returns a random float number between and min and max values
  1752. * @param min min value of random
  1753. * @param max max value of random
  1754. * @returns random value
  1755. */
  1756. static RandomRange(min: number, max: number): number;
  1757. /**
  1758. * This function returns percentage of a number in a given range.
  1759. *
  1760. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1761. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1762. * @param number to convert to percentage
  1763. * @param min min range
  1764. * @param max max range
  1765. * @returns the percentage
  1766. */
  1767. static RangeToPercent(number: number, min: number, max: number): number;
  1768. /**
  1769. * This function returns number that corresponds to the percentage in a given range.
  1770. *
  1771. * PercentToRange(0.34,0,100) will return 34.
  1772. * @param percent to convert to number
  1773. * @param min min range
  1774. * @param max max range
  1775. * @returns the number
  1776. */
  1777. static PercentToRange(percent: number, min: number, max: number): number;
  1778. /**
  1779. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1780. * @param angle The angle to normalize in radian.
  1781. * @return The converted angle.
  1782. */
  1783. static NormalizeRadians(angle: number): number;
  1784. }
  1785. }
  1786. declare module "babylonjs/Maths/math.constants" {
  1787. /**
  1788. * Constant used to convert a value to gamma space
  1789. * @ignorenaming
  1790. */
  1791. export const ToGammaSpace: number;
  1792. /**
  1793. * Constant used to convert a value to linear space
  1794. * @ignorenaming
  1795. */
  1796. export const ToLinearSpace = 2.2;
  1797. /**
  1798. * Constant used to define the minimal number value in Babylon.js
  1799. * @ignorenaming
  1800. */
  1801. let Epsilon: number;
  1802. export { Epsilon };
  1803. }
  1804. declare module "babylonjs/Maths/math.viewport" {
  1805. /**
  1806. * Class used to represent a viewport on screen
  1807. */
  1808. export class Viewport {
  1809. /** viewport left coordinate */
  1810. x: number;
  1811. /** viewport top coordinate */
  1812. y: number;
  1813. /**viewport width */
  1814. width: number;
  1815. /** viewport height */
  1816. height: number;
  1817. /**
  1818. * Creates a Viewport object located at (x, y) and sized (width, height)
  1819. * @param x defines viewport left coordinate
  1820. * @param y defines viewport top coordinate
  1821. * @param width defines the viewport width
  1822. * @param height defines the viewport height
  1823. */
  1824. constructor(
  1825. /** viewport left coordinate */
  1826. x: number,
  1827. /** viewport top coordinate */
  1828. y: number,
  1829. /**viewport width */
  1830. width: number,
  1831. /** viewport height */
  1832. height: number);
  1833. /**
  1834. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1835. * @param renderWidth defines the rendering width
  1836. * @param renderHeight defines the rendering height
  1837. * @returns a new Viewport
  1838. */
  1839. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1840. /**
  1841. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1842. * @param renderWidth defines the rendering width
  1843. * @param renderHeight defines the rendering height
  1844. * @param ref defines the target viewport
  1845. * @returns the current viewport
  1846. */
  1847. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1848. /**
  1849. * Returns a new Viewport copied from the current one
  1850. * @returns a new Viewport
  1851. */
  1852. clone(): Viewport;
  1853. }
  1854. }
  1855. declare module "babylonjs/Misc/arrayTools" {
  1856. /**
  1857. * Class containing a set of static utilities functions for arrays.
  1858. */
  1859. export class ArrayTools {
  1860. /**
  1861. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1862. * @param size the number of element to construct and put in the array
  1863. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1864. * @returns a new array filled with new objects
  1865. */
  1866. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1867. }
  1868. }
  1869. declare module "babylonjs/Maths/math.vector" {
  1870. import { Viewport } from "babylonjs/Maths/math.viewport";
  1871. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1872. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1873. /**
  1874. * Class representing a vector containing 2 coordinates
  1875. */
  1876. export class Vector2 {
  1877. /** defines the first coordinate */
  1878. x: number;
  1879. /** defines the second coordinate */
  1880. y: number;
  1881. /**
  1882. * Creates a new Vector2 from the given x and y coordinates
  1883. * @param x defines the first coordinate
  1884. * @param y defines the second coordinate
  1885. */
  1886. constructor(
  1887. /** defines the first coordinate */
  1888. x?: number,
  1889. /** defines the second coordinate */
  1890. y?: number);
  1891. /**
  1892. * Gets a string with the Vector2 coordinates
  1893. * @returns a string with the Vector2 coordinates
  1894. */
  1895. toString(): string;
  1896. /**
  1897. * Gets class name
  1898. * @returns the string "Vector2"
  1899. */
  1900. getClassName(): string;
  1901. /**
  1902. * Gets current vector hash code
  1903. * @returns the Vector2 hash code as a number
  1904. */
  1905. getHashCode(): number;
  1906. /**
  1907. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1908. * @param array defines the source array
  1909. * @param index defines the offset in source array
  1910. * @returns the current Vector2
  1911. */
  1912. toArray(array: FloatArray, index?: number): Vector2;
  1913. /**
  1914. * Copy the current vector to an array
  1915. * @returns a new array with 2 elements: the Vector2 coordinates.
  1916. */
  1917. asArray(): number[];
  1918. /**
  1919. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1920. * @param source defines the source Vector2
  1921. * @returns the current updated Vector2
  1922. */
  1923. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1924. /**
  1925. * Sets the Vector2 coordinates with the given floats
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. * @returns the current updated Vector2
  1929. */
  1930. copyFromFloats(x: number, y: number): Vector2;
  1931. /**
  1932. * Sets the Vector2 coordinates with the given floats
  1933. * @param x defines the first coordinate
  1934. * @param y defines the second coordinate
  1935. * @returns the current updated Vector2
  1936. */
  1937. set(x: number, y: number): Vector2;
  1938. /**
  1939. * Add another vector with the current one
  1940. * @param otherVector defines the other vector
  1941. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1942. */
  1943. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1944. /**
  1945. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1946. * @param otherVector defines the other vector
  1947. * @param result defines the target vector
  1948. * @returns the unmodified current Vector2
  1949. */
  1950. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1951. /**
  1952. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1953. * @param otherVector defines the other vector
  1954. * @returns the current updated Vector2
  1955. */
  1956. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1957. /**
  1958. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1959. * @param otherVector defines the other vector
  1960. * @returns a new Vector2
  1961. */
  1962. addVector3(otherVector: Vector3): Vector2;
  1963. /**
  1964. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2
  1967. */
  1968. subtract(otherVector: Vector2): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Multiplies in place the current Vector2 coordinates by the given ones
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1994. /**
  1995. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns a new Vector2
  2006. */
  2007. multiplyByFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns a new Vector2
  2012. */
  2013. divide(otherVector: Vector2): Vector2;
  2014. /**
  2015. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2016. * @param otherVector defines the other vector
  2017. * @param result defines the target vector
  2018. * @returns the unmodified current Vector2
  2019. */
  2020. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2021. /**
  2022. * Divides the current Vector2 coordinates by the given ones
  2023. * @param otherVector defines the other vector
  2024. * @returns the current updated Vector2
  2025. */
  2026. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2027. /**
  2028. * Gets a new Vector2 with current Vector2 negated coordinates
  2029. * @returns a new Vector2
  2030. */
  2031. negate(): Vector2;
  2032. /**
  2033. * Multiply the Vector2 coordinates by scale
  2034. * @param scale defines the scaling factor
  2035. * @returns the current updated Vector2
  2036. */
  2037. scaleInPlace(scale: number): Vector2;
  2038. /**
  2039. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2040. * @param scale defines the scaling factor
  2041. * @returns a new Vector2
  2042. */
  2043. scale(scale: number): Vector2;
  2044. /**
  2045. * Scale the current Vector2 values by a factor to a given Vector2
  2046. * @param scale defines the scale factor
  2047. * @param result defines the Vector2 object where to store the result
  2048. * @returns the unmodified current Vector2
  2049. */
  2050. scaleToRef(scale: number, result: Vector2): Vector2;
  2051. /**
  2052. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2053. * @param scale defines the scale factor
  2054. * @param result defines the Vector2 object where to store the result
  2055. * @returns the unmodified current Vector2
  2056. */
  2057. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2058. /**
  2059. * Gets a boolean if two vectors are equals
  2060. * @param otherVector defines the other vector
  2061. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2062. */
  2063. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2064. /**
  2065. * Gets a boolean if two vectors are equals (using an epsilon value)
  2066. * @param otherVector defines the other vector
  2067. * @param epsilon defines the minimal distance to consider equality
  2068. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2069. */
  2070. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2071. /**
  2072. * Gets a new Vector2 from current Vector2 floored values
  2073. * @returns a new Vector2
  2074. */
  2075. floor(): Vector2;
  2076. /**
  2077. * Gets a new Vector2 from current Vector2 floored values
  2078. * @returns a new Vector2
  2079. */
  2080. fract(): Vector2;
  2081. /**
  2082. * Gets the length of the vector
  2083. * @returns the vector length (float)
  2084. */
  2085. length(): number;
  2086. /**
  2087. * Gets the vector squared length
  2088. * @returns the vector squared length (float)
  2089. */
  2090. lengthSquared(): number;
  2091. /**
  2092. * Normalize the vector
  2093. * @returns the current updated Vector2
  2094. */
  2095. normalize(): Vector2;
  2096. /**
  2097. * Gets a new Vector2 copied from the Vector2
  2098. * @returns a new Vector2
  2099. */
  2100. clone(): Vector2;
  2101. /**
  2102. * Gets a new Vector2(0, 0)
  2103. * @returns a new Vector2
  2104. */
  2105. static Zero(): Vector2;
  2106. /**
  2107. * Gets a new Vector2(1, 1)
  2108. * @returns a new Vector2
  2109. */
  2110. static One(): Vector2;
  2111. /**
  2112. * Gets a new Vector2 set from the given index element of the given array
  2113. * @param array defines the data source
  2114. * @param offset defines the offset in the data source
  2115. * @returns a new Vector2
  2116. */
  2117. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2118. /**
  2119. * Sets "result" from the given index element of the given array
  2120. * @param array defines the data source
  2121. * @param offset defines the offset in the data source
  2122. * @param result defines the target vector
  2123. */
  2124. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2125. /**
  2126. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2127. * @param value1 defines 1st point of control
  2128. * @param value2 defines 2nd point of control
  2129. * @param value3 defines 3rd point of control
  2130. * @param value4 defines 4th point of control
  2131. * @param amount defines the interpolation factor
  2132. * @returns a new Vector2
  2133. */
  2134. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2135. /**
  2136. * 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".
  2137. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2138. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2139. * @param value defines the value to clamp
  2140. * @param min defines the lower limit
  2141. * @param max defines the upper limit
  2142. * @returns a new Vector2
  2143. */
  2144. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2145. /**
  2146. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2147. * @param value1 defines the 1st control point
  2148. * @param tangent1 defines the outgoing tangent
  2149. * @param value2 defines the 2nd control point
  2150. * @param tangent2 defines the incoming tangent
  2151. * @param amount defines the interpolation factor
  2152. * @returns a new Vector2
  2153. */
  2154. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2155. /**
  2156. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2157. * @param start defines the start vector
  2158. * @param end defines the end vector
  2159. * @param amount defines the interpolation factor
  2160. * @returns a new Vector2
  2161. */
  2162. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2163. /**
  2164. * Gets the dot product of the vector "left" and the vector "right"
  2165. * @param left defines first vector
  2166. * @param right defines second vector
  2167. * @returns the dot product (float)
  2168. */
  2169. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2170. /**
  2171. * Returns a new Vector2 equal to the normalized given vector
  2172. * @param vector defines the vector to normalize
  2173. * @returns a new Vector2
  2174. */
  2175. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2178. * @param left defines 1st vector
  2179. * @param right defines 2nd vector
  2180. * @returns a new Vector2
  2181. */
  2182. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2185. * @param left defines 1st vector
  2186. * @param right defines 2nd vector
  2187. * @returns a new Vector2
  2188. */
  2189. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2192. * @param vector defines the vector to transform
  2193. * @param transformation defines the matrix to apply
  2194. * @returns a new Vector2
  2195. */
  2196. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2197. /**
  2198. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2199. * @param vector defines the vector to transform
  2200. * @param transformation defines the matrix to apply
  2201. * @param result defines the target vector
  2202. */
  2203. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2204. /**
  2205. * Determines if a given vector is included in a triangle
  2206. * @param p defines the vector to test
  2207. * @param p0 defines 1st triangle point
  2208. * @param p1 defines 2nd triangle point
  2209. * @param p2 defines 3rd triangle point
  2210. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2211. */
  2212. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2213. /**
  2214. * Gets the distance between the vectors "value1" and "value2"
  2215. * @param value1 defines first vector
  2216. * @param value2 defines second vector
  2217. * @returns the distance between vectors
  2218. */
  2219. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2220. /**
  2221. * Returns the squared distance between the vectors "value1" and "value2"
  2222. * @param value1 defines first vector
  2223. * @param value2 defines second vector
  2224. * @returns the squared distance between vectors
  2225. */
  2226. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2227. /**
  2228. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2229. * @param value1 defines first vector
  2230. * @param value2 defines second vector
  2231. * @returns a new Vector2
  2232. */
  2233. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2236. * @param p defines the middle point
  2237. * @param segA defines one point of the segment
  2238. * @param segB defines the other point of the segment
  2239. * @returns the shortest distance
  2240. */
  2241. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2242. }
  2243. /**
  2244. * Classed used to store (x,y,z) vector representation
  2245. * A Vector3 is the main object used in 3D geometry
  2246. * It can represent etiher the coordinates of a point the space, either a direction
  2247. * Reminder: js uses a left handed forward facing system
  2248. */
  2249. export class Vector3 {
  2250. /**
  2251. * Defines the first coordinates (on X axis)
  2252. */
  2253. x: number;
  2254. /**
  2255. * Defines the second coordinates (on Y axis)
  2256. */
  2257. y: number;
  2258. /**
  2259. * Defines the third coordinates (on Z axis)
  2260. */
  2261. z: number;
  2262. private static _UpReadOnly;
  2263. private static _ZeroReadOnly;
  2264. /**
  2265. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2266. * @param x defines the first coordinates (on X axis)
  2267. * @param y defines the second coordinates (on Y axis)
  2268. * @param z defines the third coordinates (on Z axis)
  2269. */
  2270. constructor(
  2271. /**
  2272. * Defines the first coordinates (on X axis)
  2273. */
  2274. x?: number,
  2275. /**
  2276. * Defines the second coordinates (on Y axis)
  2277. */
  2278. y?: number,
  2279. /**
  2280. * Defines the third coordinates (on Z axis)
  2281. */
  2282. z?: number);
  2283. /**
  2284. * Creates a string representation of the Vector3
  2285. * @returns a string with the Vector3 coordinates.
  2286. */
  2287. toString(): string;
  2288. /**
  2289. * Gets the class name
  2290. * @returns the string "Vector3"
  2291. */
  2292. getClassName(): string;
  2293. /**
  2294. * Creates the Vector3 hash code
  2295. * @returns a number which tends to be unique between Vector3 instances
  2296. */
  2297. getHashCode(): number;
  2298. /**
  2299. * Creates an array containing three elements : the coordinates of the Vector3
  2300. * @returns a new array of numbers
  2301. */
  2302. asArray(): number[];
  2303. /**
  2304. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2305. * @param array defines the destination array
  2306. * @param index defines the offset in the destination array
  2307. * @returns the current Vector3
  2308. */
  2309. toArray(array: FloatArray, index?: number): Vector3;
  2310. /**
  2311. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2312. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2313. */
  2314. toQuaternion(): Quaternion;
  2315. /**
  2316. * Adds the given vector to the current Vector3
  2317. * @param otherVector defines the second operand
  2318. * @returns the current updated Vector3
  2319. */
  2320. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2321. /**
  2322. * Adds the given coordinates to the current Vector3
  2323. * @param x defines the x coordinate of the operand
  2324. * @param y defines the y coordinate of the operand
  2325. * @param z defines the z coordinate of the operand
  2326. * @returns the current updated Vector3
  2327. */
  2328. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2329. /**
  2330. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2331. * @param otherVector defines the second operand
  2332. * @returns the resulting Vector3
  2333. */
  2334. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2335. /**
  2336. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2337. * @param otherVector defines the second operand
  2338. * @param result defines the Vector3 object where to store the result
  2339. * @returns the current Vector3
  2340. */
  2341. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2342. /**
  2343. * Subtract the given vector from the current Vector3
  2344. * @param otherVector defines the second operand
  2345. * @returns the current updated Vector3
  2346. */
  2347. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2348. /**
  2349. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2350. * @param otherVector defines the second operand
  2351. * @returns the resulting Vector3
  2352. */
  2353. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2356. * @param otherVector defines the second operand
  2357. * @param result defines the Vector3 object where to store the result
  2358. * @returns the current Vector3
  2359. */
  2360. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2361. /**
  2362. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the resulting Vector3
  2367. */
  2368. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2371. * @param x defines the x coordinate of the operand
  2372. * @param y defines the y coordinate of the operand
  2373. * @param z defines the z coordinate of the operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2378. /**
  2379. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2380. * @returns a new Vector3
  2381. */
  2382. negate(): Vector3;
  2383. /**
  2384. * Multiplies the Vector3 coordinates by the float "scale"
  2385. * @param scale defines the multiplier factor
  2386. * @returns the current updated Vector3
  2387. */
  2388. scaleInPlace(scale: number): Vector3;
  2389. /**
  2390. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2391. * @param scale defines the multiplier factor
  2392. * @returns a new Vector3
  2393. */
  2394. scale(scale: number): Vector3;
  2395. /**
  2396. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2397. * @param scale defines the multiplier factor
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. scaleToRef(scale: number, result: Vector3): Vector3;
  2402. /**
  2403. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2404. * @param scale defines the scale factor
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the unmodified current Vector3
  2407. */
  2408. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2409. /**
  2410. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2411. * @param otherVector defines the second operand
  2412. * @returns true if both vectors are equals
  2413. */
  2414. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2415. /**
  2416. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2417. * @param otherVector defines the second operand
  2418. * @param epsilon defines the minimal distance to define values as equals
  2419. * @returns true if both vectors are distant less than epsilon
  2420. */
  2421. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2422. /**
  2423. * Returns true if the current Vector3 coordinates equals the given floats
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns true if both vectors are equals
  2428. */
  2429. equalsToFloats(x: number, y: number, z: number): boolean;
  2430. /**
  2431. * Multiplies the current Vector3 coordinates by the given ones
  2432. * @param otherVector defines the second operand
  2433. * @returns the current updated Vector3
  2434. */
  2435. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2436. /**
  2437. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2438. * @param otherVector defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2444. * @param otherVector defines the second operand
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2449. /**
  2450. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the new Vector3
  2455. */
  2456. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2459. * @param otherVector defines the second operand
  2460. * @returns the new Vector3
  2461. */
  2462. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2463. /**
  2464. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2465. * @param otherVector defines the second operand
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2470. /**
  2471. * Divides the current Vector3 coordinates by the given ones.
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. divideInPlace(otherVector: Vector3): Vector3;
  2476. /**
  2477. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2478. * @param other defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2484. * @param other defines the second operand
  2485. * @returns the current updated Vector3
  2486. */
  2487. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2490. * @param x defines the x coordinate of the operand
  2491. * @param y defines the y coordinate of the operand
  2492. * @param z defines the z coordinate of the operand
  2493. * @returns the current updated Vector3
  2494. */
  2495. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2496. /**
  2497. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2506. * Check if is non uniform within a certain amount of decimal places to account for this
  2507. * @param epsilon the amount the values can differ
  2508. * @returns if the the vector is non uniform to a certain number of decimal places
  2509. */
  2510. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2511. /**
  2512. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2513. */
  2514. readonly isNonUniform: boolean;
  2515. /**
  2516. * Gets a new Vector3 from current Vector3 floored values
  2517. * @returns a new Vector3
  2518. */
  2519. floor(): Vector3;
  2520. /**
  2521. * Gets a new Vector3 from current Vector3 floored values
  2522. * @returns a new Vector3
  2523. */
  2524. fract(): Vector3;
  2525. /**
  2526. * Gets the length of the Vector3
  2527. * @returns the length of the Vector3
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Gets the squared length of the Vector3
  2532. * @returns squared length of the Vector3
  2533. */
  2534. lengthSquared(): number;
  2535. /**
  2536. * Normalize the current Vector3.
  2537. * Please note that this is an in place operation.
  2538. * @returns the current updated Vector3
  2539. */
  2540. normalize(): Vector3;
  2541. /**
  2542. * Reorders the x y z properties of the vector in place
  2543. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2544. * @returns the current updated vector
  2545. */
  2546. reorderInPlace(order: string): this;
  2547. /**
  2548. * Rotates the vector around 0,0,0 by a quaternion
  2549. * @param quaternion the rotation quaternion
  2550. * @param result vector to store the result
  2551. * @returns the resulting vector
  2552. */
  2553. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2554. /**
  2555. * Rotates a vector around a given point
  2556. * @param quaternion the rotation quaternion
  2557. * @param point the point to rotate around
  2558. * @param result vector to store the result
  2559. * @returns the resulting vector
  2560. */
  2561. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2562. /**
  2563. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2564. * The cross product is then orthogonal to both current and "other"
  2565. * @param other defines the right operand
  2566. * @returns the cross product
  2567. */
  2568. cross(other: Vector3): Vector3;
  2569. /**
  2570. * Normalize the current Vector3 with the given input length.
  2571. * Please note that this is an in place operation.
  2572. * @param len the length of the vector
  2573. * @returns the current updated Vector3
  2574. */
  2575. normalizeFromLength(len: number): Vector3;
  2576. /**
  2577. * Normalize the current Vector3 to a new vector
  2578. * @returns the new Vector3
  2579. */
  2580. normalizeToNew(): Vector3;
  2581. /**
  2582. * Normalize the current Vector3 to the reference
  2583. * @param reference define the Vector3 to update
  2584. * @returns the updated Vector3
  2585. */
  2586. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2587. /**
  2588. * Creates a new Vector3 copied from the current Vector3
  2589. * @returns the new Vector3
  2590. */
  2591. clone(): Vector3;
  2592. /**
  2593. * Copies the given vector coordinates to the current Vector3 ones
  2594. * @param source defines the source Vector3
  2595. * @returns the current updated Vector3
  2596. */
  2597. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2598. /**
  2599. * Copies the given floats to the current Vector3 coordinates
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @returns the current updated Vector3
  2604. */
  2605. copyFromFloats(x: number, y: number, z: number): Vector3;
  2606. /**
  2607. * Copies the given floats to the current Vector3 coordinates
  2608. * @param x defines the x coordinate of the operand
  2609. * @param y defines the y coordinate of the operand
  2610. * @param z defines the z coordinate of the operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. set(x: number, y: number, z: number): Vector3;
  2614. /**
  2615. * Copies the given float to the current Vector3 coordinates
  2616. * @param v defines the x, y and z coordinates of the operand
  2617. * @returns the current updated Vector3
  2618. */
  2619. setAll(v: number): Vector3;
  2620. /**
  2621. * Get the clip factor between two vectors
  2622. * @param vector0 defines the first operand
  2623. * @param vector1 defines the second operand
  2624. * @param axis defines the axis to use
  2625. * @param size defines the size along the axis
  2626. * @returns the clip factor
  2627. */
  2628. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2629. /**
  2630. * Get angle between two vectors
  2631. * @param vector0 angle between vector0 and vector1
  2632. * @param vector1 angle between vector0 and vector1
  2633. * @param normal direction of the normal
  2634. * @return the angle between vector0 and vector1
  2635. */
  2636. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2637. /**
  2638. * Returns a new Vector3 set from the index "offset" of the given array
  2639. * @param array defines the source array
  2640. * @param offset defines the offset in the source array
  2641. * @returns the new Vector3
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2644. /**
  2645. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2646. * This function is deprecated. Use FromArray instead
  2647. * @param array defines the source array
  2648. * @param offset defines the offset in the source array
  2649. * @returns the new Vector3
  2650. */
  2651. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2652. /**
  2653. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2654. * @param array defines the source array
  2655. * @param offset defines the offset in the source array
  2656. * @param result defines the Vector3 where to store the result
  2657. */
  2658. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2659. /**
  2660. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2661. * This function is deprecated. Use FromArrayToRef instead.
  2662. * @param array defines the source array
  2663. * @param offset defines the offset in the source array
  2664. * @param result defines the Vector3 where to store the result
  2665. */
  2666. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2667. /**
  2668. * Sets the given vector "result" with the given floats.
  2669. * @param x defines the x coordinate of the source
  2670. * @param y defines the y coordinate of the source
  2671. * @param z defines the z coordinate of the source
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2675. /**
  2676. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2677. * @returns a new empty Vector3
  2678. */
  2679. static Zero(): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2682. * @returns a new unit Vector3
  2683. */
  2684. static One(): Vector3;
  2685. /**
  2686. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2687. * @returns a new up Vector3
  2688. */
  2689. static Up(): Vector3;
  2690. /**
  2691. * Gets a up Vector3 that must not be updated
  2692. */
  2693. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2694. /**
  2695. * Gets a zero Vector3 that must not be updated
  2696. */
  2697. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2698. /**
  2699. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2700. * @returns a new down Vector3
  2701. */
  2702. static Down(): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2705. * @returns a new forward Vector3
  2706. */
  2707. static Forward(): Vector3;
  2708. /**
  2709. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2710. * @returns a new forward Vector3
  2711. */
  2712. static Backward(): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2715. * @returns a new right Vector3
  2716. */
  2717. static Right(): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2720. * @returns a new left Vector3
  2721. */
  2722. static Left(): Vector3;
  2723. /**
  2724. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2725. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2726. * @param vector defines the Vector3 to transform
  2727. * @param transformation defines the transformation matrix
  2728. * @returns the transformed Vector3
  2729. */
  2730. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2731. /**
  2732. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2733. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2734. * @param vector defines the Vector3 to transform
  2735. * @param transformation defines the transformation matrix
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2741. * This method computes tranformed coordinates only, not transformed direction vectors
  2742. * @param x define the x coordinate of the source vector
  2743. * @param y define the y coordinate of the source vector
  2744. * @param z define the z coordinate of the source vector
  2745. * @param transformation defines the transformation matrix
  2746. * @param result defines the Vector3 where to store the result
  2747. */
  2748. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2749. /**
  2750. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2751. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2752. * @param vector defines the Vector3 to transform
  2753. * @param transformation defines the transformation matrix
  2754. * @returns the new Vector3
  2755. */
  2756. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2757. /**
  2758. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2760. * @param vector defines the Vector3 to transform
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param x define the x coordinate of the source vector
  2769. * @param y define the y coordinate of the source vector
  2770. * @param z define the z coordinate of the source vector
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2777. * @param value1 defines the first control point
  2778. * @param value2 defines the second control point
  2779. * @param value3 defines the third control point
  2780. * @param value4 defines the fourth control point
  2781. * @param amount defines the amount on the spline to use
  2782. * @returns the new Vector3
  2783. */
  2784. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2785. /**
  2786. * 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"
  2787. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2788. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2789. * @param value defines the current value
  2790. * @param min defines the lower range value
  2791. * @param max defines the upper range value
  2792. * @returns the new Vector3
  2793. */
  2794. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2795. /**
  2796. * 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"
  2797. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2798. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2799. * @param value defines the current value
  2800. * @param min defines the lower range value
  2801. * @param max defines the upper range value
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2805. /**
  2806. * Checks if a given vector is inside a specific range
  2807. * @param v defines the vector to test
  2808. * @param min defines the minimum range
  2809. * @param max defines the maximum range
  2810. */
  2811. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2812. /**
  2813. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2814. * @param value1 defines the first control point
  2815. * @param tangent1 defines the first tangent vector
  2816. * @param value2 defines the second control point
  2817. * @param tangent2 defines the second tangent vector
  2818. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2819. * @returns the new Vector3
  2820. */
  2821. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2824. * @param start defines the start value
  2825. * @param end defines the end value
  2826. * @param amount max defines amount between both (between 0 and 1)
  2827. * @returns the new Vector3
  2828. */
  2829. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2832. * @param start defines the start value
  2833. * @param end defines the end value
  2834. * @param amount max defines amount between both (between 0 and 1)
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2838. /**
  2839. * Returns the dot product (float) between the vectors "left" and "right"
  2840. * @param left defines the left operand
  2841. * @param right defines the right operand
  2842. * @returns the dot product
  2843. */
  2844. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2845. /**
  2846. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2847. * The cross product is then orthogonal to both "left" and "right"
  2848. * @param left defines the left operand
  2849. * @param right defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2853. /**
  2854. * Sets the given vector "result" with the cross product of "left" and "right"
  2855. * The cross product is then orthogonal to both "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 as the normalization of the given vector
  2863. * @param vector defines the Vector3 to normalize
  2864. * @returns the new Vector3
  2865. */
  2866. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2867. /**
  2868. * Sets the given vector "result" with the normalization of the given first vector
  2869. * @param vector defines the Vector3 to normalize
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2873. /**
  2874. * Project a Vector3 onto screen space
  2875. * @param vector defines the Vector3 to project
  2876. * @param world defines the world matrix to use
  2877. * @param transform defines the transform (view x projection) matrix to use
  2878. * @param viewport defines the screen viewport to use
  2879. * @returns the new Vector3
  2880. */
  2881. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2882. /** @hidden */
  2883. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2884. /**
  2885. * Unproject from screen space to object space
  2886. * @param source defines the screen space Vector3 to use
  2887. * @param viewportWidth defines the current width of the viewport
  2888. * @param viewportHeight defines the current height of the viewport
  2889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2890. * @param transform defines the transform (view x projection) matrix to use
  2891. * @returns the new Vector3
  2892. */
  2893. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2894. /**
  2895. * Unproject from screen space to object space
  2896. * @param source defines the screen space Vector3 to use
  2897. * @param viewportWidth defines the current width of the viewport
  2898. * @param viewportHeight defines the current height of the viewport
  2899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2900. * @param view defines the view matrix to use
  2901. * @param projection defines the projection matrix to use
  2902. * @returns the new Vector3
  2903. */
  2904. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2905. /**
  2906. * Unproject from screen space to object space
  2907. * @param source defines the screen space Vector3 to use
  2908. * @param viewportWidth defines the current width of the viewport
  2909. * @param viewportHeight defines the current height of the viewport
  2910. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2911. * @param view defines the view matrix to use
  2912. * @param projection defines the projection matrix to use
  2913. * @param result defines the Vector3 where to store the result
  2914. */
  2915. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2916. /**
  2917. * Unproject from screen space to object space
  2918. * @param sourceX defines the screen space x coordinate to use
  2919. * @param sourceY defines the screen space y coordinate to use
  2920. * @param sourceZ defines the screen space z coordinate to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Gets the minimal coordinate values between two Vector3
  2931. * @param left defines the first operand
  2932. * @param right defines the second operand
  2933. * @returns the new Vector3
  2934. */
  2935. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Gets the maximal coordinate values between two Vector3
  2938. * @param left defines the first operand
  2939. * @param right defines the second operand
  2940. * @returns the new Vector3
  2941. */
  2942. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2943. /**
  2944. * Returns the distance between the vectors "value1" and "value2"
  2945. * @param value1 defines the first operand
  2946. * @param value2 defines the second operand
  2947. * @returns the distance
  2948. */
  2949. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2950. /**
  2951. * Returns the squared distance between the vectors "value1" and "value2"
  2952. * @param value1 defines the first operand
  2953. * @param value2 defines the second operand
  2954. * @returns the squared distance
  2955. */
  2956. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2957. /**
  2958. * Returns a new Vector3 located at the center between "value1" and "value2"
  2959. * @param value1 defines the first operand
  2960. * @param value2 defines the second operand
  2961. * @returns the new Vector3
  2962. */
  2963. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2964. /**
  2965. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2966. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2967. * to something in order to rotate it from its local system to the given target system
  2968. * Note: axis1, axis2 and axis3 are normalized during this operation
  2969. * @param axis1 defines the first axis
  2970. * @param axis2 defines the second axis
  2971. * @param axis3 defines the third axis
  2972. * @returns a new Vector3
  2973. */
  2974. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2977. * @param axis1 defines the first axis
  2978. * @param axis2 defines the second axis
  2979. * @param axis3 defines the third axis
  2980. * @param ref defines the Vector3 where to store the result
  2981. */
  2982. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2983. }
  2984. /**
  2985. * Vector4 class created for EulerAngle class conversion to Quaternion
  2986. */
  2987. export class Vector4 {
  2988. /** x value of the vector */
  2989. x: number;
  2990. /** y value of the vector */
  2991. y: number;
  2992. /** z value of the vector */
  2993. z: number;
  2994. /** w value of the vector */
  2995. w: number;
  2996. /**
  2997. * Creates a Vector4 object from the given floats.
  2998. * @param x x value of the vector
  2999. * @param y y value of the vector
  3000. * @param z z value of the vector
  3001. * @param w w value of the vector
  3002. */
  3003. constructor(
  3004. /** x value of the vector */
  3005. x: number,
  3006. /** y value of the vector */
  3007. y: number,
  3008. /** z value of the vector */
  3009. z: number,
  3010. /** w value of the vector */
  3011. w: number);
  3012. /**
  3013. * Returns the string with the Vector4 coordinates.
  3014. * @returns a string containing all the vector values
  3015. */
  3016. toString(): string;
  3017. /**
  3018. * Returns the string "Vector4".
  3019. * @returns "Vector4"
  3020. */
  3021. getClassName(): string;
  3022. /**
  3023. * Returns the Vector4 hash code.
  3024. * @returns a unique hash code
  3025. */
  3026. getHashCode(): number;
  3027. /**
  3028. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3029. * @returns the resulting array
  3030. */
  3031. asArray(): number[];
  3032. /**
  3033. * Populates the given array from the given index with the Vector4 coordinates.
  3034. * @param array array to populate
  3035. * @param index index of the array to start at (default: 0)
  3036. * @returns the Vector4.
  3037. */
  3038. toArray(array: FloatArray, index?: number): Vector4;
  3039. /**
  3040. * Adds the given vector to the current Vector4.
  3041. * @param otherVector the vector to add
  3042. * @returns the updated Vector4.
  3043. */
  3044. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3045. /**
  3046. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3047. * @param otherVector the vector to add
  3048. * @returns the resulting vector
  3049. */
  3050. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3051. /**
  3052. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3053. * @param otherVector the vector to add
  3054. * @param result the vector to store the result
  3055. * @returns the current Vector4.
  3056. */
  3057. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3058. /**
  3059. * Subtract in place the given vector from the current Vector4.
  3060. * @param otherVector the vector to subtract
  3061. * @returns the updated Vector4.
  3062. */
  3063. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3064. /**
  3065. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3066. * @param otherVector the vector to add
  3067. * @returns the new vector with the result
  3068. */
  3069. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3070. /**
  3071. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3072. * @param otherVector the vector to subtract
  3073. * @param result the vector to store the result
  3074. * @returns the current Vector4.
  3075. */
  3076. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3077. /**
  3078. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3079. */
  3080. /**
  3081. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3082. * @param x value to subtract
  3083. * @param y value to subtract
  3084. * @param z value to subtract
  3085. * @param w value to subtract
  3086. * @returns new vector containing the result
  3087. */
  3088. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3089. /**
  3090. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3091. * @param x value to subtract
  3092. * @param y value to subtract
  3093. * @param z value to subtract
  3094. * @param w value to subtract
  3095. * @param result the vector to store the result in
  3096. * @returns the current Vector4.
  3097. */
  3098. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3099. /**
  3100. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3101. * @returns a new vector with the negated values
  3102. */
  3103. negate(): Vector4;
  3104. /**
  3105. * Multiplies the current Vector4 coordinates by scale (float).
  3106. * @param scale the number to scale with
  3107. * @returns the updated Vector4.
  3108. */
  3109. scaleInPlace(scale: number): Vector4;
  3110. /**
  3111. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3112. * @param scale the number to scale with
  3113. * @returns a new vector with the result
  3114. */
  3115. scale(scale: number): Vector4;
  3116. /**
  3117. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3118. * @param scale the number to scale with
  3119. * @param result a vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. scaleToRef(scale: number, result: Vector4): Vector4;
  3123. /**
  3124. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3125. * @param scale defines the scale factor
  3126. * @param result defines the Vector4 object where to store the result
  3127. * @returns the unmodified current Vector4
  3128. */
  3129. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3130. /**
  3131. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3132. * @param otherVector the vector to compare against
  3133. * @returns true if they are equal
  3134. */
  3135. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3136. /**
  3137. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3138. * @param otherVector vector to compare against
  3139. * @param epsilon (Default: very small number)
  3140. * @returns true if they are equal
  3141. */
  3142. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3143. /**
  3144. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3145. * @param x x value to compare against
  3146. * @param y y value to compare against
  3147. * @param z z value to compare against
  3148. * @param w w value to compare against
  3149. * @returns true if equal
  3150. */
  3151. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3152. /**
  3153. * Multiplies in place the current Vector4 by the given one.
  3154. * @param otherVector vector to multiple with
  3155. * @returns the updated Vector4.
  3156. */
  3157. multiplyInPlace(otherVector: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3160. * @param otherVector vector to multiple with
  3161. * @returns resulting new vector
  3162. */
  3163. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3164. /**
  3165. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3166. * @param otherVector vector to multiple with
  3167. * @param result vector to store the result
  3168. * @returns the current Vector4.
  3169. */
  3170. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3173. * @param x x value multiply with
  3174. * @param y y value multiply with
  3175. * @param z z value multiply with
  3176. * @param w w value multiply with
  3177. * @returns resulting new vector
  3178. */
  3179. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3180. /**
  3181. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3182. * @param otherVector vector to devide with
  3183. * @returns resulting new vector
  3184. */
  3185. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3186. /**
  3187. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3188. * @param otherVector vector to devide with
  3189. * @param result vector to store the result
  3190. * @returns the current Vector4.
  3191. */
  3192. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3193. /**
  3194. * Divides the current Vector3 coordinates by the given ones.
  3195. * @param otherVector vector to devide with
  3196. * @returns the updated Vector3.
  3197. */
  3198. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3199. /**
  3200. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3201. * @param other defines the second operand
  3202. * @returns the current updated Vector4
  3203. */
  3204. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3205. /**
  3206. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3207. * @param other defines the second operand
  3208. * @returns the current updated Vector4
  3209. */
  3210. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Gets a new Vector4 from current Vector4 floored values
  3213. * @returns a new Vector4
  3214. */
  3215. floor(): Vector4;
  3216. /**
  3217. * Gets a new Vector4 from current Vector3 floored values
  3218. * @returns a new Vector4
  3219. */
  3220. fract(): Vector4;
  3221. /**
  3222. * Returns the Vector4 length (float).
  3223. * @returns the length
  3224. */
  3225. length(): number;
  3226. /**
  3227. * Returns the Vector4 squared length (float).
  3228. * @returns the length squared
  3229. */
  3230. lengthSquared(): number;
  3231. /**
  3232. * Normalizes in place the Vector4.
  3233. * @returns the updated Vector4.
  3234. */
  3235. normalize(): Vector4;
  3236. /**
  3237. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3238. * @returns this converted to a new vector3
  3239. */
  3240. toVector3(): Vector3;
  3241. /**
  3242. * Returns a new Vector4 copied from the current one.
  3243. * @returns the new cloned vector
  3244. */
  3245. clone(): Vector4;
  3246. /**
  3247. * Updates the current Vector4 with the given one coordinates.
  3248. * @param source the source vector to copy from
  3249. * @returns the updated Vector4.
  3250. */
  3251. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the current Vector4 coordinates with the given floats.
  3254. * @param x float to copy from
  3255. * @param y float to copy from
  3256. * @param z float to copy from
  3257. * @param w float to copy from
  3258. * @returns the updated Vector4.
  3259. */
  3260. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3261. /**
  3262. * Updates the current Vector4 coordinates with the given floats.
  3263. * @param x float to set from
  3264. * @param y float to set from
  3265. * @param z float to set from
  3266. * @param w float to set from
  3267. * @returns the updated Vector4.
  3268. */
  3269. set(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Copies the given float to the current Vector3 coordinates
  3272. * @param v defines the x, y, z and w coordinates of the operand
  3273. * @returns the current updated Vector3
  3274. */
  3275. setAll(v: number): Vector4;
  3276. /**
  3277. * Returns a new Vector4 set from the starting index of the given array.
  3278. * @param array the array to pull values from
  3279. * @param offset the offset into the array to start at
  3280. * @returns the new vector
  3281. */
  3282. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3283. /**
  3284. * Updates the given vector "result" from the starting index of the given array.
  3285. * @param array the array to pull values from
  3286. * @param offset the offset into the array to start at
  3287. * @param result the vector to store the result in
  3288. */
  3289. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3290. /**
  3291. * Updates the given vector "result" from the starting index of the given Float32Array.
  3292. * @param array the array to pull values from
  3293. * @param offset the offset into the array to start at
  3294. * @param result the vector to store the result in
  3295. */
  3296. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3297. /**
  3298. * Updates the given vector "result" coordinates from the given floats.
  3299. * @param x float to set from
  3300. * @param y float to set from
  3301. * @param z float to set from
  3302. * @param w float to set from
  3303. * @param result the vector to the floats in
  3304. */
  3305. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3306. /**
  3307. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3308. * @returns the new vector
  3309. */
  3310. static Zero(): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3313. * @returns the new vector
  3314. */
  3315. static One(): Vector4;
  3316. /**
  3317. * Returns a new normalized Vector4 from the given one.
  3318. * @param vector the vector to normalize
  3319. * @returns the vector
  3320. */
  3321. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3322. /**
  3323. * Updates the given vector "result" from the normalization of the given one.
  3324. * @param vector the vector to normalize
  3325. * @param result the vector to store the result in
  3326. */
  3327. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3328. /**
  3329. * Returns a vector with the minimum values from the left and right vectors
  3330. * @param left left vector to minimize
  3331. * @param right right vector to minimize
  3332. * @returns a new vector with the minimum of the left and right vector values
  3333. */
  3334. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3335. /**
  3336. * Returns a vector with the maximum values from the left and right vectors
  3337. * @param left left vector to maximize
  3338. * @param right right vector to maximize
  3339. * @returns a new vector with the maximum of the left and right vector values
  3340. */
  3341. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3342. /**
  3343. * Returns the distance (float) between the vectors "value1" and "value2".
  3344. * @param value1 value to calulate the distance between
  3345. * @param value2 value to calulate the distance between
  3346. * @return the distance between the two vectors
  3347. */
  3348. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3349. /**
  3350. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3351. * @param value1 value to calulate the distance between
  3352. * @param value2 value to calulate the distance between
  3353. * @return the distance between the two vectors squared
  3354. */
  3355. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3356. /**
  3357. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3358. * @param value1 value to calulate the center between
  3359. * @param value2 value to calulate the center between
  3360. * @return the center between the two vectors
  3361. */
  3362. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3365. * This methods computes transformed normalized direction vectors only.
  3366. * @param vector the vector to transform
  3367. * @param transformation the transformation matrix to apply
  3368. * @returns the new vector
  3369. */
  3370. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3371. /**
  3372. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3373. * This methods computes transformed normalized direction vectors only.
  3374. * @param vector the vector to transform
  3375. * @param transformation the transformation matrix to apply
  3376. * @param result the vector to store the result in
  3377. */
  3378. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3379. /**
  3380. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3381. * This methods computes transformed normalized direction vectors only.
  3382. * @param x value to transform
  3383. * @param y value to transform
  3384. * @param z value to transform
  3385. * @param w value to transform
  3386. * @param transformation the transformation matrix to apply
  3387. * @param result the vector to store the results in
  3388. */
  3389. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3390. /**
  3391. * Creates a new Vector4 from a Vector3
  3392. * @param source defines the source data
  3393. * @param w defines the 4th component (default is 0)
  3394. * @returns a new Vector4
  3395. */
  3396. static FromVector3(source: Vector3, w?: number): Vector4;
  3397. }
  3398. /**
  3399. * Class used to store quaternion data
  3400. * @see https://en.wikipedia.org/wiki/Quaternion
  3401. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3402. */
  3403. export class Quaternion {
  3404. /** defines the first component (0 by default) */
  3405. x: number;
  3406. /** defines the second component (0 by default) */
  3407. y: number;
  3408. /** defines the third component (0 by default) */
  3409. z: number;
  3410. /** defines the fourth component (1.0 by default) */
  3411. w: number;
  3412. /**
  3413. * Creates a new Quaternion from the given floats
  3414. * @param x defines the first component (0 by default)
  3415. * @param y defines the second component (0 by default)
  3416. * @param z defines the third component (0 by default)
  3417. * @param w defines the fourth component (1.0 by default)
  3418. */
  3419. constructor(
  3420. /** defines the first component (0 by default) */
  3421. x?: number,
  3422. /** defines the second component (0 by default) */
  3423. y?: number,
  3424. /** defines the third component (0 by default) */
  3425. z?: number,
  3426. /** defines the fourth component (1.0 by default) */
  3427. w?: number);
  3428. /**
  3429. * Gets a string representation for the current quaternion
  3430. * @returns a string with the Quaternion coordinates
  3431. */
  3432. toString(): string;
  3433. /**
  3434. * Gets the class name of the quaternion
  3435. * @returns the string "Quaternion"
  3436. */
  3437. getClassName(): string;
  3438. /**
  3439. * Gets a hash code for this quaternion
  3440. * @returns the quaternion hash code
  3441. */
  3442. getHashCode(): number;
  3443. /**
  3444. * Copy the quaternion to an array
  3445. * @returns a new array populated with 4 elements from the quaternion coordinates
  3446. */
  3447. asArray(): number[];
  3448. /**
  3449. * Check if two quaternions are equals
  3450. * @param otherQuaternion defines the second operand
  3451. * @return true if the current quaternion and the given one coordinates are strictly equals
  3452. */
  3453. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3454. /**
  3455. * Clone the current quaternion
  3456. * @returns a new quaternion copied from the current one
  3457. */
  3458. clone(): Quaternion;
  3459. /**
  3460. * Copy a quaternion to the current one
  3461. * @param other defines the other quaternion
  3462. * @returns the updated current quaternion
  3463. */
  3464. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3465. /**
  3466. * Updates the current quaternion with the given float coordinates
  3467. * @param x defines the x coordinate
  3468. * @param y defines the y coordinate
  3469. * @param z defines the z coordinate
  3470. * @param w defines the w coordinate
  3471. * @returns the updated current quaternion
  3472. */
  3473. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3474. /**
  3475. * Updates the current quaternion from the given float coordinates
  3476. * @param x defines the x coordinate
  3477. * @param y defines the y coordinate
  3478. * @param z defines the z coordinate
  3479. * @param w defines the w coordinate
  3480. * @returns the updated current quaternion
  3481. */
  3482. set(x: number, y: number, z: number, w: number): Quaternion;
  3483. /**
  3484. * Adds two quaternions
  3485. * @param other defines the second operand
  3486. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3487. */
  3488. add(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Add a quaternion to the current one
  3491. * @param other defines the quaternion to add
  3492. * @returns the current quaternion
  3493. */
  3494. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3495. /**
  3496. * Subtract two quaternions
  3497. * @param other defines the second operand
  3498. * @returns a new quaternion as the subtraction result of the given one from the current one
  3499. */
  3500. subtract(other: Quaternion): Quaternion;
  3501. /**
  3502. * Multiplies the current quaternion by a scale factor
  3503. * @param value defines the scale factor
  3504. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3505. */
  3506. scale(value: number): Quaternion;
  3507. /**
  3508. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3509. * @param scale defines the scale factor
  3510. * @param result defines the Quaternion object where to store the result
  3511. * @returns the unmodified current quaternion
  3512. */
  3513. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3514. /**
  3515. * Multiplies in place the current quaternion by a scale factor
  3516. * @param value defines the scale factor
  3517. * @returns the current modified quaternion
  3518. */
  3519. scaleInPlace(value: number): Quaternion;
  3520. /**
  3521. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3522. * @param scale defines the scale factor
  3523. * @param result defines the Quaternion object where to store the result
  3524. * @returns the unmodified current quaternion
  3525. */
  3526. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3527. /**
  3528. * Multiplies two quaternions
  3529. * @param q1 defines the second operand
  3530. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3531. */
  3532. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3533. /**
  3534. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3535. * @param q1 defines the second operand
  3536. * @param result defines the target quaternion
  3537. * @returns the current quaternion
  3538. */
  3539. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3540. /**
  3541. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3542. * @param q1 defines the second operand
  3543. * @returns the currentupdated quaternion
  3544. */
  3545. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3546. /**
  3547. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3548. * @param ref defines the target quaternion
  3549. * @returns the current quaternion
  3550. */
  3551. conjugateToRef(ref: Quaternion): Quaternion;
  3552. /**
  3553. * Conjugates in place (1-q) the current quaternion
  3554. * @returns the current updated quaternion
  3555. */
  3556. conjugateInPlace(): Quaternion;
  3557. /**
  3558. * Conjugates in place (1-q) the current quaternion
  3559. * @returns a new quaternion
  3560. */
  3561. conjugate(): Quaternion;
  3562. /**
  3563. * Gets length of current quaternion
  3564. * @returns the quaternion length (float)
  3565. */
  3566. length(): number;
  3567. /**
  3568. * Normalize in place the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. normalize(): Quaternion;
  3572. /**
  3573. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3574. * @param order is a reserved parameter and is ignore for now
  3575. * @returns a new Vector3 containing the Euler angles
  3576. */
  3577. toEulerAngles(order?: string): Vector3;
  3578. /**
  3579. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3580. * @param result defines the vector which will be filled with the Euler angles
  3581. * @param order is a reserved parameter and is ignore for now
  3582. * @returns the current unchanged quaternion
  3583. */
  3584. toEulerAnglesToRef(result: Vector3): Quaternion;
  3585. /**
  3586. * Updates the given rotation matrix with the current quaternion values
  3587. * @param result defines the target matrix
  3588. * @returns the current unchanged quaternion
  3589. */
  3590. toRotationMatrix(result: Matrix): Quaternion;
  3591. /**
  3592. * Updates the current quaternion from the given rotation matrix values
  3593. * @param matrix defines the source matrix
  3594. * @returns the current updated quaternion
  3595. */
  3596. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3597. /**
  3598. * Creates a new quaternion from a rotation matrix
  3599. * @param matrix defines the source matrix
  3600. * @returns a new quaternion created from the given rotation matrix values
  3601. */
  3602. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3603. /**
  3604. * Updates the given quaternion with the given rotation matrix values
  3605. * @param matrix defines the source matrix
  3606. * @param result defines the target quaternion
  3607. */
  3608. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3609. /**
  3610. * Returns the dot product (float) between the quaternions "left" and "right"
  3611. * @param left defines the left operand
  3612. * @param right defines the right operand
  3613. * @returns the dot product
  3614. */
  3615. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3616. /**
  3617. * Checks if the two quaternions are close to each other
  3618. * @param quat0 defines the first quaternion to check
  3619. * @param quat1 defines the second quaternion to check
  3620. * @returns true if the two quaternions are close to each other
  3621. */
  3622. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3623. /**
  3624. * Creates an empty quaternion
  3625. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3626. */
  3627. static Zero(): Quaternion;
  3628. /**
  3629. * Inverse a given quaternion
  3630. * @param q defines the source quaternion
  3631. * @returns a new quaternion as the inverted current quaternion
  3632. */
  3633. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3634. /**
  3635. * Inverse a given quaternion
  3636. * @param q defines the source quaternion
  3637. * @param result the quaternion the result will be stored in
  3638. * @returns the result quaternion
  3639. */
  3640. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3641. /**
  3642. * Creates an identity quaternion
  3643. * @returns the identity quaternion
  3644. */
  3645. static Identity(): Quaternion;
  3646. /**
  3647. * Gets a boolean indicating if the given quaternion is identity
  3648. * @param quaternion defines the quaternion to check
  3649. * @returns true if the quaternion is identity
  3650. */
  3651. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates a quaternion from a rotation around an axis
  3654. * @param axis defines the axis to use
  3655. * @param angle defines the angle to use
  3656. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3657. */
  3658. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3659. /**
  3660. * Creates a rotation around an axis and stores it into the given quaternion
  3661. * @param axis defines the axis to use
  3662. * @param angle defines the angle to use
  3663. * @param result defines the target quaternion
  3664. * @returns the target quaternion
  3665. */
  3666. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3667. /**
  3668. * Creates a new quaternion from data stored into an array
  3669. * @param array defines the data source
  3670. * @param offset defines the offset in the source array where the data starts
  3671. * @returns a new quaternion
  3672. */
  3673. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3674. /**
  3675. * Create a quaternion from Euler rotation angles
  3676. * @param x Pitch
  3677. * @param y Yaw
  3678. * @param z Roll
  3679. * @returns the new Quaternion
  3680. */
  3681. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3682. /**
  3683. * Updates a quaternion from Euler rotation angles
  3684. * @param x Pitch
  3685. * @param y Yaw
  3686. * @param z Roll
  3687. * @param result the quaternion to store the result
  3688. * @returns the updated quaternion
  3689. */
  3690. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Create a quaternion from Euler rotation vector
  3693. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation vector
  3699. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3700. * @param result the quaternion to store the result
  3701. * @returns the updated quaternion
  3702. */
  3703. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3704. /**
  3705. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3706. * @param yaw defines the rotation around Y axis
  3707. * @param pitch defines the rotation around X axis
  3708. * @param roll defines the rotation around Z axis
  3709. * @returns the new quaternion
  3710. */
  3711. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3712. /**
  3713. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3714. * @param yaw defines the rotation around Y axis
  3715. * @param pitch defines the rotation around X axis
  3716. * @param roll defines the rotation around Z axis
  3717. * @param result defines the target quaternion
  3718. */
  3719. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3720. /**
  3721. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3722. * @param alpha defines the rotation around first axis
  3723. * @param beta defines the rotation around second axis
  3724. * @param gamma defines the rotation around third axis
  3725. * @returns the new quaternion
  3726. */
  3727. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3730. * @param alpha defines the rotation around first axis
  3731. * @param beta defines the rotation around second axis
  3732. * @param gamma defines the rotation around third axis
  3733. * @param result defines the target quaternion
  3734. */
  3735. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3736. /**
  3737. * 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)
  3738. * @param axis1 defines the first axis
  3739. * @param axis2 defines the second axis
  3740. * @param axis3 defines the third axis
  3741. * @returns the new quaternion
  3742. */
  3743. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3744. /**
  3745. * 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
  3746. * @param axis1 defines the first axis
  3747. * @param axis2 defines the second axis
  3748. * @param axis3 defines the third axis
  3749. * @param ref defines the target quaternion
  3750. */
  3751. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3752. /**
  3753. * Interpolates between two quaternions
  3754. * @param left defines first quaternion
  3755. * @param right defines second quaternion
  3756. * @param amount defines the gradient to use
  3757. * @returns the new interpolated quaternion
  3758. */
  3759. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3760. /**
  3761. * Interpolates between two quaternions and stores it into a target quaternion
  3762. * @param left defines first quaternion
  3763. * @param right defines second quaternion
  3764. * @param amount defines the gradient to use
  3765. * @param result defines the target quaternion
  3766. */
  3767. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3768. /**
  3769. * Interpolate between two quaternions using Hermite interpolation
  3770. * @param value1 defines first quaternion
  3771. * @param tangent1 defines the incoming tangent
  3772. * @param value2 defines second quaternion
  3773. * @param tangent2 defines the outgoing tangent
  3774. * @param amount defines the target quaternion
  3775. * @returns the new interpolated quaternion
  3776. */
  3777. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3778. }
  3779. /**
  3780. * Class used to store matrix data (4x4)
  3781. */
  3782. export class Matrix {
  3783. private static _updateFlagSeed;
  3784. private static _identityReadOnly;
  3785. private _isIdentity;
  3786. private _isIdentityDirty;
  3787. private _isIdentity3x2;
  3788. private _isIdentity3x2Dirty;
  3789. /**
  3790. * Gets the update flag of the matrix which is an unique number for the matrix.
  3791. * It will be incremented every time the matrix data change.
  3792. * You can use it to speed the comparison between two versions of the same matrix.
  3793. */
  3794. updateFlag: number;
  3795. private readonly _m;
  3796. /**
  3797. * Gets the internal data of the matrix
  3798. */
  3799. readonly m: DeepImmutable<Float32Array>;
  3800. /** @hidden */
  3801. _markAsUpdated(): void;
  3802. /** @hidden */
  3803. private _updateIdentityStatus;
  3804. /**
  3805. * Creates an empty matrix (filled with zeros)
  3806. */
  3807. constructor();
  3808. /**
  3809. * Check if the current matrix is identity
  3810. * @returns true is the matrix is the identity matrix
  3811. */
  3812. isIdentity(): boolean;
  3813. /**
  3814. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3815. * @returns true is the matrix is the identity matrix
  3816. */
  3817. isIdentityAs3x2(): boolean;
  3818. /**
  3819. * Gets the determinant of the matrix
  3820. * @returns the matrix determinant
  3821. */
  3822. determinant(): number;
  3823. /**
  3824. * Returns the matrix as a Float32Array
  3825. * @returns the matrix underlying array
  3826. */
  3827. toArray(): DeepImmutable<Float32Array>;
  3828. /**
  3829. * Returns the matrix as a Float32Array
  3830. * @returns the matrix underlying array.
  3831. */
  3832. asArray(): DeepImmutable<Float32Array>;
  3833. /**
  3834. * Inverts the current matrix in place
  3835. * @returns the current inverted matrix
  3836. */
  3837. invert(): Matrix;
  3838. /**
  3839. * Sets all the matrix elements to zero
  3840. * @returns the current matrix
  3841. */
  3842. reset(): Matrix;
  3843. /**
  3844. * Adds the current matrix with a second one
  3845. * @param other defines the matrix to add
  3846. * @returns a new matrix as the addition of the current matrix and the given one
  3847. */
  3848. add(other: DeepImmutable<Matrix>): Matrix;
  3849. /**
  3850. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3851. * @param other defines the matrix to add
  3852. * @param result defines the target matrix
  3853. * @returns the current matrix
  3854. */
  3855. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3856. /**
  3857. * Adds in place the given matrix to the current matrix
  3858. * @param other defines the second operand
  3859. * @returns the current updated matrix
  3860. */
  3861. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3862. /**
  3863. * Sets the given matrix to the current inverted Matrix
  3864. * @param other defines the target matrix
  3865. * @returns the unmodified current matrix
  3866. */
  3867. invertToRef(other: Matrix): Matrix;
  3868. /**
  3869. * add a value at the specified position in the current Matrix
  3870. * @param index the index of the value within the matrix. between 0 and 15.
  3871. * @param value the value to be added
  3872. * @returns the current updated matrix
  3873. */
  3874. addAtIndex(index: number, value: number): Matrix;
  3875. /**
  3876. * mutiply the specified position in the current Matrix by a value
  3877. * @param index the index of the value within the matrix. between 0 and 15.
  3878. * @param value the value to be added
  3879. * @returns the current updated matrix
  3880. */
  3881. multiplyAtIndex(index: number, value: number): Matrix;
  3882. /**
  3883. * Inserts the translation vector (using 3 floats) in the current matrix
  3884. * @param x defines the 1st component of the translation
  3885. * @param y defines the 2nd component of the translation
  3886. * @param z defines the 3rd component of the translation
  3887. * @returns the current updated matrix
  3888. */
  3889. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3890. /**
  3891. * Adds the translation vector (using 3 floats) in the current matrix
  3892. * @param x defines the 1st component of the translation
  3893. * @param y defines the 2nd component of the translation
  3894. * @param z defines the 3rd component of the translation
  3895. * @returns the current updated matrix
  3896. */
  3897. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3898. /**
  3899. * Inserts the translation vector in the current matrix
  3900. * @param vector3 defines the translation to insert
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3904. /**
  3905. * Gets the translation value of the current matrix
  3906. * @returns a new Vector3 as the extracted translation from the matrix
  3907. */
  3908. getTranslation(): Vector3;
  3909. /**
  3910. * Fill a Vector3 with the extracted translation from the matrix
  3911. * @param result defines the Vector3 where to store the translation
  3912. * @returns the current matrix
  3913. */
  3914. getTranslationToRef(result: Vector3): Matrix;
  3915. /**
  3916. * Remove rotation and scaling part from the matrix
  3917. * @returns the updated matrix
  3918. */
  3919. removeRotationAndScaling(): Matrix;
  3920. /**
  3921. * Multiply two matrices
  3922. * @param other defines the second operand
  3923. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3924. */
  3925. multiply(other: DeepImmutable<Matrix>): Matrix;
  3926. /**
  3927. * Copy the current matrix from the given one
  3928. * @param other defines the source matrix
  3929. * @returns the current updated matrix
  3930. */
  3931. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Populates the given array from the starting index with the current matrix values
  3934. * @param array defines the target array
  3935. * @param offset defines the offset in the target array where to start storing values
  3936. * @returns the current matrix
  3937. */
  3938. copyToArray(array: Float32Array, offset?: number): Matrix;
  3939. /**
  3940. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3941. * @param other defines the second operand
  3942. * @param result defines the matrix where to store the multiplication
  3943. * @returns the current matrix
  3944. */
  3945. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3946. /**
  3947. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3948. * @param other defines the second operand
  3949. * @param result defines the array where to store the multiplication
  3950. * @param offset defines the offset in the target array where to start storing values
  3951. * @returns the current matrix
  3952. */
  3953. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3954. /**
  3955. * Check equality between this matrix and a second one
  3956. * @param value defines the second matrix to compare
  3957. * @returns true is the current matrix and the given one values are strictly equal
  3958. */
  3959. equals(value: DeepImmutable<Matrix>): boolean;
  3960. /**
  3961. * Clone the current matrix
  3962. * @returns a new matrix from the current matrix
  3963. */
  3964. clone(): Matrix;
  3965. /**
  3966. * Returns the name of the current matrix class
  3967. * @returns the string "Matrix"
  3968. */
  3969. getClassName(): string;
  3970. /**
  3971. * Gets the hash code of the current matrix
  3972. * @returns the hash code
  3973. */
  3974. getHashCode(): number;
  3975. /**
  3976. * Decomposes the current Matrix into a translation, rotation and scaling components
  3977. * @param scale defines the scale vector3 given as a reference to update
  3978. * @param rotation defines the rotation quaternion given as a reference to update
  3979. * @param translation defines the translation vector3 given as a reference to update
  3980. * @returns true if operation was successful
  3981. */
  3982. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3983. /**
  3984. * Gets specific row of the matrix
  3985. * @param index defines the number of the row to get
  3986. * @returns the index-th row of the current matrix as a new Vector4
  3987. */
  3988. getRow(index: number): Nullable<Vector4>;
  3989. /**
  3990. * Sets the index-th row of the current matrix to the vector4 values
  3991. * @param index defines the number of the row to set
  3992. * @param row defines the target vector4
  3993. * @returns the updated current matrix
  3994. */
  3995. setRow(index: number, row: Vector4): Matrix;
  3996. /**
  3997. * Compute the transpose of the matrix
  3998. * @returns the new transposed matrix
  3999. */
  4000. transpose(): Matrix;
  4001. /**
  4002. * Compute the transpose of the matrix and store it in a given matrix
  4003. * @param result defines the target matrix
  4004. * @returns the current matrix
  4005. */
  4006. transposeToRef(result: Matrix): Matrix;
  4007. /**
  4008. * Sets the index-th row of the current matrix with the given 4 x float values
  4009. * @param index defines the row index
  4010. * @param x defines the x component to set
  4011. * @param y defines the y component to set
  4012. * @param z defines the z component to set
  4013. * @param w defines the w component to set
  4014. * @returns the updated current matrix
  4015. */
  4016. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4017. /**
  4018. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4019. * @param scale defines the scale factor
  4020. * @returns a new matrix
  4021. */
  4022. scale(scale: number): Matrix;
  4023. /**
  4024. * Scale the current matrix values by a factor to a given result matrix
  4025. * @param scale defines the scale factor
  4026. * @param result defines the matrix to store the result
  4027. * @returns the current matrix
  4028. */
  4029. scaleToRef(scale: number, result: Matrix): Matrix;
  4030. /**
  4031. * Scale the current matrix values by a factor and add the result to a given matrix
  4032. * @param scale defines the scale factor
  4033. * @param result defines the Matrix to store the result
  4034. * @returns the current matrix
  4035. */
  4036. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4037. /**
  4038. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4039. * @param ref matrix to store the result
  4040. */
  4041. toNormalMatrix(ref: Matrix): void;
  4042. /**
  4043. * Gets only rotation part of the current matrix
  4044. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4045. */
  4046. getRotationMatrix(): Matrix;
  4047. /**
  4048. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4049. * @param result defines the target matrix to store data to
  4050. * @returns the current matrix
  4051. */
  4052. getRotationMatrixToRef(result: Matrix): Matrix;
  4053. /**
  4054. * Toggles model matrix from being right handed to left handed in place and vice versa
  4055. */
  4056. toggleModelMatrixHandInPlace(): void;
  4057. /**
  4058. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4059. */
  4060. toggleProjectionMatrixHandInPlace(): void;
  4061. /**
  4062. * Creates a matrix from an array
  4063. * @param array defines the source array
  4064. * @param offset defines an offset in the source array
  4065. * @returns a new Matrix set from the starting index of the given array
  4066. */
  4067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4068. /**
  4069. * Copy the content of an array into a given matrix
  4070. * @param array defines the source array
  4071. * @param offset defines an offset in the source array
  4072. * @param result defines the target matrix
  4073. */
  4074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4075. /**
  4076. * Stores an array into a matrix after having multiplied each component by a given factor
  4077. * @param array defines the source array
  4078. * @param offset defines the offset in the source array
  4079. * @param scale defines the scaling factor
  4080. * @param result defines the target matrix
  4081. */
  4082. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4083. /**
  4084. * Gets an identity matrix that must not be updated
  4085. */
  4086. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4087. /**
  4088. * Stores a list of values (16) inside a given matrix
  4089. * @param initialM11 defines 1st value of 1st row
  4090. * @param initialM12 defines 2nd value of 1st row
  4091. * @param initialM13 defines 3rd value of 1st row
  4092. * @param initialM14 defines 4th value of 1st row
  4093. * @param initialM21 defines 1st value of 2nd row
  4094. * @param initialM22 defines 2nd value of 2nd row
  4095. * @param initialM23 defines 3rd value of 2nd row
  4096. * @param initialM24 defines 4th value of 2nd row
  4097. * @param initialM31 defines 1st value of 3rd row
  4098. * @param initialM32 defines 2nd value of 3rd row
  4099. * @param initialM33 defines 3rd value of 3rd row
  4100. * @param initialM34 defines 4th value of 3rd row
  4101. * @param initialM41 defines 1st value of 4th row
  4102. * @param initialM42 defines 2nd value of 4th row
  4103. * @param initialM43 defines 3rd value of 4th row
  4104. * @param initialM44 defines 4th value of 4th row
  4105. * @param result defines the target matrix
  4106. */
  4107. 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;
  4108. /**
  4109. * Creates new matrix from a list of values (16)
  4110. * @param initialM11 defines 1st value of 1st row
  4111. * @param initialM12 defines 2nd value of 1st row
  4112. * @param initialM13 defines 3rd value of 1st row
  4113. * @param initialM14 defines 4th value of 1st row
  4114. * @param initialM21 defines 1st value of 2nd row
  4115. * @param initialM22 defines 2nd value of 2nd row
  4116. * @param initialM23 defines 3rd value of 2nd row
  4117. * @param initialM24 defines 4th value of 2nd row
  4118. * @param initialM31 defines 1st value of 3rd row
  4119. * @param initialM32 defines 2nd value of 3rd row
  4120. * @param initialM33 defines 3rd value of 3rd row
  4121. * @param initialM34 defines 4th value of 3rd row
  4122. * @param initialM41 defines 1st value of 4th row
  4123. * @param initialM42 defines 2nd value of 4th row
  4124. * @param initialM43 defines 3rd value of 4th row
  4125. * @param initialM44 defines 4th value of 4th row
  4126. * @returns the new matrix
  4127. */
  4128. 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;
  4129. /**
  4130. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4131. * @param scale defines the scale vector3
  4132. * @param rotation defines the rotation quaternion
  4133. * @param translation defines the translation vector3
  4134. * @returns a new matrix
  4135. */
  4136. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4137. /**
  4138. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4139. * @param scale defines the scale vector3
  4140. * @param rotation defines the rotation quaternion
  4141. * @param translation defines the translation vector3
  4142. * @param result defines the target matrix
  4143. */
  4144. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4145. /**
  4146. * Creates a new identity matrix
  4147. * @returns a new identity matrix
  4148. */
  4149. static Identity(): Matrix;
  4150. /**
  4151. * Creates a new identity matrix and stores the result in a given matrix
  4152. * @param result defines the target matrix
  4153. */
  4154. static IdentityToRef(result: Matrix): void;
  4155. /**
  4156. * Creates a new zero matrix
  4157. * @returns a new zero matrix
  4158. */
  4159. static Zero(): Matrix;
  4160. /**
  4161. * Creates a new rotation matrix for "angle" radians around the X axis
  4162. * @param angle defines the angle (in radians) to use
  4163. * @return the new matrix
  4164. */
  4165. static RotationX(angle: number): Matrix;
  4166. /**
  4167. * Creates a new matrix as the invert of a given matrix
  4168. * @param source defines the source matrix
  4169. * @returns the new matrix
  4170. */
  4171. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4174. * @param angle defines the angle (in radians) to use
  4175. * @param result defines the target matrix
  4176. */
  4177. static RotationXToRef(angle: number, result: Matrix): void;
  4178. /**
  4179. * Creates a new rotation matrix for "angle" radians around the Y axis
  4180. * @param angle defines the angle (in radians) to use
  4181. * @return the new matrix
  4182. */
  4183. static RotationY(angle: number): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4186. * @param angle defines the angle (in radians) to use
  4187. * @param result defines the target matrix
  4188. */
  4189. static RotationYToRef(angle: number, result: Matrix): void;
  4190. /**
  4191. * Creates a new rotation matrix for "angle" radians around the Z axis
  4192. * @param angle defines the angle (in radians) to use
  4193. * @return the new matrix
  4194. */
  4195. static RotationZ(angle: number): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationZToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the given axis
  4204. * @param axis defines the axis to use
  4205. * @param angle defines the angle (in radians) to use
  4206. * @return the new matrix
  4207. */
  4208. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4211. * @param axis defines the axis to use
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4216. /**
  4217. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4218. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4219. * @param from defines the vector to align
  4220. * @param to defines the vector to align to
  4221. * @param result defines the target matrix
  4222. */
  4223. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4224. /**
  4225. * Creates a rotation matrix
  4226. * @param yaw defines the yaw angle in radians (Y axis)
  4227. * @param pitch defines the pitch angle in radians (X axis)
  4228. * @param roll defines the roll angle in radians (X axis)
  4229. * @returns the new rotation matrix
  4230. */
  4231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4232. /**
  4233. * Creates a rotation matrix and stores it in a given matrix
  4234. * @param yaw defines the yaw angle in radians (Y axis)
  4235. * @param pitch defines the pitch angle in radians (X axis)
  4236. * @param roll defines the roll angle in radians (X axis)
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4240. /**
  4241. * Creates a scaling matrix
  4242. * @param x defines the scale factor on X axis
  4243. * @param y defines the scale factor on Y axis
  4244. * @param z defines the scale factor on Z axis
  4245. * @returns the new matrix
  4246. */
  4247. static Scaling(x: number, y: number, z: number): Matrix;
  4248. /**
  4249. * Creates a scaling matrix and stores it in a given matrix
  4250. * @param x defines the scale factor on X axis
  4251. * @param y defines the scale factor on Y axis
  4252. * @param z defines the scale factor on Z axis
  4253. * @param result defines the target matrix
  4254. */
  4255. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4256. /**
  4257. * Creates a translation matrix
  4258. * @param x defines the translation on X axis
  4259. * @param y defines the translation on Y axis
  4260. * @param z defines the translationon Z axis
  4261. * @returns the new matrix
  4262. */
  4263. static Translation(x: number, y: number, z: number): Matrix;
  4264. /**
  4265. * Creates a translation matrix and stores it in a given matrix
  4266. * @param x defines the translation on X axis
  4267. * @param y defines the translation on Y axis
  4268. * @param z defines the translationon Z axis
  4269. * @param result defines the target matrix
  4270. */
  4271. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4272. /**
  4273. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4274. * @param startValue defines the start value
  4275. * @param endValue defines the end value
  4276. * @param gradient defines the gradient factor
  4277. * @returns the new matrix
  4278. */
  4279. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4280. /**
  4281. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4282. * @param startValue defines the start value
  4283. * @param endValue defines the end value
  4284. * @param gradient defines the gradient factor
  4285. * @param result defines the Matrix object where to store data
  4286. */
  4287. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4288. /**
  4289. * Builds a new matrix whose values are computed by:
  4290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4293. * @param startValue defines the first matrix
  4294. * @param endValue defines the second matrix
  4295. * @param gradient defines the gradient between the two matrices
  4296. * @returns the new matrix
  4297. */
  4298. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4299. /**
  4300. * Update a matrix to values which are computed by:
  4301. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4302. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4303. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4304. * @param startValue defines the first matrix
  4305. * @param endValue defines the second matrix
  4306. * @param gradient defines the gradient between the two matrices
  4307. * @param result defines the target matrix
  4308. */
  4309. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4310. /**
  4311. * 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"
  4312. * This function works in left handed mode
  4313. * @param eye defines the final position of the entity
  4314. * @param target defines where the entity should look at
  4315. * @param up defines the up vector for the entity
  4316. * @returns the new matrix
  4317. */
  4318. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4319. /**
  4320. * 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".
  4321. * This function works in left handed mode
  4322. * @param eye defines the final position of the entity
  4323. * @param target defines where the entity should look at
  4324. * @param up defines the up vector for the entity
  4325. * @param result defines the target matrix
  4326. */
  4327. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4328. /**
  4329. * 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"
  4330. * This function works in right handed mode
  4331. * @param eye defines the final position of the entity
  4332. * @param target defines where the entity should look at
  4333. * @param up defines the up vector for the entity
  4334. * @returns the new matrix
  4335. */
  4336. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4337. /**
  4338. * 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".
  4339. * This function works in right handed mode
  4340. * @param eye defines the final position of the entity
  4341. * @param target defines where the entity should look at
  4342. * @param up defines the up vector for the entity
  4343. * @param result defines the target matrix
  4344. */
  4345. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4346. /**
  4347. * Create a left-handed orthographic projection matrix
  4348. * @param width defines the viewport width
  4349. * @param height defines the viewport height
  4350. * @param znear defines the near clip plane
  4351. * @param zfar defines the far clip plane
  4352. * @returns a new matrix as a left-handed orthographic projection matrix
  4353. */
  4354. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4355. /**
  4356. * Store a left-handed orthographic projection to a given matrix
  4357. * @param width defines the viewport width
  4358. * @param height defines the viewport height
  4359. * @param znear defines the near clip plane
  4360. * @param zfar defines the far clip plane
  4361. * @param result defines the target matrix
  4362. */
  4363. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4364. /**
  4365. * Create a left-handed orthographic projection matrix
  4366. * @param left defines the viewport left coordinate
  4367. * @param right defines the viewport right coordinate
  4368. * @param bottom defines the viewport bottom coordinate
  4369. * @param top defines the viewport top coordinate
  4370. * @param znear defines the near clip plane
  4371. * @param zfar defines the far clip plane
  4372. * @returns a new matrix as a left-handed orthographic projection matrix
  4373. */
  4374. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4375. /**
  4376. * Stores a left-handed orthographic projection into a given matrix
  4377. * @param left defines the viewport left coordinate
  4378. * @param right defines the viewport right coordinate
  4379. * @param bottom defines the viewport bottom coordinate
  4380. * @param top defines the viewport top coordinate
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @param result defines the target matrix
  4384. */
  4385. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4386. /**
  4387. * Creates a right-handed orthographic projection matrix
  4388. * @param left defines the viewport left coordinate
  4389. * @param right defines the viewport right coordinate
  4390. * @param bottom defines the viewport bottom coordinate
  4391. * @param top defines the viewport top coordinate
  4392. * @param znear defines the near clip plane
  4393. * @param zfar defines the far clip plane
  4394. * @returns a new matrix as a right-handed orthographic projection matrix
  4395. */
  4396. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4397. /**
  4398. * Stores a right-handed orthographic projection into a given matrix
  4399. * @param left defines the viewport left coordinate
  4400. * @param right defines the viewport right coordinate
  4401. * @param bottom defines the viewport bottom coordinate
  4402. * @param top defines the viewport top coordinate
  4403. * @param znear defines the near clip plane
  4404. * @param zfar defines the far clip plane
  4405. * @param result defines the target matrix
  4406. */
  4407. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4408. /**
  4409. * Creates a left-handed perspective projection matrix
  4410. * @param width defines the viewport width
  4411. * @param height defines the viewport height
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @returns a new matrix as a left-handed perspective projection matrix
  4415. */
  4416. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4417. /**
  4418. * Creates a left-handed perspective projection matrix
  4419. * @param fov defines the horizontal field of view
  4420. * @param aspect defines the aspect ratio
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a left-handed perspective projection matrix
  4424. */
  4425. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a left-handed perspective projection into a given matrix
  4428. * @param fov defines the horizontal field of view
  4429. * @param aspect defines the aspect ratio
  4430. * @param znear defines the near clip plane
  4431. * @param zfar defines the far clip plane
  4432. * @param result defines the target matrix
  4433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4434. */
  4435. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4436. /**
  4437. * Creates a right-handed perspective projection matrix
  4438. * @param fov defines the horizontal field of view
  4439. * @param aspect defines the aspect ratio
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @returns a new matrix as a right-handed perspective projection matrix
  4443. */
  4444. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4445. /**
  4446. * Stores a right-handed perspective projection into a given matrix
  4447. * @param fov defines the horizontal field of view
  4448. * @param aspect defines the aspect ratio
  4449. * @param znear defines the near clip plane
  4450. * @param zfar defines the far clip plane
  4451. * @param result defines the target matrix
  4452. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4453. */
  4454. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4455. /**
  4456. * Stores a perspective projection for WebVR info a given matrix
  4457. * @param fov defines the field of view
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4462. */
  4463. static PerspectiveFovWebVRToRef(fov: {
  4464. upDegrees: number;
  4465. downDegrees: number;
  4466. leftDegrees: number;
  4467. rightDegrees: number;
  4468. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4469. /**
  4470. * Computes a complete transformation matrix
  4471. * @param viewport defines the viewport to use
  4472. * @param world defines the world matrix
  4473. * @param view defines the view matrix
  4474. * @param projection defines the projection matrix
  4475. * @param zmin defines the near clip plane
  4476. * @param zmax defines the far clip plane
  4477. * @returns the transformation matrix
  4478. */
  4479. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4480. /**
  4481. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4482. * @param matrix defines the matrix to use
  4483. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4484. */
  4485. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4486. /**
  4487. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4488. * @param matrix defines the matrix to use
  4489. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4490. */
  4491. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4492. /**
  4493. * Compute the transpose of a given matrix
  4494. * @param matrix defines the matrix to transpose
  4495. * @returns the new matrix
  4496. */
  4497. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4498. /**
  4499. * Compute the transpose of a matrix and store it in a target matrix
  4500. * @param matrix defines the matrix to transpose
  4501. * @param result defines the target matrix
  4502. */
  4503. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4504. /**
  4505. * Computes a reflection matrix from a plane
  4506. * @param plane defines the reflection plane
  4507. * @returns a new matrix
  4508. */
  4509. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4510. /**
  4511. * Computes a reflection matrix from a plane
  4512. * @param plane defines the reflection plane
  4513. * @param result defines the target matrix
  4514. */
  4515. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4516. /**
  4517. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4518. * @param xaxis defines the value of the 1st axis
  4519. * @param yaxis defines the value of the 2nd axis
  4520. * @param zaxis defines the value of the 3rd axis
  4521. * @param result defines the target matrix
  4522. */
  4523. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4524. /**
  4525. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4526. * @param quat defines the quaternion to use
  4527. * @param result defines the target matrix
  4528. */
  4529. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4530. }
  4531. /**
  4532. * @hidden
  4533. */
  4534. export class TmpVectors {
  4535. static Vector2: Vector2[];
  4536. static Vector3: Vector3[];
  4537. static Vector4: Vector4[];
  4538. static Quaternion: Quaternion[];
  4539. static Matrix: Matrix[];
  4540. }
  4541. }
  4542. declare module "babylonjs/Maths/math.path" {
  4543. import { DeepImmutable, Nullable } from "babylonjs/types";
  4544. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4545. /**
  4546. * Defines potential orientation for back face culling
  4547. */
  4548. export enum Orientation {
  4549. /**
  4550. * Clockwise
  4551. */
  4552. CW = 0,
  4553. /** Counter clockwise */
  4554. CCW = 1
  4555. }
  4556. /** Class used to represent a Bezier curve */
  4557. export class BezierCurve {
  4558. /**
  4559. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4560. * @param t defines the time
  4561. * @param x1 defines the left coordinate on X axis
  4562. * @param y1 defines the left coordinate on Y axis
  4563. * @param x2 defines the right coordinate on X axis
  4564. * @param y2 defines the right coordinate on Y axis
  4565. * @returns the interpolated value
  4566. */
  4567. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4568. }
  4569. /**
  4570. * Defines angle representation
  4571. */
  4572. export class Angle {
  4573. private _radians;
  4574. /**
  4575. * Creates an Angle object of "radians" radians (float).
  4576. * @param radians the angle in radians
  4577. */
  4578. constructor(radians: number);
  4579. /**
  4580. * Get value in degrees
  4581. * @returns the Angle value in degrees (float)
  4582. */
  4583. degrees(): number;
  4584. /**
  4585. * Get value in radians
  4586. * @returns the Angle value in radians (float)
  4587. */
  4588. radians(): number;
  4589. /**
  4590. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4591. * @param a defines first vector
  4592. * @param b defines second vector
  4593. * @returns a new Angle
  4594. */
  4595. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4596. /**
  4597. * Gets a new Angle object from the given float in radians
  4598. * @param radians defines the angle value in radians
  4599. * @returns a new Angle
  4600. */
  4601. static FromRadians(radians: number): Angle;
  4602. /**
  4603. * Gets a new Angle object from the given float in degrees
  4604. * @param degrees defines the angle value in degrees
  4605. * @returns a new Angle
  4606. */
  4607. static FromDegrees(degrees: number): Angle;
  4608. }
  4609. /**
  4610. * This represents an arc in a 2d space.
  4611. */
  4612. export class Arc2 {
  4613. /** Defines the start point of the arc */
  4614. startPoint: Vector2;
  4615. /** Defines the mid point of the arc */
  4616. midPoint: Vector2;
  4617. /** Defines the end point of the arc */
  4618. endPoint: Vector2;
  4619. /**
  4620. * Defines the center point of the arc.
  4621. */
  4622. centerPoint: Vector2;
  4623. /**
  4624. * Defines the radius of the arc.
  4625. */
  4626. radius: number;
  4627. /**
  4628. * Defines the angle of the arc (from mid point to end point).
  4629. */
  4630. angle: Angle;
  4631. /**
  4632. * Defines the start angle of the arc (from start point to middle point).
  4633. */
  4634. startAngle: Angle;
  4635. /**
  4636. * Defines the orientation of the arc (clock wise/counter clock wise).
  4637. */
  4638. orientation: Orientation;
  4639. /**
  4640. * Creates an Arc object from the three given points : start, middle and end.
  4641. * @param startPoint Defines the start point of the arc
  4642. * @param midPoint Defines the midlle point of the arc
  4643. * @param endPoint Defines the end point of the arc
  4644. */
  4645. constructor(
  4646. /** Defines the start point of the arc */
  4647. startPoint: Vector2,
  4648. /** Defines the mid point of the arc */
  4649. midPoint: Vector2,
  4650. /** Defines the end point of the arc */
  4651. endPoint: Vector2);
  4652. }
  4653. /**
  4654. * Represents a 2D path made up of multiple 2D points
  4655. */
  4656. export class Path2 {
  4657. private _points;
  4658. private _length;
  4659. /**
  4660. * If the path start and end point are the same
  4661. */
  4662. closed: boolean;
  4663. /**
  4664. * Creates a Path2 object from the starting 2D coordinates x and y.
  4665. * @param x the starting points x value
  4666. * @param y the starting points y value
  4667. */
  4668. constructor(x: number, y: number);
  4669. /**
  4670. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4671. * @param x the added points x value
  4672. * @param y the added points y value
  4673. * @returns the updated Path2.
  4674. */
  4675. addLineTo(x: number, y: number): Path2;
  4676. /**
  4677. * 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.
  4678. * @param midX middle point x value
  4679. * @param midY middle point y value
  4680. * @param endX end point x value
  4681. * @param endY end point y value
  4682. * @param numberOfSegments (default: 36)
  4683. * @returns the updated Path2.
  4684. */
  4685. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4686. /**
  4687. * Closes the Path2.
  4688. * @returns the Path2.
  4689. */
  4690. close(): Path2;
  4691. /**
  4692. * Gets the sum of the distance between each sequential point in the path
  4693. * @returns the Path2 total length (float).
  4694. */
  4695. length(): number;
  4696. /**
  4697. * Gets the points which construct the path
  4698. * @returns the Path2 internal array of points.
  4699. */
  4700. getPoints(): Vector2[];
  4701. /**
  4702. * Retreives the point at the distance aways from the starting point
  4703. * @param normalizedLengthPosition the length along the path to retreive the point from
  4704. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4705. */
  4706. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4707. /**
  4708. * Creates a new path starting from an x and y position
  4709. * @param x starting x value
  4710. * @param y starting y value
  4711. * @returns a new Path2 starting at the coordinates (x, y).
  4712. */
  4713. static StartingAt(x: number, y: number): Path2;
  4714. }
  4715. /**
  4716. * Represents a 3D path made up of multiple 3D points
  4717. */
  4718. export class Path3D {
  4719. /**
  4720. * an array of Vector3, the curve axis of the Path3D
  4721. */
  4722. path: Vector3[];
  4723. private _curve;
  4724. private _distances;
  4725. private _tangents;
  4726. private _normals;
  4727. private _binormals;
  4728. private _raw;
  4729. /**
  4730. * new Path3D(path, normal, raw)
  4731. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4732. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4733. * @param path an array of Vector3, the curve axis of the Path3D
  4734. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4735. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4736. */
  4737. constructor(
  4738. /**
  4739. * an array of Vector3, the curve axis of the Path3D
  4740. */
  4741. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4742. /**
  4743. * Returns the Path3D array of successive Vector3 designing its curve.
  4744. * @returns the Path3D array of successive Vector3 designing its curve.
  4745. */
  4746. getCurve(): Vector3[];
  4747. /**
  4748. * Returns an array populated with tangent vectors on each Path3D curve point.
  4749. * @returns an array populated with tangent vectors on each Path3D curve point.
  4750. */
  4751. getTangents(): Vector3[];
  4752. /**
  4753. * Returns an array populated with normal vectors on each Path3D curve point.
  4754. * @returns an array populated with normal vectors on each Path3D curve point.
  4755. */
  4756. getNormals(): Vector3[];
  4757. /**
  4758. * Returns an array populated with binormal vectors on each Path3D curve point.
  4759. * @returns an array populated with binormal vectors on each Path3D curve point.
  4760. */
  4761. getBinormals(): Vector3[];
  4762. /**
  4763. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4764. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4765. */
  4766. getDistances(): number[];
  4767. /**
  4768. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4769. * @param path path which all values are copied into the curves points
  4770. * @param firstNormal which should be projected onto the curve
  4771. * @returns the same object updated.
  4772. */
  4773. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4774. private _compute;
  4775. private _getFirstNonNullVector;
  4776. private _getLastNonNullVector;
  4777. private _normalVector;
  4778. }
  4779. /**
  4780. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4781. * A Curve3 is designed from a series of successive Vector3.
  4782. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4783. */
  4784. export class Curve3 {
  4785. private _points;
  4786. private _length;
  4787. /**
  4788. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4789. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4790. * @param v1 (Vector3) the control point
  4791. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4792. * @param nbPoints (integer) the wanted number of points in the curve
  4793. * @returns the created Curve3
  4794. */
  4795. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4796. /**
  4797. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4798. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4799. * @param v1 (Vector3) the first control point
  4800. * @param v2 (Vector3) the second control point
  4801. * @param v3 (Vector3) the end point of the Cubic Bezier
  4802. * @param nbPoints (integer) the wanted number of points in the curve
  4803. * @returns the created Curve3
  4804. */
  4805. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4806. /**
  4807. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4808. * @param p1 (Vector3) the origin point of the Hermite Spline
  4809. * @param t1 (Vector3) the tangent vector at the origin point
  4810. * @param p2 (Vector3) the end point of the Hermite Spline
  4811. * @param t2 (Vector3) the tangent vector at the end point
  4812. * @param nbPoints (integer) the wanted number of points in the curve
  4813. * @returns the created Curve3
  4814. */
  4815. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4816. /**
  4817. * Returns a Curve3 object along a CatmullRom Spline curve :
  4818. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4819. * @param nbPoints (integer) the wanted number of points between each curve control points
  4820. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4821. * @returns the created Curve3
  4822. */
  4823. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4824. /**
  4825. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4826. * A Curve3 is designed from a series of successive Vector3.
  4827. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4828. * @param points points which make up the curve
  4829. */
  4830. constructor(points: Vector3[]);
  4831. /**
  4832. * @returns the Curve3 stored array of successive Vector3
  4833. */
  4834. getPoints(): Vector3[];
  4835. /**
  4836. * @returns the computed length (float) of the curve.
  4837. */
  4838. length(): number;
  4839. /**
  4840. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4841. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4842. * curveA and curveB keep unchanged.
  4843. * @param curve the curve to continue from this curve
  4844. * @returns the newly constructed curve
  4845. */
  4846. continue(curve: DeepImmutable<Curve3>): Curve3;
  4847. private _computeLength;
  4848. }
  4849. }
  4850. declare module "babylonjs/Animations/easing" {
  4851. /**
  4852. * This represents the main contract an easing function should follow.
  4853. * Easing functions are used throughout the animation system.
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. export interface IEasingFunction {
  4857. /**
  4858. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4859. * of the easing function.
  4860. * The link below provides some of the most common examples of easing functions.
  4861. * @see https://easings.net/
  4862. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4863. * @returns the corresponding value on the curve defined by the easing function
  4864. */
  4865. ease(gradient: number): number;
  4866. }
  4867. /**
  4868. * Base class used for every default easing function.
  4869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4870. */
  4871. export class EasingFunction implements IEasingFunction {
  4872. /**
  4873. * Interpolation follows the mathematical formula associated with the easing function.
  4874. */
  4875. static readonly EASINGMODE_EASEIN: number;
  4876. /**
  4877. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4878. */
  4879. static readonly EASINGMODE_EASEOUT: number;
  4880. /**
  4881. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4882. */
  4883. static readonly EASINGMODE_EASEINOUT: number;
  4884. private _easingMode;
  4885. /**
  4886. * Sets the easing mode of the current function.
  4887. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4888. */
  4889. setEasingMode(easingMode: number): void;
  4890. /**
  4891. * Gets the current easing mode.
  4892. * @returns the easing mode
  4893. */
  4894. getEasingMode(): number;
  4895. /**
  4896. * @hidden
  4897. */
  4898. easeInCore(gradient: number): number;
  4899. /**
  4900. * Given an input gradient between 0 and 1, this returns the corresponding value
  4901. * of the easing function.
  4902. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4903. * @returns the corresponding value on the curve defined by the easing function
  4904. */
  4905. ease(gradient: number): number;
  4906. }
  4907. /**
  4908. * Easing function with a circle shape (see link below).
  4909. * @see https://easings.net/#easeInCirc
  4910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4911. */
  4912. export class CircleEase extends EasingFunction implements IEasingFunction {
  4913. /** @hidden */
  4914. easeInCore(gradient: number): number;
  4915. }
  4916. /**
  4917. * Easing function with a ease back shape (see link below).
  4918. * @see https://easings.net/#easeInBack
  4919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4920. */
  4921. export class BackEase extends EasingFunction implements IEasingFunction {
  4922. /** Defines the amplitude of the function */
  4923. amplitude: number;
  4924. /**
  4925. * Instantiates a back ease easing
  4926. * @see https://easings.net/#easeInBack
  4927. * @param amplitude Defines the amplitude of the function
  4928. */
  4929. constructor(
  4930. /** Defines the amplitude of the function */
  4931. amplitude?: number);
  4932. /** @hidden */
  4933. easeInCore(gradient: number): number;
  4934. }
  4935. /**
  4936. * Easing function with a bouncing shape (see link below).
  4937. * @see https://easings.net/#easeInBounce
  4938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4939. */
  4940. export class BounceEase extends EasingFunction implements IEasingFunction {
  4941. /** Defines the number of bounces */
  4942. bounces: number;
  4943. /** Defines the amplitude of the bounce */
  4944. bounciness: number;
  4945. /**
  4946. * Instantiates a bounce easing
  4947. * @see https://easings.net/#easeInBounce
  4948. * @param bounces Defines the number of bounces
  4949. * @param bounciness Defines the amplitude of the bounce
  4950. */
  4951. constructor(
  4952. /** Defines the number of bounces */
  4953. bounces?: number,
  4954. /** Defines the amplitude of the bounce */
  4955. bounciness?: number);
  4956. /** @hidden */
  4957. easeInCore(gradient: number): number;
  4958. }
  4959. /**
  4960. * Easing function with a power of 3 shape (see link below).
  4961. * @see https://easings.net/#easeInCubic
  4962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4963. */
  4964. export class CubicEase extends EasingFunction implements IEasingFunction {
  4965. /** @hidden */
  4966. easeInCore(gradient: number): number;
  4967. }
  4968. /**
  4969. * Easing function with an elastic shape (see link below).
  4970. * @see https://easings.net/#easeInElastic
  4971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4972. */
  4973. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4974. /** Defines the number of oscillations*/
  4975. oscillations: number;
  4976. /** Defines the amplitude of the oscillations*/
  4977. springiness: number;
  4978. /**
  4979. * Instantiates an elastic easing function
  4980. * @see https://easings.net/#easeInElastic
  4981. * @param oscillations Defines the number of oscillations
  4982. * @param springiness Defines the amplitude of the oscillations
  4983. */
  4984. constructor(
  4985. /** Defines the number of oscillations*/
  4986. oscillations?: number,
  4987. /** Defines the amplitude of the oscillations*/
  4988. springiness?: number);
  4989. /** @hidden */
  4990. easeInCore(gradient: number): number;
  4991. }
  4992. /**
  4993. * Easing function with an exponential shape (see link below).
  4994. * @see https://easings.net/#easeInExpo
  4995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4996. */
  4997. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4998. /** Defines the exponent of the function */
  4999. exponent: number;
  5000. /**
  5001. * Instantiates an exponential easing function
  5002. * @see https://easings.net/#easeInExpo
  5003. * @param exponent Defines the exponent of the function
  5004. */
  5005. constructor(
  5006. /** Defines the exponent of the function */
  5007. exponent?: number);
  5008. /** @hidden */
  5009. easeInCore(gradient: number): number;
  5010. }
  5011. /**
  5012. * Easing function with a power shape (see link below).
  5013. * @see https://easings.net/#easeInQuad
  5014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5015. */
  5016. export class PowerEase extends EasingFunction implements IEasingFunction {
  5017. /** Defines the power of the function */
  5018. power: number;
  5019. /**
  5020. * Instantiates an power base easing function
  5021. * @see https://easings.net/#easeInQuad
  5022. * @param power Defines the power of the function
  5023. */
  5024. constructor(
  5025. /** Defines the power of the function */
  5026. power?: number);
  5027. /** @hidden */
  5028. easeInCore(gradient: number): number;
  5029. }
  5030. /**
  5031. * Easing function with a power of 2 shape (see link below).
  5032. * @see https://easings.net/#easeInQuad
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5036. /** @hidden */
  5037. easeInCore(gradient: number): number;
  5038. }
  5039. /**
  5040. * Easing function with a power of 4 shape (see link below).
  5041. * @see https://easings.net/#easeInQuart
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5045. /** @hidden */
  5046. easeInCore(gradient: number): number;
  5047. }
  5048. /**
  5049. * Easing function with a power of 5 shape (see link below).
  5050. * @see https://easings.net/#easeInQuint
  5051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5052. */
  5053. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5054. /** @hidden */
  5055. easeInCore(gradient: number): number;
  5056. }
  5057. /**
  5058. * Easing function with a sin shape (see link below).
  5059. * @see https://easings.net/#easeInSine
  5060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5061. */
  5062. export class SineEase extends EasingFunction implements IEasingFunction {
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a bezier shape (see link below).
  5068. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the x component of the start tangent in the bezier curve */
  5073. x1: number;
  5074. /** Defines the y component of the start tangent in the bezier curve */
  5075. y1: number;
  5076. /** Defines the x component of the end tangent in the bezier curve */
  5077. x2: number;
  5078. /** Defines the y component of the end tangent in the bezier curve */
  5079. y2: number;
  5080. /**
  5081. * Instantiates a bezier function
  5082. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5083. * @param x1 Defines the x component of the start tangent in the bezier curve
  5084. * @param y1 Defines the y component of the start tangent in the bezier curve
  5085. * @param x2 Defines the x component of the end tangent in the bezier curve
  5086. * @param y2 Defines the y component of the end tangent in the bezier curve
  5087. */
  5088. constructor(
  5089. /** Defines the x component of the start tangent in the bezier curve */
  5090. x1?: number,
  5091. /** Defines the y component of the start tangent in the bezier curve */
  5092. y1?: number,
  5093. /** Defines the x component of the end tangent in the bezier curve */
  5094. x2?: number,
  5095. /** Defines the y component of the end tangent in the bezier curve */
  5096. y2?: number);
  5097. /** @hidden */
  5098. easeInCore(gradient: number): number;
  5099. }
  5100. }
  5101. declare module "babylonjs/Maths/math.color" {
  5102. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5103. /**
  5104. * Class used to hold a RBG color
  5105. */
  5106. export class Color3 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5121. * @param r defines the red component (between 0 and 1, default is 0)
  5122. * @param g defines the green component (between 0 and 1, default is 0)
  5123. * @param b defines the blue component (between 0 and 1, default is 0)
  5124. */
  5125. constructor(
  5126. /**
  5127. * Defines the red component (between 0 and 1, default is 0)
  5128. */
  5129. r?: number,
  5130. /**
  5131. * Defines the green component (between 0 and 1, default is 0)
  5132. */
  5133. g?: number,
  5134. /**
  5135. * Defines the blue component (between 0 and 1, default is 0)
  5136. */
  5137. b?: number);
  5138. /**
  5139. * Creates a string with the Color3 current values
  5140. * @returns the string representation of the Color3 object
  5141. */
  5142. toString(): string;
  5143. /**
  5144. * Returns the string "Color3"
  5145. * @returns "Color3"
  5146. */
  5147. getClassName(): string;
  5148. /**
  5149. * Compute the Color3 hash code
  5150. * @returns an unique number that can be used to hash Color3 objects
  5151. */
  5152. getHashCode(): number;
  5153. /**
  5154. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5155. * @param array defines the array where to store the r,g,b components
  5156. * @param index defines an optional index in the target array to define where to start storing values
  5157. * @returns the current Color3 object
  5158. */
  5159. toArray(array: FloatArray, index?: number): Color3;
  5160. /**
  5161. * Returns a new Color4 object from the current Color3 and the given alpha
  5162. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5163. * @returns a new Color4 object
  5164. */
  5165. toColor4(alpha?: number): Color4;
  5166. /**
  5167. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Returns the luminance value
  5173. * @returns a float value
  5174. */
  5175. toLuminance(): number;
  5176. /**
  5177. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5178. * @param otherColor defines the second operand
  5179. * @returns the new Color3 object
  5180. */
  5181. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5182. /**
  5183. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5184. * @param otherColor defines the second operand
  5185. * @param result defines the Color3 object where to store the result
  5186. * @returns the current Color3
  5187. */
  5188. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5189. /**
  5190. * Determines equality between Color3 objects
  5191. * @param otherColor defines the second operand
  5192. * @returns true if the rgb values are equal to the given ones
  5193. */
  5194. equals(otherColor: DeepImmutable<Color3>): boolean;
  5195. /**
  5196. * Determines equality between the current Color3 object and a set of r,b,g values
  5197. * @param r defines the red component to check
  5198. * @param g defines the green component to check
  5199. * @param b defines the blue component to check
  5200. * @returns true if the rgb values are equal to the given ones
  5201. */
  5202. equalsFloats(r: number, g: number, b: number): boolean;
  5203. /**
  5204. * Multiplies in place each rgb value by scale
  5205. * @param scale defines the scaling factor
  5206. * @returns the updated Color3
  5207. */
  5208. scale(scale: number): Color3;
  5209. /**
  5210. * Multiplies the rgb values by scale and stores the result into "result"
  5211. * @param scale defines the scaling factor
  5212. * @param result defines the Color3 object where to store the result
  5213. * @returns the unmodified current Color3
  5214. */
  5215. scaleToRef(scale: number, result: Color3): Color3;
  5216. /**
  5217. * Scale the current Color3 values by a factor and add the result to a given Color3
  5218. * @param scale defines the scale factor
  5219. * @param result defines color to store the result into
  5220. * @returns the unmodified current Color3
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into
  5228. * @returns the original Color3
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5231. /**
  5232. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5233. * @param otherColor defines the second operand
  5234. * @returns the new Color3
  5235. */
  5236. add(otherColor: DeepImmutable<Color3>): Color3;
  5237. /**
  5238. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5239. * @param otherColor defines the second operand
  5240. * @param result defines Color3 object to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5244. /**
  5245. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5246. * @param otherColor defines the second operand
  5247. * @returns the new Color3
  5248. */
  5249. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5250. /**
  5251. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5252. * @param otherColor defines the second operand
  5253. * @param result defines Color3 object to store the result into
  5254. * @returns the unmodified current Color3
  5255. */
  5256. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5257. /**
  5258. * Copy the current object
  5259. * @returns a new Color3 copied the current one
  5260. */
  5261. clone(): Color3;
  5262. /**
  5263. * Copies the rgb values from the source in the current Color3
  5264. * @param source defines the source Color3 object
  5265. * @returns the updated Color3 object
  5266. */
  5267. copyFrom(source: DeepImmutable<Color3>): Color3;
  5268. /**
  5269. * Updates the Color3 rgb values from the given floats
  5270. * @param r defines the red component to read from
  5271. * @param g defines the green component to read from
  5272. * @param b defines the blue component to read from
  5273. * @returns the current Color3 object
  5274. */
  5275. copyFromFloats(r: number, g: number, b: number): Color3;
  5276. /**
  5277. * Updates the Color3 rgb values from the given floats
  5278. * @param r defines the red component to read from
  5279. * @param g defines the green component to read from
  5280. * @param b defines the blue component to read from
  5281. * @returns the current Color3 object
  5282. */
  5283. set(r: number, g: number, b: number): Color3;
  5284. /**
  5285. * Compute the Color3 hexadecimal code as a string
  5286. * @returns a string containing the hexadecimal representation of the Color3 object
  5287. */
  5288. toHexString(): string;
  5289. /**
  5290. * Computes a new Color3 converted from the current one to linear space
  5291. * @returns a new Color3 object
  5292. */
  5293. toLinearSpace(): Color3;
  5294. /**
  5295. * Converts current color in rgb space to HSV values
  5296. * @returns a new color3 representing the HSV values
  5297. */
  5298. toHSV(): Color3;
  5299. /**
  5300. * Converts current color in rgb space to HSV values
  5301. * @param result defines the Color3 where to store the HSV values
  5302. */
  5303. toHSVToRef(result: Color3): void;
  5304. /**
  5305. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color3 object where to store the linear space version
  5307. * @returns the unmodified Color3
  5308. */
  5309. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to gamma space
  5312. * @returns a new Color3 object
  5313. */
  5314. toGammaSpace(): Color3;
  5315. /**
  5316. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the gamma space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5321. private static _BlackReadOnly;
  5322. /**
  5323. * Convert Hue, saturation and value to a Color3 (RGB)
  5324. * @param hue defines the hue
  5325. * @param saturation defines the saturation
  5326. * @param value defines the value
  5327. * @param result defines the Color3 where to store the RGB values
  5328. */
  5329. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5330. /**
  5331. * Creates a new Color3 from the string containing valid hexadecimal values
  5332. * @param hex defines a string containing valid hexadecimal values
  5333. * @returns a new Color3 object
  5334. */
  5335. static FromHexString(hex: string): Color3;
  5336. /**
  5337. * Creates a new Color3 from the starting index of the given array
  5338. * @param array defines the source array
  5339. * @param offset defines an offset in the source array
  5340. * @returns a new Color3 object
  5341. */
  5342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5343. /**
  5344. * Creates a new Color3 from integer values (< 256)
  5345. * @param r defines the red component to read from (value between 0 and 255)
  5346. * @param g defines the green component to read from (value between 0 and 255)
  5347. * @param b defines the blue component to read from (value between 0 and 255)
  5348. * @returns a new Color3 object
  5349. */
  5350. static FromInts(r: number, g: number, b: number): Color3;
  5351. /**
  5352. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5353. * @param start defines the start Color3 value
  5354. * @param end defines the end Color3 value
  5355. * @param amount defines the gradient value between start and end
  5356. * @returns a new Color3 object
  5357. */
  5358. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5359. /**
  5360. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5361. * @param left defines the start value
  5362. * @param right defines the end value
  5363. * @param amount defines the gradient factor
  5364. * @param result defines the Color3 object where to store the result
  5365. */
  5366. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5367. /**
  5368. * Returns a Color3 value containing a red color
  5369. * @returns a new Color3 object
  5370. */
  5371. static Red(): Color3;
  5372. /**
  5373. * Returns a Color3 value containing a green color
  5374. * @returns a new Color3 object
  5375. */
  5376. static Green(): Color3;
  5377. /**
  5378. * Returns a Color3 value containing a blue color
  5379. * @returns a new Color3 object
  5380. */
  5381. static Blue(): Color3;
  5382. /**
  5383. * Returns a Color3 value containing a black color
  5384. * @returns a new Color3 object
  5385. */
  5386. static Black(): Color3;
  5387. /**
  5388. * Gets a Color3 value containing a black color that must not be updated
  5389. */
  5390. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5391. /**
  5392. * Returns a Color3 value containing a white color
  5393. * @returns a new Color3 object
  5394. */
  5395. static White(): Color3;
  5396. /**
  5397. * Returns a Color3 value containing a purple color
  5398. * @returns a new Color3 object
  5399. */
  5400. static Purple(): Color3;
  5401. /**
  5402. * Returns a Color3 value containing a magenta color
  5403. * @returns a new Color3 object
  5404. */
  5405. static Magenta(): Color3;
  5406. /**
  5407. * Returns a Color3 value containing a yellow color
  5408. * @returns a new Color3 object
  5409. */
  5410. static Yellow(): Color3;
  5411. /**
  5412. * Returns a Color3 value containing a gray color
  5413. * @returns a new Color3 object
  5414. */
  5415. static Gray(): Color3;
  5416. /**
  5417. * Returns a Color3 value containing a teal color
  5418. * @returns a new Color3 object
  5419. */
  5420. static Teal(): Color3;
  5421. /**
  5422. * Returns a Color3 value containing a random color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Random(): Color3;
  5426. }
  5427. /**
  5428. * Class used to hold a RBGA color
  5429. */
  5430. export class Color4 {
  5431. /**
  5432. * Defines the red component (between 0 and 1, default is 0)
  5433. */
  5434. r: number;
  5435. /**
  5436. * Defines the green component (between 0 and 1, default is 0)
  5437. */
  5438. g: number;
  5439. /**
  5440. * Defines the blue component (between 0 and 1, default is 0)
  5441. */
  5442. b: number;
  5443. /**
  5444. * Defines the alpha component (between 0 and 1, default is 1)
  5445. */
  5446. a: number;
  5447. /**
  5448. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5449. * @param r defines the red component (between 0 and 1, default is 0)
  5450. * @param g defines the green component (between 0 and 1, default is 0)
  5451. * @param b defines the blue component (between 0 and 1, default is 0)
  5452. * @param a defines the alpha component (between 0 and 1, default is 1)
  5453. */
  5454. constructor(
  5455. /**
  5456. * Defines the red component (between 0 and 1, default is 0)
  5457. */
  5458. r?: number,
  5459. /**
  5460. * Defines the green component (between 0 and 1, default is 0)
  5461. */
  5462. g?: number,
  5463. /**
  5464. * Defines the blue component (between 0 and 1, default is 0)
  5465. */
  5466. b?: number,
  5467. /**
  5468. * Defines the alpha component (between 0 and 1, default is 1)
  5469. */
  5470. a?: number);
  5471. /**
  5472. * Adds in place the given Color4 values to the current Color4 object
  5473. * @param right defines the second operand
  5474. * @returns the current updated Color4 object
  5475. */
  5476. addInPlace(right: DeepImmutable<Color4>): Color4;
  5477. /**
  5478. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Stores from the starting index in the given array the Color4 successive values
  5484. * @param array defines the array where to store the r,g,b components
  5485. * @param index defines an optional index in the target array to define where to start storing values
  5486. * @returns the current Color4 object
  5487. */
  5488. toArray(array: number[], index?: number): Color4;
  5489. /**
  5490. * Determines equality between Color4 objects
  5491. * @param otherColor defines the second operand
  5492. * @returns true if the rgba values are equal to the given ones
  5493. */
  5494. equals(otherColor: DeepImmutable<Color4>): boolean;
  5495. /**
  5496. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5497. * @param right defines the second operand
  5498. * @returns a new Color4 object
  5499. */
  5500. add(right: DeepImmutable<Color4>): Color4;
  5501. /**
  5502. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5503. * @param right defines the second operand
  5504. * @returns a new Color4 object
  5505. */
  5506. subtract(right: DeepImmutable<Color4>): Color4;
  5507. /**
  5508. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5509. * @param right defines the second operand
  5510. * @param result defines the Color4 object where to store the result
  5511. * @returns the current Color4 object
  5512. */
  5513. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5514. /**
  5515. * Creates a new Color4 with the current Color4 values multiplied by scale
  5516. * @param scale defines the scaling factor to apply
  5517. * @returns a new Color4 object
  5518. */
  5519. scale(scale: number): Color4;
  5520. /**
  5521. * Multiplies the current Color4 values by scale and stores the result in "result"
  5522. * @param scale defines the scaling factor to apply
  5523. * @param result defines the Color4 object where to store the result
  5524. * @returns the current unmodified Color4
  5525. */
  5526. scaleToRef(scale: number, result: Color4): Color4;
  5527. /**
  5528. * Scale the current Color4 values by a factor and add the result to a given Color4
  5529. * @param scale defines the scale factor
  5530. * @param result defines the Color4 object where to store the result
  5531. * @returns the unmodified current Color4
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into.
  5539. * @returns the cuurent Color4
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5542. /**
  5543. * Multipy an Color4 value by another and return a new Color4 object
  5544. * @param color defines the Color4 value to multiply by
  5545. * @returns a new Color4 object
  5546. */
  5547. multiply(color: Color4): Color4;
  5548. /**
  5549. * Multipy a Color4 value by another and push the result in a reference value
  5550. * @param color defines the Color4 value to multiply by
  5551. * @param result defines the Color4 to fill the result in
  5552. * @returns the result Color4
  5553. */
  5554. multiplyToRef(color: Color4, result: Color4): Color4;
  5555. /**
  5556. * Creates a string with the Color4 current values
  5557. * @returns the string representation of the Color4 object
  5558. */
  5559. toString(): string;
  5560. /**
  5561. * Returns the string "Color4"
  5562. * @returns "Color4"
  5563. */
  5564. getClassName(): string;
  5565. /**
  5566. * Compute the Color4 hash code
  5567. * @returns an unique number that can be used to hash Color4 objects
  5568. */
  5569. getHashCode(): number;
  5570. /**
  5571. * Creates a new Color4 copied from the current one
  5572. * @returns a new Color4 object
  5573. */
  5574. clone(): Color4;
  5575. /**
  5576. * Copies the given Color4 values into the current one
  5577. * @param source defines the source Color4 object
  5578. * @returns the current updated Color4 object
  5579. */
  5580. copyFrom(source: Color4): Color4;
  5581. /**
  5582. * Copies the given float values into the current one
  5583. * @param r defines the red component to read from
  5584. * @param g defines the green component to read from
  5585. * @param b defines the blue component to read from
  5586. * @param a defines the alpha component to read from
  5587. * @returns the current updated Color4 object
  5588. */
  5589. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5590. /**
  5591. * Copies the given float values into the current one
  5592. * @param r defines the red component to read from
  5593. * @param g defines the green component to read from
  5594. * @param b defines the blue component to read from
  5595. * @param a defines the alpha component to read from
  5596. * @returns the current updated Color4 object
  5597. */
  5598. set(r: number, g: number, b: number, a: number): Color4;
  5599. /**
  5600. * Compute the Color4 hexadecimal code as a string
  5601. * @returns a string containing the hexadecimal representation of the Color4 object
  5602. */
  5603. toHexString(): string;
  5604. /**
  5605. * Computes a new Color4 converted from the current one to linear space
  5606. * @returns a new Color4 object
  5607. */
  5608. toLinearSpace(): Color4;
  5609. /**
  5610. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5611. * @param convertedColor defines the Color4 object where to store the linear space version
  5612. * @returns the unmodified Color4
  5613. */
  5614. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to gamma space
  5617. * @returns a new Color4 object
  5618. */
  5619. toGammaSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the gamma space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Creates a new Color4 from the string containing valid hexadecimal values
  5628. * @param hex defines a string containing valid hexadecimal values
  5629. * @returns a new Color4 object
  5630. */
  5631. static FromHexString(hex: string): Color4;
  5632. /**
  5633. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5634. * @param left defines the start value
  5635. * @param right defines the end value
  5636. * @param amount defines the gradient factor
  5637. * @returns a new Color4 object
  5638. */
  5639. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5640. /**
  5641. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5642. * @param left defines the start value
  5643. * @param right defines the end value
  5644. * @param amount defines the gradient factor
  5645. * @param result defines the Color4 object where to store data
  5646. */
  5647. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5648. /**
  5649. * Creates a new Color4 from a Color3 and an alpha value
  5650. * @param color3 defines the source Color3 to read from
  5651. * @param alpha defines the alpha component (1.0 by default)
  5652. * @returns a new Color4 object
  5653. */
  5654. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5655. /**
  5656. * Creates a new Color4 from the starting index element of the given array
  5657. * @param array defines the source array to read from
  5658. * @param offset defines the offset in the source array
  5659. * @returns a new Color4 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @param a defines the alpha component to read from (value between 0 and 255)
  5668. * @returns a new Color3 object
  5669. */
  5670. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5671. /**
  5672. * Check the content of a given array and convert it to an array containing RGBA data
  5673. * If the original array was already containing count * 4 values then it is returned directly
  5674. * @param colors defines the array to check
  5675. * @param count defines the number of RGBA data to expect
  5676. * @returns an array containing count * 4 values (RGBA)
  5677. */
  5678. static CheckColors4(colors: number[], count: number): number[];
  5679. }
  5680. /**
  5681. * @hidden
  5682. */
  5683. export class TmpColors {
  5684. static Color3: Color3[];
  5685. static Color4: Color4[];
  5686. }
  5687. }
  5688. declare module "babylonjs/Animations/animationKey" {
  5689. /**
  5690. * Defines an interface which represents an animation key frame
  5691. */
  5692. export interface IAnimationKey {
  5693. /**
  5694. * Frame of the key frame
  5695. */
  5696. frame: number;
  5697. /**
  5698. * Value at the specifies key frame
  5699. */
  5700. value: any;
  5701. /**
  5702. * The input tangent for the cubic hermite spline
  5703. */
  5704. inTangent?: any;
  5705. /**
  5706. * The output tangent for the cubic hermite spline
  5707. */
  5708. outTangent?: any;
  5709. /**
  5710. * The animation interpolation type
  5711. */
  5712. interpolation?: AnimationKeyInterpolation;
  5713. }
  5714. /**
  5715. * Enum for the animation key frame interpolation type
  5716. */
  5717. export enum AnimationKeyInterpolation {
  5718. /**
  5719. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5720. */
  5721. STEP = 1
  5722. }
  5723. }
  5724. declare module "babylonjs/Animations/animationRange" {
  5725. /**
  5726. * Represents the range of an animation
  5727. */
  5728. export class AnimationRange {
  5729. /**The name of the animation range**/
  5730. name: string;
  5731. /**The starting frame of the animation */
  5732. from: number;
  5733. /**The ending frame of the animation*/
  5734. to: number;
  5735. /**
  5736. * Initializes the range of an animation
  5737. * @param name The name of the animation range
  5738. * @param from The starting frame of the animation
  5739. * @param to The ending frame of the animation
  5740. */
  5741. constructor(
  5742. /**The name of the animation range**/
  5743. name: string,
  5744. /**The starting frame of the animation */
  5745. from: number,
  5746. /**The ending frame of the animation*/
  5747. to: number);
  5748. /**
  5749. * Makes a copy of the animation range
  5750. * @returns A copy of the animation range
  5751. */
  5752. clone(): AnimationRange;
  5753. }
  5754. }
  5755. declare module "babylonjs/Animations/animationEvent" {
  5756. /**
  5757. * Composed of a frame, and an action function
  5758. */
  5759. export class AnimationEvent {
  5760. /** The frame for which the event is triggered **/
  5761. frame: number;
  5762. /** The event to perform when triggered **/
  5763. action: (currentFrame: number) => void;
  5764. /** Specifies if the event should be triggered only once**/
  5765. onlyOnce?: boolean | undefined;
  5766. /**
  5767. * Specifies if the animation event is done
  5768. */
  5769. isDone: boolean;
  5770. /**
  5771. * Initializes the animation event
  5772. * @param frame The frame for which the event is triggered
  5773. * @param action The event to perform when triggered
  5774. * @param onlyOnce Specifies if the event should be triggered only once
  5775. */
  5776. constructor(
  5777. /** The frame for which the event is triggered **/
  5778. frame: number,
  5779. /** The event to perform when triggered **/
  5780. action: (currentFrame: number) => void,
  5781. /** Specifies if the event should be triggered only once**/
  5782. onlyOnce?: boolean | undefined);
  5783. /** @hidden */
  5784. _clone(): AnimationEvent;
  5785. }
  5786. }
  5787. declare module "babylonjs/Behaviors/behavior" {
  5788. import { Nullable } from "babylonjs/types";
  5789. /**
  5790. * Interface used to define a behavior
  5791. */
  5792. export interface Behavior<T> {
  5793. /** gets or sets behavior's name */
  5794. name: string;
  5795. /**
  5796. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5797. */
  5798. init(): void;
  5799. /**
  5800. * Called when the behavior is attached to a target
  5801. * @param target defines the target where the behavior is attached to
  5802. */
  5803. attach(target: T): void;
  5804. /**
  5805. * Called when the behavior is detached from its target
  5806. */
  5807. detach(): void;
  5808. }
  5809. /**
  5810. * Interface implemented by classes supporting behaviors
  5811. */
  5812. export interface IBehaviorAware<T> {
  5813. /**
  5814. * Attach a behavior
  5815. * @param behavior defines the behavior to attach
  5816. * @returns the current host
  5817. */
  5818. addBehavior(behavior: Behavior<T>): T;
  5819. /**
  5820. * Remove a behavior from the current object
  5821. * @param behavior defines the behavior to detach
  5822. * @returns the current host
  5823. */
  5824. removeBehavior(behavior: Behavior<T>): T;
  5825. /**
  5826. * Gets a behavior using its name to search
  5827. * @param name defines the name to search
  5828. * @returns the behavior or null if not found
  5829. */
  5830. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5831. }
  5832. }
  5833. declare module "babylonjs/Misc/smartArray" {
  5834. /**
  5835. * Defines an array and its length.
  5836. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5837. */
  5838. export interface ISmartArrayLike<T> {
  5839. /**
  5840. * The data of the array.
  5841. */
  5842. data: Array<T>;
  5843. /**
  5844. * The active length of the array.
  5845. */
  5846. length: number;
  5847. }
  5848. /**
  5849. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5850. */
  5851. export class SmartArray<T> implements ISmartArrayLike<T> {
  5852. /**
  5853. * The full set of data from the array.
  5854. */
  5855. data: Array<T>;
  5856. /**
  5857. * The active length of the array.
  5858. */
  5859. length: number;
  5860. protected _id: number;
  5861. /**
  5862. * Instantiates a Smart Array.
  5863. * @param capacity defines the default capacity of the array.
  5864. */
  5865. constructor(capacity: number);
  5866. /**
  5867. * Pushes a value at the end of the active data.
  5868. * @param value defines the object to push in the array.
  5869. */
  5870. push(value: T): void;
  5871. /**
  5872. * Iterates over the active data and apply the lambda to them.
  5873. * @param func defines the action to apply on each value.
  5874. */
  5875. forEach(func: (content: T) => void): void;
  5876. /**
  5877. * Sorts the full sets of data.
  5878. * @param compareFn defines the comparison function to apply.
  5879. */
  5880. sort(compareFn: (a: T, b: T) => number): void;
  5881. /**
  5882. * Resets the active data to an empty array.
  5883. */
  5884. reset(): void;
  5885. /**
  5886. * Releases all the data from the array as well as the array.
  5887. */
  5888. dispose(): void;
  5889. /**
  5890. * Concats the active data with a given array.
  5891. * @param array defines the data to concatenate with.
  5892. */
  5893. concat(array: any): void;
  5894. /**
  5895. * Returns the position of a value in the active data.
  5896. * @param value defines the value to find the index for
  5897. * @returns the index if found in the active data otherwise -1
  5898. */
  5899. indexOf(value: T): number;
  5900. /**
  5901. * Returns whether an element is part of the active data.
  5902. * @param value defines the value to look for
  5903. * @returns true if found in the active data otherwise false
  5904. */
  5905. contains(value: T): boolean;
  5906. private static _GlobalId;
  5907. }
  5908. /**
  5909. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5910. * The data in this array can only be present once
  5911. */
  5912. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5913. private _duplicateId;
  5914. /**
  5915. * Pushes a value at the end of the active data.
  5916. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5917. * @param value defines the object to push in the array.
  5918. */
  5919. push(value: T): void;
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * If the data is already present, it won t be added again
  5923. * @param value defines the object to push in the array.
  5924. * @returns true if added false if it was already present
  5925. */
  5926. pushNoDuplicate(value: T): boolean;
  5927. /**
  5928. * Resets the active data to an empty array.
  5929. */
  5930. reset(): void;
  5931. /**
  5932. * Concats the active data with a given array.
  5933. * This ensures no dupplicate will be present in the result.
  5934. * @param array defines the data to concatenate with.
  5935. */
  5936. concatWithNoDuplicate(array: any): void;
  5937. }
  5938. }
  5939. declare module "babylonjs/Cameras/cameraInputsManager" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Camera } from "babylonjs/Cameras/camera";
  5942. /**
  5943. * @ignore
  5944. * This is a list of all the different input types that are available in the application.
  5945. * Fo instance: ArcRotateCameraGamepadInput...
  5946. */
  5947. export var CameraInputTypes: {};
  5948. /**
  5949. * This is the contract to implement in order to create a new input class.
  5950. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5951. */
  5952. export interface ICameraInput<TCamera extends Camera> {
  5953. /**
  5954. * Defines the camera the input is attached to.
  5955. */
  5956. camera: Nullable<TCamera>;
  5957. /**
  5958. * Gets the class name of the current intput.
  5959. * @returns the class name
  5960. */
  5961. getClassName(): string;
  5962. /**
  5963. * Get the friendly name associated with the input class.
  5964. * @returns the input friendly name
  5965. */
  5966. getSimpleName(): string;
  5967. /**
  5968. * Attach the input controls to a specific dom element to get the input from.
  5969. * @param element Defines the element the controls should be listened from
  5970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5971. */
  5972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5973. /**
  5974. * Detach the current controls from the specified dom element.
  5975. * @param element Defines the element to stop listening the inputs from
  5976. */
  5977. detachControl(element: Nullable<HTMLElement>): void;
  5978. /**
  5979. * Update the current camera state depending on the inputs that have been used this frame.
  5980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5981. */
  5982. checkInputs?: () => void;
  5983. }
  5984. /**
  5985. * Represents a map of input types to input instance or input index to input instance.
  5986. */
  5987. export interface CameraInputsMap<TCamera extends Camera> {
  5988. /**
  5989. * Accessor to the input by input type.
  5990. */
  5991. [name: string]: ICameraInput<TCamera>;
  5992. /**
  5993. * Accessor to the input by input index.
  5994. */
  5995. [idx: number]: ICameraInput<TCamera>;
  5996. }
  5997. /**
  5998. * This represents the input manager used within a camera.
  5999. * It helps dealing with all the different kind of input attached to a camera.
  6000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6001. */
  6002. export class CameraInputsManager<TCamera extends Camera> {
  6003. /**
  6004. * Defines the list of inputs attahed to the camera.
  6005. */
  6006. attached: CameraInputsMap<TCamera>;
  6007. /**
  6008. * Defines the dom element the camera is collecting inputs from.
  6009. * This is null if the controls have not been attached.
  6010. */
  6011. attachedElement: Nullable<HTMLElement>;
  6012. /**
  6013. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6014. */
  6015. noPreventDefault: boolean;
  6016. /**
  6017. * Defined the camera the input manager belongs to.
  6018. */
  6019. camera: TCamera;
  6020. /**
  6021. * Update the current camera state depending on the inputs that have been used this frame.
  6022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6023. */
  6024. checkInputs: () => void;
  6025. /**
  6026. * Instantiate a new Camera Input Manager.
  6027. * @param camera Defines the camera the input manager blongs to
  6028. */
  6029. constructor(camera: TCamera);
  6030. /**
  6031. * Add an input method to a camera
  6032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6033. * @param input camera input method
  6034. */
  6035. add(input: ICameraInput<TCamera>): void;
  6036. /**
  6037. * Remove a specific input method from a camera
  6038. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6039. * @param inputToRemove camera input method
  6040. */
  6041. remove(inputToRemove: ICameraInput<TCamera>): void;
  6042. /**
  6043. * Remove a specific input type from a camera
  6044. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6045. * @param inputType the type of the input to remove
  6046. */
  6047. removeByType(inputType: string): void;
  6048. private _addCheckInputs;
  6049. /**
  6050. * Attach the input controls to the currently attached dom element to listen the events from.
  6051. * @param input Defines the input to attach
  6052. */
  6053. attachInput(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6056. * @param element Defines the dom element to collect the events from
  6057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6058. */
  6059. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6060. /**
  6061. * Detach the current manager inputs controls from a specific dom element.
  6062. * @param element Defines the dom element to collect the events from
  6063. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6064. */
  6065. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6066. /**
  6067. * Rebuild the dynamic inputCheck function from the current list of
  6068. * defined inputs in the manager.
  6069. */
  6070. rebuildInputCheck(): void;
  6071. /**
  6072. * Remove all attached input methods from a camera
  6073. */
  6074. clear(): void;
  6075. /**
  6076. * Serialize the current input manager attached to a camera.
  6077. * This ensures than once parsed,
  6078. * the input associated to the camera will be identical to the current ones
  6079. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6080. */
  6081. serialize(serializedCamera: any): void;
  6082. /**
  6083. * Parses an input manager serialized JSON to restore the previous list of inputs
  6084. * and states associated to a camera.
  6085. * @param parsedCamera Defines the JSON to parse
  6086. */
  6087. parse(parsedCamera: any): void;
  6088. }
  6089. }
  6090. declare module "babylonjs/Meshes/buffer" {
  6091. import { Nullable, DataArray } from "babylonjs/types";
  6092. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6093. /**
  6094. * Class used to store data that will be store in GPU memory
  6095. */
  6096. export class Buffer {
  6097. private _engine;
  6098. private _buffer;
  6099. /** @hidden */
  6100. _data: Nullable<DataArray>;
  6101. private _updatable;
  6102. private _instanced;
  6103. private _divisor;
  6104. /**
  6105. * Gets the byte stride.
  6106. */
  6107. readonly byteStride: number;
  6108. /**
  6109. * Constructor
  6110. * @param engine the engine
  6111. * @param data the data to use for this buffer
  6112. * @param updatable whether the data is updatable
  6113. * @param stride the stride (optional)
  6114. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6115. * @param instanced whether the buffer is instanced (optional)
  6116. * @param useBytes set to true if the stride in in bytes (optional)
  6117. * @param divisor sets an optional divisor for instances (1 by default)
  6118. */
  6119. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6120. /**
  6121. * Create a new VertexBuffer based on the current buffer
  6122. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6123. * @param offset defines offset in the buffer (0 by default)
  6124. * @param size defines the size in floats of attributes (position is 3 for instance)
  6125. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6126. * @param instanced defines if the vertex buffer contains indexed data
  6127. * @param useBytes defines if the offset and stride are in bytes *
  6128. * @param divisor sets an optional divisor for instances (1 by default)
  6129. * @returns the new vertex buffer
  6130. */
  6131. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6132. /**
  6133. * Gets a boolean indicating if the Buffer is updatable?
  6134. * @returns true if the buffer is updatable
  6135. */
  6136. isUpdatable(): boolean;
  6137. /**
  6138. * Gets current buffer's data
  6139. * @returns a DataArray or null
  6140. */
  6141. getData(): Nullable<DataArray>;
  6142. /**
  6143. * Gets underlying native buffer
  6144. * @returns underlying native buffer
  6145. */
  6146. getBuffer(): Nullable<DataBuffer>;
  6147. /**
  6148. * Gets the stride in float32 units (i.e. byte stride / 4).
  6149. * May not be an integer if the byte stride is not divisible by 4.
  6150. * DEPRECATED. Use byteStride instead.
  6151. * @returns the stride in float32 units
  6152. */
  6153. getStrideSize(): number;
  6154. /**
  6155. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6156. * @param data defines the data to store
  6157. */
  6158. create(data?: Nullable<DataArray>): void;
  6159. /** @hidden */
  6160. _rebuild(): void;
  6161. /**
  6162. * Update current buffer data
  6163. * @param data defines the data to store
  6164. */
  6165. update(data: DataArray): void;
  6166. /**
  6167. * Updates the data directly.
  6168. * @param data the new data
  6169. * @param offset the new offset
  6170. * @param vertexCount the vertex count (optional)
  6171. * @param useBytes set to true if the offset is in bytes
  6172. */
  6173. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6174. /**
  6175. * Release all resources
  6176. */
  6177. dispose(): void;
  6178. }
  6179. /**
  6180. * Specialized buffer used to store vertex data
  6181. */
  6182. export class VertexBuffer {
  6183. /** @hidden */
  6184. _buffer: Buffer;
  6185. private _kind;
  6186. private _size;
  6187. private _ownsBuffer;
  6188. private _instanced;
  6189. private _instanceDivisor;
  6190. /**
  6191. * The byte type.
  6192. */
  6193. static readonly BYTE: number;
  6194. /**
  6195. * The unsigned byte type.
  6196. */
  6197. static readonly UNSIGNED_BYTE: number;
  6198. /**
  6199. * The short type.
  6200. */
  6201. static readonly SHORT: number;
  6202. /**
  6203. * The unsigned short type.
  6204. */
  6205. static readonly UNSIGNED_SHORT: number;
  6206. /**
  6207. * The integer type.
  6208. */
  6209. static readonly INT: number;
  6210. /**
  6211. * The unsigned integer type.
  6212. */
  6213. static readonly UNSIGNED_INT: number;
  6214. /**
  6215. * The float type.
  6216. */
  6217. static readonly FLOAT: number;
  6218. /**
  6219. * Gets or sets the instance divisor when in instanced mode
  6220. */
  6221. instanceDivisor: number;
  6222. /**
  6223. * Gets the byte stride.
  6224. */
  6225. readonly byteStride: number;
  6226. /**
  6227. * Gets the byte offset.
  6228. */
  6229. readonly byteOffset: number;
  6230. /**
  6231. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6232. */
  6233. readonly normalized: boolean;
  6234. /**
  6235. * Gets the data type of each component in the array.
  6236. */
  6237. readonly type: number;
  6238. /**
  6239. * Constructor
  6240. * @param engine the engine
  6241. * @param data the data to use for this vertex buffer
  6242. * @param kind the vertex buffer kind
  6243. * @param updatable whether the data is updatable
  6244. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6245. * @param stride the stride (optional)
  6246. * @param instanced whether the buffer is instanced (optional)
  6247. * @param offset the offset of the data (optional)
  6248. * @param size the number of components (optional)
  6249. * @param type the type of the component (optional)
  6250. * @param normalized whether the data contains normalized data (optional)
  6251. * @param useBytes set to true if stride and offset are in bytes (optional)
  6252. * @param divisor defines the instance divisor to use (1 by default)
  6253. */
  6254. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6255. /** @hidden */
  6256. _rebuild(): void;
  6257. /**
  6258. * Returns the kind of the VertexBuffer (string)
  6259. * @returns a string
  6260. */
  6261. getKind(): string;
  6262. /**
  6263. * Gets a boolean indicating if the VertexBuffer is updatable?
  6264. * @returns true if the buffer is updatable
  6265. */
  6266. isUpdatable(): boolean;
  6267. /**
  6268. * Gets current buffer's data
  6269. * @returns a DataArray or null
  6270. */
  6271. getData(): Nullable<DataArray>;
  6272. /**
  6273. * Gets underlying native buffer
  6274. * @returns underlying native buffer
  6275. */
  6276. getBuffer(): Nullable<DataBuffer>;
  6277. /**
  6278. * Gets the stride in float32 units (i.e. byte stride / 4).
  6279. * May not be an integer if the byte stride is not divisible by 4.
  6280. * DEPRECATED. Use byteStride instead.
  6281. * @returns the stride in float32 units
  6282. */
  6283. getStrideSize(): number;
  6284. /**
  6285. * Returns the offset as a multiple of the type byte length.
  6286. * DEPRECATED. Use byteOffset instead.
  6287. * @returns the offset in bytes
  6288. */
  6289. getOffset(): number;
  6290. /**
  6291. * Returns the number of components per vertex attribute (integer)
  6292. * @returns the size in float
  6293. */
  6294. getSize(): number;
  6295. /**
  6296. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6297. * @returns true if this buffer is instanced
  6298. */
  6299. getIsInstanced(): boolean;
  6300. /**
  6301. * Returns the instancing divisor, zero for non-instanced (integer).
  6302. * @returns a number
  6303. */
  6304. getInstanceDivisor(): number;
  6305. /**
  6306. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6307. * @param data defines the data to store
  6308. */
  6309. create(data?: DataArray): void;
  6310. /**
  6311. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6312. * This function will create a new buffer if the current one is not updatable
  6313. * @param data defines the data to store
  6314. */
  6315. update(data: DataArray): void;
  6316. /**
  6317. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6318. * Returns the directly updated WebGLBuffer.
  6319. * @param data the new data
  6320. * @param offset the new offset
  6321. * @param useBytes set to true if the offset is in bytes
  6322. */
  6323. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6324. /**
  6325. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6326. */
  6327. dispose(): void;
  6328. /**
  6329. * Enumerates each value of this vertex buffer as numbers.
  6330. * @param count the number of values to enumerate
  6331. * @param callback the callback function called for each value
  6332. */
  6333. forEach(count: number, callback: (value: number, index: number) => void): void;
  6334. /**
  6335. * Positions
  6336. */
  6337. static readonly PositionKind: string;
  6338. /**
  6339. * Normals
  6340. */
  6341. static readonly NormalKind: string;
  6342. /**
  6343. * Tangents
  6344. */
  6345. static readonly TangentKind: string;
  6346. /**
  6347. * Texture coordinates
  6348. */
  6349. static readonly UVKind: string;
  6350. /**
  6351. * Texture coordinates 2
  6352. */
  6353. static readonly UV2Kind: string;
  6354. /**
  6355. * Texture coordinates 3
  6356. */
  6357. static readonly UV3Kind: string;
  6358. /**
  6359. * Texture coordinates 4
  6360. */
  6361. static readonly UV4Kind: string;
  6362. /**
  6363. * Texture coordinates 5
  6364. */
  6365. static readonly UV5Kind: string;
  6366. /**
  6367. * Texture coordinates 6
  6368. */
  6369. static readonly UV6Kind: string;
  6370. /**
  6371. * Colors
  6372. */
  6373. static readonly ColorKind: string;
  6374. /**
  6375. * Matrix indices (for bones)
  6376. */
  6377. static readonly MatricesIndicesKind: string;
  6378. /**
  6379. * Matrix weights (for bones)
  6380. */
  6381. static readonly MatricesWeightsKind: string;
  6382. /**
  6383. * Additional matrix indices (for bones)
  6384. */
  6385. static readonly MatricesIndicesExtraKind: string;
  6386. /**
  6387. * Additional matrix weights (for bones)
  6388. */
  6389. static readonly MatricesWeightsExtraKind: string;
  6390. /**
  6391. * Deduces the stride given a kind.
  6392. * @param kind The kind string to deduce
  6393. * @returns The deduced stride
  6394. */
  6395. static DeduceStride(kind: string): number;
  6396. /**
  6397. * Gets the byte length of the given type.
  6398. * @param type the type
  6399. * @returns the number of bytes
  6400. */
  6401. static GetTypeByteLength(type: number): number;
  6402. /**
  6403. * Enumerates each value of the given parameters as numbers.
  6404. * @param data the data to enumerate
  6405. * @param byteOffset the byte offset of the data
  6406. * @param byteStride the byte stride of the data
  6407. * @param componentCount the number of components per element
  6408. * @param componentType the type of the component
  6409. * @param count the number of values to enumerate
  6410. * @param normalized whether the data is normalized
  6411. * @param callback the callback function called for each value
  6412. */
  6413. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6414. private static _GetFloatValue;
  6415. }
  6416. }
  6417. declare module "babylonjs/Collisions/intersectionInfo" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. */
  6422. export class IntersectionInfo {
  6423. bu: Nullable<number>;
  6424. bv: Nullable<number>;
  6425. distance: number;
  6426. faceId: number;
  6427. subMeshId: number;
  6428. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6429. }
  6430. }
  6431. declare module "babylonjs/Maths/math.plane" {
  6432. import { DeepImmutable } from "babylonjs/types";
  6433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6434. /**
  6435. * Represens a plane by the equation ax + by + cz + d = 0
  6436. */
  6437. export class Plane {
  6438. private static _TmpMatrix;
  6439. /**
  6440. * Normal of the plane (a,b,c)
  6441. */
  6442. normal: Vector3;
  6443. /**
  6444. * d component of the plane
  6445. */
  6446. d: number;
  6447. /**
  6448. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6449. * @param a a component of the plane
  6450. * @param b b component of the plane
  6451. * @param c c component of the plane
  6452. * @param d d component of the plane
  6453. */
  6454. constructor(a: number, b: number, c: number, d: number);
  6455. /**
  6456. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6457. */
  6458. asArray(): number[];
  6459. /**
  6460. * @returns a new plane copied from the current Plane.
  6461. */
  6462. clone(): Plane;
  6463. /**
  6464. * @returns the string "Plane".
  6465. */
  6466. getClassName(): string;
  6467. /**
  6468. * @returns the Plane hash code.
  6469. */
  6470. getHashCode(): number;
  6471. /**
  6472. * Normalize the current Plane in place.
  6473. * @returns the updated Plane.
  6474. */
  6475. normalize(): Plane;
  6476. /**
  6477. * Applies a transformation the plane and returns the result
  6478. * @param transformation the transformation matrix to be applied to the plane
  6479. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6480. */
  6481. transform(transformation: DeepImmutable<Matrix>): Plane;
  6482. /**
  6483. * Calcualtte the dot product between the point and the plane normal
  6484. * @param point point to calculate the dot product with
  6485. * @returns the dot product (float) of the point coordinates and the plane normal.
  6486. */
  6487. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6488. /**
  6489. * Updates the current Plane from the plane defined by the three given points.
  6490. * @param point1 one of the points used to contruct the plane
  6491. * @param point2 one of the points used to contruct the plane
  6492. * @param point3 one of the points used to contruct the plane
  6493. * @returns the updated Plane.
  6494. */
  6495. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6496. /**
  6497. * Checks if the plane is facing a given direction
  6498. * @param direction the direction to check if the plane is facing
  6499. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6500. * @returns True is the vector "direction" is the same side than the plane normal.
  6501. */
  6502. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6503. /**
  6504. * Calculates the distance to a point
  6505. * @param point point to calculate distance to
  6506. * @returns the signed distance (float) from the given point to the Plane.
  6507. */
  6508. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6509. /**
  6510. * Creates a plane from an array
  6511. * @param array the array to create a plane from
  6512. * @returns a new Plane from the given array.
  6513. */
  6514. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6515. /**
  6516. * Creates a plane from three points
  6517. * @param point1 point used to create the plane
  6518. * @param point2 point used to create the plane
  6519. * @param point3 point used to create the plane
  6520. * @returns a new Plane defined by the three given points.
  6521. */
  6522. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6523. /**
  6524. * Creates a plane from an origin point and a normal
  6525. * @param origin origin of the plane to be constructed
  6526. * @param normal normal of the plane to be constructed
  6527. * @returns a new Plane the normal vector to this plane at the given origin point.
  6528. * Note : the vector "normal" is updated because normalized.
  6529. */
  6530. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6531. /**
  6532. * Calculates the distance from a plane and a point
  6533. * @param origin origin of the plane to be constructed
  6534. * @param normal normal of the plane to be constructed
  6535. * @param point point to calculate distance to
  6536. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6537. */
  6538. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6539. }
  6540. }
  6541. declare module "babylonjs/Culling/boundingSphere" {
  6542. import { DeepImmutable } from "babylonjs/types";
  6543. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6544. import { Plane } from "babylonjs/Maths/math.plane";
  6545. /**
  6546. * Class used to store bounding sphere information
  6547. */
  6548. export class BoundingSphere {
  6549. /**
  6550. * Gets the center of the bounding sphere in local space
  6551. */
  6552. readonly center: Vector3;
  6553. /**
  6554. * Radius of the bounding sphere in local space
  6555. */
  6556. radius: number;
  6557. /**
  6558. * Gets the center of the bounding sphere in world space
  6559. */
  6560. readonly centerWorld: Vector3;
  6561. /**
  6562. * Radius of the bounding sphere in world space
  6563. */
  6564. radiusWorld: number;
  6565. /**
  6566. * Gets the minimum vector in local space
  6567. */
  6568. readonly minimum: Vector3;
  6569. /**
  6570. * Gets the maximum vector in local space
  6571. */
  6572. readonly maximum: Vector3;
  6573. private _worldMatrix;
  6574. private static readonly TmpVector3;
  6575. /**
  6576. * Creates a new bounding sphere
  6577. * @param min defines the minimum vector (in local space)
  6578. * @param max defines the maximum vector (in local space)
  6579. * @param worldMatrix defines the new world matrix
  6580. */
  6581. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6582. /**
  6583. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6584. * @param min defines the new minimum vector (in local space)
  6585. * @param max defines the new maximum vector (in local space)
  6586. * @param worldMatrix defines the new world matrix
  6587. */
  6588. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6589. /**
  6590. * Scale the current bounding sphere by applying a scale factor
  6591. * @param factor defines the scale factor to apply
  6592. * @returns the current bounding box
  6593. */
  6594. scale(factor: number): BoundingSphere;
  6595. /**
  6596. * Gets the world matrix of the bounding box
  6597. * @returns a matrix
  6598. */
  6599. getWorldMatrix(): DeepImmutable<Matrix>;
  6600. /** @hidden */
  6601. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6602. /**
  6603. * Tests if the bounding sphere is intersecting the frustum planes
  6604. * @param frustumPlanes defines the frustum planes to test
  6605. * @returns true if there is an intersection
  6606. */
  6607. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6608. /**
  6609. * Tests if the bounding sphere center is in between the frustum planes.
  6610. * Used for optimistic fast inclusion.
  6611. * @param frustumPlanes defines the frustum planes to test
  6612. * @returns true if the sphere center is in between the frustum planes
  6613. */
  6614. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6615. /**
  6616. * Tests if a point is inside the bounding sphere
  6617. * @param point defines the point to test
  6618. * @returns true if the point is inside the bounding sphere
  6619. */
  6620. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6621. /**
  6622. * Checks if two sphere intersct
  6623. * @param sphere0 sphere 0
  6624. * @param sphere1 sphere 1
  6625. * @returns true if the speres intersect
  6626. */
  6627. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6628. }
  6629. }
  6630. declare module "babylonjs/Culling/boundingBox" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6633. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6634. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6635. import { Plane } from "babylonjs/Maths/math.plane";
  6636. /**
  6637. * Class used to store bounding box information
  6638. */
  6639. export class BoundingBox implements ICullable {
  6640. /**
  6641. * Gets the 8 vectors representing the bounding box in local space
  6642. */
  6643. readonly vectors: Vector3[];
  6644. /**
  6645. * Gets the center of the bounding box in local space
  6646. */
  6647. readonly center: Vector3;
  6648. /**
  6649. * Gets the center of the bounding box in world space
  6650. */
  6651. readonly centerWorld: Vector3;
  6652. /**
  6653. * Gets the extend size in local space
  6654. */
  6655. readonly extendSize: Vector3;
  6656. /**
  6657. * Gets the extend size in world space
  6658. */
  6659. readonly extendSizeWorld: Vector3;
  6660. /**
  6661. * Gets the OBB (object bounding box) directions
  6662. */
  6663. readonly directions: Vector3[];
  6664. /**
  6665. * Gets the 8 vectors representing the bounding box in world space
  6666. */
  6667. readonly vectorsWorld: Vector3[];
  6668. /**
  6669. * Gets the minimum vector in world space
  6670. */
  6671. readonly minimumWorld: Vector3;
  6672. /**
  6673. * Gets the maximum vector in world space
  6674. */
  6675. readonly maximumWorld: Vector3;
  6676. /**
  6677. * Gets the minimum vector in local space
  6678. */
  6679. readonly minimum: Vector3;
  6680. /**
  6681. * Gets the maximum vector in local space
  6682. */
  6683. readonly maximum: Vector3;
  6684. private _worldMatrix;
  6685. private static readonly TmpVector3;
  6686. /**
  6687. * @hidden
  6688. */
  6689. _tag: number;
  6690. /**
  6691. * Creates a new bounding box
  6692. * @param min defines the minimum vector (in local space)
  6693. * @param max defines the maximum vector (in local space)
  6694. * @param worldMatrix defines the new world matrix
  6695. */
  6696. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6697. /**
  6698. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6699. * @param min defines the new minimum vector (in local space)
  6700. * @param max defines the new maximum vector (in local space)
  6701. * @param worldMatrix defines the new world matrix
  6702. */
  6703. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6704. /**
  6705. * Scale the current bounding box by applying a scale factor
  6706. * @param factor defines the scale factor to apply
  6707. * @returns the current bounding box
  6708. */
  6709. scale(factor: number): BoundingBox;
  6710. /**
  6711. * Gets the world matrix of the bounding box
  6712. * @returns a matrix
  6713. */
  6714. getWorldMatrix(): DeepImmutable<Matrix>;
  6715. /** @hidden */
  6716. _update(world: DeepImmutable<Matrix>): void;
  6717. /**
  6718. * Tests if the bounding box is intersecting the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an intersection
  6721. */
  6722. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if the bounding box is entirely inside the frustum planes
  6725. * @param frustumPlanes defines the frustum planes to test
  6726. * @returns true if there is an inclusion
  6727. */
  6728. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6729. /**
  6730. * Tests if a point is inside the bounding box
  6731. * @param point defines the point to test
  6732. * @returns true if the point is inside the bounding box
  6733. */
  6734. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a bounding sphere
  6737. * @param sphere defines the sphere to test
  6738. * @returns true if there is an intersection
  6739. */
  6740. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6741. /**
  6742. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6743. * @param min defines the min vector to use
  6744. * @param max defines the max vector to use
  6745. * @returns true if there is an intersection
  6746. */
  6747. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6748. /**
  6749. * Tests if two bounding boxes are intersections
  6750. * @param box0 defines the first box to test
  6751. * @param box1 defines the second box to test
  6752. * @returns true if there is an intersection
  6753. */
  6754. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6755. /**
  6756. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6757. * @param minPoint defines the minimum vector of the bounding box
  6758. * @param maxPoint defines the maximum vector of the bounding box
  6759. * @param sphereCenter defines the sphere center
  6760. * @param sphereRadius defines the sphere radius
  6761. * @returns true if there is an intersection
  6762. */
  6763. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6764. /**
  6765. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6766. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @return true if there is an inclusion
  6769. */
  6770. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6773. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @return true if there is an intersection
  6776. */
  6777. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. }
  6779. }
  6780. declare module "babylonjs/Collisions/collider" {
  6781. import { Nullable, IndicesArray } from "babylonjs/types";
  6782. import { Vector3 } from "babylonjs/Maths/math.vector";
  6783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6784. import { Plane } from "babylonjs/Maths/math.plane";
  6785. /** @hidden */
  6786. export class Collider {
  6787. /** Define if a collision was found */
  6788. collisionFound: boolean;
  6789. /**
  6790. * Define last intersection point in local space
  6791. */
  6792. intersectionPoint: Vector3;
  6793. /**
  6794. * Define last collided mesh
  6795. */
  6796. collidedMesh: Nullable<AbstractMesh>;
  6797. private _collisionPoint;
  6798. private _planeIntersectionPoint;
  6799. private _tempVector;
  6800. private _tempVector2;
  6801. private _tempVector3;
  6802. private _tempVector4;
  6803. private _edge;
  6804. private _baseToVertex;
  6805. private _destinationPoint;
  6806. private _slidePlaneNormal;
  6807. private _displacementVector;
  6808. /** @hidden */
  6809. _radius: Vector3;
  6810. /** @hidden */
  6811. _retry: number;
  6812. private _velocity;
  6813. private _basePoint;
  6814. private _epsilon;
  6815. /** @hidden */
  6816. _velocityWorldLength: number;
  6817. /** @hidden */
  6818. _basePointWorld: Vector3;
  6819. private _velocityWorld;
  6820. private _normalizedVelocity;
  6821. /** @hidden */
  6822. _initialVelocity: Vector3;
  6823. /** @hidden */
  6824. _initialPosition: Vector3;
  6825. private _nearestDistance;
  6826. private _collisionMask;
  6827. collisionMask: number;
  6828. /**
  6829. * Gets the plane normal used to compute the sliding response (in local space)
  6830. */
  6831. readonly slidePlaneNormal: Vector3;
  6832. /** @hidden */
  6833. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6834. /** @hidden */
  6835. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6836. /** @hidden */
  6837. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6838. /** @hidden */
  6839. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6840. /** @hidden */
  6841. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6842. /** @hidden */
  6843. _getResponse(pos: Vector3, vel: Vector3): void;
  6844. }
  6845. }
  6846. declare module "babylonjs/Culling/boundingInfo" {
  6847. import { DeepImmutable } from "babylonjs/types";
  6848. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6849. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6850. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6851. import { Plane } from "babylonjs/Maths/math.plane";
  6852. import { Collider } from "babylonjs/Collisions/collider";
  6853. /**
  6854. * Interface for cullable objects
  6855. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6856. */
  6857. export interface ICullable {
  6858. /**
  6859. * Checks if the object or part of the object is in the frustum
  6860. * @param frustumPlanes Camera near/planes
  6861. * @returns true if the object is in frustum otherwise false
  6862. */
  6863. isInFrustum(frustumPlanes: Plane[]): boolean;
  6864. /**
  6865. * Checks if a cullable object (mesh...) is in the camera frustum
  6866. * Unlike isInFrustum this cheks the full bounding box
  6867. * @param frustumPlanes Camera near/planes
  6868. * @returns true if the object is in frustum otherwise false
  6869. */
  6870. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6871. }
  6872. /**
  6873. * Info for a bounding data of a mesh
  6874. */
  6875. export class BoundingInfo implements ICullable {
  6876. /**
  6877. * Bounding box for the mesh
  6878. */
  6879. readonly boundingBox: BoundingBox;
  6880. /**
  6881. * Bounding sphere for the mesh
  6882. */
  6883. readonly boundingSphere: BoundingSphere;
  6884. private _isLocked;
  6885. private static readonly TmpVector3;
  6886. /**
  6887. * Constructs bounding info
  6888. * @param minimum min vector of the bounding box/sphere
  6889. * @param maximum max vector of the bounding box/sphere
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6893. /**
  6894. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6895. * @param min defines the new minimum vector (in local space)
  6896. * @param max defines the new maximum vector (in local space)
  6897. * @param worldMatrix defines the new world matrix
  6898. */
  6899. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * min vector of the bounding box/sphere
  6902. */
  6903. readonly minimum: Vector3;
  6904. /**
  6905. * max vector of the bounding box/sphere
  6906. */
  6907. readonly maximum: Vector3;
  6908. /**
  6909. * If the info is locked and won't be updated to avoid perf overhead
  6910. */
  6911. isLocked: boolean;
  6912. /**
  6913. * Updates the bounding sphere and box
  6914. * @param world world matrix to be used to update
  6915. */
  6916. update(world: DeepImmutable<Matrix>): void;
  6917. /**
  6918. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6919. * @param center New center of the bounding info
  6920. * @param extend New extend of the bounding info
  6921. * @returns the current bounding info
  6922. */
  6923. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6924. /**
  6925. * Scale the current bounding info by applying a scale factor
  6926. * @param factor defines the scale factor to apply
  6927. * @returns the current bounding info
  6928. */
  6929. scale(factor: number): BoundingInfo;
  6930. /**
  6931. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6932. * @param frustumPlanes defines the frustum to test
  6933. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6934. * @returns true if the bounding info is in the frustum planes
  6935. */
  6936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6937. /**
  6938. * Gets the world distance between the min and max points of the bounding box
  6939. */
  6940. readonly diagonalLength: number;
  6941. /**
  6942. * Checks if a cullable object (mesh...) is in the camera frustum
  6943. * Unlike isInFrustum this cheks the full bounding box
  6944. * @param frustumPlanes Camera near/planes
  6945. * @returns true if the object is in frustum otherwise false
  6946. */
  6947. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /** @hidden */
  6949. _checkCollision(collider: Collider): boolean;
  6950. /**
  6951. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6952. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6953. * @param point the point to check intersection with
  6954. * @returns if the point intersects
  6955. */
  6956. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6957. /**
  6958. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6959. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6960. * @param boundingInfo the bounding info to check intersection with
  6961. * @param precise if the intersection should be done using OBB
  6962. * @returns if the bounding info intersects
  6963. */
  6964. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Maths/math.functions" {
  6968. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6969. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6970. /**
  6971. * Extracts minimum and maximum values from a list of indexed positions
  6972. * @param positions defines the positions to use
  6973. * @param indices defines the indices to the positions
  6974. * @param indexStart defines the start index
  6975. * @param indexCount defines the end index
  6976. * @param bias defines bias value to add to the result
  6977. * @return minimum and maximum values
  6978. */
  6979. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6980. minimum: Vector3;
  6981. maximum: Vector3;
  6982. };
  6983. /**
  6984. * Extracts minimum and maximum values from a list of positions
  6985. * @param positions defines the positions to use
  6986. * @param start defines the start index in the positions array
  6987. * @param count defines the number of positions to handle
  6988. * @param bias defines bias value to add to the result
  6989. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6990. * @return minimum and maximum values
  6991. */
  6992. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6993. minimum: Vector3;
  6994. maximum: Vector3;
  6995. };
  6996. }
  6997. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6998. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6999. /** @hidden */
  7000. export class WebGLDataBuffer extends DataBuffer {
  7001. private _buffer;
  7002. constructor(resource: WebGLBuffer);
  7003. readonly underlyingResource: any;
  7004. }
  7005. }
  7006. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7007. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7008. import { Nullable } from "babylonjs/types";
  7009. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7010. /** @hidden */
  7011. export class WebGLPipelineContext implements IPipelineContext {
  7012. engine: ThinEngine;
  7013. program: Nullable<WebGLProgram>;
  7014. context?: WebGLRenderingContext;
  7015. vertexShader?: WebGLShader;
  7016. fragmentShader?: WebGLShader;
  7017. isParallelCompiled: boolean;
  7018. onCompiled?: () => void;
  7019. transformFeedback?: WebGLTransformFeedback | null;
  7020. readonly isAsync: boolean;
  7021. readonly isReady: boolean;
  7022. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7023. }
  7024. }
  7025. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7026. import { FloatArray, Nullable } from "babylonjs/types";
  7027. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7028. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7029. module "babylonjs/Engines/thinEngine" {
  7030. interface ThinEngine {
  7031. /**
  7032. * Create an uniform buffer
  7033. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7034. * @param elements defines the content of the uniform buffer
  7035. * @returns the webGL uniform buffer
  7036. */
  7037. createUniformBuffer(elements: FloatArray): DataBuffer;
  7038. /**
  7039. * Create a dynamic uniform buffer
  7040. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7041. * @param elements defines the content of the uniform buffer
  7042. * @returns the webGL uniform buffer
  7043. */
  7044. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7045. /**
  7046. * Update an existing uniform buffer
  7047. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7048. * @param uniformBuffer defines the target uniform buffer
  7049. * @param elements defines the content to update
  7050. * @param offset defines the offset in the uniform buffer where update should start
  7051. * @param count defines the size of the data to update
  7052. */
  7053. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7054. /**
  7055. * Bind an uniform buffer to the current webGL context
  7056. * @param buffer defines the buffer to bind
  7057. */
  7058. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7059. /**
  7060. * Bind a buffer to the current webGL context at a given location
  7061. * @param buffer defines the buffer to bind
  7062. * @param location defines the index where to bind the buffer
  7063. */
  7064. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7065. /**
  7066. * Bind a specific block at a given index in a specific shader program
  7067. * @param pipelineContext defines the pipeline context to use
  7068. * @param blockName defines the block name
  7069. * @param index defines the index where to bind the block
  7070. */
  7071. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7072. }
  7073. }
  7074. }
  7075. declare module "babylonjs/Materials/uniformBuffer" {
  7076. import { Nullable, FloatArray } from "babylonjs/types";
  7077. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7078. import { Engine } from "babylonjs/Engines/engine";
  7079. import { Effect } from "babylonjs/Materials/effect";
  7080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { Color3 } from "babylonjs/Maths/math.color";
  7083. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7084. /**
  7085. * Uniform buffer objects.
  7086. *
  7087. * Handles blocks of uniform on the GPU.
  7088. *
  7089. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7090. *
  7091. * For more information, please refer to :
  7092. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7093. */
  7094. export class UniformBuffer {
  7095. private _engine;
  7096. private _buffer;
  7097. private _data;
  7098. private _bufferData;
  7099. private _dynamic?;
  7100. private _uniformLocations;
  7101. private _uniformSizes;
  7102. private _uniformLocationPointer;
  7103. private _needSync;
  7104. private _noUBO;
  7105. private _currentEffect;
  7106. private static _MAX_UNIFORM_SIZE;
  7107. private static _tempBuffer;
  7108. /**
  7109. * Lambda to Update a 3x3 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7114. /**
  7115. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7120. /**
  7121. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7126. /**
  7127. * Lambda to Update a vec2 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7132. /**
  7133. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7138. /**
  7139. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7144. /**
  7145. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7150. /**
  7151. * Lambda to Update vec3 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. updateVector3: (name: string, vector: Vector3) => void;
  7156. /**
  7157. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7162. /**
  7163. * Lambda to Update vec3 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7168. /**
  7169. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7170. * This is dynamic to allow compat with webgl 1 and 2.
  7171. * You will need to pass the name of the uniform as well as the value.
  7172. */
  7173. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7174. /**
  7175. * Instantiates a new Uniform buffer objects.
  7176. *
  7177. * Handles blocks of uniform on the GPU.
  7178. *
  7179. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7180. *
  7181. * For more information, please refer to :
  7182. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7183. * @param engine Define the engine the buffer is associated with
  7184. * @param data Define the data contained in the buffer
  7185. * @param dynamic Define if the buffer is updatable
  7186. */
  7187. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7188. /**
  7189. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7190. * or just falling back on setUniformXXX calls.
  7191. */
  7192. readonly useUbo: boolean;
  7193. /**
  7194. * Indicates if the WebGL underlying uniform buffer is in sync
  7195. * with the javascript cache data.
  7196. */
  7197. readonly isSync: boolean;
  7198. /**
  7199. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7200. * Also, a dynamic UniformBuffer will disable cache verification and always
  7201. * update the underlying WebGL uniform buffer to the GPU.
  7202. * @returns if Dynamic, otherwise false
  7203. */
  7204. isDynamic(): boolean;
  7205. /**
  7206. * The data cache on JS side.
  7207. * @returns the underlying data as a float array
  7208. */
  7209. getData(): Float32Array;
  7210. /**
  7211. * The underlying WebGL Uniform buffer.
  7212. * @returns the webgl buffer
  7213. */
  7214. getBuffer(): Nullable<DataBuffer>;
  7215. /**
  7216. * std140 layout specifies how to align data within an UBO structure.
  7217. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7218. * for specs.
  7219. */
  7220. private _fillAlignment;
  7221. /**
  7222. * Adds an uniform in the buffer.
  7223. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7224. * for the layout to be correct !
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param size Data size, or data directly.
  7227. */
  7228. addUniform(name: string, size: number | number[]): void;
  7229. /**
  7230. * Adds a Matrix 4x4 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param mat A 4x4 matrix.
  7233. */
  7234. addMatrix(name: string, mat: Matrix): void;
  7235. /**
  7236. * Adds a vec2 to the uniform buffer.
  7237. * @param name Name of the uniform, as used in the uniform block in the shader.
  7238. * @param x Define the x component value of the vec2
  7239. * @param y Define the y component value of the vec2
  7240. */
  7241. addFloat2(name: string, x: number, y: number): void;
  7242. /**
  7243. * Adds a vec3 to the uniform buffer.
  7244. * @param name Name of the uniform, as used in the uniform block in the shader.
  7245. * @param x Define the x component value of the vec3
  7246. * @param y Define the y component value of the vec3
  7247. * @param z Define the z component value of the vec3
  7248. */
  7249. addFloat3(name: string, x: number, y: number, z: number): void;
  7250. /**
  7251. * Adds a vec3 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 vec3 from a Color
  7254. */
  7255. addColor3(name: string, color: Color3): void;
  7256. /**
  7257. * Adds a vec4 to the uniform buffer.
  7258. * @param name Name of the uniform, as used in the uniform block in the shader.
  7259. * @param color Define the rgb components from a Color
  7260. * @param alpha Define the a component of the vec4
  7261. */
  7262. addColor4(name: string, color: Color3, alpha: number): void;
  7263. /**
  7264. * Adds a vec3 to the uniform buffer.
  7265. * @param name Name of the uniform, as used in the uniform block in the shader.
  7266. * @param vector Define the vec3 components from a Vector
  7267. */
  7268. addVector3(name: string, vector: Vector3): void;
  7269. /**
  7270. * Adds a Matrix 3x3 to the uniform buffer.
  7271. * @param name Name of the uniform, as used in the uniform block in the shader.
  7272. */
  7273. addMatrix3x3(name: string): void;
  7274. /**
  7275. * Adds a Matrix 2x2 to the uniform buffer.
  7276. * @param name Name of the uniform, as used in the uniform block in the shader.
  7277. */
  7278. addMatrix2x2(name: string): void;
  7279. /**
  7280. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7281. */
  7282. create(): void;
  7283. /** @hidden */
  7284. _rebuild(): void;
  7285. /**
  7286. * Updates the WebGL Uniform Buffer on the GPU.
  7287. * If the `dynamic` flag is set to true, no cache comparison is done.
  7288. * Otherwise, the buffer will be updated only if the cache differs.
  7289. */
  7290. update(): void;
  7291. /**
  7292. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7293. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7294. * @param data Define the flattened data
  7295. * @param size Define the size of the data.
  7296. */
  7297. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7298. private _valueCache;
  7299. private _cacheMatrix;
  7300. private _updateMatrix3x3ForUniform;
  7301. private _updateMatrix3x3ForEffect;
  7302. private _updateMatrix2x2ForEffect;
  7303. private _updateMatrix2x2ForUniform;
  7304. private _updateFloatForEffect;
  7305. private _updateFloatForUniform;
  7306. private _updateFloat2ForEffect;
  7307. private _updateFloat2ForUniform;
  7308. private _updateFloat3ForEffect;
  7309. private _updateFloat3ForUniform;
  7310. private _updateFloat4ForEffect;
  7311. private _updateFloat4ForUniform;
  7312. private _updateMatrixForEffect;
  7313. private _updateMatrixForUniform;
  7314. private _updateVector3ForEffect;
  7315. private _updateVector3ForUniform;
  7316. private _updateVector4ForEffect;
  7317. private _updateVector4ForUniform;
  7318. private _updateColor3ForEffect;
  7319. private _updateColor3ForUniform;
  7320. private _updateColor4ForEffect;
  7321. private _updateColor4ForUniform;
  7322. /**
  7323. * Sets a sampler uniform on the effect.
  7324. * @param name Define the name of the sampler.
  7325. * @param texture Define the texture to set in the sampler
  7326. */
  7327. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7328. /**
  7329. * Directly updates the value of the uniform in the cache AND on the GPU.
  7330. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7331. * @param data Define the flattened data
  7332. */
  7333. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7334. /**
  7335. * Binds this uniform buffer to an effect.
  7336. * @param effect Define the effect to bind the buffer to
  7337. * @param name Name of the uniform block in the shader.
  7338. */
  7339. bindToEffect(effect: Effect, name: string): void;
  7340. /**
  7341. * Disposes the uniform buffer.
  7342. */
  7343. dispose(): void;
  7344. }
  7345. }
  7346. declare module "babylonjs/Misc/iInspectable" {
  7347. /**
  7348. * Enum that determines the text-wrapping mode to use.
  7349. */
  7350. export enum InspectableType {
  7351. /**
  7352. * Checkbox for booleans
  7353. */
  7354. Checkbox = 0,
  7355. /**
  7356. * Sliders for numbers
  7357. */
  7358. Slider = 1,
  7359. /**
  7360. * Vector3
  7361. */
  7362. Vector3 = 2,
  7363. /**
  7364. * Quaternions
  7365. */
  7366. Quaternion = 3,
  7367. /**
  7368. * Color3
  7369. */
  7370. Color3 = 4,
  7371. /**
  7372. * String
  7373. */
  7374. String = 5
  7375. }
  7376. /**
  7377. * Interface used to define custom inspectable properties.
  7378. * This interface is used by the inspector to display custom property grids
  7379. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7380. */
  7381. export interface IInspectable {
  7382. /**
  7383. * Gets the label to display
  7384. */
  7385. label: string;
  7386. /**
  7387. * Gets the name of the property to edit
  7388. */
  7389. propertyName: string;
  7390. /**
  7391. * Gets the type of the editor to use
  7392. */
  7393. type: InspectableType;
  7394. /**
  7395. * Gets the minimum value of the property when using in "slider" mode
  7396. */
  7397. min?: number;
  7398. /**
  7399. * Gets the maximum value of the property when using in "slider" mode
  7400. */
  7401. max?: number;
  7402. /**
  7403. * Gets the setp to use when using in "slider" mode
  7404. */
  7405. step?: number;
  7406. }
  7407. }
  7408. declare module "babylonjs/Misc/timingTools" {
  7409. /**
  7410. * Class used to provide helper for timing
  7411. */
  7412. export class TimingTools {
  7413. /**
  7414. * Polyfill for setImmediate
  7415. * @param action defines the action to execute after the current execution block
  7416. */
  7417. static SetImmediate(action: () => void): void;
  7418. }
  7419. }
  7420. declare module "babylonjs/Misc/instantiationTools" {
  7421. /**
  7422. * Class used to enable instatition of objects by class name
  7423. */
  7424. export class InstantiationTools {
  7425. /**
  7426. * Use this object to register external classes like custom textures or material
  7427. * to allow the laoders to instantiate them
  7428. */
  7429. static RegisteredExternalClasses: {
  7430. [key: string]: Object;
  7431. };
  7432. /**
  7433. * Tries to instantiate a new object from a given class name
  7434. * @param className defines the class name to instantiate
  7435. * @returns the new object or null if the system was not able to do the instantiation
  7436. */
  7437. static Instantiate(className: string): any;
  7438. }
  7439. }
  7440. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7441. /**
  7442. * Define options used to create a depth texture
  7443. */
  7444. export class DepthTextureCreationOptions {
  7445. /** Specifies whether or not a stencil should be allocated in the texture */
  7446. generateStencil?: boolean;
  7447. /** Specifies whether or not bilinear filtering is enable on the texture */
  7448. bilinearFiltering?: boolean;
  7449. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7450. comparisonFunction?: number;
  7451. /** Specifies if the created texture is a cube texture */
  7452. isCube?: boolean;
  7453. }
  7454. }
  7455. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7457. import { Nullable } from "babylonjs/types";
  7458. import { Scene } from "babylonjs/scene";
  7459. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7460. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7461. module "babylonjs/Engines/thinEngine" {
  7462. interface ThinEngine {
  7463. /**
  7464. * Creates a depth stencil cube texture.
  7465. * This is only available in WebGL 2.
  7466. * @param size The size of face edge in the cube texture.
  7467. * @param options The options defining the cube texture.
  7468. * @returns The cube texture
  7469. */
  7470. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7471. /**
  7472. * Creates a cube texture
  7473. * @param rootUrl defines the url where the files to load is located
  7474. * @param scene defines the current scene
  7475. * @param files defines the list of files to load (1 per face)
  7476. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7477. * @param onLoad defines an optional callback raised when the texture is loaded
  7478. * @param onError defines an optional callback raised if there is an issue to load the texture
  7479. * @param format defines the format of the data
  7480. * @param forcedExtension defines the extension to use to pick the right loader
  7481. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7482. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7483. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7484. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7485. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7486. * @returns the cube texture as an InternalTexture
  7487. */
  7488. 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;
  7489. /**
  7490. * Creates a cube texture
  7491. * @param rootUrl defines the url where the files to load is located
  7492. * @param scene defines the current scene
  7493. * @param files defines the list of files to load (1 per face)
  7494. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7495. * @param onLoad defines an optional callback raised when the texture is loaded
  7496. * @param onError defines an optional callback raised if there is an issue to load the texture
  7497. * @param format defines the format of the data
  7498. * @param forcedExtension defines the extension to use to pick the right loader
  7499. * @returns the cube texture as an InternalTexture
  7500. */
  7501. 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;
  7502. /**
  7503. * Creates a cube texture
  7504. * @param rootUrl defines the url where the files to load is located
  7505. * @param scene defines the current scene
  7506. * @param files defines the list of files to load (1 per face)
  7507. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7508. * @param onLoad defines an optional callback raised when the texture is loaded
  7509. * @param onError defines an optional callback raised if there is an issue to load the texture
  7510. * @param format defines the format of the data
  7511. * @param forcedExtension defines the extension to use to pick the right loader
  7512. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7513. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7514. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7515. * @returns the cube texture as an InternalTexture
  7516. */
  7517. 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;
  7518. /** @hidden */
  7519. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7520. /** @hidden */
  7521. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7522. /** @hidden */
  7523. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7524. /** @hidden */
  7525. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7526. }
  7527. }
  7528. }
  7529. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7530. import { Nullable } from "babylonjs/types";
  7531. import { Scene } from "babylonjs/scene";
  7532. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7534. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7535. /**
  7536. * Class for creating a cube texture
  7537. */
  7538. export class CubeTexture extends BaseTexture {
  7539. private _delayedOnLoad;
  7540. /**
  7541. * The url of the texture
  7542. */
  7543. url: string;
  7544. /**
  7545. * Gets or sets the center of the bounding box associated with the cube texture.
  7546. * It must define where the camera used to render the texture was set
  7547. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7548. */
  7549. boundingBoxPosition: Vector3;
  7550. private _boundingBoxSize;
  7551. /**
  7552. * Gets or sets the size of the bounding box associated with the cube texture
  7553. * When defined, the cubemap will switch to local mode
  7554. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7555. * @example https://www.babylonjs-playground.com/#RNASML
  7556. */
  7557. /**
  7558. * Returns the bounding box size
  7559. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7560. */
  7561. boundingBoxSize: Vector3;
  7562. protected _rotationY: number;
  7563. /**
  7564. * Sets texture matrix rotation angle around Y axis in radians.
  7565. */
  7566. /**
  7567. * Gets texture matrix rotation angle around Y axis radians.
  7568. */
  7569. rotationY: number;
  7570. /**
  7571. * Are mip maps generated for this texture or not.
  7572. */
  7573. readonly noMipmap: boolean;
  7574. private _noMipmap;
  7575. private _files;
  7576. protected _forcedExtension: Nullable<string>;
  7577. private _extensions;
  7578. private _textureMatrix;
  7579. private _format;
  7580. private _createPolynomials;
  7581. /** @hidden */
  7582. _prefiltered: boolean;
  7583. /**
  7584. * Creates a cube texture from an array of image urls
  7585. * @param files defines an array of image urls
  7586. * @param scene defines the hosting scene
  7587. * @param noMipmap specifies if mip maps are not used
  7588. * @returns a cube texture
  7589. */
  7590. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7591. /**
  7592. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7593. * @param url defines the url of the prefiltered texture
  7594. * @param scene defines the scene the texture is attached to
  7595. * @param forcedExtension defines the extension of the file if different from the url
  7596. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7597. * @return the prefiltered texture
  7598. */
  7599. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7600. /**
  7601. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7602. * as prefiltered data.
  7603. * @param rootUrl defines the url of the texture or the root name of the six images
  7604. * @param scene defines the scene the texture is attached to
  7605. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7606. * @param noMipmap defines if mipmaps should be created or not
  7607. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7608. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7609. * @param onError defines a callback triggered in case of error during load
  7610. * @param format defines the internal format to use for the texture once loaded
  7611. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7612. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7613. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7614. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7615. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7616. * @return the cube texture
  7617. */
  7618. 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);
  7619. /**
  7620. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7621. */
  7622. readonly isPrefiltered: boolean;
  7623. /**
  7624. * Get the current class name of the texture useful for serialization or dynamic coding.
  7625. * @returns "CubeTexture"
  7626. */
  7627. getClassName(): string;
  7628. /**
  7629. * Update the url (and optional buffer) of this texture if url was null during construction.
  7630. * @param url the url of the texture
  7631. * @param forcedExtension defines the extension to use
  7632. * @param onLoad callback called when the texture is loaded (defaults to null)
  7633. */
  7634. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7635. /**
  7636. * Delays loading of the cube texture
  7637. * @param forcedExtension defines the extension to use
  7638. */
  7639. delayLoad(forcedExtension?: string): void;
  7640. /**
  7641. * Returns the reflection texture matrix
  7642. * @returns the reflection texture matrix
  7643. */
  7644. getReflectionTextureMatrix(): Matrix;
  7645. /**
  7646. * Sets the reflection texture matrix
  7647. * @param value Reflection texture matrix
  7648. */
  7649. setReflectionTextureMatrix(value: Matrix): void;
  7650. /**
  7651. * Parses text to create a cube texture
  7652. * @param parsedTexture define the serialized text to read from
  7653. * @param scene defines the hosting scene
  7654. * @param rootUrl defines the root url of the cube texture
  7655. * @returns a cube texture
  7656. */
  7657. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7658. /**
  7659. * Makes a clone, or deep copy, of the cube texture
  7660. * @returns a new cube texture
  7661. */
  7662. clone(): CubeTexture;
  7663. }
  7664. }
  7665. declare module "babylonjs/Materials/materialDefines" {
  7666. /**
  7667. * Manages the defines for the Material
  7668. */
  7669. export class MaterialDefines {
  7670. /** @hidden */
  7671. protected _keys: string[];
  7672. private _isDirty;
  7673. /** @hidden */
  7674. _renderId: number;
  7675. /** @hidden */
  7676. _areLightsDirty: boolean;
  7677. /** @hidden */
  7678. _areLightsDisposed: boolean;
  7679. /** @hidden */
  7680. _areAttributesDirty: boolean;
  7681. /** @hidden */
  7682. _areTexturesDirty: boolean;
  7683. /** @hidden */
  7684. _areFresnelDirty: boolean;
  7685. /** @hidden */
  7686. _areMiscDirty: boolean;
  7687. /** @hidden */
  7688. _areImageProcessingDirty: boolean;
  7689. /** @hidden */
  7690. _normals: boolean;
  7691. /** @hidden */
  7692. _uvs: boolean;
  7693. /** @hidden */
  7694. _needNormals: boolean;
  7695. /** @hidden */
  7696. _needUVs: boolean;
  7697. [id: string]: any;
  7698. /**
  7699. * Specifies if the material needs to be re-calculated
  7700. */
  7701. readonly isDirty: boolean;
  7702. /**
  7703. * Marks the material to indicate that it has been re-calculated
  7704. */
  7705. markAsProcessed(): void;
  7706. /**
  7707. * Marks the material to indicate that it needs to be re-calculated
  7708. */
  7709. markAsUnprocessed(): void;
  7710. /**
  7711. * Marks the material to indicate all of its defines need to be re-calculated
  7712. */
  7713. markAllAsDirty(): void;
  7714. /**
  7715. * Marks the material to indicate that image processing needs to be re-calculated
  7716. */
  7717. markAsImageProcessingDirty(): void;
  7718. /**
  7719. * Marks the material to indicate the lights need to be re-calculated
  7720. * @param disposed Defines whether the light is dirty due to dispose or not
  7721. */
  7722. markAsLightDirty(disposed?: boolean): void;
  7723. /**
  7724. * Marks the attribute state as changed
  7725. */
  7726. markAsAttributesDirty(): void;
  7727. /**
  7728. * Marks the texture state as changed
  7729. */
  7730. markAsTexturesDirty(): void;
  7731. /**
  7732. * Marks the fresnel state as changed
  7733. */
  7734. markAsFresnelDirty(): void;
  7735. /**
  7736. * Marks the misc state as changed
  7737. */
  7738. markAsMiscDirty(): void;
  7739. /**
  7740. * Rebuilds the material defines
  7741. */
  7742. rebuild(): void;
  7743. /**
  7744. * Specifies if two material defines are equal
  7745. * @param other - A material define instance to compare to
  7746. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7747. */
  7748. isEqual(other: MaterialDefines): boolean;
  7749. /**
  7750. * Clones this instance's defines to another instance
  7751. * @param other - material defines to clone values to
  7752. */
  7753. cloneTo(other: MaterialDefines): void;
  7754. /**
  7755. * Resets the material define values
  7756. */
  7757. reset(): void;
  7758. /**
  7759. * Converts the material define values to a string
  7760. * @returns - String of material define information
  7761. */
  7762. toString(): string;
  7763. }
  7764. }
  7765. declare module "babylonjs/Materials/colorCurves" {
  7766. import { Effect } from "babylonjs/Materials/effect";
  7767. /**
  7768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7770. * 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;
  7771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7772. */
  7773. export class ColorCurves {
  7774. private _dirty;
  7775. private _tempColor;
  7776. private _globalCurve;
  7777. private _highlightsCurve;
  7778. private _midtonesCurve;
  7779. private _shadowsCurve;
  7780. private _positiveCurve;
  7781. private _negativeCurve;
  7782. private _globalHue;
  7783. private _globalDensity;
  7784. private _globalSaturation;
  7785. private _globalExposure;
  7786. /**
  7787. * Gets the global Hue value.
  7788. * 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).
  7789. */
  7790. /**
  7791. * Sets the global Hue value.
  7792. * 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).
  7793. */
  7794. globalHue: number;
  7795. /**
  7796. * Gets the global Density value.
  7797. * 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.
  7798. * Values less than zero provide a filter of opposite hue.
  7799. */
  7800. /**
  7801. * Sets the global Density value.
  7802. * 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.
  7803. * Values less than zero provide a filter of opposite hue.
  7804. */
  7805. globalDensity: number;
  7806. /**
  7807. * Gets the global Saturation value.
  7808. * 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.
  7809. */
  7810. /**
  7811. * Sets the global Saturation value.
  7812. * 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.
  7813. */
  7814. globalSaturation: number;
  7815. /**
  7816. * Gets the global Exposure value.
  7817. * 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.
  7818. */
  7819. /**
  7820. * Sets the global Exposure value.
  7821. * 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.
  7822. */
  7823. globalExposure: number;
  7824. private _highlightsHue;
  7825. private _highlightsDensity;
  7826. private _highlightsSaturation;
  7827. private _highlightsExposure;
  7828. /**
  7829. * Gets the highlights Hue value.
  7830. * 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).
  7831. */
  7832. /**
  7833. * Sets the highlights Hue value.
  7834. * 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).
  7835. */
  7836. highlightsHue: number;
  7837. /**
  7838. * Gets the highlights Density value.
  7839. * 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.
  7840. * Values less than zero provide a filter of opposite hue.
  7841. */
  7842. /**
  7843. * Sets the highlights Density value.
  7844. * 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.
  7845. * Values less than zero provide a filter of opposite hue.
  7846. */
  7847. highlightsDensity: number;
  7848. /**
  7849. * Gets the highlights Saturation value.
  7850. * 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.
  7851. */
  7852. /**
  7853. * Sets the highlights Saturation value.
  7854. * 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.
  7855. */
  7856. highlightsSaturation: number;
  7857. /**
  7858. * Gets the highlights Exposure value.
  7859. * 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.
  7860. */
  7861. /**
  7862. * Sets the highlights Exposure value.
  7863. * 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.
  7864. */
  7865. highlightsExposure: number;
  7866. private _midtonesHue;
  7867. private _midtonesDensity;
  7868. private _midtonesSaturation;
  7869. private _midtonesExposure;
  7870. /**
  7871. * Gets the midtones Hue value.
  7872. * 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).
  7873. */
  7874. /**
  7875. * Sets the midtones Hue value.
  7876. * 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).
  7877. */
  7878. midtonesHue: number;
  7879. /**
  7880. * Gets the midtones Density value.
  7881. * 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.
  7882. * Values less than zero provide a filter of opposite hue.
  7883. */
  7884. /**
  7885. * Sets the midtones Density value.
  7886. * 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.
  7887. * Values less than zero provide a filter of opposite hue.
  7888. */
  7889. midtonesDensity: number;
  7890. /**
  7891. * Gets the midtones Saturation value.
  7892. * 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.
  7893. */
  7894. /**
  7895. * Sets the midtones Saturation value.
  7896. * 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.
  7897. */
  7898. midtonesSaturation: number;
  7899. /**
  7900. * Gets the midtones Exposure value.
  7901. * 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.
  7902. */
  7903. /**
  7904. * Sets the midtones Exposure value.
  7905. * 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.
  7906. */
  7907. midtonesExposure: number;
  7908. private _shadowsHue;
  7909. private _shadowsDensity;
  7910. private _shadowsSaturation;
  7911. private _shadowsExposure;
  7912. /**
  7913. * Gets the shadows Hue value.
  7914. * 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).
  7915. */
  7916. /**
  7917. * Sets the shadows Hue value.
  7918. * 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).
  7919. */
  7920. shadowsHue: number;
  7921. /**
  7922. * Gets the shadows Density value.
  7923. * 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.
  7924. * Values less than zero provide a filter of opposite hue.
  7925. */
  7926. /**
  7927. * Sets the shadows Density value.
  7928. * 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.
  7929. * Values less than zero provide a filter of opposite hue.
  7930. */
  7931. shadowsDensity: number;
  7932. /**
  7933. * Gets the shadows Saturation value.
  7934. * 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.
  7935. */
  7936. /**
  7937. * Sets the shadows Saturation value.
  7938. * 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.
  7939. */
  7940. shadowsSaturation: number;
  7941. /**
  7942. * Gets the shadows Exposure value.
  7943. * 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.
  7944. */
  7945. /**
  7946. * Sets the shadows Exposure value.
  7947. * 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.
  7948. */
  7949. shadowsExposure: number;
  7950. /**
  7951. * Returns the class name
  7952. * @returns The class name
  7953. */
  7954. getClassName(): string;
  7955. /**
  7956. * Binds the color curves to the shader.
  7957. * @param colorCurves The color curve to bind
  7958. * @param effect The effect to bind to
  7959. * @param positiveUniform The positive uniform shader parameter
  7960. * @param neutralUniform The neutral uniform shader parameter
  7961. * @param negativeUniform The negative uniform shader parameter
  7962. */
  7963. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7964. /**
  7965. * Prepare the list of uniforms associated with the ColorCurves effects.
  7966. * @param uniformsList The list of uniforms used in the effect
  7967. */
  7968. static PrepareUniforms(uniformsList: string[]): void;
  7969. /**
  7970. * Returns color grading data based on a hue, density, saturation and exposure value.
  7971. * @param filterHue The hue of the color filter.
  7972. * @param filterDensity The density of the color filter.
  7973. * @param saturation The saturation.
  7974. * @param exposure The exposure.
  7975. * @param result The result data container.
  7976. */
  7977. private getColorGradingDataToRef;
  7978. /**
  7979. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7980. * @param value The input slider value in range [-100,100].
  7981. * @returns Adjusted value.
  7982. */
  7983. private static applyColorGradingSliderNonlinear;
  7984. /**
  7985. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7986. * @param hue The hue (H) input.
  7987. * @param saturation The saturation (S) input.
  7988. * @param brightness The brightness (B) input.
  7989. * @result An RGBA color represented as Vector4.
  7990. */
  7991. private static fromHSBToRef;
  7992. /**
  7993. * Returns a value clamped between min and max
  7994. * @param value The value to clamp
  7995. * @param min The minimum of value
  7996. * @param max The maximum of value
  7997. * @returns The clamped value.
  7998. */
  7999. private static clamp;
  8000. /**
  8001. * Clones the current color curve instance.
  8002. * @return The cloned curves
  8003. */
  8004. clone(): ColorCurves;
  8005. /**
  8006. * Serializes the current color curve instance to a json representation.
  8007. * @return a JSON representation
  8008. */
  8009. serialize(): any;
  8010. /**
  8011. * Parses the color curve from a json representation.
  8012. * @param source the JSON source to parse
  8013. * @return The parsed curves
  8014. */
  8015. static Parse(source: any): ColorCurves;
  8016. }
  8017. }
  8018. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8019. import { Observable } from "babylonjs/Misc/observable";
  8020. import { Nullable } from "babylonjs/types";
  8021. import { Color4 } from "babylonjs/Maths/math.color";
  8022. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8023. import { Effect } from "babylonjs/Materials/effect";
  8024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8025. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8026. /**
  8027. * Interface to follow in your material defines to integrate easily the
  8028. * Image proccessing functions.
  8029. * @hidden
  8030. */
  8031. export interface IImageProcessingConfigurationDefines {
  8032. IMAGEPROCESSING: boolean;
  8033. VIGNETTE: boolean;
  8034. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8035. VIGNETTEBLENDMODEOPAQUE: boolean;
  8036. TONEMAPPING: boolean;
  8037. TONEMAPPING_ACES: boolean;
  8038. CONTRAST: boolean;
  8039. EXPOSURE: boolean;
  8040. COLORCURVES: boolean;
  8041. COLORGRADING: boolean;
  8042. COLORGRADING3D: boolean;
  8043. SAMPLER3DGREENDEPTH: boolean;
  8044. SAMPLER3DBGRMAP: boolean;
  8045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8046. }
  8047. /**
  8048. * @hidden
  8049. */
  8050. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8051. IMAGEPROCESSING: boolean;
  8052. VIGNETTE: boolean;
  8053. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8054. VIGNETTEBLENDMODEOPAQUE: boolean;
  8055. TONEMAPPING: boolean;
  8056. TONEMAPPING_ACES: boolean;
  8057. CONTRAST: boolean;
  8058. COLORCURVES: boolean;
  8059. COLORGRADING: boolean;
  8060. COLORGRADING3D: boolean;
  8061. SAMPLER3DGREENDEPTH: boolean;
  8062. SAMPLER3DBGRMAP: boolean;
  8063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8064. EXPOSURE: boolean;
  8065. constructor();
  8066. }
  8067. /**
  8068. * This groups together the common properties used for image processing either in direct forward pass
  8069. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8070. * or not.
  8071. */
  8072. export class ImageProcessingConfiguration {
  8073. /**
  8074. * Default tone mapping applied in BabylonJS.
  8075. */
  8076. static readonly TONEMAPPING_STANDARD: number;
  8077. /**
  8078. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8079. * to other engines rendering to increase portability.
  8080. */
  8081. static readonly TONEMAPPING_ACES: number;
  8082. /**
  8083. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8084. */
  8085. colorCurves: Nullable<ColorCurves>;
  8086. private _colorCurvesEnabled;
  8087. /**
  8088. * Gets wether the color curves effect is enabled.
  8089. */
  8090. /**
  8091. * Sets wether the color curves effect is enabled.
  8092. */
  8093. colorCurvesEnabled: boolean;
  8094. private _colorGradingTexture;
  8095. /**
  8096. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8097. */
  8098. /**
  8099. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8100. */
  8101. colorGradingTexture: Nullable<BaseTexture>;
  8102. private _colorGradingEnabled;
  8103. /**
  8104. * Gets wether the color grading effect is enabled.
  8105. */
  8106. /**
  8107. * Sets wether the color grading effect is enabled.
  8108. */
  8109. colorGradingEnabled: boolean;
  8110. private _colorGradingWithGreenDepth;
  8111. /**
  8112. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8113. */
  8114. /**
  8115. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8116. */
  8117. colorGradingWithGreenDepth: boolean;
  8118. private _colorGradingBGR;
  8119. /**
  8120. * Gets wether the color grading texture contains BGR values.
  8121. */
  8122. /**
  8123. * Sets wether the color grading texture contains BGR values.
  8124. */
  8125. colorGradingBGR: boolean;
  8126. /** @hidden */
  8127. _exposure: number;
  8128. /**
  8129. * Gets the Exposure used in the effect.
  8130. */
  8131. /**
  8132. * Sets the Exposure used in the effect.
  8133. */
  8134. exposure: number;
  8135. private _toneMappingEnabled;
  8136. /**
  8137. * Gets wether the tone mapping effect is enabled.
  8138. */
  8139. /**
  8140. * Sets wether the tone mapping effect is enabled.
  8141. */
  8142. toneMappingEnabled: boolean;
  8143. private _toneMappingType;
  8144. /**
  8145. * Gets the type of tone mapping effect.
  8146. */
  8147. /**
  8148. * Sets the type of tone mapping effect used in BabylonJS.
  8149. */
  8150. toneMappingType: number;
  8151. protected _contrast: number;
  8152. /**
  8153. * Gets the contrast used in the effect.
  8154. */
  8155. /**
  8156. * Sets the contrast used in the effect.
  8157. */
  8158. contrast: number;
  8159. /**
  8160. * Vignette stretch size.
  8161. */
  8162. vignetteStretch: number;
  8163. /**
  8164. * Vignette centre X Offset.
  8165. */
  8166. vignetteCentreX: number;
  8167. /**
  8168. * Vignette centre Y Offset.
  8169. */
  8170. vignetteCentreY: number;
  8171. /**
  8172. * Vignette weight or intensity of the vignette effect.
  8173. */
  8174. vignetteWeight: number;
  8175. /**
  8176. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8177. * if vignetteEnabled is set to true.
  8178. */
  8179. vignetteColor: Color4;
  8180. /**
  8181. * Camera field of view used by the Vignette effect.
  8182. */
  8183. vignetteCameraFov: number;
  8184. private _vignetteBlendMode;
  8185. /**
  8186. * Gets the vignette blend mode allowing different kind of effect.
  8187. */
  8188. /**
  8189. * Sets the vignette blend mode allowing different kind of effect.
  8190. */
  8191. vignetteBlendMode: number;
  8192. private _vignetteEnabled;
  8193. /**
  8194. * Gets wether the vignette effect is enabled.
  8195. */
  8196. /**
  8197. * Sets wether the vignette effect is enabled.
  8198. */
  8199. vignetteEnabled: boolean;
  8200. private _applyByPostProcess;
  8201. /**
  8202. * Gets wether the image processing is applied through a post process or not.
  8203. */
  8204. /**
  8205. * Sets wether the image processing is applied through a post process or not.
  8206. */
  8207. applyByPostProcess: boolean;
  8208. private _isEnabled;
  8209. /**
  8210. * Gets wether the image processing is enabled or not.
  8211. */
  8212. /**
  8213. * Sets wether the image processing is enabled or not.
  8214. */
  8215. isEnabled: boolean;
  8216. /**
  8217. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8218. */
  8219. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8220. /**
  8221. * Method called each time the image processing information changes requires to recompile the effect.
  8222. */
  8223. protected _updateParameters(): void;
  8224. /**
  8225. * Gets the current class name.
  8226. * @return "ImageProcessingConfiguration"
  8227. */
  8228. getClassName(): string;
  8229. /**
  8230. * Prepare the list of uniforms associated with the Image Processing effects.
  8231. * @param uniforms The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of samplers associated with the Image Processing effects.
  8237. * @param samplersList The list of uniforms used in the effect
  8238. * @param defines the list of defines currently in use
  8239. */
  8240. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8241. /**
  8242. * Prepare the list of defines associated to the shader.
  8243. * @param defines the list of defines to complete
  8244. * @param forPostProcess Define if we are currently in post process mode or not
  8245. */
  8246. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8247. /**
  8248. * Returns true if all the image processing information are ready.
  8249. * @returns True if ready, otherwise, false
  8250. */
  8251. isReady(): boolean;
  8252. /**
  8253. * Binds the image processing to the shader.
  8254. * @param effect The effect to bind to
  8255. * @param aspectRatio Define the current aspect ratio of the effect
  8256. */
  8257. bind(effect: Effect, aspectRatio?: number): void;
  8258. /**
  8259. * Clones the current image processing instance.
  8260. * @return The cloned image processing
  8261. */
  8262. clone(): ImageProcessingConfiguration;
  8263. /**
  8264. * Serializes the current image processing instance to a json representation.
  8265. * @return a JSON representation
  8266. */
  8267. serialize(): any;
  8268. /**
  8269. * Parses the image processing from a json representation.
  8270. * @param source the JSON source to parse
  8271. * @return The parsed image processing
  8272. */
  8273. static Parse(source: any): ImageProcessingConfiguration;
  8274. private static _VIGNETTEMODE_MULTIPLY;
  8275. private static _VIGNETTEMODE_OPAQUE;
  8276. /**
  8277. * Used to apply the vignette as a mix with the pixel color.
  8278. */
  8279. static readonly VIGNETTEMODE_MULTIPLY: number;
  8280. /**
  8281. * Used to apply the vignette as a replacement of the pixel color.
  8282. */
  8283. static readonly VIGNETTEMODE_OPAQUE: number;
  8284. }
  8285. }
  8286. declare module "babylonjs/Shaders/postprocess.vertex" {
  8287. /** @hidden */
  8288. export var postprocessVertexShader: {
  8289. name: string;
  8290. shader: string;
  8291. };
  8292. }
  8293. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8294. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8295. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8296. module "babylonjs/Engines/thinEngine" {
  8297. interface ThinEngine {
  8298. /**
  8299. * Creates a new render target texture
  8300. * @param size defines the size of the texture
  8301. * @param options defines the options used to create the texture
  8302. * @returns a new render target texture stored in an InternalTexture
  8303. */
  8304. createRenderTargetTexture(size: number | {
  8305. width: number;
  8306. height: number;
  8307. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8308. }
  8309. }
  8310. }
  8311. declare module "babylonjs/Maths/math.axis" {
  8312. import { Vector3 } from "babylonjs/Maths/math.vector";
  8313. /** Defines supported spaces */
  8314. export enum Space {
  8315. /** Local (object) space */
  8316. LOCAL = 0,
  8317. /** World space */
  8318. WORLD = 1,
  8319. /** Bone space */
  8320. BONE = 2
  8321. }
  8322. /** Defines the 3 main axes */
  8323. export class Axis {
  8324. /** X axis */
  8325. static X: Vector3;
  8326. /** Y axis */
  8327. static Y: Vector3;
  8328. /** Z axis */
  8329. static Z: Vector3;
  8330. }
  8331. }
  8332. declare module "babylonjs/Cameras/targetCamera" {
  8333. import { Nullable } from "babylonjs/types";
  8334. import { Camera } from "babylonjs/Cameras/camera";
  8335. import { Scene } from "babylonjs/scene";
  8336. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * 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)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module "babylonjs/Events/keyboardEvents" {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8561. import { Nullable } from "babylonjs/types";
  8562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8564. /**
  8565. * Manage the keyboard inputs to control the movement of a free camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: FreeCamera;
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8575. */
  8576. keysUp: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8579. */
  8580. keysDown: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8583. */
  8584. keysLeft: number[];
  8585. /**
  8586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8587. */
  8588. keysRight: number[];
  8589. private _keys;
  8590. private _onCanvasBlurObserver;
  8591. private _onKeyboardObserver;
  8592. private _engine;
  8593. private _scene;
  8594. /**
  8595. * Attach the input controls to a specific dom element to get the input from.
  8596. * @param element Defines the element the controls should be listened from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current controls from the specified dom element.
  8602. * @param element Defines the element to stop listening the inputs from
  8603. */
  8604. detachControl(element: Nullable<HTMLElement>): void;
  8605. /**
  8606. * Update the current camera state depending on the inputs that have been used this frame.
  8607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8608. */
  8609. checkInputs(): void;
  8610. /**
  8611. * Gets the class name of the current intput.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /** @hidden */
  8616. _onLostFocus(): void;
  8617. /**
  8618. * Get the friendly name associated with the input class.
  8619. * @returns the input friendly name
  8620. */
  8621. getSimpleName(): string;
  8622. }
  8623. }
  8624. declare module "babylonjs/Lights/shadowLight" {
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8629. import { Light } from "babylonjs/Lights/light";
  8630. /**
  8631. * Interface describing all the common properties and methods a shadow light needs to implement.
  8632. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8633. * as well as binding the different shadow properties to the effects.
  8634. */
  8635. export interface IShadowLight extends Light {
  8636. /**
  8637. * The light id in the scene (used in scene.findLighById for instance)
  8638. */
  8639. id: string;
  8640. /**
  8641. * The position the shdow will be casted from.
  8642. */
  8643. position: Vector3;
  8644. /**
  8645. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8646. */
  8647. direction: Vector3;
  8648. /**
  8649. * The transformed position. Position of the light in world space taking parenting in account.
  8650. */
  8651. transformedPosition: Vector3;
  8652. /**
  8653. * The transformed direction. Direction of the light in world space taking parenting in account.
  8654. */
  8655. transformedDirection: Vector3;
  8656. /**
  8657. * The friendly name of the light in the scene.
  8658. */
  8659. name: string;
  8660. /**
  8661. * Defines the shadow projection clipping minimum z value.
  8662. */
  8663. shadowMinZ: number;
  8664. /**
  8665. * Defines the shadow projection clipping maximum z value.
  8666. */
  8667. shadowMaxZ: number;
  8668. /**
  8669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8671. */
  8672. computeTransformedInformation(): boolean;
  8673. /**
  8674. * Gets the scene the light belongs to.
  8675. * @returns The scene
  8676. */
  8677. getScene(): Scene;
  8678. /**
  8679. * Callback defining a custom Projection Matrix Builder.
  8680. * This can be used to override the default projection matrix computation.
  8681. */
  8682. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. /**
  8692. * Gets the current depth scale used in ESM.
  8693. * @returns The scale
  8694. */
  8695. getDepthScale(): number;
  8696. /**
  8697. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8698. * @returns true if a cube texture needs to be use
  8699. */
  8700. needCube(): boolean;
  8701. /**
  8702. * Detects if the projection matrix requires to be recomputed this frame.
  8703. * @returns true if it requires to be recomputed otherwise, false.
  8704. */
  8705. needProjectionMatrixCompute(): boolean;
  8706. /**
  8707. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8708. */
  8709. forceProjectionMatrixCompute(): void;
  8710. /**
  8711. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8714. */
  8715. getShadowDirection(faceIndex?: number): Vector3;
  8716. /**
  8717. * Gets the minZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the min for
  8719. * @returns the depth min z
  8720. */
  8721. getDepthMinZ(activeCamera: Camera): number;
  8722. /**
  8723. * Gets the maxZ used for shadow according to both the scene and the light.
  8724. * @param activeCamera The camera we are returning the max for
  8725. * @returns the depth max z
  8726. */
  8727. getDepthMaxZ(activeCamera: Camera): number;
  8728. }
  8729. /**
  8730. * Base implementation IShadowLight
  8731. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8732. */
  8733. export abstract class ShadowLight extends Light implements IShadowLight {
  8734. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8735. protected _position: Vector3;
  8736. protected _setPosition(value: Vector3): void;
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. /**
  8742. * Sets the position the shadow will be casted from. Also use as the light position for both
  8743. * point and spot lights.
  8744. */
  8745. position: Vector3;
  8746. protected _direction: Vector3;
  8747. protected _setDirection(value: Vector3): void;
  8748. /**
  8749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. /**
  8753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8754. * Also use as the light direction on spot and directional lights.
  8755. */
  8756. direction: Vector3;
  8757. private _shadowMinZ;
  8758. /**
  8759. * Gets the shadow projection clipping minimum z value.
  8760. */
  8761. /**
  8762. * Sets the shadow projection clipping minimum z value.
  8763. */
  8764. shadowMinZ: number;
  8765. private _shadowMaxZ;
  8766. /**
  8767. * Sets the shadow projection clipping maximum z value.
  8768. */
  8769. /**
  8770. * Gets the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Callback defining a custom Projection Matrix Builder.
  8775. * This can be used to override the default projection matrix computation.
  8776. */
  8777. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8778. /**
  8779. * The transformed position. Position of the light in world space taking parenting in account.
  8780. */
  8781. transformedPosition: Vector3;
  8782. /**
  8783. * The transformed direction. Direction of the light in world space taking parenting in account.
  8784. */
  8785. transformedDirection: Vector3;
  8786. private _needProjectionMatrixCompute;
  8787. /**
  8788. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8789. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8790. */
  8791. computeTransformedInformation(): boolean;
  8792. /**
  8793. * Return the depth scale used for the shadow map.
  8794. * @returns the depth scale.
  8795. */
  8796. getDepthScale(): number;
  8797. /**
  8798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8801. */
  8802. getShadowDirection(faceIndex?: number): Vector3;
  8803. /**
  8804. * Returns the ShadowLight absolute position in the World.
  8805. * @returns the position vector in world space
  8806. */
  8807. getAbsolutePosition(): Vector3;
  8808. /**
  8809. * Sets the ShadowLight direction toward the passed target.
  8810. * @param target The point to target in local space
  8811. * @returns the updated ShadowLight direction
  8812. */
  8813. setDirectionToTarget(target: Vector3): Vector3;
  8814. /**
  8815. * Returns the light rotation in euler definition.
  8816. * @returns the x y z rotation in local space.
  8817. */
  8818. getRotation(): Vector3;
  8819. /**
  8820. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8821. * @returns true if a cube texture needs to be use
  8822. */
  8823. needCube(): boolean;
  8824. /**
  8825. * Detects if the projection matrix requires to be recomputed this frame.
  8826. * @returns true if it requires to be recomputed otherwise, false.
  8827. */
  8828. needProjectionMatrixCompute(): boolean;
  8829. /**
  8830. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8831. */
  8832. forceProjectionMatrixCompute(): void;
  8833. /** @hidden */
  8834. _initCache(): void;
  8835. /** @hidden */
  8836. _isSynchronized(): boolean;
  8837. /**
  8838. * Computes the world matrix of the node
  8839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8840. * @returns the world matrix
  8841. */
  8842. computeWorldMatrix(force?: boolean): Matrix;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. }
  8864. }
  8865. declare module "babylonjs/Materials/effectFallbacks" {
  8866. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8867. import { Effect } from "babylonjs/Materials/effect";
  8868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8869. /**
  8870. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8871. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8872. */
  8873. export class EffectFallbacks implements IEffectFallbacks {
  8874. private _defines;
  8875. private _currentRank;
  8876. private _maxRank;
  8877. private _mesh;
  8878. /**
  8879. * Removes the fallback from the bound mesh.
  8880. */
  8881. unBindMesh(): void;
  8882. /**
  8883. * Adds a fallback on the specified property.
  8884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8885. * @param define The name of the define in the shader
  8886. */
  8887. addFallback(rank: number, define: string): void;
  8888. /**
  8889. * Sets the mesh to use CPU skinning when needing to fallback.
  8890. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8891. * @param mesh The mesh to use the fallbacks.
  8892. */
  8893. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8894. /**
  8895. * Checks to see if more fallbacks are still availible.
  8896. */
  8897. readonly hasMoreFallbacks: boolean;
  8898. /**
  8899. * Removes the defines that should be removed when falling back.
  8900. * @param currentDefines defines the current define statements for the shader.
  8901. * @param effect defines the current effect we try to compile
  8902. * @returns The resulting defines with defines of the current rank removed.
  8903. */
  8904. reduce(currentDefines: string, effect: Effect): string;
  8905. }
  8906. }
  8907. declare module "babylonjs/Materials/materialHelper" {
  8908. import { Nullable } from "babylonjs/types";
  8909. import { Scene } from "babylonjs/scene";
  8910. import { Engine } from "babylonjs/Engines/engine";
  8911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8912. import { Light } from "babylonjs/Lights/light";
  8913. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8914. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8916. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8917. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8918. /**
  8919. * "Static Class" containing the most commonly used helper while dealing with material for
  8920. * rendering purpose.
  8921. *
  8922. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8923. *
  8924. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8925. */
  8926. export class MaterialHelper {
  8927. /**
  8928. * Bind the current view position to an effect.
  8929. * @param effect The effect to be bound
  8930. * @param scene The scene the eyes position is used from
  8931. */
  8932. static BindEyePosition(effect: Effect, scene: Scene): void;
  8933. /**
  8934. * Helps preparing the defines values about the UVs in used in the effect.
  8935. * UVs are shared as much as we can accross channels in the shaders.
  8936. * @param texture The texture we are preparing the UVs for
  8937. * @param defines The defines to update
  8938. * @param key The channel key "diffuse", "specular"... used in the shader
  8939. */
  8940. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8941. /**
  8942. * Binds a texture matrix value to its corrsponding uniform
  8943. * @param texture The texture to bind the matrix for
  8944. * @param uniformBuffer The uniform buffer receivin the data
  8945. * @param key The channel key "diffuse", "specular"... used in the shader
  8946. */
  8947. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8948. /**
  8949. * Gets the current status of the fog (should it be enabled?)
  8950. * @param mesh defines the mesh to evaluate for fog support
  8951. * @param scene defines the hosting scene
  8952. * @returns true if fog must be enabled
  8953. */
  8954. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8955. /**
  8956. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8957. * @param mesh defines the current mesh
  8958. * @param scene defines the current scene
  8959. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8960. * @param pointsCloud defines if point cloud rendering has to be turned on
  8961. * @param fogEnabled defines if fog has to be turned on
  8962. * @param alphaTest defines if alpha testing has to be turned on
  8963. * @param defines defines the current list of defines
  8964. */
  8965. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8966. /**
  8967. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8968. * @param scene defines the current scene
  8969. * @param engine defines the current engine
  8970. * @param defines specifies the list of active defines
  8971. * @param useInstances defines if instances have to be turned on
  8972. * @param useClipPlane defines if clip plane have to be turned on
  8973. */
  8974. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8975. /**
  8976. * Prepares the defines for bones
  8977. * @param mesh The mesh containing the geometry data we will draw
  8978. * @param defines The defines to update
  8979. */
  8980. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8981. /**
  8982. * Prepares the defines for morph targets
  8983. * @param mesh The mesh containing the geometry data we will draw
  8984. * @param defines The defines to update
  8985. */
  8986. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8987. /**
  8988. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8989. * @param mesh The mesh containing the geometry data we will draw
  8990. * @param defines The defines to update
  8991. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8992. * @param useBones Precise whether bones should be used or not (override mesh info)
  8993. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8994. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8995. * @returns false if defines are considered not dirty and have not been checked
  8996. */
  8997. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8998. /**
  8999. * Prepares the defines related to multiview
  9000. * @param scene The scene we are intending to draw
  9001. * @param defines The defines to update
  9002. */
  9003. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9004. /**
  9005. * Prepares the defines related to the light information passed in parameter
  9006. * @param scene The scene we are intending to draw
  9007. * @param mesh The mesh the effect is compiling for
  9008. * @param light The light the effect is compiling for
  9009. * @param lightIndex The index of the light
  9010. * @param defines The defines to update
  9011. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9012. * @param state Defines the current state regarding what is needed (normals, etc...)
  9013. */
  9014. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9015. needNormals: boolean;
  9016. needRebuild: boolean;
  9017. shadowEnabled: boolean;
  9018. specularEnabled: boolean;
  9019. lightmapMode: boolean;
  9020. }): void;
  9021. /**
  9022. * Prepares the defines related to the light information passed in parameter
  9023. * @param scene The scene we are intending to draw
  9024. * @param mesh The mesh the effect is compiling for
  9025. * @param defines The defines to update
  9026. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9027. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9028. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9029. * @returns true if normals will be required for the rest of the effect
  9030. */
  9031. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9032. /**
  9033. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9034. * @param lightIndex defines the light index
  9035. * @param uniformsList The uniform list
  9036. * @param samplersList The sampler list
  9037. * @param projectedLightTexture defines if projected texture must be used
  9038. * @param uniformBuffersList defines an optional list of uniform buffers
  9039. */
  9040. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9041. /**
  9042. * Prepares the uniforms and samplers list to be used in the effect
  9043. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9044. * @param samplersList The sampler list
  9045. * @param defines The defines helping in the list generation
  9046. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9047. */
  9048. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9049. /**
  9050. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9051. * @param defines The defines to update while falling back
  9052. * @param fallbacks The authorized effect fallbacks
  9053. * @param maxSimultaneousLights The maximum number of lights allowed
  9054. * @param rank the current rank of the Effect
  9055. * @returns The newly affected rank
  9056. */
  9057. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9058. private static _TmpMorphInfluencers;
  9059. /**
  9060. * Prepares the list of attributes required for morph targets according to the effect defines.
  9061. * @param attribs The current list of supported attribs
  9062. * @param mesh The mesh to prepare the morph targets attributes for
  9063. * @param influencers The number of influencers
  9064. */
  9065. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9066. /**
  9067. * Prepares the list of attributes required for morph targets according to the effect defines.
  9068. * @param attribs The current list of supported attribs
  9069. * @param mesh The mesh to prepare the morph targets attributes for
  9070. * @param defines The current Defines of the effect
  9071. */
  9072. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9073. /**
  9074. * Prepares the list of attributes required for bones according to the effect defines.
  9075. * @param attribs The current list of supported attribs
  9076. * @param mesh The mesh to prepare the bones attributes for
  9077. * @param defines The current Defines of the effect
  9078. * @param fallbacks The current efffect fallback strategy
  9079. */
  9080. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9081. /**
  9082. * Check and prepare the list of attributes required for instances according to the effect defines.
  9083. * @param attribs The current list of supported attribs
  9084. * @param defines The current MaterialDefines of the effect
  9085. */
  9086. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9087. /**
  9088. * Add the list of attributes required for instances to the attribs array.
  9089. * @param attribs The current list of supported attribs
  9090. */
  9091. static PushAttributesForInstances(attribs: string[]): void;
  9092. /**
  9093. * Binds the light shadow information to the effect for the given mesh.
  9094. * @param light The light containing the generator
  9095. * @param scene The scene the lights belongs to
  9096. * @param mesh The mesh we are binding the information to render
  9097. * @param lightIndex The light index in the effect used to render the mesh
  9098. * @param effect The effect we are binding the data to
  9099. */
  9100. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9101. /**
  9102. * Binds the light information to the effect.
  9103. * @param light The light containing the generator
  9104. * @param effect The effect we are binding the data to
  9105. * @param lightIndex The light index in the effect used to render
  9106. */
  9107. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9108. /**
  9109. * Binds the lights information from the scene to the effect for the given mesh.
  9110. * @param light Light to bind
  9111. * @param lightIndex Light index
  9112. * @param scene The scene where the light belongs to
  9113. * @param mesh The mesh we are binding the information to render
  9114. * @param effect The effect we are binding the data to
  9115. * @param useSpecular Defines if specular is supported
  9116. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9117. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9118. */
  9119. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9120. /**
  9121. * Binds the lights information from the scene to the effect for the given mesh.
  9122. * @param scene The scene the lights belongs to
  9123. * @param mesh The mesh we are binding the information to render
  9124. * @param effect The effect we are binding the data to
  9125. * @param defines The generated defines for the effect
  9126. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9127. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9128. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9129. */
  9130. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9131. private static _tempFogColor;
  9132. /**
  9133. * Binds the fog information from the scene to the effect for the given mesh.
  9134. * @param scene The scene the lights belongs to
  9135. * @param mesh The mesh we are binding the information to render
  9136. * @param effect The effect we are binding the data to
  9137. * @param linearSpace Defines if the fog effect is applied in linear space
  9138. */
  9139. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9140. /**
  9141. * Binds the bones information from the mesh to the effect.
  9142. * @param mesh The mesh we are binding the information to render
  9143. * @param effect The effect we are binding the data to
  9144. */
  9145. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9146. /**
  9147. * Binds the morph targets information from the mesh to the effect.
  9148. * @param abstractMesh The mesh we are binding the information to render
  9149. * @param effect The effect we are binding the data to
  9150. */
  9151. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9152. /**
  9153. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9154. * @param defines The generated defines used in the effect
  9155. * @param effect The effect we are binding the data to
  9156. * @param scene The scene we are willing to render with logarithmic scale for
  9157. */
  9158. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9159. /**
  9160. * Binds the clip plane information from the scene to the effect.
  9161. * @param scene The scene the clip plane information are extracted from
  9162. * @param effect The effect we are binding the data to
  9163. */
  9164. static BindClipPlane(effect: Effect, scene: Scene): void;
  9165. }
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9168. /** @hidden */
  9169. export var packingFunctions: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9175. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9176. /** @hidden */
  9177. export var shadowMapPixelShader: {
  9178. name: string;
  9179. shader: string;
  9180. };
  9181. }
  9182. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9183. /** @hidden */
  9184. export var bonesDeclaration: {
  9185. name: string;
  9186. shader: string;
  9187. };
  9188. }
  9189. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9190. /** @hidden */
  9191. export var morphTargetsVertexGlobalDeclaration: {
  9192. name: string;
  9193. shader: string;
  9194. };
  9195. }
  9196. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9197. /** @hidden */
  9198. export var morphTargetsVertexDeclaration: {
  9199. name: string;
  9200. shader: string;
  9201. };
  9202. }
  9203. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9204. /** @hidden */
  9205. export var instancesDeclaration: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9211. /** @hidden */
  9212. export var helperFunctions: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9218. /** @hidden */
  9219. export var morphTargetsVertex: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9225. /** @hidden */
  9226. export var instancesVertex: {
  9227. name: string;
  9228. shader: string;
  9229. };
  9230. }
  9231. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9232. /** @hidden */
  9233. export var bonesVertex: {
  9234. name: string;
  9235. shader: string;
  9236. };
  9237. }
  9238. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9239. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9241. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9242. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9243. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9245. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9246. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9247. /** @hidden */
  9248. export var shadowMapVertexShader: {
  9249. name: string;
  9250. shader: string;
  9251. };
  9252. }
  9253. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9254. /** @hidden */
  9255. export var depthBoxBlurPixelShader: {
  9256. name: string;
  9257. shader: string;
  9258. };
  9259. }
  9260. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9261. import { Nullable } from "babylonjs/types";
  9262. import { Scene } from "babylonjs/scene";
  9263. import { Matrix } from "babylonjs/Maths/math.vector";
  9264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9266. import { Mesh } from "babylonjs/Meshes/mesh";
  9267. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9268. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9269. import { Effect } from "babylonjs/Materials/effect";
  9270. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9271. import "babylonjs/Shaders/shadowMap.fragment";
  9272. import "babylonjs/Shaders/shadowMap.vertex";
  9273. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9274. import { Observable } from "babylonjs/Misc/observable";
  9275. /**
  9276. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9277. */
  9278. export interface ICustomShaderOptions {
  9279. /**
  9280. * Gets or sets the custom shader name to use
  9281. */
  9282. shaderName: string;
  9283. /**
  9284. * The list of attribute names used in the shader
  9285. */
  9286. attributes?: string[];
  9287. /**
  9288. * The list of unifrom names used in the shader
  9289. */
  9290. uniforms?: string[];
  9291. /**
  9292. * The list of sampler names used in the shader
  9293. */
  9294. samplers?: string[];
  9295. /**
  9296. * The list of defines used in the shader
  9297. */
  9298. defines?: string[];
  9299. }
  9300. /**
  9301. * Interface to implement to create a shadow generator compatible with BJS.
  9302. */
  9303. export interface IShadowGenerator {
  9304. /**
  9305. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9306. * @returns The render target texture if present otherwise, null
  9307. */
  9308. getShadowMap(): Nullable<RenderTargetTexture>;
  9309. /**
  9310. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9311. * @returns The render target texture if the shadow map is present otherwise, null
  9312. */
  9313. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9314. /**
  9315. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9316. * @param subMesh The submesh we want to render in the shadow map
  9317. * @param useInstances Defines wether will draw in the map using instances
  9318. * @returns true if ready otherwise, false
  9319. */
  9320. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9321. /**
  9322. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9323. * @param defines Defines of the material we want to update
  9324. * @param lightIndex Index of the light in the enabled light list of the material
  9325. */
  9326. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9327. /**
  9328. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9329. * defined in the generator but impacting the effect).
  9330. * It implies the unifroms available on the materials are the standard BJS ones.
  9331. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9332. * @param effect The effect we are binfing the information for
  9333. */
  9334. bindShadowLight(lightIndex: string, effect: Effect): void;
  9335. /**
  9336. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9337. * (eq to shadow prjection matrix * light transform matrix)
  9338. * @returns The transform matrix used to create the shadow map
  9339. */
  9340. getTransformMatrix(): Matrix;
  9341. /**
  9342. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9343. * Cube and 2D textures for instance.
  9344. */
  9345. recreateShadowMap(): void;
  9346. /**
  9347. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9348. * @param onCompiled Callback triggered at the and of the effects compilation
  9349. * @param options Sets of optional options forcing the compilation with different modes
  9350. */
  9351. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9352. useInstances: boolean;
  9353. }>): void;
  9354. /**
  9355. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9356. * @param options Sets of optional options forcing the compilation with different modes
  9357. * @returns A promise that resolves when the compilation completes
  9358. */
  9359. forceCompilationAsync(options?: Partial<{
  9360. useInstances: boolean;
  9361. }>): Promise<void>;
  9362. /**
  9363. * Serializes the shadow generator setup to a json object.
  9364. * @returns The serialized JSON object
  9365. */
  9366. serialize(): any;
  9367. /**
  9368. * Disposes the Shadow map and related Textures and effects.
  9369. */
  9370. dispose(): void;
  9371. }
  9372. /**
  9373. * Default implementation IShadowGenerator.
  9374. * This is the main object responsible of generating shadows in the framework.
  9375. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9376. */
  9377. export class ShadowGenerator implements IShadowGenerator {
  9378. /**
  9379. * Shadow generator mode None: no filtering applied.
  9380. */
  9381. static readonly FILTER_NONE: number;
  9382. /**
  9383. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9385. */
  9386. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9387. /**
  9388. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9389. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9390. */
  9391. static readonly FILTER_POISSONSAMPLING: number;
  9392. /**
  9393. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode ESM: 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_CLOSEEXPONENTIALSHADOWMAP: number;
  9403. /**
  9404. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9405. * edge artifacts on steep falloff.
  9406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9407. */
  9408. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9409. /**
  9410. * Shadow generator mode PCF: Percentage Closer Filtering
  9411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9412. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9413. */
  9414. static readonly FILTER_PCF: number;
  9415. /**
  9416. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9417. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9418. * Contact Hardening
  9419. */
  9420. static readonly FILTER_PCSS: number;
  9421. /**
  9422. * Reserved for PCF and PCSS
  9423. * Highest Quality.
  9424. *
  9425. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9426. *
  9427. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9428. */
  9429. static readonly QUALITY_HIGH: number;
  9430. /**
  9431. * Reserved for PCF and PCSS
  9432. * Good tradeoff for quality/perf cross devices
  9433. *
  9434. * Execute PCF on a 3*3 kernel.
  9435. *
  9436. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9437. */
  9438. static readonly QUALITY_MEDIUM: number;
  9439. /**
  9440. * Reserved for PCF and PCSS
  9441. * The lowest quality but the fastest.
  9442. *
  9443. * Execute PCF on a 1*1 kernel.
  9444. *
  9445. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9446. */
  9447. static readonly QUALITY_LOW: number;
  9448. /** Gets or sets the custom shader name to use */
  9449. customShaderOptions: ICustomShaderOptions;
  9450. /**
  9451. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9452. */
  9453. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9454. /**
  9455. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9456. */
  9457. onAfterShadowMapRenderObservable: Observable<Effect>;
  9458. /**
  9459. * Observable triggered before a mesh is rendered in the shadow map.
  9460. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9461. */
  9462. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9463. /**
  9464. * Observable triggered after a mesh is rendered in the shadow map.
  9465. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9466. */
  9467. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9468. private _bias;
  9469. /**
  9470. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9471. */
  9472. /**
  9473. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9474. */
  9475. bias: number;
  9476. private _normalBias;
  9477. /**
  9478. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9479. */
  9480. /**
  9481. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9482. */
  9483. normalBias: number;
  9484. private _blurBoxOffset;
  9485. /**
  9486. * Gets the blur box offset: offset applied during the blur pass.
  9487. * Only useful if useKernelBlur = false
  9488. */
  9489. /**
  9490. * Sets the blur box offset: offset applied during the blur pass.
  9491. * Only useful if useKernelBlur = false
  9492. */
  9493. blurBoxOffset: number;
  9494. private _blurScale;
  9495. /**
  9496. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9497. * 2 means half of the size.
  9498. */
  9499. /**
  9500. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9501. * 2 means half of the size.
  9502. */
  9503. blurScale: number;
  9504. private _blurKernel;
  9505. /**
  9506. * Gets the blur kernel: kernel size of the blur pass.
  9507. * Only useful if useKernelBlur = true
  9508. */
  9509. /**
  9510. * Sets the blur kernel: kernel size of the blur pass.
  9511. * Only useful if useKernelBlur = true
  9512. */
  9513. blurKernel: number;
  9514. private _useKernelBlur;
  9515. /**
  9516. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9517. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9518. */
  9519. /**
  9520. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9521. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9522. */
  9523. useKernelBlur: boolean;
  9524. private _depthScale;
  9525. /**
  9526. * Gets the depth scale used in ESM mode.
  9527. */
  9528. /**
  9529. * Sets the depth scale used in ESM mode.
  9530. * This can override the scale stored on the light.
  9531. */
  9532. depthScale: number;
  9533. private _filter;
  9534. /**
  9535. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9537. */
  9538. /**
  9539. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9540. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9541. */
  9542. filter: number;
  9543. /**
  9544. * Gets if the current filter is set to Poisson Sampling.
  9545. */
  9546. /**
  9547. * Sets the current filter to Poisson Sampling.
  9548. */
  9549. usePoissonSampling: boolean;
  9550. /**
  9551. * Gets if the current filter is set to ESM.
  9552. */
  9553. /**
  9554. * Sets the current filter is to ESM.
  9555. */
  9556. useExponentialShadowMap: boolean;
  9557. /**
  9558. * Gets if the current filter is set to filtered ESM.
  9559. */
  9560. /**
  9561. * Gets if the current filter is set to filtered ESM.
  9562. */
  9563. useBlurExponentialShadowMap: boolean;
  9564. /**
  9565. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9566. * exponential to prevent steep falloff artifacts).
  9567. */
  9568. /**
  9569. * Sets the current filter to "close ESM" (using the inverse of the
  9570. * exponential to prevent steep falloff artifacts).
  9571. */
  9572. useCloseExponentialShadowMap: boolean;
  9573. /**
  9574. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9575. * exponential to prevent steep falloff artifacts).
  9576. */
  9577. /**
  9578. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9579. * exponential to prevent steep falloff artifacts).
  9580. */
  9581. useBlurCloseExponentialShadowMap: boolean;
  9582. /**
  9583. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9584. */
  9585. /**
  9586. * Sets the current filter to "PCF" (percentage closer filtering).
  9587. */
  9588. usePercentageCloserFiltering: boolean;
  9589. private _filteringQuality;
  9590. /**
  9591. * Gets the PCF or PCSS Quality.
  9592. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9593. */
  9594. /**
  9595. * Sets the PCF or PCSS Quality.
  9596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9597. */
  9598. filteringQuality: number;
  9599. /**
  9600. * Gets if the current filter is set to "PCSS" (contact hardening).
  9601. */
  9602. /**
  9603. * Sets the current filter to "PCSS" (contact hardening).
  9604. */
  9605. useContactHardeningShadow: boolean;
  9606. private _contactHardeningLightSizeUVRatio;
  9607. /**
  9608. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9609. * Using a ratio helps keeping shape stability independently of the map size.
  9610. *
  9611. * It does not account for the light projection as it was having too much
  9612. * instability during the light setup or during light position changes.
  9613. *
  9614. * Only valid if useContactHardeningShadow is true.
  9615. */
  9616. /**
  9617. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9618. * Using a ratio helps keeping shape stability independently of the map size.
  9619. *
  9620. * It does not account for the light projection as it was having too much
  9621. * instability during the light setup or during light position changes.
  9622. *
  9623. * Only valid if useContactHardeningShadow is true.
  9624. */
  9625. contactHardeningLightSizeUVRatio: number;
  9626. private _darkness;
  9627. /** Gets or sets the actual darkness of a shadow */
  9628. darkness: number;
  9629. /**
  9630. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9631. * 0 means strongest and 1 would means no shadow.
  9632. * @returns the darkness.
  9633. */
  9634. getDarkness(): number;
  9635. /**
  9636. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9637. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9638. * @returns the shadow generator allowing fluent coding.
  9639. */
  9640. setDarkness(darkness: number): ShadowGenerator;
  9641. private _transparencyShadow;
  9642. /** Gets or sets the ability to have transparent shadow */
  9643. transparencyShadow: boolean;
  9644. /**
  9645. * Sets the ability to have transparent shadow (boolean).
  9646. * @param transparent True if transparent else False
  9647. * @returns the shadow generator allowing fluent coding
  9648. */
  9649. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9650. private _shadowMap;
  9651. private _shadowMap2;
  9652. /**
  9653. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9654. * @returns The render target texture if present otherwise, null
  9655. */
  9656. getShadowMap(): Nullable<RenderTargetTexture>;
  9657. /**
  9658. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9659. * @returns The render target texture if the shadow map is present otherwise, null
  9660. */
  9661. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9662. /**
  9663. * Gets the class name of that object
  9664. * @returns "ShadowGenerator"
  9665. */
  9666. getClassName(): string;
  9667. /**
  9668. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9669. * @param mesh Mesh to add
  9670. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9671. * @returns the Shadow Generator itself
  9672. */
  9673. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9674. /**
  9675. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9676. * @param mesh Mesh to remove
  9677. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9678. * @returns the Shadow Generator itself
  9679. */
  9680. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9681. /**
  9682. * Controls the extent to which the shadows fade out at the edge of the frustum
  9683. * Used only by directionals and spots
  9684. */
  9685. frustumEdgeFalloff: number;
  9686. private _light;
  9687. /**
  9688. * Returns the associated light object.
  9689. * @returns the light generating the shadow
  9690. */
  9691. getLight(): IShadowLight;
  9692. /**
  9693. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9694. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9695. * It might on the other hand introduce peter panning.
  9696. */
  9697. forceBackFacesOnly: boolean;
  9698. private _scene;
  9699. private _lightDirection;
  9700. private _effect;
  9701. private _viewMatrix;
  9702. private _projectionMatrix;
  9703. private _transformMatrix;
  9704. private _cachedPosition;
  9705. private _cachedDirection;
  9706. private _cachedDefines;
  9707. private _currentRenderID;
  9708. private _boxBlurPostprocess;
  9709. private _kernelBlurXPostprocess;
  9710. private _kernelBlurYPostprocess;
  9711. private _blurPostProcesses;
  9712. private _mapSize;
  9713. private _currentFaceIndex;
  9714. private _currentFaceIndexCache;
  9715. private _textureType;
  9716. private _defaultTextureMatrix;
  9717. private _storedUniqueId;
  9718. /** @hidden */
  9719. static _SceneComponentInitialization: (scene: Scene) => void;
  9720. /**
  9721. * Creates a ShadowGenerator object.
  9722. * A ShadowGenerator is the required tool to use the shadows.
  9723. * Each light casting shadows needs to use its own ShadowGenerator.
  9724. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9725. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9726. * @param light The light object generating the shadows.
  9727. * @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.
  9728. */
  9729. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9730. private _initializeGenerator;
  9731. private _initializeShadowMap;
  9732. private _initializeBlurRTTAndPostProcesses;
  9733. private _renderForShadowMap;
  9734. private _renderSubMeshForShadowMap;
  9735. private _applyFilterValues;
  9736. /**
  9737. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9738. * @param onCompiled Callback triggered at the and of the effects compilation
  9739. * @param options Sets of optional options forcing the compilation with different modes
  9740. */
  9741. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9742. useInstances: boolean;
  9743. }>): void;
  9744. /**
  9745. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9746. * @param options Sets of optional options forcing the compilation with different modes
  9747. * @returns A promise that resolves when the compilation completes
  9748. */
  9749. forceCompilationAsync(options?: Partial<{
  9750. useInstances: boolean;
  9751. }>): Promise<void>;
  9752. /**
  9753. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9754. * @param subMesh The submesh we want to render in the shadow map
  9755. * @param useInstances Defines wether will draw in the map using instances
  9756. * @returns true if ready otherwise, false
  9757. */
  9758. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9759. /**
  9760. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9761. * @param defines Defines of the material we want to update
  9762. * @param lightIndex Index of the light in the enabled light list of the material
  9763. */
  9764. prepareDefines(defines: any, lightIndex: number): void;
  9765. /**
  9766. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9767. * defined in the generator but impacting the effect).
  9768. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9769. * @param effect The effect we are binfing the information for
  9770. */
  9771. bindShadowLight(lightIndex: string, effect: Effect): void;
  9772. /**
  9773. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9774. * (eq to shadow prjection matrix * light transform matrix)
  9775. * @returns The transform matrix used to create the shadow map
  9776. */
  9777. getTransformMatrix(): Matrix;
  9778. /**
  9779. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9780. * Cube and 2D textures for instance.
  9781. */
  9782. recreateShadowMap(): void;
  9783. private _disposeBlurPostProcesses;
  9784. private _disposeRTTandPostProcesses;
  9785. /**
  9786. * Disposes the ShadowGenerator.
  9787. * Returns nothing.
  9788. */
  9789. dispose(): void;
  9790. /**
  9791. * Serializes the shadow generator setup to a json object.
  9792. * @returns The serialized JSON object
  9793. */
  9794. serialize(): any;
  9795. /**
  9796. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9797. * @param parsedShadowGenerator The JSON object to parse
  9798. * @param scene The scene to create the shadow map for
  9799. * @returns The parsed shadow generator
  9800. */
  9801. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9802. }
  9803. }
  9804. declare module "babylonjs/Lights/light" {
  9805. import { Nullable } from "babylonjs/types";
  9806. import { Scene } from "babylonjs/scene";
  9807. import { Vector3 } from "babylonjs/Maths/math.vector";
  9808. import { Color3 } from "babylonjs/Maths/math.color";
  9809. import { Node } from "babylonjs/node";
  9810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9811. import { Effect } from "babylonjs/Materials/effect";
  9812. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9813. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9814. /**
  9815. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9816. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9817. * 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.
  9818. */
  9819. export abstract class Light extends Node {
  9820. /**
  9821. * Falloff Default: light is falling off following the material specification:
  9822. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9823. */
  9824. static readonly FALLOFF_DEFAULT: number;
  9825. /**
  9826. * Falloff Physical: light is falling off following the inverse squared distance law.
  9827. */
  9828. static readonly FALLOFF_PHYSICAL: number;
  9829. /**
  9830. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9831. * to enhance interoperability with other engines.
  9832. */
  9833. static readonly FALLOFF_GLTF: number;
  9834. /**
  9835. * Falloff Standard: light is falling off like in the standard material
  9836. * to enhance interoperability with other materials.
  9837. */
  9838. static readonly FALLOFF_STANDARD: number;
  9839. /**
  9840. * If every light affecting the material is in this lightmapMode,
  9841. * material.lightmapTexture adds or multiplies
  9842. * (depends on material.useLightmapAsShadowmap)
  9843. * after every other light calculations.
  9844. */
  9845. static readonly LIGHTMAP_DEFAULT: number;
  9846. /**
  9847. * material.lightmapTexture as only diffuse lighting from this light
  9848. * adds only specular lighting from this light
  9849. * adds dynamic shadows
  9850. */
  9851. static readonly LIGHTMAP_SPECULAR: number;
  9852. /**
  9853. * material.lightmapTexture as only lighting
  9854. * no light calculation from this light
  9855. * only adds dynamic shadows from this light
  9856. */
  9857. static readonly LIGHTMAP_SHADOWSONLY: number;
  9858. /**
  9859. * Each light type uses the default quantity according to its type:
  9860. * point/spot lights use luminous intensity
  9861. * directional lights use illuminance
  9862. */
  9863. static readonly INTENSITYMODE_AUTOMATIC: number;
  9864. /**
  9865. * lumen (lm)
  9866. */
  9867. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9868. /**
  9869. * candela (lm/sr)
  9870. */
  9871. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9872. /**
  9873. * lux (lm/m^2)
  9874. */
  9875. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9876. /**
  9877. * nit (cd/m^2)
  9878. */
  9879. static readonly INTENSITYMODE_LUMINANCE: number;
  9880. /**
  9881. * Light type const id of the point light.
  9882. */
  9883. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9884. /**
  9885. * Light type const id of the directional light.
  9886. */
  9887. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9888. /**
  9889. * Light type const id of the spot light.
  9890. */
  9891. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9892. /**
  9893. * Light type const id of the hemispheric light.
  9894. */
  9895. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9896. /**
  9897. * Diffuse gives the basic color to an object.
  9898. */
  9899. diffuse: Color3;
  9900. /**
  9901. * Specular produces a highlight color on an object.
  9902. * Note: This is note affecting PBR materials.
  9903. */
  9904. specular: Color3;
  9905. /**
  9906. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9907. * falling off base on range or angle.
  9908. * This can be set to any values in Light.FALLOFF_x.
  9909. *
  9910. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9911. * other types of materials.
  9912. */
  9913. falloffType: number;
  9914. /**
  9915. * Strength of the light.
  9916. * Note: By default it is define in the framework own unit.
  9917. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9918. */
  9919. intensity: number;
  9920. private _range;
  9921. protected _inverseSquaredRange: number;
  9922. /**
  9923. * Defines how far from the source the light is impacting in scene units.
  9924. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9925. */
  9926. /**
  9927. * Defines how far from the source the light is impacting in scene units.
  9928. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9929. */
  9930. range: number;
  9931. /**
  9932. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9933. * of light.
  9934. */
  9935. private _photometricScale;
  9936. private _intensityMode;
  9937. /**
  9938. * Gets the photometric scale used to interpret the intensity.
  9939. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9940. */
  9941. /**
  9942. * Sets the photometric scale used to interpret the intensity.
  9943. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9944. */
  9945. intensityMode: number;
  9946. private _radius;
  9947. /**
  9948. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9949. */
  9950. /**
  9951. * sets the light radius used by PBR Materials to simulate soft area lights.
  9952. */
  9953. radius: number;
  9954. private _renderPriority;
  9955. /**
  9956. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9957. * exceeding the number allowed of the materials.
  9958. */
  9959. renderPriority: number;
  9960. private _shadowEnabled;
  9961. /**
  9962. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9963. * the current shadow generator.
  9964. */
  9965. /**
  9966. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9967. * the current shadow generator.
  9968. */
  9969. shadowEnabled: boolean;
  9970. private _includedOnlyMeshes;
  9971. /**
  9972. * Gets the only meshes impacted by this light.
  9973. */
  9974. /**
  9975. * Sets the only meshes impacted by this light.
  9976. */
  9977. includedOnlyMeshes: AbstractMesh[];
  9978. private _excludedMeshes;
  9979. /**
  9980. * Gets the meshes not impacted by this light.
  9981. */
  9982. /**
  9983. * Sets the meshes not impacted by this light.
  9984. */
  9985. excludedMeshes: AbstractMesh[];
  9986. private _excludeWithLayerMask;
  9987. /**
  9988. * Gets the layer id use to find what meshes are not impacted by the light.
  9989. * Inactive if 0
  9990. */
  9991. /**
  9992. * Sets the layer id use to find what meshes are not impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. excludeWithLayerMask: number;
  9996. private _includeOnlyWithLayerMask;
  9997. /**
  9998. * Gets the layer id use to find what meshes are impacted by the light.
  9999. * Inactive if 0
  10000. */
  10001. /**
  10002. * Sets the layer id use to find what meshes are impacted by the light.
  10003. * Inactive if 0
  10004. */
  10005. includeOnlyWithLayerMask: number;
  10006. private _lightmapMode;
  10007. /**
  10008. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10009. */
  10010. /**
  10011. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10012. */
  10013. lightmapMode: number;
  10014. /**
  10015. * Shadow generator associted to the light.
  10016. * @hidden Internal use only.
  10017. */
  10018. _shadowGenerator: Nullable<IShadowGenerator>;
  10019. /**
  10020. * @hidden Internal use only.
  10021. */
  10022. _excludedMeshesIds: string[];
  10023. /**
  10024. * @hidden Internal use only.
  10025. */
  10026. _includedOnlyMeshesIds: string[];
  10027. /**
  10028. * The current light unifom buffer.
  10029. * @hidden Internal use only.
  10030. */
  10031. _uniformBuffer: UniformBuffer;
  10032. /**
  10033. * Creates a Light object in the scene.
  10034. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10035. * @param name The firendly name of the light
  10036. * @param scene The scene the light belongs too
  10037. */
  10038. constructor(name: string, scene: Scene);
  10039. protected abstract _buildUniformLayout(): void;
  10040. /**
  10041. * Sets the passed Effect "effect" with the Light information.
  10042. * @param effect The effect to update
  10043. * @param lightIndex The index of the light in the effect to update
  10044. * @returns The light
  10045. */
  10046. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10047. /**
  10048. * Sets the passed Effect "effect" with the Light information.
  10049. * @param effect The effect to update
  10050. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10051. * @returns The light
  10052. */
  10053. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10054. /**
  10055. * Returns the string "Light".
  10056. * @returns the class name
  10057. */
  10058. getClassName(): string;
  10059. /** @hidden */
  10060. readonly _isLight: boolean;
  10061. /**
  10062. * Converts the light information to a readable string for debug purpose.
  10063. * @param fullDetails Supports for multiple levels of logging within scene loading
  10064. * @returns the human readable light info
  10065. */
  10066. toString(fullDetails?: boolean): string;
  10067. /** @hidden */
  10068. protected _syncParentEnabledState(): void;
  10069. /**
  10070. * Set the enabled state of this node.
  10071. * @param value - the new enabled state
  10072. */
  10073. setEnabled(value: boolean): void;
  10074. /**
  10075. * Returns the Light associated shadow generator if any.
  10076. * @return the associated shadow generator.
  10077. */
  10078. getShadowGenerator(): Nullable<IShadowGenerator>;
  10079. /**
  10080. * Returns a Vector3, the absolute light position in the World.
  10081. * @returns the world space position of the light
  10082. */
  10083. getAbsolutePosition(): Vector3;
  10084. /**
  10085. * Specifies if the light will affect the passed mesh.
  10086. * @param mesh The mesh to test against the light
  10087. * @return true the mesh is affected otherwise, false.
  10088. */
  10089. canAffectMesh(mesh: AbstractMesh): boolean;
  10090. /**
  10091. * Sort function to order lights for rendering.
  10092. * @param a First Light object to compare to second.
  10093. * @param b Second Light object to compare first.
  10094. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10095. */
  10096. static CompareLightsPriority(a: Light, b: Light): number;
  10097. /**
  10098. * Releases resources associated with this node.
  10099. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10100. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10101. */
  10102. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10103. /**
  10104. * Returns the light type ID (integer).
  10105. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10106. */
  10107. getTypeID(): number;
  10108. /**
  10109. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10110. * @returns the scaled intensity in intensity mode unit
  10111. */
  10112. getScaledIntensity(): number;
  10113. /**
  10114. * Returns a new Light object, named "name", from the current one.
  10115. * @param name The name of the cloned light
  10116. * @returns the new created light
  10117. */
  10118. clone(name: string): Nullable<Light>;
  10119. /**
  10120. * Serializes the current light into a Serialization object.
  10121. * @returns the serialized object.
  10122. */
  10123. serialize(): any;
  10124. /**
  10125. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10126. * This new light is named "name" and added to the passed scene.
  10127. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10128. * @param name The friendly name of the light
  10129. * @param scene The scene the new light will belong to
  10130. * @returns the constructor function
  10131. */
  10132. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10133. /**
  10134. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10135. * @param parsedLight The JSON representation of the light
  10136. * @param scene The scene to create the parsed light in
  10137. * @returns the created light after parsing
  10138. */
  10139. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10140. private _hookArrayForExcluded;
  10141. private _hookArrayForIncludedOnly;
  10142. private _resyncMeshes;
  10143. /**
  10144. * Forces the meshes to update their light related information in their rendering used effects
  10145. * @hidden Internal Use Only
  10146. */
  10147. _markMeshesAsLightDirty(): void;
  10148. /**
  10149. * Recomputes the cached photometric scale if needed.
  10150. */
  10151. private _computePhotometricScale;
  10152. /**
  10153. * Returns the Photometric Scale according to the light type and intensity mode.
  10154. */
  10155. private _getPhotometricScale;
  10156. /**
  10157. * Reorder the light in the scene according to their defined priority.
  10158. * @hidden Internal Use Only
  10159. */
  10160. _reorderLightsInScene(): void;
  10161. /**
  10162. * Prepares the list of defines specific to the light type.
  10163. * @param defines the list of defines
  10164. * @param lightIndex defines the index of the light for the effect
  10165. */
  10166. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10167. }
  10168. }
  10169. declare module "babylonjs/Actions/action" {
  10170. import { Observable } from "babylonjs/Misc/observable";
  10171. import { Condition } from "babylonjs/Actions/condition";
  10172. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10173. import { ActionManager } from "babylonjs/Actions/actionManager";
  10174. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10175. /**
  10176. * Interface used to define Action
  10177. */
  10178. export interface IAction {
  10179. /**
  10180. * Trigger for the action
  10181. */
  10182. trigger: number;
  10183. /** Options of the trigger */
  10184. triggerOptions: any;
  10185. /**
  10186. * Gets the trigger parameters
  10187. * @returns the trigger parameters
  10188. */
  10189. getTriggerParameter(): any;
  10190. /**
  10191. * Internal only - executes current action event
  10192. * @hidden
  10193. */
  10194. _executeCurrent(evt?: ActionEvent): void;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @param parent of child
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. _prepare(): void;
  10206. /**
  10207. * Internal only - manager for action
  10208. * @hidden
  10209. */
  10210. _actionManager: AbstractActionManager;
  10211. /**
  10212. * Adds action to chain of actions, may be a DoNothingAction
  10213. * @param action defines the next action to execute
  10214. * @returns The action passed in
  10215. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10216. */
  10217. then(action: IAction): IAction;
  10218. }
  10219. /**
  10220. * The action to be carried out following a trigger
  10221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10222. */
  10223. export class Action implements IAction {
  10224. /** the trigger, with or without parameters, for the action */
  10225. triggerOptions: any;
  10226. /**
  10227. * Trigger for the action
  10228. */
  10229. trigger: number;
  10230. /**
  10231. * Internal only - manager for action
  10232. * @hidden
  10233. */
  10234. _actionManager: ActionManager;
  10235. private _nextActiveAction;
  10236. private _child;
  10237. private _condition?;
  10238. private _triggerParameter;
  10239. /**
  10240. * An event triggered prior to action being executed.
  10241. */
  10242. onBeforeExecuteObservable: Observable<Action>;
  10243. /**
  10244. * Creates a new Action
  10245. * @param triggerOptions the trigger, with or without parameters, for the action
  10246. * @param condition an optional determinant of action
  10247. */
  10248. constructor(
  10249. /** the trigger, with or without parameters, for the action */
  10250. triggerOptions: any, condition?: Condition);
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. _prepare(): void;
  10256. /**
  10257. * Gets the trigger parameters
  10258. * @returns the trigger parameters
  10259. */
  10260. getTriggerParameter(): any;
  10261. /**
  10262. * Internal only - executes current action event
  10263. * @hidden
  10264. */
  10265. _executeCurrent(evt?: ActionEvent): void;
  10266. /**
  10267. * Execute placeholder for child classes
  10268. * @param evt optional action event
  10269. */
  10270. execute(evt?: ActionEvent): void;
  10271. /**
  10272. * Skips to next active action
  10273. */
  10274. skipToNextActiveAction(): void;
  10275. /**
  10276. * Adds action to chain of actions, may be a DoNothingAction
  10277. * @param action defines the next action to execute
  10278. * @returns The action passed in
  10279. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10280. */
  10281. then(action: Action): Action;
  10282. /**
  10283. * Internal only
  10284. * @hidden
  10285. */
  10286. _getProperty(propertyPath: string): string;
  10287. /**
  10288. * Internal only
  10289. * @hidden
  10290. */
  10291. _getEffectiveTarget(target: any, propertyPath: string): any;
  10292. /**
  10293. * Serialize placeholder for child classes
  10294. * @param parent of child
  10295. * @returns the serialized object
  10296. */
  10297. serialize(parent: any): any;
  10298. /**
  10299. * Internal only called by serialize
  10300. * @hidden
  10301. */
  10302. protected _serialize(serializedAction: any, parent?: any): any;
  10303. /**
  10304. * Internal only
  10305. * @hidden
  10306. */
  10307. static _SerializeValueAsString: (value: any) => string;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10313. name: string;
  10314. targetType: string;
  10315. value: string;
  10316. };
  10317. }
  10318. }
  10319. declare module "babylonjs/Actions/condition" {
  10320. import { ActionManager } from "babylonjs/Actions/actionManager";
  10321. /**
  10322. * A Condition applied to an Action
  10323. */
  10324. export class Condition {
  10325. /**
  10326. * Internal only - manager for action
  10327. * @hidden
  10328. */
  10329. _actionManager: ActionManager;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. _evaluationId: number;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. _currentResult: boolean;
  10340. /**
  10341. * Creates a new Condition
  10342. * @param actionManager the manager of the action the condition is applied to
  10343. */
  10344. constructor(actionManager: ActionManager);
  10345. /**
  10346. * Check if the current condition is valid
  10347. * @returns a boolean
  10348. */
  10349. isValid(): boolean;
  10350. /**
  10351. * Internal only
  10352. * @hidden
  10353. */
  10354. _getProperty(propertyPath: string): string;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */
  10359. _getEffectiveTarget(target: any, propertyPath: string): any;
  10360. /**
  10361. * Serialize placeholder for child classes
  10362. * @returns the serialized object
  10363. */
  10364. serialize(): any;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */
  10369. protected _serialize(serializedCondition: any): any;
  10370. }
  10371. /**
  10372. * Defines specific conditional operators as extensions of Condition
  10373. */
  10374. export class ValueCondition extends Condition {
  10375. /** path to specify the property of the target the conditional operator uses */
  10376. propertyPath: string;
  10377. /** the value compared by the conditional operator against the current value of the property */
  10378. value: any;
  10379. /** the conditional operator, default ValueCondition.IsEqual */
  10380. operator: number;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. private static _IsEqual;
  10386. /**
  10387. * Internal only
  10388. * @hidden
  10389. */
  10390. private static _IsDifferent;
  10391. /**
  10392. * Internal only
  10393. * @hidden
  10394. */
  10395. private static _IsGreater;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. private static _IsLesser;
  10401. /**
  10402. * returns the number for IsEqual
  10403. */
  10404. static readonly IsEqual: number;
  10405. /**
  10406. * Returns the number for IsDifferent
  10407. */
  10408. static readonly IsDifferent: number;
  10409. /**
  10410. * Returns the number for IsGreater
  10411. */
  10412. static readonly IsGreater: number;
  10413. /**
  10414. * Returns the number for IsLesser
  10415. */
  10416. static readonly IsLesser: number;
  10417. /**
  10418. * Internal only The action manager for the condition
  10419. * @hidden
  10420. */
  10421. _actionManager: ActionManager;
  10422. /**
  10423. * Internal only
  10424. * @hidden
  10425. */
  10426. private _target;
  10427. /**
  10428. * Internal only
  10429. * @hidden
  10430. */
  10431. private _effectiveTarget;
  10432. /**
  10433. * Internal only
  10434. * @hidden
  10435. */
  10436. private _property;
  10437. /**
  10438. * Creates a new ValueCondition
  10439. * @param actionManager manager for the action the condition applies to
  10440. * @param target for the action
  10441. * @param propertyPath path to specify the property of the target the conditional operator uses
  10442. * @param value the value compared by the conditional operator against the current value of the property
  10443. * @param operator the conditional operator, default ValueCondition.IsEqual
  10444. */
  10445. constructor(actionManager: ActionManager, target: any,
  10446. /** path to specify the property of the target the conditional operator uses */
  10447. propertyPath: string,
  10448. /** the value compared by the conditional operator against the current value of the property */
  10449. value: any,
  10450. /** the conditional operator, default ValueCondition.IsEqual */
  10451. operator?: number);
  10452. /**
  10453. * Compares the given value with the property value for the specified conditional operator
  10454. * @returns the result of the comparison
  10455. */
  10456. isValid(): boolean;
  10457. /**
  10458. * Serialize the ValueCondition into a JSON compatible object
  10459. * @returns serialization object
  10460. */
  10461. serialize(): any;
  10462. /**
  10463. * Gets the name of the conditional operator for the ValueCondition
  10464. * @param operator the conditional operator
  10465. * @returns the name
  10466. */
  10467. static GetOperatorName(operator: number): string;
  10468. }
  10469. /**
  10470. * Defines a predicate condition as an extension of Condition
  10471. */
  10472. export class PredicateCondition extends Condition {
  10473. /** defines the predicate function used to validate the condition */
  10474. predicate: () => boolean;
  10475. /**
  10476. * Internal only - manager for action
  10477. * @hidden
  10478. */
  10479. _actionManager: ActionManager;
  10480. /**
  10481. * Creates a new PredicateCondition
  10482. * @param actionManager manager for the action the condition applies to
  10483. * @param predicate defines the predicate function used to validate the condition
  10484. */
  10485. constructor(actionManager: ActionManager,
  10486. /** defines the predicate function used to validate the condition */
  10487. predicate: () => boolean);
  10488. /**
  10489. * @returns the validity of the predicate condition
  10490. */
  10491. isValid(): boolean;
  10492. }
  10493. /**
  10494. * Defines a state condition as an extension of Condition
  10495. */
  10496. export class StateCondition extends Condition {
  10497. /** Value to compare with target state */
  10498. value: string;
  10499. /**
  10500. * Internal only - manager for action
  10501. * @hidden
  10502. */
  10503. _actionManager: ActionManager;
  10504. /**
  10505. * Internal only
  10506. * @hidden
  10507. */
  10508. private _target;
  10509. /**
  10510. * Creates a new StateCondition
  10511. * @param actionManager manager for the action the condition applies to
  10512. * @param target of the condition
  10513. * @param value to compare with target state
  10514. */
  10515. constructor(actionManager: ActionManager, target: any,
  10516. /** Value to compare with target state */
  10517. value: string);
  10518. /**
  10519. * Gets a boolean indicating if the current condition is met
  10520. * @returns the validity of the state
  10521. */
  10522. isValid(): boolean;
  10523. /**
  10524. * Serialize the StateCondition into a JSON compatible object
  10525. * @returns serialization object
  10526. */
  10527. serialize(): any;
  10528. }
  10529. }
  10530. declare module "babylonjs/Actions/directActions" {
  10531. import { Action } from "babylonjs/Actions/action";
  10532. import { Condition } from "babylonjs/Actions/condition";
  10533. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10534. /**
  10535. * This defines an action responsible to toggle a boolean once triggered.
  10536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10537. */
  10538. export class SwitchBooleanAction extends Action {
  10539. /**
  10540. * The path to the boolean property in the target object
  10541. */
  10542. propertyPath: string;
  10543. private _target;
  10544. private _effectiveTarget;
  10545. private _property;
  10546. /**
  10547. * Instantiate the action
  10548. * @param triggerOptions defines the trigger options
  10549. * @param target defines the object containing the boolean
  10550. * @param propertyPath defines the path to the boolean property in the target object
  10551. * @param condition defines the trigger related conditions
  10552. */
  10553. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10554. /** @hidden */
  10555. _prepare(): void;
  10556. /**
  10557. * Execute the action toggle the boolean value.
  10558. */
  10559. execute(): void;
  10560. /**
  10561. * Serializes the actions and its related information.
  10562. * @param parent defines the object to serialize in
  10563. * @returns the serialized object
  10564. */
  10565. serialize(parent: any): any;
  10566. }
  10567. /**
  10568. * This defines an action responsible to set a the state field of the target
  10569. * to a desired value once triggered.
  10570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10571. */
  10572. export class SetStateAction extends Action {
  10573. /**
  10574. * The value to store in the state field.
  10575. */
  10576. value: string;
  10577. private _target;
  10578. /**
  10579. * Instantiate the action
  10580. * @param triggerOptions defines the trigger options
  10581. * @param target defines the object containing the state property
  10582. * @param value defines the value to store in the state field
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10586. /**
  10587. * Execute the action and store the value on the target state property.
  10588. */
  10589. execute(): void;
  10590. /**
  10591. * Serializes the actions and its related information.
  10592. * @param parent defines the object to serialize in
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. }
  10597. /**
  10598. * This defines an action responsible to set a property of the target
  10599. * to a desired value once triggered.
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10601. */
  10602. export class SetValueAction extends Action {
  10603. /**
  10604. * The path of the property to set in the target.
  10605. */
  10606. propertyPath: string;
  10607. /**
  10608. * The value to set in the property
  10609. */
  10610. value: any;
  10611. private _target;
  10612. private _effectiveTarget;
  10613. private _property;
  10614. /**
  10615. * Instantiate the action
  10616. * @param triggerOptions defines the trigger options
  10617. * @param target defines the object containing the property
  10618. * @param propertyPath defines the path of the property to set in the target
  10619. * @param value defines the value to set in the property
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action and set the targetted property to the desired value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to increment the target value
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class IncrementValueAction extends Action {
  10642. /**
  10643. * The path of the property to increment in the target.
  10644. */
  10645. propertyPath: string;
  10646. /**
  10647. * The value we should increment the property by.
  10648. */
  10649. value: any;
  10650. private _target;
  10651. private _effectiveTarget;
  10652. private _property;
  10653. /**
  10654. * Instantiate the action
  10655. * @param triggerOptions defines the trigger options
  10656. * @param target defines the object containing the property
  10657. * @param propertyPath defines the path of the property to increment in the target
  10658. * @param value defines the value value we should increment the property by
  10659. * @param condition defines the trigger related conditions
  10660. */
  10661. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10662. /** @hidden */
  10663. _prepare(): void;
  10664. /**
  10665. * Execute the action and increment the target of the value amount.
  10666. */
  10667. execute(): void;
  10668. /**
  10669. * Serializes the actions and its related information.
  10670. * @param parent defines the object to serialize in
  10671. * @returns the serialized object
  10672. */
  10673. serialize(parent: any): any;
  10674. }
  10675. /**
  10676. * This defines an action responsible to start an animation once triggered.
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10678. */
  10679. export class PlayAnimationAction extends Action {
  10680. /**
  10681. * Where the animation should start (animation frame)
  10682. */
  10683. from: number;
  10684. /**
  10685. * Where the animation should stop (animation frame)
  10686. */
  10687. to: number;
  10688. /**
  10689. * Define if the animation should loop or stop after the first play.
  10690. */
  10691. loop?: boolean;
  10692. private _target;
  10693. /**
  10694. * Instantiate the action
  10695. * @param triggerOptions defines the trigger options
  10696. * @param target defines the target animation or animation name
  10697. * @param from defines from where the animation should start (animation frame)
  10698. * @param end defines where the animation should stop (animation frame)
  10699. * @param loop defines if the animation should loop or stop after the first play
  10700. * @param condition defines the trigger related conditions
  10701. */
  10702. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10703. /** @hidden */
  10704. _prepare(): void;
  10705. /**
  10706. * Execute the action and play the animation.
  10707. */
  10708. execute(): void;
  10709. /**
  10710. * Serializes the actions and its related information.
  10711. * @param parent defines the object to serialize in
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. }
  10716. /**
  10717. * This defines an action responsible to stop an animation once triggered.
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10719. */
  10720. export class StopAnimationAction extends Action {
  10721. private _target;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the target animation or animation name
  10726. * @param condition defines the trigger related conditions
  10727. */
  10728. constructor(triggerOptions: any, target: any, condition?: Condition);
  10729. /** @hidden */
  10730. _prepare(): void;
  10731. /**
  10732. * Execute the action and stop the animation.
  10733. */
  10734. execute(): void;
  10735. /**
  10736. * Serializes the actions and its related information.
  10737. * @param parent defines the object to serialize in
  10738. * @returns the serialized object
  10739. */
  10740. serialize(parent: any): any;
  10741. }
  10742. /**
  10743. * This defines an action responsible that does nothing once triggered.
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10745. */
  10746. export class DoNothingAction extends Action {
  10747. /**
  10748. * Instantiate the action
  10749. * @param triggerOptions defines the trigger options
  10750. * @param condition defines the trigger related conditions
  10751. */
  10752. constructor(triggerOptions?: any, condition?: Condition);
  10753. /**
  10754. * Execute the action and do nothing.
  10755. */
  10756. execute(): void;
  10757. /**
  10758. * Serializes the actions and its related information.
  10759. * @param parent defines the object to serialize in
  10760. * @returns the serialized object
  10761. */
  10762. serialize(parent: any): any;
  10763. }
  10764. /**
  10765. * This defines an action responsible to trigger several actions once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class CombineAction extends Action {
  10769. /**
  10770. * The list of aggregated animations to run.
  10771. */
  10772. children: Action[];
  10773. /**
  10774. * Instantiate the action
  10775. * @param triggerOptions defines the trigger options
  10776. * @param children defines the list of aggregated animations to run
  10777. * @param condition defines the trigger related conditions
  10778. */
  10779. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10780. /** @hidden */
  10781. _prepare(): void;
  10782. /**
  10783. * Execute the action and executes all the aggregated actions.
  10784. */
  10785. execute(evt: ActionEvent): void;
  10786. /**
  10787. * Serializes the actions and its related information.
  10788. * @param parent defines the object to serialize in
  10789. * @returns the serialized object
  10790. */
  10791. serialize(parent: any): any;
  10792. }
  10793. /**
  10794. * This defines an action responsible to run code (external event) once triggered.
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10796. */
  10797. export class ExecuteCodeAction extends Action {
  10798. /**
  10799. * The callback function to run.
  10800. */
  10801. func: (evt: ActionEvent) => void;
  10802. /**
  10803. * Instantiate the action
  10804. * @param triggerOptions defines the trigger options
  10805. * @param func defines the callback function to run
  10806. * @param condition defines the trigger related conditions
  10807. */
  10808. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10809. /**
  10810. * Execute the action and run the attached code.
  10811. */
  10812. execute(evt: ActionEvent): void;
  10813. }
  10814. /**
  10815. * This defines an action responsible to set the parent property of the target once triggered.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class SetParentAction extends Action {
  10819. private _parent;
  10820. private _target;
  10821. /**
  10822. * Instantiate the action
  10823. * @param triggerOptions defines the trigger options
  10824. * @param target defines the target containing the parent property
  10825. * @param parent defines from where the animation should start (animation frame)
  10826. * @param condition defines the trigger related conditions
  10827. */
  10828. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10829. /** @hidden */
  10830. _prepare(): void;
  10831. /**
  10832. * Execute the action and set the parent property.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. }
  10843. declare module "babylonjs/Actions/actionManager" {
  10844. import { Nullable } from "babylonjs/types";
  10845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10846. import { Scene } from "babylonjs/scene";
  10847. import { IAction } from "babylonjs/Actions/action";
  10848. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10849. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10850. /**
  10851. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10852. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10854. */
  10855. export class ActionManager extends AbstractActionManager {
  10856. /**
  10857. * Nothing
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly NothingTrigger: number;
  10861. /**
  10862. * On pick
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnPickTrigger: number;
  10866. /**
  10867. * On left pick
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnLeftPickTrigger: number;
  10871. /**
  10872. * On right pick
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnRightPickTrigger: number;
  10876. /**
  10877. * On center pick
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnCenterPickTrigger: number;
  10881. /**
  10882. * On pick down
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnPickDownTrigger: number;
  10886. /**
  10887. * On double pick
  10888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10889. */
  10890. static readonly OnDoublePickTrigger: number;
  10891. /**
  10892. * On pick up
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickUpTrigger: number;
  10896. /**
  10897. * On pick out.
  10898. * This trigger will only be raised if you also declared a OnPickDown
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnPickOutTrigger: number;
  10902. /**
  10903. * On long press
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnLongPressTrigger: number;
  10907. /**
  10908. * On pointer over
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnPointerOverTrigger: number;
  10912. /**
  10913. * On pointer out
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnPointerOutTrigger: number;
  10917. /**
  10918. * On every frame
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10920. */
  10921. static readonly OnEveryFrameTrigger: number;
  10922. /**
  10923. * On intersection enter
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnIntersectionEnterTrigger: number;
  10927. /**
  10928. * On intersection exit
  10929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10930. */
  10931. static readonly OnIntersectionExitTrigger: number;
  10932. /**
  10933. * On key down
  10934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10935. */
  10936. static readonly OnKeyDownTrigger: number;
  10937. /**
  10938. * On key up
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10940. */
  10941. static readonly OnKeyUpTrigger: number;
  10942. private _scene;
  10943. /**
  10944. * Creates a new action manager
  10945. * @param scene defines the hosting scene
  10946. */
  10947. constructor(scene: Scene);
  10948. /**
  10949. * Releases all associated resources
  10950. */
  10951. dispose(): void;
  10952. /**
  10953. * Gets hosting scene
  10954. * @returns the hosting scene
  10955. */
  10956. getScene(): Scene;
  10957. /**
  10958. * Does this action manager handles actions of any of the given triggers
  10959. * @param triggers defines the triggers to be tested
  10960. * @return a boolean indicating whether one (or more) of the triggers is handled
  10961. */
  10962. hasSpecificTriggers(triggers: number[]): boolean;
  10963. /**
  10964. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10965. * speed.
  10966. * @param triggerA defines the trigger to be tested
  10967. * @param triggerB defines the trigger to be tested
  10968. * @return a boolean indicating whether one (or more) of the triggers is handled
  10969. */
  10970. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10971. /**
  10972. * Does this action manager handles actions of a given trigger
  10973. * @param trigger defines the trigger to be tested
  10974. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10975. * @return whether the trigger is handled
  10976. */
  10977. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10978. /**
  10979. * Does this action manager has pointer triggers
  10980. */
  10981. readonly hasPointerTriggers: boolean;
  10982. /**
  10983. * Does this action manager has pick triggers
  10984. */
  10985. readonly hasPickTriggers: boolean;
  10986. /**
  10987. * Registers an action to this action manager
  10988. * @param action defines the action to be registered
  10989. * @return the action amended (prepared) after registration
  10990. */
  10991. registerAction(action: IAction): Nullable<IAction>;
  10992. /**
  10993. * Unregisters an action to this action manager
  10994. * @param action defines the action to be unregistered
  10995. * @return a boolean indicating whether the action has been unregistered
  10996. */
  10997. unregisterAction(action: IAction): Boolean;
  10998. /**
  10999. * Process a specific trigger
  11000. * @param trigger defines the trigger to process
  11001. * @param evt defines the event details to be processed
  11002. */
  11003. processTrigger(trigger: number, evt?: IActionEvent): void;
  11004. /** @hidden */
  11005. _getEffectiveTarget(target: any, propertyPath: string): any;
  11006. /** @hidden */
  11007. _getProperty(propertyPath: string): string;
  11008. /**
  11009. * Serialize this manager to a JSON object
  11010. * @param name defines the property name to store this manager
  11011. * @returns a JSON representation of this manager
  11012. */
  11013. serialize(name: string): any;
  11014. /**
  11015. * Creates a new ActionManager from a JSON data
  11016. * @param parsedActions defines the JSON data to read from
  11017. * @param object defines the hosting mesh
  11018. * @param scene defines the hosting scene
  11019. */
  11020. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11021. /**
  11022. * Get a trigger name by index
  11023. * @param trigger defines the trigger index
  11024. * @returns a trigger name
  11025. */
  11026. static GetTriggerName(trigger: number): string;
  11027. }
  11028. }
  11029. declare module "babylonjs/Culling/ray" {
  11030. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11031. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11033. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11034. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11035. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11037. import { Plane } from "babylonjs/Maths/math.plane";
  11038. /**
  11039. * Class representing a ray with position and direction
  11040. */
  11041. export class Ray {
  11042. /** origin point */
  11043. origin: Vector3;
  11044. /** direction */
  11045. direction: Vector3;
  11046. /** length of the ray */
  11047. length: number;
  11048. private static readonly TmpVector3;
  11049. private _tmpRay;
  11050. /**
  11051. * Creates a new ray
  11052. * @param origin origin point
  11053. * @param direction direction
  11054. * @param length length of the ray
  11055. */
  11056. constructor(
  11057. /** origin point */
  11058. origin: Vector3,
  11059. /** direction */
  11060. direction: Vector3,
  11061. /** length of the ray */
  11062. length?: number);
  11063. /**
  11064. * Checks if the ray intersects a box
  11065. * @param minimum bound of the box
  11066. * @param maximum bound of the box
  11067. * @param intersectionTreshold extra extend to be added to the box in all direction
  11068. * @returns if the box was hit
  11069. */
  11070. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11071. /**
  11072. * Checks if the ray intersects a box
  11073. * @param box the bounding box to check
  11074. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11075. * @returns if the box was hit
  11076. */
  11077. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11078. /**
  11079. * If the ray hits a sphere
  11080. * @param sphere the bounding sphere to check
  11081. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11082. * @returns true if it hits the sphere
  11083. */
  11084. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11085. /**
  11086. * If the ray hits a triange
  11087. * @param vertex0 triangle vertex
  11088. * @param vertex1 triangle vertex
  11089. * @param vertex2 triangle vertex
  11090. * @returns intersection information if hit
  11091. */
  11092. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11093. /**
  11094. * Checks if ray intersects a plane
  11095. * @param plane the plane to check
  11096. * @returns the distance away it was hit
  11097. */
  11098. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11099. /**
  11100. * Calculate the intercept of a ray on a given axis
  11101. * @param axis to check 'x' | 'y' | 'z'
  11102. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11103. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11104. */
  11105. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11106. /**
  11107. * Checks if ray intersects a mesh
  11108. * @param mesh the mesh to check
  11109. * @param fastCheck if only the bounding box should checked
  11110. * @returns picking info of the intersecton
  11111. */
  11112. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11113. /**
  11114. * Checks if ray intersects a mesh
  11115. * @param meshes the meshes to check
  11116. * @param fastCheck if only the bounding box should checked
  11117. * @param results array to store result in
  11118. * @returns Array of picking infos
  11119. */
  11120. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11121. private _comparePickingInfo;
  11122. private static smallnum;
  11123. private static rayl;
  11124. /**
  11125. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11126. * @param sega the first point of the segment to test the intersection against
  11127. * @param segb the second point of the segment to test the intersection against
  11128. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11129. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11130. */
  11131. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11132. /**
  11133. * Update the ray from viewport position
  11134. * @param x position
  11135. * @param y y position
  11136. * @param viewportWidth viewport width
  11137. * @param viewportHeight viewport height
  11138. * @param world world matrix
  11139. * @param view view matrix
  11140. * @param projection projection matrix
  11141. * @returns this ray updated
  11142. */
  11143. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11144. /**
  11145. * Creates a ray with origin and direction of 0,0,0
  11146. * @returns the new ray
  11147. */
  11148. static Zero(): Ray;
  11149. /**
  11150. * Creates a new ray from screen space and viewport
  11151. * @param x position
  11152. * @param y y position
  11153. * @param viewportWidth viewport width
  11154. * @param viewportHeight viewport height
  11155. * @param world world matrix
  11156. * @param view view matrix
  11157. * @param projection projection matrix
  11158. * @returns new ray
  11159. */
  11160. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11161. /**
  11162. * 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
  11163. * transformed to the given world matrix.
  11164. * @param origin The origin point
  11165. * @param end The end point
  11166. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11167. * @returns the new ray
  11168. */
  11169. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11170. /**
  11171. * Transforms a ray by a matrix
  11172. * @param ray ray to transform
  11173. * @param matrix matrix to apply
  11174. * @returns the resulting new ray
  11175. */
  11176. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11177. /**
  11178. * Transforms a ray by a matrix
  11179. * @param ray ray to transform
  11180. * @param matrix matrix to apply
  11181. * @param result ray to store result in
  11182. */
  11183. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11184. /**
  11185. * Unproject a ray from screen space to object space
  11186. * @param sourceX defines the screen space x coordinate to use
  11187. * @param sourceY defines the screen space y coordinate to use
  11188. * @param viewportWidth defines the current width of the viewport
  11189. * @param viewportHeight defines the current height of the viewport
  11190. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11191. * @param view defines the view matrix to use
  11192. * @param projection defines the projection matrix to use
  11193. */
  11194. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11195. }
  11196. /**
  11197. * Type used to define predicate used to select faces when a mesh intersection is detected
  11198. */
  11199. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11200. module "babylonjs/scene" {
  11201. interface Scene {
  11202. /** @hidden */
  11203. _tempPickingRay: Nullable<Ray>;
  11204. /** @hidden */
  11205. _cachedRayForTransform: Ray;
  11206. /** @hidden */
  11207. _pickWithRayInverseMatrix: Matrix;
  11208. /** @hidden */
  11209. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11210. /** @hidden */
  11211. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11212. }
  11213. }
  11214. }
  11215. declare module "babylonjs/sceneComponent" {
  11216. import { Scene } from "babylonjs/scene";
  11217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11218. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11219. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11220. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11221. import { Nullable } from "babylonjs/types";
  11222. import { Camera } from "babylonjs/Cameras/camera";
  11223. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11224. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11225. import { AbstractScene } from "babylonjs/abstractScene";
  11226. /**
  11227. * Groups all the scene component constants in one place to ease maintenance.
  11228. * @hidden
  11229. */
  11230. export class SceneComponentConstants {
  11231. static readonly NAME_EFFECTLAYER: string;
  11232. static readonly NAME_LAYER: string;
  11233. static readonly NAME_LENSFLARESYSTEM: string;
  11234. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11235. static readonly NAME_PARTICLESYSTEM: string;
  11236. static readonly NAME_GAMEPAD: string;
  11237. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11238. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11239. static readonly NAME_DEPTHRENDERER: string;
  11240. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11241. static readonly NAME_SPRITE: string;
  11242. static readonly NAME_OUTLINERENDERER: string;
  11243. static readonly NAME_PROCEDURALTEXTURE: string;
  11244. static readonly NAME_SHADOWGENERATOR: string;
  11245. static readonly NAME_OCTREE: string;
  11246. static readonly NAME_PHYSICSENGINE: string;
  11247. static readonly NAME_AUDIO: string;
  11248. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11249. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11250. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11251. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11252. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11253. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11254. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11255. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11256. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11257. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11258. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11259. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11260. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11261. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11262. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11263. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11264. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11265. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11267. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11268. static readonly STEP_AFTERRENDER_AUDIO: number;
  11269. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11270. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11272. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11273. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11274. static readonly STEP_POINTERMOVE_SPRITE: number;
  11275. static readonly STEP_POINTERDOWN_SPRITE: number;
  11276. static readonly STEP_POINTERUP_SPRITE: number;
  11277. }
  11278. /**
  11279. * This represents a scene component.
  11280. *
  11281. * This is used to decouple the dependency the scene is having on the different workloads like
  11282. * layers, post processes...
  11283. */
  11284. export interface ISceneComponent {
  11285. /**
  11286. * The name of the component. Each component must have a unique name.
  11287. */
  11288. name: string;
  11289. /**
  11290. * The scene the component belongs to.
  11291. */
  11292. scene: Scene;
  11293. /**
  11294. * Register the component to one instance of a scene.
  11295. */
  11296. register(): void;
  11297. /**
  11298. * Rebuilds the elements related to this component in case of
  11299. * context lost for instance.
  11300. */
  11301. rebuild(): void;
  11302. /**
  11303. * Disposes the component and the associated ressources.
  11304. */
  11305. dispose(): void;
  11306. }
  11307. /**
  11308. * This represents a SERIALIZABLE scene component.
  11309. *
  11310. * This extends Scene Component to add Serialization methods on top.
  11311. */
  11312. export interface ISceneSerializableComponent extends ISceneComponent {
  11313. /**
  11314. * Adds all the elements from the container to the scene
  11315. * @param container the container holding the elements
  11316. */
  11317. addFromContainer(container: AbstractScene): void;
  11318. /**
  11319. * Removes all the elements in the container from the scene
  11320. * @param container contains the elements to remove
  11321. * @param dispose if the removed element should be disposed (default: false)
  11322. */
  11323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11324. /**
  11325. * Serializes the component data to the specified json object
  11326. * @param serializationObject The object to serialize to
  11327. */
  11328. serialize(serializationObject: any): void;
  11329. }
  11330. /**
  11331. * Strong typing of a Mesh related stage step action
  11332. */
  11333. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11334. /**
  11335. * Strong typing of a Evaluate Sub Mesh related stage step action
  11336. */
  11337. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11338. /**
  11339. * Strong typing of a Active Mesh related stage step action
  11340. */
  11341. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11342. /**
  11343. * Strong typing of a Camera related stage step action
  11344. */
  11345. export type CameraStageAction = (camera: Camera) => void;
  11346. /**
  11347. * Strong typing of a Camera Frame buffer related stage step action
  11348. */
  11349. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11350. /**
  11351. * Strong typing of a Render Target related stage step action
  11352. */
  11353. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11354. /**
  11355. * Strong typing of a RenderingGroup related stage step action
  11356. */
  11357. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11358. /**
  11359. * Strong typing of a Mesh Render related stage step action
  11360. */
  11361. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11362. /**
  11363. * Strong typing of a simple stage step action
  11364. */
  11365. export type SimpleStageAction = () => void;
  11366. /**
  11367. * Strong typing of a render target action.
  11368. */
  11369. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11370. /**
  11371. * Strong typing of a pointer move action.
  11372. */
  11373. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11374. /**
  11375. * Strong typing of a pointer up/down action.
  11376. */
  11377. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11378. /**
  11379. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11380. * @hidden
  11381. */
  11382. export class Stage<T extends Function> extends Array<{
  11383. index: number;
  11384. component: ISceneComponent;
  11385. action: T;
  11386. }> {
  11387. /**
  11388. * Hide ctor from the rest of the world.
  11389. * @param items The items to add.
  11390. */
  11391. private constructor();
  11392. /**
  11393. * Creates a new Stage.
  11394. * @returns A new instance of a Stage
  11395. */
  11396. static Create<T extends Function>(): Stage<T>;
  11397. /**
  11398. * Registers a step in an ordered way in the targeted stage.
  11399. * @param index Defines the position to register the step in
  11400. * @param component Defines the component attached to the step
  11401. * @param action Defines the action to launch during the step
  11402. */
  11403. registerStep(index: number, component: ISceneComponent, action: T): void;
  11404. /**
  11405. * Clears all the steps from the stage.
  11406. */
  11407. clear(): void;
  11408. }
  11409. }
  11410. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11411. import { Nullable } from "babylonjs/types";
  11412. import { Observable } from "babylonjs/Misc/observable";
  11413. import { Scene } from "babylonjs/scene";
  11414. import { Sprite } from "babylonjs/Sprites/sprite";
  11415. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11416. import { Ray } from "babylonjs/Culling/ray";
  11417. import { Camera } from "babylonjs/Cameras/camera";
  11418. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11419. import { ISceneComponent } from "babylonjs/sceneComponent";
  11420. module "babylonjs/scene" {
  11421. interface Scene {
  11422. /** @hidden */
  11423. _pointerOverSprite: Nullable<Sprite>;
  11424. /** @hidden */
  11425. _pickedDownSprite: Nullable<Sprite>;
  11426. /** @hidden */
  11427. _tempSpritePickingRay: Nullable<Ray>;
  11428. /**
  11429. * All of the sprite managers added to this scene
  11430. * @see http://doc.babylonjs.com/babylon101/sprites
  11431. */
  11432. spriteManagers: Array<ISpriteManager>;
  11433. /**
  11434. * An event triggered when sprites rendering is about to start
  11435. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11436. */
  11437. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11438. /**
  11439. * An event triggered when sprites rendering is done
  11440. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11441. */
  11442. onAfterSpritesRenderingObservable: Observable<Scene>;
  11443. /** @hidden */
  11444. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11445. /** Launch a ray to try to pick a sprite in the scene
  11446. * @param x position on screen
  11447. * @param y position on screen
  11448. * @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
  11449. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11450. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11451. * @returns a PickingInfo
  11452. */
  11453. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11454. /** Use the given ray to pick a sprite in the scene
  11455. * @param ray The ray (in world space) to use to pick meshes
  11456. * @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
  11457. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11458. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11459. * @returns a PickingInfo
  11460. */
  11461. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11462. /** @hidden */
  11463. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11464. /** Launch a ray to try to pick sprites in the scene
  11465. * @param x position on screen
  11466. * @param y position on screen
  11467. * @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
  11468. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11469. * @returns a PickingInfo array
  11470. */
  11471. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11472. /** Use the given ray to pick sprites in the scene
  11473. * @param ray The ray (in world space) to use to pick meshes
  11474. * @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
  11475. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11476. * @returns a PickingInfo array
  11477. */
  11478. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11479. /**
  11480. * Force the sprite under the pointer
  11481. * @param sprite defines the sprite to use
  11482. */
  11483. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11484. /**
  11485. * Gets the sprite under the pointer
  11486. * @returns a Sprite or null if no sprite is under the pointer
  11487. */
  11488. getPointerOverSprite(): Nullable<Sprite>;
  11489. }
  11490. }
  11491. /**
  11492. * Defines the sprite scene component responsible to manage sprites
  11493. * in a given scene.
  11494. */
  11495. export class SpriteSceneComponent implements ISceneComponent {
  11496. /**
  11497. * The component name helpfull to identify the component in the list of scene components.
  11498. */
  11499. readonly name: string;
  11500. /**
  11501. * The scene the component belongs to.
  11502. */
  11503. scene: Scene;
  11504. /** @hidden */
  11505. private _spritePredicate;
  11506. /**
  11507. * Creates a new instance of the component for the given scene
  11508. * @param scene Defines the scene to register the component in
  11509. */
  11510. constructor(scene: Scene);
  11511. /**
  11512. * Registers the component in a given scene
  11513. */
  11514. register(): void;
  11515. /**
  11516. * Rebuilds the elements related to this component in case of
  11517. * context lost for instance.
  11518. */
  11519. rebuild(): void;
  11520. /**
  11521. * Disposes the component and the associated ressources.
  11522. */
  11523. dispose(): void;
  11524. private _pickSpriteButKeepRay;
  11525. private _pointerMove;
  11526. private _pointerDown;
  11527. private _pointerUp;
  11528. }
  11529. }
  11530. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11531. /** @hidden */
  11532. export var fogFragmentDeclaration: {
  11533. name: string;
  11534. shader: string;
  11535. };
  11536. }
  11537. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11538. /** @hidden */
  11539. export var fogFragment: {
  11540. name: string;
  11541. shader: string;
  11542. };
  11543. }
  11544. declare module "babylonjs/Shaders/sprites.fragment" {
  11545. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11546. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11547. /** @hidden */
  11548. export var spritesPixelShader: {
  11549. name: string;
  11550. shader: string;
  11551. };
  11552. }
  11553. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11554. /** @hidden */
  11555. export var fogVertexDeclaration: {
  11556. name: string;
  11557. shader: string;
  11558. };
  11559. }
  11560. declare module "babylonjs/Shaders/sprites.vertex" {
  11561. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11562. /** @hidden */
  11563. export var spritesVertexShader: {
  11564. name: string;
  11565. shader: string;
  11566. };
  11567. }
  11568. declare module "babylonjs/Sprites/spriteManager" {
  11569. import { IDisposable, Scene } from "babylonjs/scene";
  11570. import { Nullable } from "babylonjs/types";
  11571. import { Observable } from "babylonjs/Misc/observable";
  11572. import { Sprite } from "babylonjs/Sprites/sprite";
  11573. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11574. import { Camera } from "babylonjs/Cameras/camera";
  11575. import { Texture } from "babylonjs/Materials/Textures/texture";
  11576. import "babylonjs/Shaders/sprites.fragment";
  11577. import "babylonjs/Shaders/sprites.vertex";
  11578. import { Ray } from "babylonjs/Culling/ray";
  11579. /**
  11580. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11581. */
  11582. export interface ISpriteManager extends IDisposable {
  11583. /**
  11584. * Restricts the camera to viewing objects with the same layerMask.
  11585. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11586. */
  11587. layerMask: number;
  11588. /**
  11589. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11590. */
  11591. isPickable: boolean;
  11592. /**
  11593. * Specifies the rendering group id for this mesh (0 by default)
  11594. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11595. */
  11596. renderingGroupId: number;
  11597. /**
  11598. * Defines the list of sprites managed by the manager.
  11599. */
  11600. sprites: Array<Sprite>;
  11601. /**
  11602. * Tests the intersection of a sprite with a specific ray.
  11603. * @param ray The ray we are sending to test the collision
  11604. * @param camera The camera space we are sending rays in
  11605. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11606. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11607. * @returns picking info or null.
  11608. */
  11609. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11610. /**
  11611. * Intersects the sprites with a ray
  11612. * @param ray defines the ray to intersect with
  11613. * @param camera defines the current active camera
  11614. * @param predicate defines a predicate used to select candidate sprites
  11615. * @returns null if no hit or a PickingInfo array
  11616. */
  11617. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11618. /**
  11619. * Renders the list of sprites on screen.
  11620. */
  11621. render(): void;
  11622. }
  11623. /**
  11624. * Class used to manage multiple sprites on the same spritesheet
  11625. * @see http://doc.babylonjs.com/babylon101/sprites
  11626. */
  11627. export class SpriteManager implements ISpriteManager {
  11628. /** defines the manager's name */
  11629. name: string;
  11630. /** Gets the list of sprites */
  11631. sprites: Sprite[];
  11632. /** Gets or sets the rendering group id (0 by default) */
  11633. renderingGroupId: number;
  11634. /** Gets or sets camera layer mask */
  11635. layerMask: number;
  11636. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11637. fogEnabled: boolean;
  11638. /** Gets or sets a boolean indicating if the sprites are pickable */
  11639. isPickable: boolean;
  11640. /** Defines the default width of a cell in the spritesheet */
  11641. cellWidth: number;
  11642. /** Defines the default height of a cell in the spritesheet */
  11643. cellHeight: number;
  11644. /** Associative array from JSON sprite data file */
  11645. private _cellData;
  11646. /** Array of sprite names from JSON sprite data file */
  11647. private _spriteMap;
  11648. /** True when packed cell data from JSON file is ready*/
  11649. private _packedAndReady;
  11650. /**
  11651. * An event triggered when the manager is disposed.
  11652. */
  11653. onDisposeObservable: Observable<SpriteManager>;
  11654. private _onDisposeObserver;
  11655. /**
  11656. * Callback called when the manager is disposed
  11657. */
  11658. onDispose: () => void;
  11659. private _capacity;
  11660. private _fromPacked;
  11661. private _spriteTexture;
  11662. private _epsilon;
  11663. private _scene;
  11664. private _vertexData;
  11665. private _buffer;
  11666. private _vertexBuffers;
  11667. private _indexBuffer;
  11668. private _effectBase;
  11669. private _effectFog;
  11670. /**
  11671. * Gets or sets the spritesheet texture
  11672. */
  11673. texture: Texture;
  11674. /**
  11675. * Creates a new sprite manager
  11676. * @param name defines the manager's name
  11677. * @param imgUrl defines the sprite sheet url
  11678. * @param capacity defines the maximum allowed number of sprites
  11679. * @param cellSize defines the size of a sprite cell
  11680. * @param scene defines the hosting scene
  11681. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11682. * @param samplingMode defines the smapling mode to use with spritesheet
  11683. * @param fromPacked set to false; do not alter
  11684. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11685. */
  11686. constructor(
  11687. /** defines the manager's name */
  11688. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11689. private _makePacked;
  11690. private _appendSpriteVertex;
  11691. /**
  11692. * Intersects the sprites with a ray
  11693. * @param ray defines the ray to intersect with
  11694. * @param camera defines the current active camera
  11695. * @param predicate defines a predicate used to select candidate sprites
  11696. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11697. * @returns null if no hit or a PickingInfo
  11698. */
  11699. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11700. /**
  11701. * Intersects the sprites with a ray
  11702. * @param ray defines the ray to intersect with
  11703. * @param camera defines the current active camera
  11704. * @param predicate defines a predicate used to select candidate sprites
  11705. * @returns null if no hit or a PickingInfo array
  11706. */
  11707. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11708. /**
  11709. * Render all child sprites
  11710. */
  11711. render(): void;
  11712. /**
  11713. * Release associated resources
  11714. */
  11715. dispose(): void;
  11716. }
  11717. }
  11718. declare module "babylonjs/Sprites/sprite" {
  11719. import { Vector3 } from "babylonjs/Maths/math.vector";
  11720. import { Nullable } from "babylonjs/types";
  11721. import { ActionManager } from "babylonjs/Actions/actionManager";
  11722. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11723. import { Color4 } from "babylonjs/Maths/math.color";
  11724. /**
  11725. * Class used to represent a sprite
  11726. * @see http://doc.babylonjs.com/babylon101/sprites
  11727. */
  11728. export class Sprite {
  11729. /** defines the name */
  11730. name: string;
  11731. /** Gets or sets the current world position */
  11732. position: Vector3;
  11733. /** Gets or sets the main color */
  11734. color: Color4;
  11735. /** Gets or sets the width */
  11736. width: number;
  11737. /** Gets or sets the height */
  11738. height: number;
  11739. /** Gets or sets rotation angle */
  11740. angle: number;
  11741. /** Gets or sets the cell index in the sprite sheet */
  11742. cellIndex: number;
  11743. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11744. cellRef: string;
  11745. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11746. invertU: number;
  11747. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11748. invertV: number;
  11749. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11750. disposeWhenFinishedAnimating: boolean;
  11751. /** Gets the list of attached animations */
  11752. animations: Animation[];
  11753. /** Gets or sets a boolean indicating if the sprite can be picked */
  11754. isPickable: boolean;
  11755. /**
  11756. * Gets or sets the associated action manager
  11757. */
  11758. actionManager: Nullable<ActionManager>;
  11759. private _animationStarted;
  11760. private _loopAnimation;
  11761. private _fromIndex;
  11762. private _toIndex;
  11763. private _delay;
  11764. private _direction;
  11765. private _manager;
  11766. private _time;
  11767. private _onAnimationEnd;
  11768. /**
  11769. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11770. */
  11771. isVisible: boolean;
  11772. /**
  11773. * Gets or sets the sprite size
  11774. */
  11775. size: number;
  11776. /**
  11777. * Creates a new Sprite
  11778. * @param name defines the name
  11779. * @param manager defines the manager
  11780. */
  11781. constructor(
  11782. /** defines the name */
  11783. name: string, manager: ISpriteManager);
  11784. /**
  11785. * Starts an animation
  11786. * @param from defines the initial key
  11787. * @param to defines the end key
  11788. * @param loop defines if the animation must loop
  11789. * @param delay defines the start delay (in ms)
  11790. * @param onAnimationEnd defines a callback to call when animation ends
  11791. */
  11792. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11793. /** Stops current animation (if any) */
  11794. stopAnimation(): void;
  11795. /** @hidden */
  11796. _animate(deltaTime: number): void;
  11797. /** Release associated resources */
  11798. dispose(): void;
  11799. }
  11800. }
  11801. declare module "babylonjs/Collisions/pickingInfo" {
  11802. import { Nullable } from "babylonjs/types";
  11803. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11805. import { Sprite } from "babylonjs/Sprites/sprite";
  11806. import { Ray } from "babylonjs/Culling/ray";
  11807. /**
  11808. * Information about the result of picking within a scene
  11809. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11810. */
  11811. export class PickingInfo {
  11812. /** @hidden */
  11813. _pickingUnavailable: boolean;
  11814. /**
  11815. * If the pick collided with an object
  11816. */
  11817. hit: boolean;
  11818. /**
  11819. * Distance away where the pick collided
  11820. */
  11821. distance: number;
  11822. /**
  11823. * The location of pick collision
  11824. */
  11825. pickedPoint: Nullable<Vector3>;
  11826. /**
  11827. * The mesh corresponding the the pick collision
  11828. */
  11829. pickedMesh: Nullable<AbstractMesh>;
  11830. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11831. bu: number;
  11832. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11833. bv: number;
  11834. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11835. faceId: number;
  11836. /** Id of the the submesh that was picked */
  11837. subMeshId: number;
  11838. /** If a sprite was picked, this will be the sprite the pick collided with */
  11839. pickedSprite: Nullable<Sprite>;
  11840. /**
  11841. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11842. */
  11843. originMesh: Nullable<AbstractMesh>;
  11844. /**
  11845. * The ray that was used to perform the picking.
  11846. */
  11847. ray: Nullable<Ray>;
  11848. /**
  11849. * Gets the normal correspodning to the face the pick collided with
  11850. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11851. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11852. * @returns The normal correspodning to the face the pick collided with
  11853. */
  11854. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11855. /**
  11856. * Gets the texture coordinates of where the pick occured
  11857. * @returns the vector containing the coordnates of the texture
  11858. */
  11859. getTextureCoordinates(): Nullable<Vector2>;
  11860. }
  11861. }
  11862. declare module "babylonjs/Events/pointerEvents" {
  11863. import { Nullable } from "babylonjs/types";
  11864. import { Vector2 } from "babylonjs/Maths/math.vector";
  11865. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11866. import { Ray } from "babylonjs/Culling/ray";
  11867. /**
  11868. * Gather the list of pointer event types as constants.
  11869. */
  11870. export class PointerEventTypes {
  11871. /**
  11872. * 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.
  11873. */
  11874. static readonly POINTERDOWN: number;
  11875. /**
  11876. * The pointerup event is fired when a pointer is no longer active.
  11877. */
  11878. static readonly POINTERUP: number;
  11879. /**
  11880. * The pointermove event is fired when a pointer changes coordinates.
  11881. */
  11882. static readonly POINTERMOVE: number;
  11883. /**
  11884. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11885. */
  11886. static readonly POINTERWHEEL: number;
  11887. /**
  11888. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11889. */
  11890. static readonly POINTERPICK: number;
  11891. /**
  11892. * The pointertap event is fired when a the object has been touched and released without drag.
  11893. */
  11894. static readonly POINTERTAP: number;
  11895. /**
  11896. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11897. */
  11898. static readonly POINTERDOUBLETAP: number;
  11899. }
  11900. /**
  11901. * Base class of pointer info types.
  11902. */
  11903. export class PointerInfoBase {
  11904. /**
  11905. * Defines the type of event (PointerEventTypes)
  11906. */
  11907. type: number;
  11908. /**
  11909. * Defines the related dom event
  11910. */
  11911. event: PointerEvent | MouseWheelEvent;
  11912. /**
  11913. * Instantiates the base class of pointers info.
  11914. * @param type Defines the type of event (PointerEventTypes)
  11915. * @param event Defines the related dom event
  11916. */
  11917. constructor(
  11918. /**
  11919. * Defines the type of event (PointerEventTypes)
  11920. */
  11921. type: number,
  11922. /**
  11923. * Defines the related dom event
  11924. */
  11925. event: PointerEvent | MouseWheelEvent);
  11926. }
  11927. /**
  11928. * This class is used to store pointer related info for the onPrePointerObservable event.
  11929. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11930. */
  11931. export class PointerInfoPre extends PointerInfoBase {
  11932. /**
  11933. * Ray from a pointer if availible (eg. 6dof controller)
  11934. */
  11935. ray: Nullable<Ray>;
  11936. /**
  11937. * Defines the local position of the pointer on the canvas.
  11938. */
  11939. localPosition: Vector2;
  11940. /**
  11941. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11942. */
  11943. skipOnPointerObservable: boolean;
  11944. /**
  11945. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11946. * @param type Defines the type of event (PointerEventTypes)
  11947. * @param event Defines the related dom event
  11948. * @param localX Defines the local x coordinates of the pointer when the event occured
  11949. * @param localY Defines the local y coordinates of the pointer when the event occured
  11950. */
  11951. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11952. }
  11953. /**
  11954. * This type contains all the data related to a pointer event in Babylon.js.
  11955. * 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.
  11956. */
  11957. export class PointerInfo extends PointerInfoBase {
  11958. /**
  11959. * Defines the picking info associated to the info (if any)\
  11960. */
  11961. pickInfo: Nullable<PickingInfo>;
  11962. /**
  11963. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11964. * @param type Defines the type of event (PointerEventTypes)
  11965. * @param event Defines the related dom event
  11966. * @param pickInfo Defines the picking info associated to the info (if any)\
  11967. */
  11968. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11969. /**
  11970. * Defines the picking info associated to the info (if any)\
  11971. */
  11972. pickInfo: Nullable<PickingInfo>);
  11973. }
  11974. /**
  11975. * Data relating to a touch event on the screen.
  11976. */
  11977. export interface PointerTouch {
  11978. /**
  11979. * X coordinate of touch.
  11980. */
  11981. x: number;
  11982. /**
  11983. * Y coordinate of touch.
  11984. */
  11985. y: number;
  11986. /**
  11987. * Id of touch. Unique for each finger.
  11988. */
  11989. pointerId: number;
  11990. /**
  11991. * Event type passed from DOM.
  11992. */
  11993. type: any;
  11994. }
  11995. }
  11996. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11997. import { Observable } from "babylonjs/Misc/observable";
  11998. import { Nullable } from "babylonjs/types";
  11999. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12000. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. */
  12005. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12006. /**
  12007. * Define if touch is enabled in the mouse input
  12008. */
  12009. touchEnabled: boolean;
  12010. /**
  12011. * Defines the camera the input is attached to.
  12012. */
  12013. camera: FreeCamera;
  12014. /**
  12015. * Defines the buttons associated with the input to handle camera move.
  12016. */
  12017. buttons: number[];
  12018. /**
  12019. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12020. */
  12021. angularSensibility: number;
  12022. private _pointerInput;
  12023. private _onMouseMove;
  12024. private _observer;
  12025. private previousPosition;
  12026. /**
  12027. * Observable for when a pointer move event occurs containing the move offset
  12028. */
  12029. onPointerMovedObservable: Observable<{
  12030. offsetX: number;
  12031. offsetY: number;
  12032. }>;
  12033. /**
  12034. * @hidden
  12035. * If the camera should be rotated automatically based on pointer movement
  12036. */
  12037. _allowCameraRotation: boolean;
  12038. /**
  12039. * Manage the mouse inputs to control the movement of a free camera.
  12040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12041. * @param touchEnabled Defines if touch is enabled or not
  12042. */
  12043. constructor(
  12044. /**
  12045. * Define if touch is enabled in the mouse input
  12046. */
  12047. touchEnabled?: boolean);
  12048. /**
  12049. * Attach the input controls to a specific dom element to get the input from.
  12050. * @param element Defines the element the controls should be listened from
  12051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12052. */
  12053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12054. /**
  12055. * Called on JS contextmenu event.
  12056. * Override this method to provide functionality.
  12057. */
  12058. protected onContextMenu(evt: PointerEvent): void;
  12059. /**
  12060. * Detach the current controls from the specified dom element.
  12061. * @param element Defines the element to stop listening the inputs from
  12062. */
  12063. detachControl(element: Nullable<HTMLElement>): void;
  12064. /**
  12065. * Gets the class name of the current intput.
  12066. * @returns the class name
  12067. */
  12068. getClassName(): string;
  12069. /**
  12070. * Get the friendly name associated with the input class.
  12071. * @returns the input friendly name
  12072. */
  12073. getSimpleName(): string;
  12074. }
  12075. }
  12076. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12077. import { Nullable } from "babylonjs/types";
  12078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12079. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12080. /**
  12081. * Manage the touch inputs to control the movement of a free camera.
  12082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12083. */
  12084. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12085. /**
  12086. * Defines the camera the input is attached to.
  12087. */
  12088. camera: FreeCamera;
  12089. /**
  12090. * Defines the touch sensibility for rotation.
  12091. * The higher the faster.
  12092. */
  12093. touchAngularSensibility: number;
  12094. /**
  12095. * Defines the touch sensibility for move.
  12096. * The higher the faster.
  12097. */
  12098. touchMoveSensibility: number;
  12099. private _offsetX;
  12100. private _offsetY;
  12101. private _pointerPressed;
  12102. private _pointerInput;
  12103. private _observer;
  12104. private _onLostFocus;
  12105. /**
  12106. * Attach the input controls to a specific dom element to get the input from.
  12107. * @param element Defines the element the controls should be listened from
  12108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12109. */
  12110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12111. /**
  12112. * Detach the current controls from the specified dom element.
  12113. * @param element Defines the element to stop listening the inputs from
  12114. */
  12115. detachControl(element: Nullable<HTMLElement>): void;
  12116. /**
  12117. * Update the current camera state depending on the inputs that have been used this frame.
  12118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12119. */
  12120. checkInputs(): void;
  12121. /**
  12122. * Gets the class name of the current intput.
  12123. * @returns the class name
  12124. */
  12125. getClassName(): string;
  12126. /**
  12127. * Get the friendly name associated with the input class.
  12128. * @returns the input friendly name
  12129. */
  12130. getSimpleName(): string;
  12131. }
  12132. }
  12133. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12134. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12135. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12136. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12137. import { Nullable } from "babylonjs/types";
  12138. /**
  12139. * Default Inputs manager for the FreeCamera.
  12140. * It groups all the default supported inputs for ease of use.
  12141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12142. */
  12143. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12144. /**
  12145. * @hidden
  12146. */
  12147. _mouseInput: Nullable<FreeCameraMouseInput>;
  12148. /**
  12149. * Instantiates a new FreeCameraInputsManager.
  12150. * @param camera Defines the camera the inputs belong to
  12151. */
  12152. constructor(camera: FreeCamera);
  12153. /**
  12154. * Add keyboard input support to the input manager.
  12155. * @returns the current input manager
  12156. */
  12157. addKeyboard(): FreeCameraInputsManager;
  12158. /**
  12159. * Add mouse input support to the input manager.
  12160. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12161. * @returns the current input manager
  12162. */
  12163. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12164. /**
  12165. * Removes the mouse input support from the manager
  12166. * @returns the current input manager
  12167. */
  12168. removeMouse(): FreeCameraInputsManager;
  12169. /**
  12170. * Add touch input support to the input manager.
  12171. * @returns the current input manager
  12172. */
  12173. addTouch(): FreeCameraInputsManager;
  12174. /**
  12175. * Remove all attached input methods from a camera
  12176. */
  12177. clear(): void;
  12178. }
  12179. }
  12180. declare module "babylonjs/Cameras/freeCamera" {
  12181. import { Vector3 } from "babylonjs/Maths/math.vector";
  12182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12183. import { Scene } from "babylonjs/scene";
  12184. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12185. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12186. /**
  12187. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12188. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12190. */
  12191. export class FreeCamera extends TargetCamera {
  12192. /**
  12193. * Define the collision ellipsoid of the camera.
  12194. * This is helpful to simulate a camera body like the player body around the camera
  12195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12196. */
  12197. ellipsoid: Vector3;
  12198. /**
  12199. * Define an offset for the position of the ellipsoid around the camera.
  12200. * This can be helpful to determine the center of the body near the gravity center of the body
  12201. * instead of its head.
  12202. */
  12203. ellipsoidOffset: Vector3;
  12204. /**
  12205. * Enable or disable collisions of the camera with the rest of the scene objects.
  12206. */
  12207. checkCollisions: boolean;
  12208. /**
  12209. * Enable or disable gravity on the camera.
  12210. */
  12211. applyGravity: boolean;
  12212. /**
  12213. * Define the input manager associated to the camera.
  12214. */
  12215. inputs: FreeCameraInputsManager;
  12216. /**
  12217. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12218. * Higher values reduce sensitivity.
  12219. */
  12220. /**
  12221. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12222. * Higher values reduce sensitivity.
  12223. */
  12224. angularSensibility: number;
  12225. /**
  12226. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12227. */
  12228. keysUp: number[];
  12229. /**
  12230. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12231. */
  12232. keysDown: number[];
  12233. /**
  12234. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12235. */
  12236. keysLeft: number[];
  12237. /**
  12238. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12239. */
  12240. keysRight: number[];
  12241. /**
  12242. * Event raised when the camera collide with a mesh in the scene.
  12243. */
  12244. onCollide: (collidedMesh: AbstractMesh) => void;
  12245. private _collider;
  12246. private _needMoveForGravity;
  12247. private _oldPosition;
  12248. private _diffPosition;
  12249. private _newPosition;
  12250. /** @hidden */
  12251. _localDirection: Vector3;
  12252. /** @hidden */
  12253. _transformedDirection: Vector3;
  12254. /**
  12255. * Instantiates a Free Camera.
  12256. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12257. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12259. * @param name Define the name of the camera in the scene
  12260. * @param position Define the start position of the camera in the scene
  12261. * @param scene Define the scene the camera belongs to
  12262. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12263. */
  12264. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12265. /**
  12266. * Attached controls to the current camera.
  12267. * @param element Defines the element the controls should be listened from
  12268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12269. */
  12270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12271. /**
  12272. * Detach the current controls from the camera.
  12273. * The camera will stop reacting to inputs.
  12274. * @param element Defines the element to stop listening the inputs from
  12275. */
  12276. detachControl(element: HTMLElement): void;
  12277. private _collisionMask;
  12278. /**
  12279. * Define a collision mask to limit the list of object the camera can collide with
  12280. */
  12281. collisionMask: number;
  12282. /** @hidden */
  12283. _collideWithWorld(displacement: Vector3): void;
  12284. private _onCollisionPositionChange;
  12285. /** @hidden */
  12286. _checkInputs(): void;
  12287. /** @hidden */
  12288. _decideIfNeedsToMove(): boolean;
  12289. /** @hidden */
  12290. _updatePosition(): void;
  12291. /**
  12292. * Destroy the camera and release the current resources hold by it.
  12293. */
  12294. dispose(): void;
  12295. /**
  12296. * Gets the current object class name.
  12297. * @return the class name
  12298. */
  12299. getClassName(): string;
  12300. }
  12301. }
  12302. declare module "babylonjs/Gamepads/gamepad" {
  12303. import { Observable } from "babylonjs/Misc/observable";
  12304. /**
  12305. * Represents a gamepad control stick position
  12306. */
  12307. export class StickValues {
  12308. /**
  12309. * The x component of the control stick
  12310. */
  12311. x: number;
  12312. /**
  12313. * The y component of the control stick
  12314. */
  12315. y: number;
  12316. /**
  12317. * Initializes the gamepad x and y control stick values
  12318. * @param x The x component of the gamepad control stick value
  12319. * @param y The y component of the gamepad control stick value
  12320. */
  12321. constructor(
  12322. /**
  12323. * The x component of the control stick
  12324. */
  12325. x: number,
  12326. /**
  12327. * The y component of the control stick
  12328. */
  12329. y: number);
  12330. }
  12331. /**
  12332. * An interface which manages callbacks for gamepad button changes
  12333. */
  12334. export interface GamepadButtonChanges {
  12335. /**
  12336. * Called when a gamepad has been changed
  12337. */
  12338. changed: boolean;
  12339. /**
  12340. * Called when a gamepad press event has been triggered
  12341. */
  12342. pressChanged: boolean;
  12343. /**
  12344. * Called when a touch event has been triggered
  12345. */
  12346. touchChanged: boolean;
  12347. /**
  12348. * Called when a value has changed
  12349. */
  12350. valueChanged: boolean;
  12351. }
  12352. /**
  12353. * Represents a gamepad
  12354. */
  12355. export class Gamepad {
  12356. /**
  12357. * The id of the gamepad
  12358. */
  12359. id: string;
  12360. /**
  12361. * The index of the gamepad
  12362. */
  12363. index: number;
  12364. /**
  12365. * The browser gamepad
  12366. */
  12367. browserGamepad: any;
  12368. /**
  12369. * Specifies what type of gamepad this represents
  12370. */
  12371. type: number;
  12372. private _leftStick;
  12373. private _rightStick;
  12374. /** @hidden */
  12375. _isConnected: boolean;
  12376. private _leftStickAxisX;
  12377. private _leftStickAxisY;
  12378. private _rightStickAxisX;
  12379. private _rightStickAxisY;
  12380. /**
  12381. * Triggered when the left control stick has been changed
  12382. */
  12383. private _onleftstickchanged;
  12384. /**
  12385. * Triggered when the right control stick has been changed
  12386. */
  12387. private _onrightstickchanged;
  12388. /**
  12389. * Represents a gamepad controller
  12390. */
  12391. static GAMEPAD: number;
  12392. /**
  12393. * Represents a generic controller
  12394. */
  12395. static GENERIC: number;
  12396. /**
  12397. * Represents an XBox controller
  12398. */
  12399. static XBOX: number;
  12400. /**
  12401. * Represents a pose-enabled controller
  12402. */
  12403. static POSE_ENABLED: number;
  12404. /**
  12405. * Represents an Dual Shock controller
  12406. */
  12407. static DUALSHOCK: number;
  12408. /**
  12409. * Specifies whether the left control stick should be Y-inverted
  12410. */
  12411. protected _invertLeftStickY: boolean;
  12412. /**
  12413. * Specifies if the gamepad has been connected
  12414. */
  12415. readonly isConnected: boolean;
  12416. /**
  12417. * Initializes the gamepad
  12418. * @param id The id of the gamepad
  12419. * @param index The index of the gamepad
  12420. * @param browserGamepad The browser gamepad
  12421. * @param leftStickX The x component of the left joystick
  12422. * @param leftStickY The y component of the left joystick
  12423. * @param rightStickX The x component of the right joystick
  12424. * @param rightStickY The y component of the right joystick
  12425. */
  12426. constructor(
  12427. /**
  12428. * The id of the gamepad
  12429. */
  12430. id: string,
  12431. /**
  12432. * The index of the gamepad
  12433. */
  12434. index: number,
  12435. /**
  12436. * The browser gamepad
  12437. */
  12438. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12439. /**
  12440. * Callback triggered when the left joystick has changed
  12441. * @param callback
  12442. */
  12443. onleftstickchanged(callback: (values: StickValues) => void): void;
  12444. /**
  12445. * Callback triggered when the right joystick has changed
  12446. * @param callback
  12447. */
  12448. onrightstickchanged(callback: (values: StickValues) => void): void;
  12449. /**
  12450. * Gets the left joystick
  12451. */
  12452. /**
  12453. * Sets the left joystick values
  12454. */
  12455. leftStick: StickValues;
  12456. /**
  12457. * Gets the right joystick
  12458. */
  12459. /**
  12460. * Sets the right joystick value
  12461. */
  12462. rightStick: StickValues;
  12463. /**
  12464. * Updates the gamepad joystick positions
  12465. */
  12466. update(): void;
  12467. /**
  12468. * Disposes the gamepad
  12469. */
  12470. dispose(): void;
  12471. }
  12472. /**
  12473. * Represents a generic gamepad
  12474. */
  12475. export class GenericPad extends Gamepad {
  12476. private _buttons;
  12477. private _onbuttondown;
  12478. private _onbuttonup;
  12479. /**
  12480. * Observable triggered when a button has been pressed
  12481. */
  12482. onButtonDownObservable: Observable<number>;
  12483. /**
  12484. * Observable triggered when a button has been released
  12485. */
  12486. onButtonUpObservable: Observable<number>;
  12487. /**
  12488. * Callback triggered when a button has been pressed
  12489. * @param callback Called when a button has been pressed
  12490. */
  12491. onbuttondown(callback: (buttonPressed: number) => void): void;
  12492. /**
  12493. * Callback triggered when a button has been released
  12494. * @param callback Called when a button has been released
  12495. */
  12496. onbuttonup(callback: (buttonReleased: number) => void): void;
  12497. /**
  12498. * Initializes the generic gamepad
  12499. * @param id The id of the generic gamepad
  12500. * @param index The index of the generic gamepad
  12501. * @param browserGamepad The browser gamepad
  12502. */
  12503. constructor(id: string, index: number, browserGamepad: any);
  12504. private _setButtonValue;
  12505. /**
  12506. * Updates the generic gamepad
  12507. */
  12508. update(): void;
  12509. /**
  12510. * Disposes the generic gamepad
  12511. */
  12512. dispose(): void;
  12513. }
  12514. }
  12515. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12516. import { Nullable } from "babylonjs/types";
  12517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12518. import { Scene } from "babylonjs/scene";
  12519. module "babylonjs/Engines/engine" {
  12520. interface Engine {
  12521. /**
  12522. * Creates a raw texture
  12523. * @param data defines the data to store in the texture
  12524. * @param width defines the width of the texture
  12525. * @param height defines the height of the texture
  12526. * @param format defines the format of the data
  12527. * @param generateMipMaps defines if the engine should generate the mip levels
  12528. * @param invertY defines if data must be stored with Y axis inverted
  12529. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12530. * @param compression defines the compression used (null by default)
  12531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12532. * @returns the raw texture inside an InternalTexture
  12533. */
  12534. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12535. /**
  12536. * Update a raw texture
  12537. * @param texture defines the texture to update
  12538. * @param data defines the data to store in the texture
  12539. * @param format defines the format of the data
  12540. * @param invertY defines if data must be stored with Y axis inverted
  12541. */
  12542. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12543. /**
  12544. * Update a raw texture
  12545. * @param texture defines the texture to update
  12546. * @param data defines the data to store in the texture
  12547. * @param format defines the format of the data
  12548. * @param invertY defines if data must be stored with Y axis inverted
  12549. * @param compression defines the compression used (null by default)
  12550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12551. */
  12552. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12553. /**
  12554. * Creates a new raw cube texture
  12555. * @param data defines the array of data to use to create each face
  12556. * @param size defines the size of the textures
  12557. * @param format defines the format of the data
  12558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12559. * @param generateMipMaps defines if the engine should generate the mip levels
  12560. * @param invertY defines if data must be stored with Y axis inverted
  12561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12562. * @param compression defines the compression used (null by default)
  12563. * @returns the cube texture as an InternalTexture
  12564. */
  12565. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12566. /**
  12567. * Update a raw cube texture
  12568. * @param texture defines the texture to udpdate
  12569. * @param data defines the data to store
  12570. * @param format defines the data format
  12571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12572. * @param invertY defines if data must be stored with Y axis inverted
  12573. */
  12574. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12575. /**
  12576. * Update a raw cube texture
  12577. * @param texture defines the texture to udpdate
  12578. * @param data defines the data to store
  12579. * @param format defines the data format
  12580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12581. * @param invertY defines if data must be stored with Y axis inverted
  12582. * @param compression defines the compression used (null by default)
  12583. */
  12584. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12585. /**
  12586. * Update a raw cube texture
  12587. * @param texture defines the texture to udpdate
  12588. * @param data defines the data to store
  12589. * @param format defines the data format
  12590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12591. * @param invertY defines if data must be stored with Y axis inverted
  12592. * @param compression defines the compression used (null by default)
  12593. * @param level defines which level of the texture to update
  12594. */
  12595. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12596. /**
  12597. * Creates a new raw cube texture from a specified url
  12598. * @param url defines the url where the data is located
  12599. * @param scene defines the current scene
  12600. * @param size defines the size of the textures
  12601. * @param format defines the format of the data
  12602. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12603. * @param noMipmap defines if the engine should avoid generating the mip levels
  12604. * @param callback defines a callback used to extract texture data from loaded data
  12605. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12606. * @param onLoad defines a callback called when texture is loaded
  12607. * @param onError defines a callback called if there is an error
  12608. * @returns the cube texture as an InternalTexture
  12609. */
  12610. 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;
  12611. /**
  12612. * Creates a new raw cube texture from a specified url
  12613. * @param url defines the url where the data is located
  12614. * @param scene defines the current scene
  12615. * @param size defines the size of the textures
  12616. * @param format defines the format of the data
  12617. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12618. * @param noMipmap defines if the engine should avoid generating the mip levels
  12619. * @param callback defines a callback used to extract texture data from loaded data
  12620. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12621. * @param onLoad defines a callback called when texture is loaded
  12622. * @param onError defines a callback called if there is an error
  12623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12624. * @param invertY defines if data must be stored with Y axis inverted
  12625. * @returns the cube texture as an InternalTexture
  12626. */
  12627. 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;
  12628. /**
  12629. * Creates a new raw 3D texture
  12630. * @param data defines the data used to create the texture
  12631. * @param width defines the width of the texture
  12632. * @param height defines the height of the texture
  12633. * @param depth defines the depth of the texture
  12634. * @param format defines the format of the texture
  12635. * @param generateMipMaps defines if the engine must generate mip levels
  12636. * @param invertY defines if data must be stored with Y axis inverted
  12637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12638. * @param compression defines the compressed used (can be null)
  12639. * @param textureType defines the compressed used (can be null)
  12640. * @returns a new raw 3D texture (stored in an InternalTexture)
  12641. */
  12642. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12643. /**
  12644. * Update a raw 3D texture
  12645. * @param texture defines the texture to update
  12646. * @param data defines the data to store
  12647. * @param format defines the data format
  12648. * @param invertY defines if data must be stored with Y axis inverted
  12649. */
  12650. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12651. /**
  12652. * Update a raw 3D texture
  12653. * @param texture defines the texture to update
  12654. * @param data defines the data to store
  12655. * @param format defines the data format
  12656. * @param invertY defines if data must be stored with Y axis inverted
  12657. * @param compression defines the used compression (can be null)
  12658. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12659. */
  12660. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12661. }
  12662. }
  12663. }
  12664. declare module "babylonjs/Materials/Textures/rawTexture" {
  12665. import { Scene } from "babylonjs/scene";
  12666. import { Texture } from "babylonjs/Materials/Textures/texture";
  12667. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12668. /**
  12669. * Raw texture can help creating a texture directly from an array of data.
  12670. * This can be super useful if you either get the data from an uncompressed source or
  12671. * if you wish to create your texture pixel by pixel.
  12672. */
  12673. export class RawTexture extends Texture {
  12674. /**
  12675. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12676. */
  12677. format: number;
  12678. private _engine;
  12679. /**
  12680. * Instantiates a new RawTexture.
  12681. * Raw texture can help creating a texture directly from an array of data.
  12682. * This can be super useful if you either get the data from an uncompressed source or
  12683. * if you wish to create your texture pixel by pixel.
  12684. * @param data define the array of data to use to create the texture
  12685. * @param width define the width of the texture
  12686. * @param height define the height of the texture
  12687. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12688. * @param scene define the scene the texture belongs to
  12689. * @param generateMipMaps define whether mip maps should be generated or not
  12690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12693. */
  12694. constructor(data: ArrayBufferView, width: number, height: number,
  12695. /**
  12696. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12697. */
  12698. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12699. /**
  12700. * Updates the texture underlying data.
  12701. * @param data Define the new data of the texture
  12702. */
  12703. update(data: ArrayBufferView): void;
  12704. /**
  12705. * Creates a luminance texture from some data.
  12706. * @param data Define the texture data
  12707. * @param width Define the width of the texture
  12708. * @param height Define the height of the texture
  12709. * @param scene Define the scene the texture belongs to
  12710. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12711. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12712. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12713. * @returns the luminance texture
  12714. */
  12715. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12716. /**
  12717. * Creates a luminance alpha texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @returns the luminance alpha texture
  12726. */
  12727. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12728. /**
  12729. * Creates an alpha texture from some data.
  12730. * @param data Define the texture data
  12731. * @param width Define the width of the texture
  12732. * @param height Define the height of the texture
  12733. * @param scene Define the scene the texture belongs to
  12734. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12735. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12736. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12737. * @returns the alpha texture
  12738. */
  12739. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12740. /**
  12741. * Creates a RGB texture from some data.
  12742. * @param data Define the texture data
  12743. * @param width Define the width of the texture
  12744. * @param height Define the height of the texture
  12745. * @param scene Define the scene the texture belongs to
  12746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12750. * @returns the RGB alpha texture
  12751. */
  12752. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12753. /**
  12754. * Creates a RGBA texture from some data.
  12755. * @param data Define the texture data
  12756. * @param width Define the width of the texture
  12757. * @param height Define the height of the texture
  12758. * @param scene Define the scene the texture belongs to
  12759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12762. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12763. * @returns the RGBA texture
  12764. */
  12765. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12766. /**
  12767. * Creates a R texture from some data.
  12768. * @param data Define the texture data
  12769. * @param width Define the width of the texture
  12770. * @param height Define the height of the texture
  12771. * @param scene Define the scene the texture belongs to
  12772. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12773. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12774. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12775. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12776. * @returns the R texture
  12777. */
  12778. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12779. }
  12780. }
  12781. declare module "babylonjs/Maths/math.size" {
  12782. /**
  12783. * Interface for the size containing width and height
  12784. */
  12785. export interface ISize {
  12786. /**
  12787. * Width
  12788. */
  12789. width: number;
  12790. /**
  12791. * Heighht
  12792. */
  12793. height: number;
  12794. }
  12795. /**
  12796. * Size containing widht and height
  12797. */
  12798. export class Size implements ISize {
  12799. /**
  12800. * Width
  12801. */
  12802. width: number;
  12803. /**
  12804. * Height
  12805. */
  12806. height: number;
  12807. /**
  12808. * Creates a Size object from the given width and height (floats).
  12809. * @param width width of the new size
  12810. * @param height height of the new size
  12811. */
  12812. constructor(width: number, height: number);
  12813. /**
  12814. * Returns a string with the Size width and height
  12815. * @returns a string with the Size width and height
  12816. */
  12817. toString(): string;
  12818. /**
  12819. * "Size"
  12820. * @returns the string "Size"
  12821. */
  12822. getClassName(): string;
  12823. /**
  12824. * Returns the Size hash code.
  12825. * @returns a hash code for a unique width and height
  12826. */
  12827. getHashCode(): number;
  12828. /**
  12829. * Updates the current size from the given one.
  12830. * @param src the given size
  12831. */
  12832. copyFrom(src: Size): void;
  12833. /**
  12834. * Updates in place the current Size from the given floats.
  12835. * @param width width of the new size
  12836. * @param height height of the new size
  12837. * @returns the updated Size.
  12838. */
  12839. copyFromFloats(width: number, height: number): Size;
  12840. /**
  12841. * Updates in place the current Size from the given floats.
  12842. * @param width width to set
  12843. * @param height height to set
  12844. * @returns the updated Size.
  12845. */
  12846. set(width: number, height: number): Size;
  12847. /**
  12848. * Multiplies the width and height by numbers
  12849. * @param w factor to multiple the width by
  12850. * @param h factor to multiple the height by
  12851. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12852. */
  12853. multiplyByFloats(w: number, h: number): Size;
  12854. /**
  12855. * Clones the size
  12856. * @returns a new Size copied from the given one.
  12857. */
  12858. clone(): Size;
  12859. /**
  12860. * True if the current Size and the given one width and height are strictly equal.
  12861. * @param other the other size to compare against
  12862. * @returns True if the current Size and the given one width and height are strictly equal.
  12863. */
  12864. equals(other: Size): boolean;
  12865. /**
  12866. * The surface of the Size : width * height (float).
  12867. */
  12868. readonly surface: number;
  12869. /**
  12870. * Create a new size of zero
  12871. * @returns a new Size set to (0.0, 0.0)
  12872. */
  12873. static Zero(): Size;
  12874. /**
  12875. * Sums the width and height of two sizes
  12876. * @param otherSize size to add to this size
  12877. * @returns a new Size set as the addition result of the current Size and the given one.
  12878. */
  12879. add(otherSize: Size): Size;
  12880. /**
  12881. * Subtracts the width and height of two
  12882. * @param otherSize size to subtract to this size
  12883. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12884. */
  12885. subtract(otherSize: Size): Size;
  12886. /**
  12887. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12888. * @param start starting size to lerp between
  12889. * @param end end size to lerp between
  12890. * @param amount amount to lerp between the start and end values
  12891. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12892. */
  12893. static Lerp(start: Size, end: Size, amount: number): Size;
  12894. }
  12895. }
  12896. declare module "babylonjs/Animations/runtimeAnimation" {
  12897. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12898. import { Animatable } from "babylonjs/Animations/animatable";
  12899. import { Scene } from "babylonjs/scene";
  12900. /**
  12901. * Defines a runtime animation
  12902. */
  12903. export class RuntimeAnimation {
  12904. private _events;
  12905. /**
  12906. * The current frame of the runtime animation
  12907. */
  12908. private _currentFrame;
  12909. /**
  12910. * The animation used by the runtime animation
  12911. */
  12912. private _animation;
  12913. /**
  12914. * The target of the runtime animation
  12915. */
  12916. private _target;
  12917. /**
  12918. * The initiating animatable
  12919. */
  12920. private _host;
  12921. /**
  12922. * The original value of the runtime animation
  12923. */
  12924. private _originalValue;
  12925. /**
  12926. * The original blend value of the runtime animation
  12927. */
  12928. private _originalBlendValue;
  12929. /**
  12930. * The offsets cache of the runtime animation
  12931. */
  12932. private _offsetsCache;
  12933. /**
  12934. * The high limits cache of the runtime animation
  12935. */
  12936. private _highLimitsCache;
  12937. /**
  12938. * Specifies if the runtime animation has been stopped
  12939. */
  12940. private _stopped;
  12941. /**
  12942. * The blending factor of the runtime animation
  12943. */
  12944. private _blendingFactor;
  12945. /**
  12946. * The BabylonJS scene
  12947. */
  12948. private _scene;
  12949. /**
  12950. * The current value of the runtime animation
  12951. */
  12952. private _currentValue;
  12953. /** @hidden */
  12954. _animationState: _IAnimationState;
  12955. /**
  12956. * The active target of the runtime animation
  12957. */
  12958. private _activeTargets;
  12959. private _currentActiveTarget;
  12960. private _directTarget;
  12961. /**
  12962. * The target path of the runtime animation
  12963. */
  12964. private _targetPath;
  12965. /**
  12966. * The weight of the runtime animation
  12967. */
  12968. private _weight;
  12969. /**
  12970. * The ratio offset of the runtime animation
  12971. */
  12972. private _ratioOffset;
  12973. /**
  12974. * The previous delay of the runtime animation
  12975. */
  12976. private _previousDelay;
  12977. /**
  12978. * The previous ratio of the runtime animation
  12979. */
  12980. private _previousRatio;
  12981. private _enableBlending;
  12982. private _keys;
  12983. private _minFrame;
  12984. private _maxFrame;
  12985. private _minValue;
  12986. private _maxValue;
  12987. private _targetIsArray;
  12988. /**
  12989. * Gets the current frame of the runtime animation
  12990. */
  12991. readonly currentFrame: number;
  12992. /**
  12993. * Gets the weight of the runtime animation
  12994. */
  12995. readonly weight: number;
  12996. /**
  12997. * Gets the current value of the runtime animation
  12998. */
  12999. readonly currentValue: any;
  13000. /**
  13001. * Gets the target path of the runtime animation
  13002. */
  13003. readonly targetPath: string;
  13004. /**
  13005. * Gets the actual target of the runtime animation
  13006. */
  13007. readonly target: any;
  13008. /** @hidden */
  13009. _onLoop: () => void;
  13010. /**
  13011. * Create a new RuntimeAnimation object
  13012. * @param target defines the target of the animation
  13013. * @param animation defines the source animation object
  13014. * @param scene defines the hosting scene
  13015. * @param host defines the initiating Animatable
  13016. */
  13017. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13018. private _preparePath;
  13019. /**
  13020. * Gets the animation from the runtime animation
  13021. */
  13022. readonly animation: Animation;
  13023. /**
  13024. * Resets the runtime animation to the beginning
  13025. * @param restoreOriginal defines whether to restore the target property to the original value
  13026. */
  13027. reset(restoreOriginal?: boolean): void;
  13028. /**
  13029. * Specifies if the runtime animation is stopped
  13030. * @returns Boolean specifying if the runtime animation is stopped
  13031. */
  13032. isStopped(): boolean;
  13033. /**
  13034. * Disposes of the runtime animation
  13035. */
  13036. dispose(): void;
  13037. /**
  13038. * Apply the interpolated value to the target
  13039. * @param currentValue defines the value computed by the animation
  13040. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13041. */
  13042. setValue(currentValue: any, weight: number): void;
  13043. private _getOriginalValues;
  13044. private _setValue;
  13045. /**
  13046. * Gets the loop pmode of the runtime animation
  13047. * @returns Loop Mode
  13048. */
  13049. private _getCorrectLoopMode;
  13050. /**
  13051. * Move the current animation to a given frame
  13052. * @param frame defines the frame to move to
  13053. */
  13054. goToFrame(frame: number): void;
  13055. /**
  13056. * @hidden Internal use only
  13057. */
  13058. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13059. /**
  13060. * Execute the current animation
  13061. * @param delay defines the delay to add to the current frame
  13062. * @param from defines the lower bound of the animation range
  13063. * @param to defines the upper bound of the animation range
  13064. * @param loop defines if the current animation must loop
  13065. * @param speedRatio defines the current speed ratio
  13066. * @param weight defines the weight of the animation (default is -1 so no weight)
  13067. * @param onLoop optional callback called when animation loops
  13068. * @returns a boolean indicating if the animation is running
  13069. */
  13070. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13071. }
  13072. }
  13073. declare module "babylonjs/Animations/animatable" {
  13074. import { Animation } from "babylonjs/Animations/animation";
  13075. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13076. import { Nullable } from "babylonjs/types";
  13077. import { Observable } from "babylonjs/Misc/observable";
  13078. import { Scene } from "babylonjs/scene";
  13079. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13080. import { Node } from "babylonjs/node";
  13081. /**
  13082. * Class used to store an actual running animation
  13083. */
  13084. export class Animatable {
  13085. /** defines the target object */
  13086. target: any;
  13087. /** defines the starting frame number (default is 0) */
  13088. fromFrame: number;
  13089. /** defines the ending frame number (default is 100) */
  13090. toFrame: number;
  13091. /** defines if the animation must loop (default is false) */
  13092. loopAnimation: boolean;
  13093. /** defines a callback to call when animation ends if it is not looping */
  13094. onAnimationEnd?: (() => void) | null | undefined;
  13095. /** defines a callback to call when animation loops */
  13096. onAnimationLoop?: (() => void) | null | undefined;
  13097. private _localDelayOffset;
  13098. private _pausedDelay;
  13099. private _runtimeAnimations;
  13100. private _paused;
  13101. private _scene;
  13102. private _speedRatio;
  13103. private _weight;
  13104. private _syncRoot;
  13105. /**
  13106. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13107. * This will only apply for non looping animation (default is true)
  13108. */
  13109. disposeOnEnd: boolean;
  13110. /**
  13111. * Gets a boolean indicating if the animation has started
  13112. */
  13113. animationStarted: boolean;
  13114. /**
  13115. * Observer raised when the animation ends
  13116. */
  13117. onAnimationEndObservable: Observable<Animatable>;
  13118. /**
  13119. * Observer raised when the animation loops
  13120. */
  13121. onAnimationLoopObservable: Observable<Animatable>;
  13122. /**
  13123. * Gets the root Animatable used to synchronize and normalize animations
  13124. */
  13125. readonly syncRoot: Nullable<Animatable>;
  13126. /**
  13127. * Gets the current frame of the first RuntimeAnimation
  13128. * Used to synchronize Animatables
  13129. */
  13130. readonly masterFrame: number;
  13131. /**
  13132. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13133. */
  13134. weight: number;
  13135. /**
  13136. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13137. */
  13138. speedRatio: number;
  13139. /**
  13140. * Creates a new Animatable
  13141. * @param scene defines the hosting scene
  13142. * @param target defines the target object
  13143. * @param fromFrame defines the starting frame number (default is 0)
  13144. * @param toFrame defines the ending frame number (default is 100)
  13145. * @param loopAnimation defines if the animation must loop (default is false)
  13146. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13147. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13148. * @param animations defines a group of animation to add to the new Animatable
  13149. * @param onAnimationLoop defines a callback to call when animation loops
  13150. */
  13151. constructor(scene: Scene,
  13152. /** defines the target object */
  13153. target: any,
  13154. /** defines the starting frame number (default is 0) */
  13155. fromFrame?: number,
  13156. /** defines the ending frame number (default is 100) */
  13157. toFrame?: number,
  13158. /** defines if the animation must loop (default is false) */
  13159. loopAnimation?: boolean, speedRatio?: number,
  13160. /** defines a callback to call when animation ends if it is not looping */
  13161. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13162. /** defines a callback to call when animation loops */
  13163. onAnimationLoop?: (() => void) | null | undefined);
  13164. /**
  13165. * Synchronize and normalize current Animatable with a source Animatable
  13166. * This is useful when using animation weights and when animations are not of the same length
  13167. * @param root defines the root Animatable to synchronize with
  13168. * @returns the current Animatable
  13169. */
  13170. syncWith(root: Animatable): Animatable;
  13171. /**
  13172. * Gets the list of runtime animations
  13173. * @returns an array of RuntimeAnimation
  13174. */
  13175. getAnimations(): RuntimeAnimation[];
  13176. /**
  13177. * Adds more animations to the current animatable
  13178. * @param target defines the target of the animations
  13179. * @param animations defines the new animations to add
  13180. */
  13181. appendAnimations(target: any, animations: Animation[]): void;
  13182. /**
  13183. * Gets the source animation for a specific property
  13184. * @param property defines the propertyu to look for
  13185. * @returns null or the source animation for the given property
  13186. */
  13187. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13188. /**
  13189. * Gets the runtime animation for a specific property
  13190. * @param property defines the propertyu to look for
  13191. * @returns null or the runtime animation for the given property
  13192. */
  13193. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13194. /**
  13195. * Resets the animatable to its original state
  13196. */
  13197. reset(): void;
  13198. /**
  13199. * Allows the animatable to blend with current running animations
  13200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13201. * @param blendingSpeed defines the blending speed to use
  13202. */
  13203. enableBlending(blendingSpeed: number): void;
  13204. /**
  13205. * Disable animation blending
  13206. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13207. */
  13208. disableBlending(): void;
  13209. /**
  13210. * Jump directly to a given frame
  13211. * @param frame defines the frame to jump to
  13212. */
  13213. goToFrame(frame: number): void;
  13214. /**
  13215. * Pause the animation
  13216. */
  13217. pause(): void;
  13218. /**
  13219. * Restart the animation
  13220. */
  13221. restart(): void;
  13222. private _raiseOnAnimationEnd;
  13223. /**
  13224. * Stop and delete the current animation
  13225. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13226. * @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)
  13227. */
  13228. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13229. /**
  13230. * Wait asynchronously for the animation to end
  13231. * @returns a promise which will be fullfilled when the animation ends
  13232. */
  13233. waitAsync(): Promise<Animatable>;
  13234. /** @hidden */
  13235. _animate(delay: number): boolean;
  13236. }
  13237. module "babylonjs/scene" {
  13238. interface Scene {
  13239. /** @hidden */
  13240. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13241. /** @hidden */
  13242. _processLateAnimationBindingsForMatrices(holder: {
  13243. totalWeight: number;
  13244. animations: RuntimeAnimation[];
  13245. originalValue: Matrix;
  13246. }): any;
  13247. /** @hidden */
  13248. _processLateAnimationBindingsForQuaternions(holder: {
  13249. totalWeight: number;
  13250. animations: RuntimeAnimation[];
  13251. originalValue: Quaternion;
  13252. }, refQuaternion: Quaternion): Quaternion;
  13253. /** @hidden */
  13254. _processLateAnimationBindings(): void;
  13255. /**
  13256. * Will start the animation sequence of a given target
  13257. * @param target defines the target
  13258. * @param from defines from which frame should animation start
  13259. * @param to defines until which frame should animation run.
  13260. * @param weight defines the weight to apply to the animation (1.0 by default)
  13261. * @param loop defines if the animation loops
  13262. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13263. * @param onAnimationEnd defines the function to be executed when the animation ends
  13264. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13265. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13266. * @param onAnimationLoop defines the callback to call when an animation loops
  13267. * @returns the animatable object created for this animation
  13268. */
  13269. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13270. /**
  13271. * Will start the animation sequence of a given target
  13272. * @param target defines the target
  13273. * @param from defines from which frame should animation start
  13274. * @param to defines until which frame should animation run.
  13275. * @param loop defines if the animation loops
  13276. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13277. * @param onAnimationEnd defines the function to be executed when the animation ends
  13278. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13279. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13280. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13281. * @param onAnimationLoop defines the callback to call when an animation loops
  13282. * @returns the animatable object created for this animation
  13283. */
  13284. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13285. /**
  13286. * Will start the animation sequence of a given target and its hierarchy
  13287. * @param target defines the target
  13288. * @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.
  13289. * @param from defines from which frame should animation start
  13290. * @param to defines until which frame should animation run.
  13291. * @param loop defines if the animation loops
  13292. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13293. * @param onAnimationEnd defines the function to be executed when the animation ends
  13294. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13295. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13296. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13297. * @param onAnimationLoop defines the callback to call when an animation loops
  13298. * @returns the list of created animatables
  13299. */
  13300. 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[];
  13301. /**
  13302. * Begin a new animation on a given node
  13303. * @param target defines the target where the animation will take place
  13304. * @param animations defines the list of animations to start
  13305. * @param from defines the initial value
  13306. * @param to defines the final value
  13307. * @param loop defines if you want animation to loop (off by default)
  13308. * @param speedRatio defines the speed ratio to apply to all animations
  13309. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13310. * @param onAnimationLoop defines the callback to call when an animation loops
  13311. * @returns the list of created animatables
  13312. */
  13313. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13314. /**
  13315. * Begin a new animation on a given node and its hierarchy
  13316. * @param target defines the root node where the animation will take place
  13317. * @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.
  13318. * @param animations defines the list of animations to start
  13319. * @param from defines the initial value
  13320. * @param to defines the final value
  13321. * @param loop defines if you want animation to loop (off by default)
  13322. * @param speedRatio defines the speed ratio to apply to all animations
  13323. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13324. * @param onAnimationLoop defines the callback to call when an animation loops
  13325. * @returns the list of animatables created for all nodes
  13326. */
  13327. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13328. /**
  13329. * Gets the animatable associated with a specific target
  13330. * @param target defines the target of the animatable
  13331. * @returns the required animatable if found
  13332. */
  13333. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13334. /**
  13335. * Gets all animatables associated with a given target
  13336. * @param target defines the target to look animatables for
  13337. * @returns an array of Animatables
  13338. */
  13339. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13340. /**
  13341. * Stops and removes all animations that have been applied to the scene
  13342. */
  13343. stopAllAnimations(): void;
  13344. /**
  13345. * Gets the current delta time used by animation engine
  13346. */
  13347. deltaTime: number;
  13348. }
  13349. }
  13350. module "babylonjs/Bones/bone" {
  13351. interface Bone {
  13352. /**
  13353. * Copy an animation range from another bone
  13354. * @param source defines the source bone
  13355. * @param rangeName defines the range name to copy
  13356. * @param frameOffset defines the frame offset
  13357. * @param rescaleAsRequired defines if rescaling must be applied if required
  13358. * @param skelDimensionsRatio defines the scaling ratio
  13359. * @returns true if operation was successful
  13360. */
  13361. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13362. }
  13363. }
  13364. }
  13365. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13366. /**
  13367. * Class used to override all child animations of a given target
  13368. */
  13369. export class AnimationPropertiesOverride {
  13370. /**
  13371. * Gets or sets a value indicating if animation blending must be used
  13372. */
  13373. enableBlending: boolean;
  13374. /**
  13375. * Gets or sets the blending speed to use when enableBlending is true
  13376. */
  13377. blendingSpeed: number;
  13378. /**
  13379. * Gets or sets the default loop mode to use
  13380. */
  13381. loopMode: number;
  13382. }
  13383. }
  13384. declare module "babylonjs/Bones/skeleton" {
  13385. import { Bone } from "babylonjs/Bones/bone";
  13386. import { Observable } from "babylonjs/Misc/observable";
  13387. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13388. import { Scene } from "babylonjs/scene";
  13389. import { Nullable } from "babylonjs/types";
  13390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13391. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13392. import { Animatable } from "babylonjs/Animations/animatable";
  13393. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13394. import { Animation } from "babylonjs/Animations/animation";
  13395. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13396. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13397. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13398. /**
  13399. * Class used to handle skinning animations
  13400. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13401. */
  13402. export class Skeleton implements IAnimatable {
  13403. /** defines the skeleton name */
  13404. name: string;
  13405. /** defines the skeleton Id */
  13406. id: string;
  13407. /**
  13408. * Defines the list of child bones
  13409. */
  13410. bones: Bone[];
  13411. /**
  13412. * Defines an estimate of the dimension of the skeleton at rest
  13413. */
  13414. dimensionsAtRest: Vector3;
  13415. /**
  13416. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13417. */
  13418. needInitialSkinMatrix: boolean;
  13419. /**
  13420. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13421. */
  13422. overrideMesh: Nullable<AbstractMesh>;
  13423. /**
  13424. * Gets the list of animations attached to this skeleton
  13425. */
  13426. animations: Array<Animation>;
  13427. private _scene;
  13428. private _isDirty;
  13429. private _transformMatrices;
  13430. private _transformMatrixTexture;
  13431. private _meshesWithPoseMatrix;
  13432. private _animatables;
  13433. private _identity;
  13434. private _synchronizedWithMesh;
  13435. private _ranges;
  13436. private _lastAbsoluteTransformsUpdateId;
  13437. private _canUseTextureForBones;
  13438. private _uniqueId;
  13439. /** @hidden */
  13440. _numBonesWithLinkedTransformNode: number;
  13441. /** @hidden */
  13442. _hasWaitingData: Nullable<boolean>;
  13443. /**
  13444. * Specifies if the skeleton should be serialized
  13445. */
  13446. doNotSerialize: boolean;
  13447. private _useTextureToStoreBoneMatrices;
  13448. /**
  13449. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13450. * Please note that this option is not available if the hardware does not support it
  13451. */
  13452. useTextureToStoreBoneMatrices: boolean;
  13453. private _animationPropertiesOverride;
  13454. /**
  13455. * Gets or sets the animation properties override
  13456. */
  13457. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13458. /**
  13459. * List of inspectable custom properties (used by the Inspector)
  13460. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13461. */
  13462. inspectableCustomProperties: IInspectable[];
  13463. /**
  13464. * An observable triggered before computing the skeleton's matrices
  13465. */
  13466. onBeforeComputeObservable: Observable<Skeleton>;
  13467. /**
  13468. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13469. */
  13470. readonly isUsingTextureForMatrices: boolean;
  13471. /**
  13472. * Gets the unique ID of this skeleton
  13473. */
  13474. readonly uniqueId: number;
  13475. /**
  13476. * Creates a new skeleton
  13477. * @param name defines the skeleton name
  13478. * @param id defines the skeleton Id
  13479. * @param scene defines the hosting scene
  13480. */
  13481. constructor(
  13482. /** defines the skeleton name */
  13483. name: string,
  13484. /** defines the skeleton Id */
  13485. id: string, scene: Scene);
  13486. /**
  13487. * Gets the current object class name.
  13488. * @return the class name
  13489. */
  13490. getClassName(): string;
  13491. /**
  13492. * Returns an array containing the root bones
  13493. * @returns an array containing the root bones
  13494. */
  13495. getChildren(): Array<Bone>;
  13496. /**
  13497. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13499. * @returns a Float32Array containing matrices data
  13500. */
  13501. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13502. /**
  13503. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13504. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13505. * @returns a raw texture containing the data
  13506. */
  13507. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13508. /**
  13509. * Gets the current hosting scene
  13510. * @returns a scene object
  13511. */
  13512. getScene(): Scene;
  13513. /**
  13514. * Gets a string representing the current skeleton data
  13515. * @param fullDetails defines a boolean indicating if we want a verbose version
  13516. * @returns a string representing the current skeleton data
  13517. */
  13518. toString(fullDetails?: boolean): string;
  13519. /**
  13520. * Get bone's index searching by name
  13521. * @param name defines bone's name to search for
  13522. * @return the indice of the bone. Returns -1 if not found
  13523. */
  13524. getBoneIndexByName(name: string): number;
  13525. /**
  13526. * Creater a new animation range
  13527. * @param name defines the name of the range
  13528. * @param from defines the start key
  13529. * @param to defines the end key
  13530. */
  13531. createAnimationRange(name: string, from: number, to: number): void;
  13532. /**
  13533. * Delete a specific animation range
  13534. * @param name defines the name of the range
  13535. * @param deleteFrames defines if frames must be removed as well
  13536. */
  13537. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13538. /**
  13539. * Gets a specific animation range
  13540. * @param name defines the name of the range to look for
  13541. * @returns the requested animation range or null if not found
  13542. */
  13543. getAnimationRange(name: string): Nullable<AnimationRange>;
  13544. /**
  13545. * Gets the list of all animation ranges defined on this skeleton
  13546. * @returns an array
  13547. */
  13548. getAnimationRanges(): Nullable<AnimationRange>[];
  13549. /**
  13550. * Copy animation range from a source skeleton.
  13551. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13552. * @param source defines the source skeleton
  13553. * @param name defines the name of the range to copy
  13554. * @param rescaleAsRequired defines if rescaling must be applied if required
  13555. * @returns true if operation was successful
  13556. */
  13557. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13558. /**
  13559. * Forces the skeleton to go to rest pose
  13560. */
  13561. returnToRest(): void;
  13562. private _getHighestAnimationFrame;
  13563. /**
  13564. * Begin a specific animation range
  13565. * @param name defines the name of the range to start
  13566. * @param loop defines if looping must be turned on (false by default)
  13567. * @param speedRatio defines the speed ratio to apply (1 by default)
  13568. * @param onAnimationEnd defines a callback which will be called when animation will end
  13569. * @returns a new animatable
  13570. */
  13571. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13572. /** @hidden */
  13573. _markAsDirty(): void;
  13574. /** @hidden */
  13575. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13576. /** @hidden */
  13577. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13578. private _computeTransformMatrices;
  13579. /**
  13580. * Build all resources required to render a skeleton
  13581. */
  13582. prepare(): void;
  13583. /**
  13584. * Gets the list of animatables currently running for this skeleton
  13585. * @returns an array of animatables
  13586. */
  13587. getAnimatables(): IAnimatable[];
  13588. /**
  13589. * Clone the current skeleton
  13590. * @param name defines the name of the new skeleton
  13591. * @param id defines the id of the new skeleton
  13592. * @returns the new skeleton
  13593. */
  13594. clone(name: string, id: string): Skeleton;
  13595. /**
  13596. * Enable animation blending for this skeleton
  13597. * @param blendingSpeed defines the blending speed to apply
  13598. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13599. */
  13600. enableBlending(blendingSpeed?: number): void;
  13601. /**
  13602. * Releases all resources associated with the current skeleton
  13603. */
  13604. dispose(): void;
  13605. /**
  13606. * Serialize the skeleton in a JSON object
  13607. * @returns a JSON object
  13608. */
  13609. serialize(): any;
  13610. /**
  13611. * Creates a new skeleton from serialized data
  13612. * @param parsedSkeleton defines the serialized data
  13613. * @param scene defines the hosting scene
  13614. * @returns a new skeleton
  13615. */
  13616. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13617. /**
  13618. * Compute all node absolute transforms
  13619. * @param forceUpdate defines if computation must be done even if cache is up to date
  13620. */
  13621. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13622. /**
  13623. * Gets the root pose matrix
  13624. * @returns a matrix
  13625. */
  13626. getPoseMatrix(): Nullable<Matrix>;
  13627. /**
  13628. * Sorts bones per internal index
  13629. */
  13630. sortBones(): void;
  13631. private _sortBones;
  13632. }
  13633. }
  13634. declare module "babylonjs/Bones/bone" {
  13635. import { Skeleton } from "babylonjs/Bones/skeleton";
  13636. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13637. import { Nullable } from "babylonjs/types";
  13638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13639. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13640. import { Node } from "babylonjs/node";
  13641. import { Space } from "babylonjs/Maths/math.axis";
  13642. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13643. /**
  13644. * Class used to store bone information
  13645. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13646. */
  13647. export class Bone extends Node {
  13648. /**
  13649. * defines the bone name
  13650. */
  13651. name: string;
  13652. private static _tmpVecs;
  13653. private static _tmpQuat;
  13654. private static _tmpMats;
  13655. /**
  13656. * Gets the list of child bones
  13657. */
  13658. children: Bone[];
  13659. /** Gets the animations associated with this bone */
  13660. animations: import("babylonjs/Animations/animation").Animation[];
  13661. /**
  13662. * Gets or sets bone length
  13663. */
  13664. length: number;
  13665. /**
  13666. * @hidden Internal only
  13667. * Set this value to map this bone to a different index in the transform matrices
  13668. * Set this value to -1 to exclude the bone from the transform matrices
  13669. */
  13670. _index: Nullable<number>;
  13671. private _skeleton;
  13672. private _localMatrix;
  13673. private _restPose;
  13674. private _baseMatrix;
  13675. private _absoluteTransform;
  13676. private _invertedAbsoluteTransform;
  13677. private _parent;
  13678. private _scalingDeterminant;
  13679. private _worldTransform;
  13680. private _localScaling;
  13681. private _localRotation;
  13682. private _localPosition;
  13683. private _needToDecompose;
  13684. private _needToCompose;
  13685. /** @hidden */
  13686. _linkedTransformNode: Nullable<TransformNode>;
  13687. /** @hidden */
  13688. _waitingTransformNodeId: Nullable<string>;
  13689. /** @hidden */
  13690. /** @hidden */
  13691. _matrix: Matrix;
  13692. /**
  13693. * Create a new bone
  13694. * @param name defines the bone name
  13695. * @param skeleton defines the parent skeleton
  13696. * @param parentBone defines the parent (can be null if the bone is the root)
  13697. * @param localMatrix defines the local matrix
  13698. * @param restPose defines the rest pose matrix
  13699. * @param baseMatrix defines the base matrix
  13700. * @param index defines index of the bone in the hiearchy
  13701. */
  13702. constructor(
  13703. /**
  13704. * defines the bone name
  13705. */
  13706. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13707. /**
  13708. * Gets the current object class name.
  13709. * @return the class name
  13710. */
  13711. getClassName(): string;
  13712. /**
  13713. * Gets the parent skeleton
  13714. * @returns a skeleton
  13715. */
  13716. getSkeleton(): Skeleton;
  13717. /**
  13718. * Gets parent bone
  13719. * @returns a bone or null if the bone is the root of the bone hierarchy
  13720. */
  13721. getParent(): Nullable<Bone>;
  13722. /**
  13723. * Returns an array containing the root bones
  13724. * @returns an array containing the root bones
  13725. */
  13726. getChildren(): Array<Bone>;
  13727. /**
  13728. * Sets the parent bone
  13729. * @param parent defines the parent (can be null if the bone is the root)
  13730. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13731. */
  13732. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13733. /**
  13734. * Gets the local matrix
  13735. * @returns a matrix
  13736. */
  13737. getLocalMatrix(): Matrix;
  13738. /**
  13739. * Gets the base matrix (initial matrix which remains unchanged)
  13740. * @returns a matrix
  13741. */
  13742. getBaseMatrix(): Matrix;
  13743. /**
  13744. * Gets the rest pose matrix
  13745. * @returns a matrix
  13746. */
  13747. getRestPose(): Matrix;
  13748. /**
  13749. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13750. */
  13751. getWorldMatrix(): Matrix;
  13752. /**
  13753. * Sets the local matrix to rest pose matrix
  13754. */
  13755. returnToRest(): void;
  13756. /**
  13757. * Gets the inverse of the absolute transform matrix.
  13758. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13759. * @returns a matrix
  13760. */
  13761. getInvertedAbsoluteTransform(): Matrix;
  13762. /**
  13763. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13764. * @returns a matrix
  13765. */
  13766. getAbsoluteTransform(): Matrix;
  13767. /**
  13768. * Links with the given transform node.
  13769. * The local matrix of this bone is copied from the transform node every frame.
  13770. * @param transformNode defines the transform node to link to
  13771. */
  13772. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13773. /**
  13774. * Gets the node used to drive the bone's transformation
  13775. * @returns a transform node or null
  13776. */
  13777. getTransformNode(): Nullable<TransformNode>;
  13778. /** Gets or sets current position (in local space) */
  13779. position: Vector3;
  13780. /** Gets or sets current rotation (in local space) */
  13781. rotation: Vector3;
  13782. /** Gets or sets current rotation quaternion (in local space) */
  13783. rotationQuaternion: Quaternion;
  13784. /** Gets or sets current scaling (in local space) */
  13785. scaling: Vector3;
  13786. /**
  13787. * Gets the animation properties override
  13788. */
  13789. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13790. private _decompose;
  13791. private _compose;
  13792. /**
  13793. * Update the base and local matrices
  13794. * @param matrix defines the new base or local matrix
  13795. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13796. * @param updateLocalMatrix defines if the local matrix should be updated
  13797. */
  13798. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13799. /** @hidden */
  13800. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13801. /**
  13802. * Flag the bone as dirty (Forcing it to update everything)
  13803. */
  13804. markAsDirty(): void;
  13805. /** @hidden */
  13806. _markAsDirtyAndCompose(): void;
  13807. private _markAsDirtyAndDecompose;
  13808. /**
  13809. * Translate the bone in local or world space
  13810. * @param vec The amount to translate the bone
  13811. * @param space The space that the translation is in
  13812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13813. */
  13814. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13815. /**
  13816. * Set the postion of the bone in local or world space
  13817. * @param position The position to set the bone
  13818. * @param space The space that the position is in
  13819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13820. */
  13821. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Set the absolute position of the bone (world space)
  13824. * @param position The position to set the bone
  13825. * @param mesh The mesh that this bone is attached to
  13826. */
  13827. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13828. /**
  13829. * Scale the bone on the x, y and z axes (in local space)
  13830. * @param x The amount to scale the bone on the x axis
  13831. * @param y The amount to scale the bone on the y axis
  13832. * @param z The amount to scale the bone on the z axis
  13833. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13834. */
  13835. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13836. /**
  13837. * Set the bone scaling in local space
  13838. * @param scale defines the scaling vector
  13839. */
  13840. setScale(scale: Vector3): void;
  13841. /**
  13842. * Gets the current scaling in local space
  13843. * @returns the current scaling vector
  13844. */
  13845. getScale(): Vector3;
  13846. /**
  13847. * Gets the current scaling in local space and stores it in a target vector
  13848. * @param result defines the target vector
  13849. */
  13850. getScaleToRef(result: Vector3): void;
  13851. /**
  13852. * Set the yaw, pitch, and roll of the bone in local or world space
  13853. * @param yaw The rotation of the bone on the y axis
  13854. * @param pitch The rotation of the bone on the x axis
  13855. * @param roll The rotation of the bone on the z axis
  13856. * @param space The space that the axes of rotation are in
  13857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13858. */
  13859. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13860. /**
  13861. * Add a rotation to the bone on an axis in local or world space
  13862. * @param axis The axis to rotate the bone on
  13863. * @param amount The amount to rotate the bone
  13864. * @param space The space that the axis is in
  13865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13866. */
  13867. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13868. /**
  13869. * Set the rotation of the bone to a particular axis angle in local or world space
  13870. * @param axis The axis to rotate the bone on
  13871. * @param angle The angle that the bone should be rotated to
  13872. * @param space The space that the axis is in
  13873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13874. */
  13875. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13876. /**
  13877. * Set the euler rotation of the bone in local of world space
  13878. * @param rotation The euler rotation that the bone should be set to
  13879. * @param space The space that the rotation is in
  13880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13881. */
  13882. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13883. /**
  13884. * Set the quaternion rotation of the bone in local of world space
  13885. * @param quat The quaternion rotation that the bone should be set to
  13886. * @param space The space that the rotation is in
  13887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13888. */
  13889. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13890. /**
  13891. * Set the rotation matrix of the bone in local of world space
  13892. * @param rotMat The rotation matrix that the bone should be set to
  13893. * @param space The space that the rotation is in
  13894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13895. */
  13896. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13897. private _rotateWithMatrix;
  13898. private _getNegativeRotationToRef;
  13899. /**
  13900. * Get the position of the bone in local or world space
  13901. * @param space The space that the returned position is in
  13902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13903. * @returns The position of the bone
  13904. */
  13905. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13906. /**
  13907. * Copy the position of the bone to a vector3 in local or world space
  13908. * @param space The space that the returned position is in
  13909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13910. * @param result The vector3 to copy the position to
  13911. */
  13912. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13913. /**
  13914. * Get the absolute position of the bone (world space)
  13915. * @param mesh The mesh that this bone is attached to
  13916. * @returns The absolute position of the bone
  13917. */
  13918. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13919. /**
  13920. * Copy the absolute position of the bone (world space) to the result param
  13921. * @param mesh The mesh that this bone is attached to
  13922. * @param result The vector3 to copy the absolute position to
  13923. */
  13924. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13925. /**
  13926. * Compute the absolute transforms of this bone and its children
  13927. */
  13928. computeAbsoluteTransforms(): void;
  13929. /**
  13930. * Get the world direction from an axis that is in the local space of the bone
  13931. * @param localAxis The local direction that is used to compute the world direction
  13932. * @param mesh The mesh that this bone is attached to
  13933. * @returns The world direction
  13934. */
  13935. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13936. /**
  13937. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13938. * @param localAxis The local direction that is used to compute the world direction
  13939. * @param mesh The mesh that this bone is attached to
  13940. * @param result The vector3 that the world direction will be copied to
  13941. */
  13942. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13943. /**
  13944. * Get the euler rotation of the bone in local or world space
  13945. * @param space The space that the rotation should be in
  13946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13947. * @returns The euler rotation
  13948. */
  13949. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13950. /**
  13951. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13952. * @param space The space that the rotation should be in
  13953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13954. * @param result The vector3 that the rotation should be copied to
  13955. */
  13956. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13957. /**
  13958. * Get the quaternion rotation of the bone in either local or world space
  13959. * @param space The space that the rotation should be in
  13960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13961. * @returns The quaternion rotation
  13962. */
  13963. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13964. /**
  13965. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13966. * @param space The space that the rotation should be in
  13967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13968. * @param result The quaternion that the rotation should be copied to
  13969. */
  13970. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13971. /**
  13972. * Get the rotation matrix of the bone in local or world space
  13973. * @param space The space that the rotation should be in
  13974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13975. * @returns The rotation matrix
  13976. */
  13977. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13978. /**
  13979. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13980. * @param space The space that the rotation should be in
  13981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13982. * @param result The quaternion that the rotation should be copied to
  13983. */
  13984. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13985. /**
  13986. * Get the world position of a point that is in the local space of the bone
  13987. * @param position The local position
  13988. * @param mesh The mesh that this bone is attached to
  13989. * @returns The world position
  13990. */
  13991. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13992. /**
  13993. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13994. * @param position The local position
  13995. * @param mesh The mesh that this bone is attached to
  13996. * @param result The vector3 that the world position should be copied to
  13997. */
  13998. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13999. /**
  14000. * Get the local position of a point that is in world space
  14001. * @param position The world position
  14002. * @param mesh The mesh that this bone is attached to
  14003. * @returns The local position
  14004. */
  14005. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14006. /**
  14007. * Get the local position of a point that is in world space and copy it to the result param
  14008. * @param position The world position
  14009. * @param mesh The mesh that this bone is attached to
  14010. * @param result The vector3 that the local position should be copied to
  14011. */
  14012. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Meshes/transformNode" {
  14016. import { DeepImmutable } from "babylonjs/types";
  14017. import { Observable } from "babylonjs/Misc/observable";
  14018. import { Nullable } from "babylonjs/types";
  14019. import { Camera } from "babylonjs/Cameras/camera";
  14020. import { Scene } from "babylonjs/scene";
  14021. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14022. import { Node } from "babylonjs/node";
  14023. import { Bone } from "babylonjs/Bones/bone";
  14024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14025. import { Space } from "babylonjs/Maths/math.axis";
  14026. /**
  14027. * 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.
  14028. * @see https://doc.babylonjs.com/how_to/transformnode
  14029. */
  14030. export class TransformNode extends Node {
  14031. /**
  14032. * Object will not rotate to face the camera
  14033. */
  14034. static BILLBOARDMODE_NONE: number;
  14035. /**
  14036. * Object will rotate to face the camera but only on the x axis
  14037. */
  14038. static BILLBOARDMODE_X: number;
  14039. /**
  14040. * Object will rotate to face the camera but only on the y axis
  14041. */
  14042. static BILLBOARDMODE_Y: number;
  14043. /**
  14044. * Object will rotate to face the camera but only on the z axis
  14045. */
  14046. static BILLBOARDMODE_Z: number;
  14047. /**
  14048. * Object will rotate to face the camera
  14049. */
  14050. static BILLBOARDMODE_ALL: number;
  14051. /**
  14052. * Object will rotate to face the camera's position instead of orientation
  14053. */
  14054. static BILLBOARDMODE_USE_POSITION: number;
  14055. private _forward;
  14056. private _forwardInverted;
  14057. private _up;
  14058. private _right;
  14059. private _rightInverted;
  14060. private _position;
  14061. private _rotation;
  14062. private _rotationQuaternion;
  14063. protected _scaling: Vector3;
  14064. protected _isDirty: boolean;
  14065. private _transformToBoneReferal;
  14066. private _isAbsoluteSynced;
  14067. private _billboardMode;
  14068. /**
  14069. * Gets or sets the billboard mode. Default is 0.
  14070. *
  14071. * | Value | Type | Description |
  14072. * | --- | --- | --- |
  14073. * | 0 | BILLBOARDMODE_NONE | |
  14074. * | 1 | BILLBOARDMODE_X | |
  14075. * | 2 | BILLBOARDMODE_Y | |
  14076. * | 4 | BILLBOARDMODE_Z | |
  14077. * | 7 | BILLBOARDMODE_ALL | |
  14078. *
  14079. */
  14080. billboardMode: number;
  14081. private _preserveParentRotationForBillboard;
  14082. /**
  14083. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14084. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14085. */
  14086. preserveParentRotationForBillboard: boolean;
  14087. /**
  14088. * 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
  14089. */
  14090. scalingDeterminant: number;
  14091. private _infiniteDistance;
  14092. /**
  14093. * Gets or sets the distance of the object to max, often used by skybox
  14094. */
  14095. infiniteDistance: boolean;
  14096. /**
  14097. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14098. * By default the system will update normals to compensate
  14099. */
  14100. ignoreNonUniformScaling: boolean;
  14101. /**
  14102. * 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
  14103. */
  14104. reIntegrateRotationIntoRotationQuaternion: boolean;
  14105. /** @hidden */
  14106. _poseMatrix: Nullable<Matrix>;
  14107. /** @hidden */
  14108. _localMatrix: Matrix;
  14109. private _usePivotMatrix;
  14110. private _absolutePosition;
  14111. private _absoluteScaling;
  14112. private _absoluteRotationQuaternion;
  14113. private _pivotMatrix;
  14114. private _pivotMatrixInverse;
  14115. protected _postMultiplyPivotMatrix: boolean;
  14116. protected _isWorldMatrixFrozen: boolean;
  14117. /** @hidden */
  14118. _indexInSceneTransformNodesArray: number;
  14119. /**
  14120. * An event triggered after the world matrix is updated
  14121. */
  14122. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14123. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14124. /**
  14125. * Gets a string identifying the name of the class
  14126. * @returns "TransformNode" string
  14127. */
  14128. getClassName(): string;
  14129. /**
  14130. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14131. */
  14132. position: Vector3;
  14133. /**
  14134. * 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)).
  14135. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14136. */
  14137. rotation: Vector3;
  14138. /**
  14139. * 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)).
  14140. */
  14141. scaling: Vector3;
  14142. /**
  14143. * 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).
  14144. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14145. */
  14146. rotationQuaternion: Nullable<Quaternion>;
  14147. /**
  14148. * The forward direction of that transform in world space.
  14149. */
  14150. readonly forward: Vector3;
  14151. /**
  14152. * The up direction of that transform in world space.
  14153. */
  14154. readonly up: Vector3;
  14155. /**
  14156. * The right direction of that transform in world space.
  14157. */
  14158. readonly right: Vector3;
  14159. /**
  14160. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14161. * @param matrix the matrix to copy the pose from
  14162. * @returns this TransformNode.
  14163. */
  14164. updatePoseMatrix(matrix: Matrix): TransformNode;
  14165. /**
  14166. * Returns the mesh Pose matrix.
  14167. * @returns the pose matrix
  14168. */
  14169. getPoseMatrix(): Matrix;
  14170. /** @hidden */
  14171. _isSynchronized(): boolean;
  14172. /** @hidden */
  14173. _initCache(): void;
  14174. /**
  14175. * Flag the transform node as dirty (Forcing it to update everything)
  14176. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14177. * @returns this transform node
  14178. */
  14179. markAsDirty(property: string): TransformNode;
  14180. /**
  14181. * Returns the current mesh absolute position.
  14182. * Returns a Vector3.
  14183. */
  14184. readonly absolutePosition: Vector3;
  14185. /**
  14186. * Returns the current mesh absolute scaling.
  14187. * Returns a Vector3.
  14188. */
  14189. readonly absoluteScaling: Vector3;
  14190. /**
  14191. * Returns the current mesh absolute rotation.
  14192. * Returns a Quaternion.
  14193. */
  14194. readonly absoluteRotationQuaternion: Quaternion;
  14195. /**
  14196. * Sets a new matrix to apply before all other transformation
  14197. * @param matrix defines the transform matrix
  14198. * @returns the current TransformNode
  14199. */
  14200. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14201. /**
  14202. * Sets a new pivot matrix to the current node
  14203. * @param matrix defines the new pivot matrix to use
  14204. * @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
  14205. * @returns the current TransformNode
  14206. */
  14207. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14208. /**
  14209. * Returns the mesh pivot matrix.
  14210. * Default : Identity.
  14211. * @returns the matrix
  14212. */
  14213. getPivotMatrix(): Matrix;
  14214. /**
  14215. * Instantiate (when possible) or clone that node with its hierarchy
  14216. * @param newParent defines the new parent to use for the instance (or clone)
  14217. * @returns an instance (or a clone) of the current node with its hiearchy
  14218. */
  14219. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14220. /**
  14221. * Prevents the World matrix to be computed any longer
  14222. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14223. * @returns the TransformNode.
  14224. */
  14225. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14226. /**
  14227. * Allows back the World matrix computation.
  14228. * @returns the TransformNode.
  14229. */
  14230. unfreezeWorldMatrix(): this;
  14231. /**
  14232. * True if the World matrix has been frozen.
  14233. */
  14234. readonly isWorldMatrixFrozen: boolean;
  14235. /**
  14236. * Retuns the mesh absolute position in the World.
  14237. * @returns a Vector3.
  14238. */
  14239. getAbsolutePosition(): Vector3;
  14240. /**
  14241. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14242. * @param absolutePosition the absolute position to set
  14243. * @returns the TransformNode.
  14244. */
  14245. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14246. /**
  14247. * Sets the mesh position in its local space.
  14248. * @param vector3 the position to set in localspace
  14249. * @returns the TransformNode.
  14250. */
  14251. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14252. /**
  14253. * Returns the mesh position in the local space from the current World matrix values.
  14254. * @returns a new Vector3.
  14255. */
  14256. getPositionExpressedInLocalSpace(): Vector3;
  14257. /**
  14258. * Translates the mesh along the passed Vector3 in its local space.
  14259. * @param vector3 the distance to translate in localspace
  14260. * @returns the TransformNode.
  14261. */
  14262. locallyTranslate(vector3: Vector3): TransformNode;
  14263. private static _lookAtVectorCache;
  14264. /**
  14265. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14266. * @param targetPoint the position (must be in same space as current mesh) to look at
  14267. * @param yawCor optional yaw (y-axis) correction in radians
  14268. * @param pitchCor optional pitch (x-axis) correction in radians
  14269. * @param rollCor optional roll (z-axis) correction in radians
  14270. * @param space the choosen space of the target
  14271. * @returns the TransformNode.
  14272. */
  14273. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14274. /**
  14275. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14276. * This Vector3 is expressed in the World space.
  14277. * @param localAxis axis to rotate
  14278. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14279. */
  14280. getDirection(localAxis: Vector3): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14283. * localAxis is expressed in the mesh local space.
  14284. * result is computed in the Wordl space from the mesh World matrix.
  14285. * @param localAxis axis to rotate
  14286. * @param result the resulting transformnode
  14287. * @returns this TransformNode.
  14288. */
  14289. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14290. /**
  14291. * Sets this transform node rotation to the given local axis.
  14292. * @param localAxis the axis in local space
  14293. * @param yawCor optional yaw (y-axis) correction in radians
  14294. * @param pitchCor optional pitch (x-axis) correction in radians
  14295. * @param rollCor optional roll (z-axis) correction in radians
  14296. * @returns this TransformNode
  14297. */
  14298. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14299. /**
  14300. * Sets a new pivot point to the current node
  14301. * @param point defines the new pivot point to use
  14302. * @param space defines if the point is in world or local space (local by default)
  14303. * @returns the current TransformNode
  14304. */
  14305. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14306. /**
  14307. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14308. * @returns the pivot point
  14309. */
  14310. getPivotPoint(): Vector3;
  14311. /**
  14312. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14313. * @param result the vector3 to store the result
  14314. * @returns this TransformNode.
  14315. */
  14316. getPivotPointToRef(result: Vector3): TransformNode;
  14317. /**
  14318. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14319. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14320. */
  14321. getAbsolutePivotPoint(): Vector3;
  14322. /**
  14323. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14324. * @param result vector3 to store the result
  14325. * @returns this TransformNode.
  14326. */
  14327. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14328. /**
  14329. * Defines the passed node as the parent of the current node.
  14330. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14331. * @see https://doc.babylonjs.com/how_to/parenting
  14332. * @param node the node ot set as the parent
  14333. * @returns this TransformNode.
  14334. */
  14335. setParent(node: Nullable<Node>): TransformNode;
  14336. private _nonUniformScaling;
  14337. /**
  14338. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14339. */
  14340. readonly nonUniformScaling: boolean;
  14341. /** @hidden */
  14342. _updateNonUniformScalingState(value: boolean): boolean;
  14343. /**
  14344. * Attach the current TransformNode to another TransformNode associated with a bone
  14345. * @param bone Bone affecting the TransformNode
  14346. * @param affectedTransformNode TransformNode associated with the bone
  14347. * @returns this object
  14348. */
  14349. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14350. /**
  14351. * Detach the transform node if its associated with a bone
  14352. * @returns this object
  14353. */
  14354. detachFromBone(): TransformNode;
  14355. private static _rotationAxisCache;
  14356. /**
  14357. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14358. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14359. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14360. * The passed axis is also normalized.
  14361. * @param axis the axis to rotate around
  14362. * @param amount the amount to rotate in radians
  14363. * @param space Space to rotate in (Default: local)
  14364. * @returns the TransformNode.
  14365. */
  14366. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14367. /**
  14368. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14369. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14370. * The passed axis is also normalized. .
  14371. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14372. * @param point the point to rotate around
  14373. * @param axis the axis to rotate around
  14374. * @param amount the amount to rotate in radians
  14375. * @returns the TransformNode
  14376. */
  14377. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14378. /**
  14379. * Translates the mesh along the axis vector for the passed distance in the given space.
  14380. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14381. * @param axis the axis to translate in
  14382. * @param distance the distance to translate
  14383. * @param space Space to rotate in (Default: local)
  14384. * @returns the TransformNode.
  14385. */
  14386. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14387. /**
  14388. * Adds a rotation step to the mesh current rotation.
  14389. * x, y, z are Euler angles expressed in radians.
  14390. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14391. * This means this rotation is made in the mesh local space only.
  14392. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14393. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14394. * ```javascript
  14395. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14396. * ```
  14397. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14398. * 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.
  14399. * @param x Rotation to add
  14400. * @param y Rotation to add
  14401. * @param z Rotation to add
  14402. * @returns the TransformNode.
  14403. */
  14404. addRotation(x: number, y: number, z: number): TransformNode;
  14405. /**
  14406. * @hidden
  14407. */
  14408. protected _getEffectiveParent(): Nullable<Node>;
  14409. /**
  14410. * Computes the world matrix of the node
  14411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14412. * @returns the world matrix
  14413. */
  14414. computeWorldMatrix(force?: boolean): Matrix;
  14415. protected _afterComputeWorldMatrix(): void;
  14416. /**
  14417. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14418. * @param func callback function to add
  14419. *
  14420. * @returns the TransformNode.
  14421. */
  14422. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14423. /**
  14424. * Removes a registered callback function.
  14425. * @param func callback function to remove
  14426. * @returns the TransformNode.
  14427. */
  14428. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14429. /**
  14430. * Gets the position of the current mesh in camera space
  14431. * @param camera defines the camera to use
  14432. * @returns a position
  14433. */
  14434. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14435. /**
  14436. * Returns the distance from the mesh to the active camera
  14437. * @param camera defines the camera to use
  14438. * @returns the distance
  14439. */
  14440. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14441. /**
  14442. * Clone the current transform node
  14443. * @param name Name of the new clone
  14444. * @param newParent New parent for the clone
  14445. * @param doNotCloneChildren Do not clone children hierarchy
  14446. * @returns the new transform node
  14447. */
  14448. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14449. /**
  14450. * Serializes the objects information.
  14451. * @param currentSerializationObject defines the object to serialize in
  14452. * @returns the serialized object
  14453. */
  14454. serialize(currentSerializationObject?: any): any;
  14455. /**
  14456. * Returns a new TransformNode object parsed from the source provided.
  14457. * @param parsedTransformNode is the source.
  14458. * @param scene the scne the object belongs to
  14459. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14460. * @returns a new TransformNode object parsed from the source provided.
  14461. */
  14462. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14463. /**
  14464. * Get all child-transformNodes of this node
  14465. * @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
  14466. * @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
  14467. * @returns an array of TransformNode
  14468. */
  14469. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14470. /**
  14471. * Releases resources associated with this transform node.
  14472. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14473. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14474. */
  14475. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14476. /**
  14477. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14478. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14479. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14480. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14481. * @returns the current mesh
  14482. */
  14483. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14484. private _syncAbsoluteScalingAndRotation;
  14485. }
  14486. }
  14487. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14488. import { Observable } from "babylonjs/Misc/observable";
  14489. import { Nullable } from "babylonjs/types";
  14490. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14493. import { Ray } from "babylonjs/Culling/ray";
  14494. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14495. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14496. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14497. /**
  14498. * Defines the types of pose enabled controllers that are supported
  14499. */
  14500. export enum PoseEnabledControllerType {
  14501. /**
  14502. * HTC Vive
  14503. */
  14504. VIVE = 0,
  14505. /**
  14506. * Oculus Rift
  14507. */
  14508. OCULUS = 1,
  14509. /**
  14510. * Windows mixed reality
  14511. */
  14512. WINDOWS = 2,
  14513. /**
  14514. * Samsung gear VR
  14515. */
  14516. GEAR_VR = 3,
  14517. /**
  14518. * Google Daydream
  14519. */
  14520. DAYDREAM = 4,
  14521. /**
  14522. * Generic
  14523. */
  14524. GENERIC = 5
  14525. }
  14526. /**
  14527. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14528. */
  14529. export interface MutableGamepadButton {
  14530. /**
  14531. * Value of the button/trigger
  14532. */
  14533. value: number;
  14534. /**
  14535. * If the button/trigger is currently touched
  14536. */
  14537. touched: boolean;
  14538. /**
  14539. * If the button/trigger is currently pressed
  14540. */
  14541. pressed: boolean;
  14542. }
  14543. /**
  14544. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14545. * @hidden
  14546. */
  14547. export interface ExtendedGamepadButton extends GamepadButton {
  14548. /**
  14549. * If the button/trigger is currently pressed
  14550. */
  14551. readonly pressed: boolean;
  14552. /**
  14553. * If the button/trigger is currently touched
  14554. */
  14555. readonly touched: boolean;
  14556. /**
  14557. * Value of the button/trigger
  14558. */
  14559. readonly value: number;
  14560. }
  14561. /** @hidden */
  14562. export interface _GamePadFactory {
  14563. /**
  14564. * Returns wether or not the current gamepad can be created for this type of controller.
  14565. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14566. * @returns true if it can be created, otherwise false
  14567. */
  14568. canCreate(gamepadInfo: any): boolean;
  14569. /**
  14570. * Creates a new instance of the Gamepad.
  14571. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14572. * @returns the new gamepad instance
  14573. */
  14574. create(gamepadInfo: any): Gamepad;
  14575. }
  14576. /**
  14577. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14578. */
  14579. export class PoseEnabledControllerHelper {
  14580. /** @hidden */
  14581. static _ControllerFactories: _GamePadFactory[];
  14582. /** @hidden */
  14583. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14584. /**
  14585. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14586. * @param vrGamepad the gamepad to initialized
  14587. * @returns a vr controller of the type the gamepad identified as
  14588. */
  14589. static InitiateController(vrGamepad: any): Gamepad;
  14590. }
  14591. /**
  14592. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14593. */
  14594. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14595. /**
  14596. * If the controller is used in a webXR session
  14597. */
  14598. isXR: boolean;
  14599. private _deviceRoomPosition;
  14600. private _deviceRoomRotationQuaternion;
  14601. /**
  14602. * The device position in babylon space
  14603. */
  14604. devicePosition: Vector3;
  14605. /**
  14606. * The device rotation in babylon space
  14607. */
  14608. deviceRotationQuaternion: Quaternion;
  14609. /**
  14610. * The scale factor of the device in babylon space
  14611. */
  14612. deviceScaleFactor: number;
  14613. /**
  14614. * (Likely devicePosition should be used instead) The device position in its room space
  14615. */
  14616. position: Vector3;
  14617. /**
  14618. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14619. */
  14620. rotationQuaternion: Quaternion;
  14621. /**
  14622. * The type of controller (Eg. Windows mixed reality)
  14623. */
  14624. controllerType: PoseEnabledControllerType;
  14625. protected _calculatedPosition: Vector3;
  14626. private _calculatedRotation;
  14627. /**
  14628. * The raw pose from the device
  14629. */
  14630. rawPose: DevicePose;
  14631. private _trackPosition;
  14632. private _maxRotationDistFromHeadset;
  14633. private _draggedRoomRotation;
  14634. /**
  14635. * @hidden
  14636. */
  14637. _disableTrackPosition(fixedPosition: Vector3): void;
  14638. /**
  14639. * Internal, the mesh attached to the controller
  14640. * @hidden
  14641. */
  14642. _mesh: Nullable<AbstractMesh>;
  14643. private _poseControlledCamera;
  14644. private _leftHandSystemQuaternion;
  14645. /**
  14646. * Internal, matrix used to convert room space to babylon space
  14647. * @hidden
  14648. */
  14649. _deviceToWorld: Matrix;
  14650. /**
  14651. * Node to be used when casting a ray from the controller
  14652. * @hidden
  14653. */
  14654. _pointingPoseNode: Nullable<TransformNode>;
  14655. /**
  14656. * Name of the child mesh that can be used to cast a ray from the controller
  14657. */
  14658. static readonly POINTING_POSE: string;
  14659. /**
  14660. * Creates a new PoseEnabledController from a gamepad
  14661. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14662. */
  14663. constructor(browserGamepad: any);
  14664. private _workingMatrix;
  14665. /**
  14666. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14667. */
  14668. update(): void;
  14669. /**
  14670. * Updates only the pose device and mesh without doing any button event checking
  14671. */
  14672. protected _updatePoseAndMesh(): void;
  14673. /**
  14674. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14675. * @param poseData raw pose fromthe device
  14676. */
  14677. updateFromDevice(poseData: DevicePose): void;
  14678. /**
  14679. * @hidden
  14680. */
  14681. _meshAttachedObservable: Observable<AbstractMesh>;
  14682. /**
  14683. * Attaches a mesh to the controller
  14684. * @param mesh the mesh to be attached
  14685. */
  14686. attachToMesh(mesh: AbstractMesh): void;
  14687. /**
  14688. * Attaches the controllers mesh to a camera
  14689. * @param camera the camera the mesh should be attached to
  14690. */
  14691. attachToPoseControlledCamera(camera: TargetCamera): void;
  14692. /**
  14693. * Disposes of the controller
  14694. */
  14695. dispose(): void;
  14696. /**
  14697. * The mesh that is attached to the controller
  14698. */
  14699. readonly mesh: Nullable<AbstractMesh>;
  14700. /**
  14701. * Gets the ray of the controller in the direction the controller is pointing
  14702. * @param length the length the resulting ray should be
  14703. * @returns a ray in the direction the controller is pointing
  14704. */
  14705. getForwardRay(length?: number): Ray;
  14706. }
  14707. }
  14708. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14709. import { Observable } from "babylonjs/Misc/observable";
  14710. import { Scene } from "babylonjs/scene";
  14711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14712. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14713. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14714. import { Nullable } from "babylonjs/types";
  14715. /**
  14716. * Defines the WebVRController object that represents controllers tracked in 3D space
  14717. */
  14718. export abstract class WebVRController extends PoseEnabledController {
  14719. /**
  14720. * Internal, the default controller model for the controller
  14721. */
  14722. protected _defaultModel: Nullable<AbstractMesh>;
  14723. /**
  14724. * Fired when the trigger state has changed
  14725. */
  14726. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14727. /**
  14728. * Fired when the main button state has changed
  14729. */
  14730. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14731. /**
  14732. * Fired when the secondary button state has changed
  14733. */
  14734. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14735. /**
  14736. * Fired when the pad state has changed
  14737. */
  14738. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14739. /**
  14740. * Fired when controllers stick values have changed
  14741. */
  14742. onPadValuesChangedObservable: Observable<StickValues>;
  14743. /**
  14744. * Array of button availible on the controller
  14745. */
  14746. protected _buttons: Array<MutableGamepadButton>;
  14747. private _onButtonStateChange;
  14748. /**
  14749. * Fired when a controller button's state has changed
  14750. * @param callback the callback containing the button that was modified
  14751. */
  14752. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14753. /**
  14754. * X and Y axis corresponding to the controllers joystick
  14755. */
  14756. pad: StickValues;
  14757. /**
  14758. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14759. */
  14760. hand: string;
  14761. /**
  14762. * The default controller model for the controller
  14763. */
  14764. readonly defaultModel: Nullable<AbstractMesh>;
  14765. /**
  14766. * Creates a new WebVRController from a gamepad
  14767. * @param vrGamepad the gamepad that the WebVRController should be created from
  14768. */
  14769. constructor(vrGamepad: any);
  14770. /**
  14771. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14772. */
  14773. update(): void;
  14774. /**
  14775. * Function to be called when a button is modified
  14776. */
  14777. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14778. /**
  14779. * Loads a mesh and attaches it to the controller
  14780. * @param scene the scene the mesh should be added to
  14781. * @param meshLoaded callback for when the mesh has been loaded
  14782. */
  14783. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14784. private _setButtonValue;
  14785. private _changes;
  14786. private _checkChanges;
  14787. /**
  14788. * Disposes of th webVRCOntroller
  14789. */
  14790. dispose(): void;
  14791. }
  14792. }
  14793. declare module "babylonjs/Lights/hemisphericLight" {
  14794. import { Nullable } from "babylonjs/types";
  14795. import { Scene } from "babylonjs/scene";
  14796. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14797. import { Color3 } from "babylonjs/Maths/math.color";
  14798. import { Effect } from "babylonjs/Materials/effect";
  14799. import { Light } from "babylonjs/Lights/light";
  14800. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14801. /**
  14802. * The HemisphericLight simulates the ambient environment light,
  14803. * so the passed direction is the light reflection direction, not the incoming direction.
  14804. */
  14805. export class HemisphericLight extends Light {
  14806. /**
  14807. * The groundColor is the light in the opposite direction to the one specified during creation.
  14808. * 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.
  14809. */
  14810. groundColor: Color3;
  14811. /**
  14812. * The light reflection direction, not the incoming direction.
  14813. */
  14814. direction: Vector3;
  14815. /**
  14816. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14817. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14818. * The HemisphericLight can't cast shadows.
  14819. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14820. * @param name The friendly name of the light
  14821. * @param direction The direction of the light reflection
  14822. * @param scene The scene the light belongs to
  14823. */
  14824. constructor(name: string, direction: Vector3, scene: Scene);
  14825. protected _buildUniformLayout(): void;
  14826. /**
  14827. * Returns the string "HemisphericLight".
  14828. * @return The class name
  14829. */
  14830. getClassName(): string;
  14831. /**
  14832. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14833. * Returns the updated direction.
  14834. * @param target The target the direction should point to
  14835. * @return The computed direction
  14836. */
  14837. setDirectionToTarget(target: Vector3): Vector3;
  14838. /**
  14839. * Returns the shadow generator associated to the light.
  14840. * @returns Always null for hemispheric lights because it does not support shadows.
  14841. */
  14842. getShadowGenerator(): Nullable<IShadowGenerator>;
  14843. /**
  14844. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14845. * @param effect The effect to update
  14846. * @param lightIndex The index of the light in the effect to update
  14847. * @returns The hemispheric light
  14848. */
  14849. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14850. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14851. /**
  14852. * Computes the world matrix of the node
  14853. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14854. * @param useWasUpdatedFlag defines a reserved property
  14855. * @returns the world matrix
  14856. */
  14857. computeWorldMatrix(): Matrix;
  14858. /**
  14859. * Returns the integer 3.
  14860. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14861. */
  14862. getTypeID(): number;
  14863. /**
  14864. * Prepares the list of defines specific to the light type.
  14865. * @param defines the list of defines
  14866. * @param lightIndex defines the index of the light for the effect
  14867. */
  14868. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14869. }
  14870. }
  14871. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14872. /** @hidden */
  14873. export var vrMultiviewToSingleviewPixelShader: {
  14874. name: string;
  14875. shader: string;
  14876. };
  14877. }
  14878. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14880. import { Scene } from "babylonjs/scene";
  14881. /**
  14882. * Renders to multiple views with a single draw call
  14883. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14884. */
  14885. export class MultiviewRenderTarget extends RenderTargetTexture {
  14886. /**
  14887. * Creates a multiview render target
  14888. * @param scene scene used with the render target
  14889. * @param size the size of the render target (used for each view)
  14890. */
  14891. constructor(scene: Scene, size?: number | {
  14892. width: number;
  14893. height: number;
  14894. } | {
  14895. ratio: number;
  14896. });
  14897. /**
  14898. * @hidden
  14899. * @param faceIndex the face index, if its a cube texture
  14900. */
  14901. _bindFrameBuffer(faceIndex?: number): void;
  14902. /**
  14903. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14904. * @returns the view count
  14905. */
  14906. getViewCount(): number;
  14907. }
  14908. }
  14909. declare module "babylonjs/Maths/math.frustum" {
  14910. import { Matrix } from "babylonjs/Maths/math.vector";
  14911. import { DeepImmutable } from "babylonjs/types";
  14912. import { Plane } from "babylonjs/Maths/math.plane";
  14913. /**
  14914. * Represents a camera frustum
  14915. */
  14916. export class Frustum {
  14917. /**
  14918. * Gets the planes representing the frustum
  14919. * @param transform matrix to be applied to the returned planes
  14920. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14921. */
  14922. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14923. /**
  14924. * Gets the near 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 GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14929. /**
  14930. * Gets the far 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 GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14935. /**
  14936. * Gets the left 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 GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14941. /**
  14942. * Gets the right 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 GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14947. /**
  14948. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14953. /**
  14954. * Gets the bottom frustum plane transformed by the transform matrix
  14955. * @param transform transformation matrix to be applied to the resulting frustum plane
  14956. * @param frustumPlane the resuling frustum plane
  14957. */
  14958. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14959. /**
  14960. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14961. * @param transform transformation matrix to be applied to the resulting frustum planes
  14962. * @param frustumPlanes the resuling frustum planes
  14963. */
  14964. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14965. }
  14966. }
  14967. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14968. import { Camera } from "babylonjs/Cameras/camera";
  14969. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14970. import { Nullable } from "babylonjs/types";
  14971. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14972. import { Matrix } from "babylonjs/Maths/math.vector";
  14973. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14974. module "babylonjs/Engines/engine" {
  14975. interface Engine {
  14976. /**
  14977. * Creates a new multiview render target
  14978. * @param width defines the width of the texture
  14979. * @param height defines the height of the texture
  14980. * @returns the created multiview texture
  14981. */
  14982. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14983. /**
  14984. * Binds a multiview framebuffer to be drawn to
  14985. * @param multiviewTexture texture to bind
  14986. */
  14987. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14988. }
  14989. }
  14990. module "babylonjs/Cameras/camera" {
  14991. interface Camera {
  14992. /**
  14993. * @hidden
  14994. * 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)
  14995. */
  14996. _useMultiviewToSingleView: boolean;
  14997. /**
  14998. * @hidden
  14999. * 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)
  15000. */
  15001. _multiviewTexture: Nullable<RenderTargetTexture>;
  15002. /**
  15003. * @hidden
  15004. * ensures the multiview texture of the camera exists and has the specified width/height
  15005. * @param width height to set on the multiview texture
  15006. * @param height width to set on the multiview texture
  15007. */
  15008. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15009. }
  15010. }
  15011. module "babylonjs/scene" {
  15012. interface Scene {
  15013. /** @hidden */
  15014. _transformMatrixR: Matrix;
  15015. /** @hidden */
  15016. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15017. /** @hidden */
  15018. _createMultiviewUbo(): void;
  15019. /** @hidden */
  15020. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15021. /** @hidden */
  15022. _renderMultiviewToSingleView(camera: Camera): void;
  15023. }
  15024. }
  15025. }
  15026. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15027. import { Camera } from "babylonjs/Cameras/camera";
  15028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15029. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15030. import "babylonjs/Engines/Extensions/engine.multiview";
  15031. /**
  15032. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15033. * This will not be used for webXR as it supports displaying texture arrays directly
  15034. */
  15035. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15036. /**
  15037. * Initializes a VRMultiviewToSingleview
  15038. * @param name name of the post process
  15039. * @param camera camera to be applied to
  15040. * @param scaleFactor scaling factor to the size of the output texture
  15041. */
  15042. constructor(name: string, camera: Camera, scaleFactor: number);
  15043. }
  15044. }
  15045. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15046. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15047. import { Nullable } from "babylonjs/types";
  15048. import { Size } from "babylonjs/Maths/math.size";
  15049. import { Observable } from "babylonjs/Misc/observable";
  15050. module "babylonjs/Engines/engine" {
  15051. interface Engine {
  15052. /** @hidden */
  15053. _vrDisplay: any;
  15054. /** @hidden */
  15055. _vrSupported: boolean;
  15056. /** @hidden */
  15057. _oldSize: Size;
  15058. /** @hidden */
  15059. _oldHardwareScaleFactor: number;
  15060. /** @hidden */
  15061. _vrExclusivePointerMode: boolean;
  15062. /** @hidden */
  15063. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15064. /** @hidden */
  15065. _onVRDisplayPointerRestricted: () => void;
  15066. /** @hidden */
  15067. _onVRDisplayPointerUnrestricted: () => void;
  15068. /** @hidden */
  15069. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15070. /** @hidden */
  15071. _onVrDisplayDisconnect: Nullable<() => void>;
  15072. /** @hidden */
  15073. _onVrDisplayPresentChange: Nullable<() => void>;
  15074. /**
  15075. * Observable signaled when VR display mode changes
  15076. */
  15077. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15078. /**
  15079. * Observable signaled when VR request present is complete
  15080. */
  15081. onVRRequestPresentComplete: Observable<boolean>;
  15082. /**
  15083. * Observable signaled when VR request present starts
  15084. */
  15085. onVRRequestPresentStart: Observable<Engine>;
  15086. /**
  15087. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15088. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15089. */
  15090. isInVRExclusivePointerMode: boolean;
  15091. /**
  15092. * Gets a boolean indicating if a webVR device was detected
  15093. * @returns true if a webVR device was detected
  15094. */
  15095. isVRDevicePresent(): boolean;
  15096. /**
  15097. * Gets the current webVR device
  15098. * @returns the current webVR device (or null)
  15099. */
  15100. getVRDevice(): any;
  15101. /**
  15102. * Initializes a webVR display and starts listening to display change events
  15103. * The onVRDisplayChangedObservable will be notified upon these changes
  15104. * @returns A promise containing a VRDisplay and if vr is supported
  15105. */
  15106. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15107. /** @hidden */
  15108. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15109. /**
  15110. * Call this function to switch to webVR mode
  15111. * Will do nothing if webVR is not supported or if there is no webVR device
  15112. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15113. */
  15114. enableVR(): void;
  15115. /** @hidden */
  15116. _onVRFullScreenTriggered(): void;
  15117. }
  15118. }
  15119. }
  15120. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15121. import { Nullable } from "babylonjs/types";
  15122. import { Observable } from "babylonjs/Misc/observable";
  15123. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15124. import { Scene } from "babylonjs/scene";
  15125. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15126. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15127. import { Node } from "babylonjs/node";
  15128. import { Ray } from "babylonjs/Culling/ray";
  15129. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15130. import "babylonjs/Engines/Extensions/engine.webVR";
  15131. /**
  15132. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15133. * IMPORTANT!! The data is right-hand data.
  15134. * @export
  15135. * @interface DevicePose
  15136. */
  15137. export interface DevicePose {
  15138. /**
  15139. * The position of the device, values in array are [x,y,z].
  15140. */
  15141. readonly position: Nullable<Float32Array>;
  15142. /**
  15143. * The linearVelocity of the device, values in array are [x,y,z].
  15144. */
  15145. readonly linearVelocity: Nullable<Float32Array>;
  15146. /**
  15147. * The linearAcceleration of the device, values in array are [x,y,z].
  15148. */
  15149. readonly linearAcceleration: Nullable<Float32Array>;
  15150. /**
  15151. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15152. */
  15153. readonly orientation: Nullable<Float32Array>;
  15154. /**
  15155. * The angularVelocity of the device, values in array are [x,y,z].
  15156. */
  15157. readonly angularVelocity: Nullable<Float32Array>;
  15158. /**
  15159. * The angularAcceleration of the device, values in array are [x,y,z].
  15160. */
  15161. readonly angularAcceleration: Nullable<Float32Array>;
  15162. }
  15163. /**
  15164. * Interface representing a pose controlled object in Babylon.
  15165. * A pose controlled object has both regular pose values as well as pose values
  15166. * from an external device such as a VR head mounted display
  15167. */
  15168. export interface PoseControlled {
  15169. /**
  15170. * The position of the object in babylon space.
  15171. */
  15172. position: Vector3;
  15173. /**
  15174. * The rotation quaternion of the object in babylon space.
  15175. */
  15176. rotationQuaternion: Quaternion;
  15177. /**
  15178. * The position of the device in babylon space.
  15179. */
  15180. devicePosition?: Vector3;
  15181. /**
  15182. * The rotation quaternion of the device in babylon space.
  15183. */
  15184. deviceRotationQuaternion: Quaternion;
  15185. /**
  15186. * The raw pose coming from the device.
  15187. */
  15188. rawPose: Nullable<DevicePose>;
  15189. /**
  15190. * The scale of the device to be used when translating from device space to babylon space.
  15191. */
  15192. deviceScaleFactor: number;
  15193. /**
  15194. * Updates the poseControlled values based on the input device pose.
  15195. * @param poseData the pose data to update the object with
  15196. */
  15197. updateFromDevice(poseData: DevicePose): void;
  15198. }
  15199. /**
  15200. * Set of options to customize the webVRCamera
  15201. */
  15202. export interface WebVROptions {
  15203. /**
  15204. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15205. */
  15206. trackPosition?: boolean;
  15207. /**
  15208. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15209. */
  15210. positionScale?: number;
  15211. /**
  15212. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15213. */
  15214. displayName?: string;
  15215. /**
  15216. * Should the native controller meshes be initialized. (default: true)
  15217. */
  15218. controllerMeshes?: boolean;
  15219. /**
  15220. * Creating a default HemiLight only on controllers. (default: true)
  15221. */
  15222. defaultLightingOnControllers?: boolean;
  15223. /**
  15224. * If you don't want to use the default VR button of the helper. (default: false)
  15225. */
  15226. useCustomVRButton?: boolean;
  15227. /**
  15228. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15229. */
  15230. customVRButton?: HTMLButtonElement;
  15231. /**
  15232. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15233. */
  15234. rayLength?: number;
  15235. /**
  15236. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15237. */
  15238. defaultHeight?: number;
  15239. /**
  15240. * If multiview should be used if availible (default: false)
  15241. */
  15242. useMultiview?: boolean;
  15243. }
  15244. /**
  15245. * This represents a WebVR camera.
  15246. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15247. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15248. */
  15249. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15250. private webVROptions;
  15251. /**
  15252. * @hidden
  15253. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15254. */
  15255. _vrDevice: any;
  15256. /**
  15257. * The rawPose of the vrDevice.
  15258. */
  15259. rawPose: Nullable<DevicePose>;
  15260. private _onVREnabled;
  15261. private _specsVersion;
  15262. private _attached;
  15263. private _frameData;
  15264. protected _descendants: Array<Node>;
  15265. private _deviceRoomPosition;
  15266. /** @hidden */
  15267. _deviceRoomRotationQuaternion: Quaternion;
  15268. private _standingMatrix;
  15269. /**
  15270. * Represents device position in babylon space.
  15271. */
  15272. devicePosition: Vector3;
  15273. /**
  15274. * Represents device rotation in babylon space.
  15275. */
  15276. deviceRotationQuaternion: Quaternion;
  15277. /**
  15278. * The scale of the device to be used when translating from device space to babylon space.
  15279. */
  15280. deviceScaleFactor: number;
  15281. private _deviceToWorld;
  15282. private _worldToDevice;
  15283. /**
  15284. * References to the webVR controllers for the vrDevice.
  15285. */
  15286. controllers: Array<WebVRController>;
  15287. /**
  15288. * Emits an event when a controller is attached.
  15289. */
  15290. onControllersAttachedObservable: Observable<WebVRController[]>;
  15291. /**
  15292. * Emits an event when a controller's mesh has been loaded;
  15293. */
  15294. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15295. /**
  15296. * Emits an event when the HMD's pose has been updated.
  15297. */
  15298. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15299. private _poseSet;
  15300. /**
  15301. * If the rig cameras be used as parent instead of this camera.
  15302. */
  15303. rigParenting: boolean;
  15304. private _lightOnControllers;
  15305. private _defaultHeight?;
  15306. /**
  15307. * Instantiates a WebVRFreeCamera.
  15308. * @param name The name of the WebVRFreeCamera
  15309. * @param position The starting anchor position for the camera
  15310. * @param scene The scene the camera belongs to
  15311. * @param webVROptions a set of customizable options for the webVRCamera
  15312. */
  15313. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15314. /**
  15315. * Gets the device distance from the ground in meters.
  15316. * @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.
  15317. */
  15318. deviceDistanceToRoomGround(): number;
  15319. /**
  15320. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15321. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15322. */
  15323. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15324. /**
  15325. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15326. * @returns A promise with a boolean set to if the standing matrix is supported.
  15327. */
  15328. useStandingMatrixAsync(): Promise<boolean>;
  15329. /**
  15330. * Disposes the camera
  15331. */
  15332. dispose(): void;
  15333. /**
  15334. * Gets a vrController by name.
  15335. * @param name The name of the controller to retreive
  15336. * @returns the controller matching the name specified or null if not found
  15337. */
  15338. getControllerByName(name: string): Nullable<WebVRController>;
  15339. private _leftController;
  15340. /**
  15341. * The controller corresponding to the users left hand.
  15342. */
  15343. readonly leftController: Nullable<WebVRController>;
  15344. private _rightController;
  15345. /**
  15346. * The controller corresponding to the users right hand.
  15347. */
  15348. readonly rightController: Nullable<WebVRController>;
  15349. /**
  15350. * Casts a ray forward from the vrCamera's gaze.
  15351. * @param length Length of the ray (default: 100)
  15352. * @returns the ray corresponding to the gaze
  15353. */
  15354. getForwardRay(length?: number): Ray;
  15355. /**
  15356. * @hidden
  15357. * Updates the camera based on device's frame data
  15358. */
  15359. _checkInputs(): void;
  15360. /**
  15361. * Updates the poseControlled values based on the input device pose.
  15362. * @param poseData Pose coming from the device
  15363. */
  15364. updateFromDevice(poseData: DevicePose): void;
  15365. private _htmlElementAttached;
  15366. private _detachIfAttached;
  15367. /**
  15368. * WebVR's attach control will start broadcasting frames to the device.
  15369. * Note that in certain browsers (chrome for example) this function must be called
  15370. * within a user-interaction callback. Example:
  15371. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15372. *
  15373. * @param element html element to attach the vrDevice to
  15374. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15375. */
  15376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15377. /**
  15378. * Detaches the camera from the html element and disables VR
  15379. *
  15380. * @param element html element to detach from
  15381. */
  15382. detachControl(element: HTMLElement): void;
  15383. /**
  15384. * @returns the name of this class
  15385. */
  15386. getClassName(): string;
  15387. /**
  15388. * Calls resetPose on the vrDisplay
  15389. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15390. */
  15391. resetToCurrentRotation(): void;
  15392. /**
  15393. * @hidden
  15394. * Updates the rig cameras (left and right eye)
  15395. */
  15396. _updateRigCameras(): void;
  15397. private _workingVector;
  15398. private _oneVector;
  15399. private _workingMatrix;
  15400. private updateCacheCalled;
  15401. private _correctPositionIfNotTrackPosition;
  15402. /**
  15403. * @hidden
  15404. * Updates the cached values of the camera
  15405. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15406. */
  15407. _updateCache(ignoreParentClass?: boolean): void;
  15408. /**
  15409. * @hidden
  15410. * Get current device position in babylon world
  15411. */
  15412. _computeDevicePosition(): void;
  15413. /**
  15414. * Updates the current device position and rotation in the babylon world
  15415. */
  15416. update(): void;
  15417. /**
  15418. * @hidden
  15419. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15420. * @returns an identity matrix
  15421. */
  15422. _getViewMatrix(): Matrix;
  15423. private _tmpMatrix;
  15424. /**
  15425. * This function is called by the two RIG cameras.
  15426. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15427. * @hidden
  15428. */
  15429. _getWebVRViewMatrix(): Matrix;
  15430. /** @hidden */
  15431. _getWebVRProjectionMatrix(): Matrix;
  15432. private _onGamepadConnectedObserver;
  15433. private _onGamepadDisconnectedObserver;
  15434. private _updateCacheWhenTrackingDisabledObserver;
  15435. /**
  15436. * Initializes the controllers and their meshes
  15437. */
  15438. initControllers(): void;
  15439. }
  15440. }
  15441. declare module "babylonjs/PostProcesses/postProcess" {
  15442. import { Nullable } from "babylonjs/types";
  15443. import { SmartArray } from "babylonjs/Misc/smartArray";
  15444. import { Observable } from "babylonjs/Misc/observable";
  15445. import { Vector2 } from "babylonjs/Maths/math.vector";
  15446. import { Camera } from "babylonjs/Cameras/camera";
  15447. import { Effect } from "babylonjs/Materials/effect";
  15448. import "babylonjs/Shaders/postprocess.vertex";
  15449. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15450. import { Engine } from "babylonjs/Engines/engine";
  15451. import { Color4 } from "babylonjs/Maths/math.color";
  15452. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15454. /**
  15455. * Size options for a post process
  15456. */
  15457. export type PostProcessOptions = {
  15458. width: number;
  15459. height: number;
  15460. };
  15461. /**
  15462. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15463. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15464. */
  15465. export class PostProcess {
  15466. /** Name of the PostProcess. */
  15467. name: string;
  15468. /**
  15469. * Gets or sets the unique id of the post process
  15470. */
  15471. uniqueId: number;
  15472. /**
  15473. * Width of the texture to apply the post process on
  15474. */
  15475. width: number;
  15476. /**
  15477. * Height of the texture to apply the post process on
  15478. */
  15479. height: number;
  15480. /**
  15481. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15482. * @hidden
  15483. */
  15484. _outputTexture: Nullable<InternalTexture>;
  15485. /**
  15486. * Sampling mode used by the shader
  15487. * See https://doc.babylonjs.com/classes/3.1/texture
  15488. */
  15489. renderTargetSamplingMode: number;
  15490. /**
  15491. * Clear color to use when screen clearing
  15492. */
  15493. clearColor: Color4;
  15494. /**
  15495. * If the buffer needs to be cleared before applying the post process. (default: true)
  15496. * Should be set to false if shader will overwrite all previous pixels.
  15497. */
  15498. autoClear: boolean;
  15499. /**
  15500. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15501. */
  15502. alphaMode: number;
  15503. /**
  15504. * Sets the setAlphaBlendConstants of the babylon engine
  15505. */
  15506. alphaConstants: Color4;
  15507. /**
  15508. * Animations to be used for the post processing
  15509. */
  15510. animations: import("babylonjs/Animations/animation").Animation[];
  15511. /**
  15512. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15513. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15514. */
  15515. enablePixelPerfectMode: boolean;
  15516. /**
  15517. * Force the postprocess to be applied without taking in account viewport
  15518. */
  15519. forceFullscreenViewport: boolean;
  15520. /**
  15521. * List of inspectable custom properties (used by the Inspector)
  15522. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15523. */
  15524. inspectableCustomProperties: IInspectable[];
  15525. /**
  15526. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15527. *
  15528. * | Value | Type | Description |
  15529. * | ----- | ----------------------------------- | ----------- |
  15530. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15531. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15532. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15533. *
  15534. */
  15535. scaleMode: number;
  15536. /**
  15537. * Force textures to be a power of two (default: false)
  15538. */
  15539. alwaysForcePOT: boolean;
  15540. private _samples;
  15541. /**
  15542. * Number of sample textures (default: 1)
  15543. */
  15544. samples: number;
  15545. /**
  15546. * Modify the scale of the post process to be the same as the viewport (default: false)
  15547. */
  15548. adaptScaleToCurrentViewport: boolean;
  15549. private _camera;
  15550. private _scene;
  15551. private _engine;
  15552. private _options;
  15553. private _reusable;
  15554. private _textureType;
  15555. /**
  15556. * Smart array of input and output textures for the post process.
  15557. * @hidden
  15558. */
  15559. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15560. /**
  15561. * The index in _textures that corresponds to the output texture.
  15562. * @hidden
  15563. */
  15564. _currentRenderTextureInd: number;
  15565. private _effect;
  15566. private _samplers;
  15567. private _fragmentUrl;
  15568. private _vertexUrl;
  15569. private _parameters;
  15570. private _scaleRatio;
  15571. protected _indexParameters: any;
  15572. private _shareOutputWithPostProcess;
  15573. private _texelSize;
  15574. private _forcedOutputTexture;
  15575. /**
  15576. * Returns the fragment url or shader name used in the post process.
  15577. * @returns the fragment url or name in the shader store.
  15578. */
  15579. getEffectName(): string;
  15580. /**
  15581. * An event triggered when the postprocess is activated.
  15582. */
  15583. onActivateObservable: Observable<Camera>;
  15584. private _onActivateObserver;
  15585. /**
  15586. * A function that is added to the onActivateObservable
  15587. */
  15588. onActivate: Nullable<(camera: Camera) => void>;
  15589. /**
  15590. * An event triggered when the postprocess changes its size.
  15591. */
  15592. onSizeChangedObservable: Observable<PostProcess>;
  15593. private _onSizeChangedObserver;
  15594. /**
  15595. * A function that is added to the onSizeChangedObservable
  15596. */
  15597. onSizeChanged: (postProcess: PostProcess) => void;
  15598. /**
  15599. * An event triggered when the postprocess applies its effect.
  15600. */
  15601. onApplyObservable: Observable<Effect>;
  15602. private _onApplyObserver;
  15603. /**
  15604. * A function that is added to the onApplyObservable
  15605. */
  15606. onApply: (effect: Effect) => void;
  15607. /**
  15608. * An event triggered before rendering the postprocess
  15609. */
  15610. onBeforeRenderObservable: Observable<Effect>;
  15611. private _onBeforeRenderObserver;
  15612. /**
  15613. * A function that is added to the onBeforeRenderObservable
  15614. */
  15615. onBeforeRender: (effect: Effect) => void;
  15616. /**
  15617. * An event triggered after rendering the postprocess
  15618. */
  15619. onAfterRenderObservable: Observable<Effect>;
  15620. private _onAfterRenderObserver;
  15621. /**
  15622. * A function that is added to the onAfterRenderObservable
  15623. */
  15624. onAfterRender: (efect: Effect) => void;
  15625. /**
  15626. * 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
  15627. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15628. */
  15629. inputTexture: InternalTexture;
  15630. /**
  15631. * Gets the camera which post process is applied to.
  15632. * @returns The camera the post process is applied to.
  15633. */
  15634. getCamera(): Camera;
  15635. /**
  15636. * Gets the texel size of the postprocess.
  15637. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15638. */
  15639. readonly texelSize: Vector2;
  15640. /**
  15641. * Creates a new instance PostProcess
  15642. * @param name The name of the PostProcess.
  15643. * @param fragmentUrl The url of the fragment shader to be used.
  15644. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15645. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15646. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15647. * @param camera The camera to apply the render pass to.
  15648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15649. * @param engine The engine which the post process will be applied. (default: current engine)
  15650. * @param reusable If the post process can be reused on the same frame. (default: false)
  15651. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15652. * @param textureType Type of textures used when performing the post process. (default: 0)
  15653. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15654. * @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
  15655. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15656. */
  15657. constructor(
  15658. /** Name of the PostProcess. */
  15659. 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);
  15660. /**
  15661. * Gets a string idenfifying the name of the class
  15662. * @returns "PostProcess" string
  15663. */
  15664. getClassName(): string;
  15665. /**
  15666. * Gets the engine which this post process belongs to.
  15667. * @returns The engine the post process was enabled with.
  15668. */
  15669. getEngine(): Engine;
  15670. /**
  15671. * The effect that is created when initializing the post process.
  15672. * @returns The created effect corresponding the the postprocess.
  15673. */
  15674. getEffect(): Effect;
  15675. /**
  15676. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15677. * @param postProcess The post process to share the output with.
  15678. * @returns This post process.
  15679. */
  15680. shareOutputWith(postProcess: PostProcess): PostProcess;
  15681. /**
  15682. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15683. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15684. */
  15685. useOwnOutput(): void;
  15686. /**
  15687. * Updates the effect with the current post process compile time values and recompiles the shader.
  15688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15691. * @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
  15692. * @param onCompiled Called when the shader has been compiled.
  15693. * @param onError Called if there is an error when compiling a shader.
  15694. */
  15695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15696. /**
  15697. * The post process is reusable if it can be used multiple times within one frame.
  15698. * @returns If the post process is reusable
  15699. */
  15700. isReusable(): boolean;
  15701. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15702. markTextureDirty(): void;
  15703. /**
  15704. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15705. * 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.
  15706. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15707. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15708. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15709. * @returns The target texture that was bound to be written to.
  15710. */
  15711. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15712. /**
  15713. * If the post process is supported.
  15714. */
  15715. readonly isSupported: boolean;
  15716. /**
  15717. * The aspect ratio of the output texture.
  15718. */
  15719. readonly aspectRatio: number;
  15720. /**
  15721. * Get a value indicating if the post-process is ready to be used
  15722. * @returns true if the post-process is ready (shader is compiled)
  15723. */
  15724. isReady(): boolean;
  15725. /**
  15726. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15727. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15728. */
  15729. apply(): Nullable<Effect>;
  15730. private _disposeTextures;
  15731. /**
  15732. * Disposes the post process.
  15733. * @param camera The camera to dispose the post process on.
  15734. */
  15735. dispose(camera?: Camera): void;
  15736. }
  15737. }
  15738. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15739. /** @hidden */
  15740. export var kernelBlurVaryingDeclaration: {
  15741. name: string;
  15742. shader: string;
  15743. };
  15744. }
  15745. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15746. /** @hidden */
  15747. export var kernelBlurFragment: {
  15748. name: string;
  15749. shader: string;
  15750. };
  15751. }
  15752. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15753. /** @hidden */
  15754. export var kernelBlurFragment2: {
  15755. name: string;
  15756. shader: string;
  15757. };
  15758. }
  15759. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15760. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15761. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15762. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15763. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15764. /** @hidden */
  15765. export var kernelBlurPixelShader: {
  15766. name: string;
  15767. shader: string;
  15768. };
  15769. }
  15770. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15771. /** @hidden */
  15772. export var kernelBlurVertex: {
  15773. name: string;
  15774. shader: string;
  15775. };
  15776. }
  15777. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15778. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15779. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15780. /** @hidden */
  15781. export var kernelBlurVertexShader: {
  15782. name: string;
  15783. shader: string;
  15784. };
  15785. }
  15786. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15787. import { Vector2 } from "babylonjs/Maths/math.vector";
  15788. import { Nullable } from "babylonjs/types";
  15789. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15790. import { Camera } from "babylonjs/Cameras/camera";
  15791. import { Effect } from "babylonjs/Materials/effect";
  15792. import { Engine } from "babylonjs/Engines/engine";
  15793. import "babylonjs/Shaders/kernelBlur.fragment";
  15794. import "babylonjs/Shaders/kernelBlur.vertex";
  15795. /**
  15796. * The Blur Post Process which blurs an image based on a kernel and direction.
  15797. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15798. */
  15799. export class BlurPostProcess extends PostProcess {
  15800. /** The direction in which to blur the image. */
  15801. direction: Vector2;
  15802. private blockCompilation;
  15803. protected _kernel: number;
  15804. protected _idealKernel: number;
  15805. protected _packedFloat: boolean;
  15806. private _staticDefines;
  15807. /**
  15808. * Sets the length in pixels of the blur sample region
  15809. */
  15810. /**
  15811. * Gets the length in pixels of the blur sample region
  15812. */
  15813. kernel: number;
  15814. /**
  15815. * Sets wether or not the blur needs to unpack/repack floats
  15816. */
  15817. /**
  15818. * Gets wether or not the blur is unpacking/repacking floats
  15819. */
  15820. packedFloat: boolean;
  15821. /**
  15822. * Creates a new instance BlurPostProcess
  15823. * @param name The name of the effect.
  15824. * @param direction The direction in which to blur the image.
  15825. * @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.
  15826. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15827. * @param camera The camera to apply the render pass to.
  15828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15829. * @param engine The engine which the post process will be applied. (default: current engine)
  15830. * @param reusable If the post process can be reused on the same frame. (default: false)
  15831. * @param textureType Type of textures used when performing the post process. (default: 0)
  15832. * @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)
  15833. */
  15834. constructor(name: string,
  15835. /** The direction in which to blur the image. */
  15836. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15837. /**
  15838. * Updates the effect with the current post process compile time values and recompiles the shader.
  15839. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15840. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15841. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15842. * @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
  15843. * @param onCompiled Called when the shader has been compiled.
  15844. * @param onError Called if there is an error when compiling a shader.
  15845. */
  15846. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15847. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15848. /**
  15849. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15850. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15851. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15852. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15853. * The gaps between physical kernels are compensated for in the weighting of the samples
  15854. * @param idealKernel Ideal blur kernel.
  15855. * @return Nearest best kernel.
  15856. */
  15857. protected _nearestBestKernel(idealKernel: number): number;
  15858. /**
  15859. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15860. * @param x The point on the Gaussian distribution to sample.
  15861. * @return the value of the Gaussian function at x.
  15862. */
  15863. protected _gaussianWeight(x: number): number;
  15864. /**
  15865. * Generates a string that can be used as a floating point number in GLSL.
  15866. * @param x Value to print.
  15867. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15868. * @return GLSL float string.
  15869. */
  15870. protected _glslFloat(x: number, decimalFigures?: number): string;
  15871. }
  15872. }
  15873. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15874. import { Scene } from "babylonjs/scene";
  15875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15876. import { Plane } from "babylonjs/Maths/math.plane";
  15877. /**
  15878. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15879. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15880. * You can then easily use it as a reflectionTexture on a flat surface.
  15881. * In case the surface is not a plane, please consider relying on reflection probes.
  15882. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15883. */
  15884. export class MirrorTexture extends RenderTargetTexture {
  15885. private scene;
  15886. /**
  15887. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15888. * 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.
  15889. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15890. */
  15891. mirrorPlane: Plane;
  15892. /**
  15893. * Define the blur ratio used to blur the reflection if needed.
  15894. */
  15895. blurRatio: number;
  15896. /**
  15897. * Define the adaptive blur kernel used to blur the reflection if needed.
  15898. * This will autocompute the closest best match for the `blurKernel`
  15899. */
  15900. adaptiveBlurKernel: number;
  15901. /**
  15902. * Define the blur kernel used to blur the reflection if needed.
  15903. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15904. */
  15905. blurKernel: number;
  15906. /**
  15907. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15908. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15909. */
  15910. blurKernelX: number;
  15911. /**
  15912. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15913. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15914. */
  15915. blurKernelY: number;
  15916. private _autoComputeBlurKernel;
  15917. protected _onRatioRescale(): void;
  15918. private _updateGammaSpace;
  15919. private _imageProcessingConfigChangeObserver;
  15920. private _transformMatrix;
  15921. private _mirrorMatrix;
  15922. private _savedViewMatrix;
  15923. private _blurX;
  15924. private _blurY;
  15925. private _adaptiveBlurKernel;
  15926. private _blurKernelX;
  15927. private _blurKernelY;
  15928. private _blurRatio;
  15929. /**
  15930. * Instantiates a Mirror Texture.
  15931. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15932. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15933. * You can then easily use it as a reflectionTexture on a flat surface.
  15934. * In case the surface is not a plane, please consider relying on reflection probes.
  15935. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15936. * @param name
  15937. * @param size
  15938. * @param scene
  15939. * @param generateMipMaps
  15940. * @param type
  15941. * @param samplingMode
  15942. * @param generateDepthBuffer
  15943. */
  15944. constructor(name: string, size: number | {
  15945. width: number;
  15946. height: number;
  15947. } | {
  15948. ratio: number;
  15949. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15950. private _preparePostProcesses;
  15951. /**
  15952. * Clone the mirror texture.
  15953. * @returns the cloned texture
  15954. */
  15955. clone(): MirrorTexture;
  15956. /**
  15957. * Serialize the texture to a JSON representation you could use in Parse later on
  15958. * @returns the serialized JSON representation
  15959. */
  15960. serialize(): any;
  15961. /**
  15962. * Dispose the texture and release its associated resources.
  15963. */
  15964. dispose(): void;
  15965. }
  15966. }
  15967. declare module "babylonjs/Materials/Textures/texture" {
  15968. import { Observable } from "babylonjs/Misc/observable";
  15969. import { Nullable } from "babylonjs/types";
  15970. import { Matrix } from "babylonjs/Maths/math.vector";
  15971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15972. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15973. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15974. import { Scene } from "babylonjs/scene";
  15975. /**
  15976. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15977. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15978. */
  15979. export class Texture extends BaseTexture {
  15980. /**
  15981. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15982. */
  15983. static SerializeBuffers: boolean;
  15984. /** @hidden */
  15985. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15986. /** @hidden */
  15987. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15988. /** @hidden */
  15989. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15990. /** nearest is mag = nearest and min = nearest and mip = linear */
  15991. static readonly NEAREST_SAMPLINGMODE: number;
  15992. /** nearest is mag = nearest and min = nearest and mip = linear */
  15993. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15994. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15995. static readonly BILINEAR_SAMPLINGMODE: number;
  15996. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15997. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15998. /** Trilinear is mag = linear and min = linear and mip = linear */
  15999. static readonly TRILINEAR_SAMPLINGMODE: number;
  16000. /** Trilinear is mag = linear and min = linear and mip = linear */
  16001. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16002. /** mag = nearest and min = nearest and mip = nearest */
  16003. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16004. /** mag = nearest and min = linear and mip = nearest */
  16005. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16006. /** mag = nearest and min = linear and mip = linear */
  16007. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16008. /** mag = nearest and min = linear and mip = none */
  16009. static readonly NEAREST_LINEAR: number;
  16010. /** mag = nearest and min = nearest and mip = none */
  16011. static readonly NEAREST_NEAREST: number;
  16012. /** mag = linear and min = nearest and mip = nearest */
  16013. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16014. /** mag = linear and min = nearest and mip = linear */
  16015. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16016. /** mag = linear and min = linear and mip = none */
  16017. static readonly LINEAR_LINEAR: number;
  16018. /** mag = linear and min = nearest and mip = none */
  16019. static readonly LINEAR_NEAREST: number;
  16020. /** Explicit coordinates mode */
  16021. static readonly EXPLICIT_MODE: number;
  16022. /** Spherical coordinates mode */
  16023. static readonly SPHERICAL_MODE: number;
  16024. /** Planar coordinates mode */
  16025. static readonly PLANAR_MODE: number;
  16026. /** Cubic coordinates mode */
  16027. static readonly CUBIC_MODE: number;
  16028. /** Projection coordinates mode */
  16029. static readonly PROJECTION_MODE: number;
  16030. /** Inverse Cubic coordinates mode */
  16031. static readonly SKYBOX_MODE: number;
  16032. /** Inverse Cubic coordinates mode */
  16033. static readonly INVCUBIC_MODE: number;
  16034. /** Equirectangular coordinates mode */
  16035. static readonly EQUIRECTANGULAR_MODE: number;
  16036. /** Equirectangular Fixed coordinates mode */
  16037. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16038. /** Equirectangular Fixed Mirrored coordinates mode */
  16039. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16040. /** Texture is not repeating outside of 0..1 UVs */
  16041. static readonly CLAMP_ADDRESSMODE: number;
  16042. /** Texture is repeating outside of 0..1 UVs */
  16043. static readonly WRAP_ADDRESSMODE: number;
  16044. /** Texture is repeating and mirrored */
  16045. static readonly MIRROR_ADDRESSMODE: number;
  16046. /**
  16047. * 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
  16048. */
  16049. static UseSerializedUrlIfAny: boolean;
  16050. /**
  16051. * Define the url of the texture.
  16052. */
  16053. url: Nullable<string>;
  16054. /**
  16055. * Define an offset on the texture to offset the u coordinates of the UVs
  16056. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16057. */
  16058. uOffset: number;
  16059. /**
  16060. * Define an offset on the texture to offset the v coordinates of the UVs
  16061. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16062. */
  16063. vOffset: number;
  16064. /**
  16065. * Define an offset on the texture to scale the u coordinates of the UVs
  16066. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16067. */
  16068. uScale: number;
  16069. /**
  16070. * Define an offset on the texture to scale the v coordinates of the UVs
  16071. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16072. */
  16073. vScale: number;
  16074. /**
  16075. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16076. * @see http://doc.babylonjs.com/how_to/more_materials
  16077. */
  16078. uAng: number;
  16079. /**
  16080. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16081. * @see http://doc.babylonjs.com/how_to/more_materials
  16082. */
  16083. vAng: number;
  16084. /**
  16085. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16086. * @see http://doc.babylonjs.com/how_to/more_materials
  16087. */
  16088. wAng: number;
  16089. /**
  16090. * Defines the center of rotation (U)
  16091. */
  16092. uRotationCenter: number;
  16093. /**
  16094. * Defines the center of rotation (V)
  16095. */
  16096. vRotationCenter: number;
  16097. /**
  16098. * Defines the center of rotation (W)
  16099. */
  16100. wRotationCenter: number;
  16101. /**
  16102. * Are mip maps generated for this texture or not.
  16103. */
  16104. readonly noMipmap: boolean;
  16105. /**
  16106. * List of inspectable custom properties (used by the Inspector)
  16107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16108. */
  16109. inspectableCustomProperties: Nullable<IInspectable[]>;
  16110. private _noMipmap;
  16111. /** @hidden */
  16112. _invertY: boolean;
  16113. private _rowGenerationMatrix;
  16114. private _cachedTextureMatrix;
  16115. private _projectionModeMatrix;
  16116. private _t0;
  16117. private _t1;
  16118. private _t2;
  16119. private _cachedUOffset;
  16120. private _cachedVOffset;
  16121. private _cachedUScale;
  16122. private _cachedVScale;
  16123. private _cachedUAng;
  16124. private _cachedVAng;
  16125. private _cachedWAng;
  16126. private _cachedProjectionMatrixId;
  16127. private _cachedCoordinatesMode;
  16128. /** @hidden */
  16129. protected _initialSamplingMode: number;
  16130. /** @hidden */
  16131. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16132. private _deleteBuffer;
  16133. protected _format: Nullable<number>;
  16134. private _delayedOnLoad;
  16135. private _delayedOnError;
  16136. private _mimeType?;
  16137. /**
  16138. * Observable triggered once the texture has been loaded.
  16139. */
  16140. onLoadObservable: Observable<Texture>;
  16141. protected _isBlocking: boolean;
  16142. /**
  16143. * Is the texture preventing material to render while loading.
  16144. * If false, a default texture will be used instead of the loading one during the preparation step.
  16145. */
  16146. isBlocking: boolean;
  16147. /**
  16148. * Get the current sampling mode associated with the texture.
  16149. */
  16150. readonly samplingMode: number;
  16151. /**
  16152. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16153. */
  16154. readonly invertY: boolean;
  16155. /**
  16156. * Instantiates a new texture.
  16157. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16158. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16159. * @param url defines the url of the picture to load as a texture
  16160. * @param scene defines the scene or engine the texture will belong to
  16161. * @param noMipmap defines if the texture will require mip maps or not
  16162. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16163. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16164. * @param onLoad defines a callback triggered when the texture has been loaded
  16165. * @param onError defines a callback triggered when an error occurred during the loading session
  16166. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16167. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16168. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16169. * @param mimeType defines an optional mime type information
  16170. */
  16171. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16172. /**
  16173. * Update the url (and optional buffer) of this texture if url was null during construction.
  16174. * @param url the url of the texture
  16175. * @param buffer the buffer of the texture (defaults to null)
  16176. * @param onLoad callback called when the texture is loaded (defaults to null)
  16177. */
  16178. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16179. /**
  16180. * Finish the loading sequence of a texture flagged as delayed load.
  16181. * @hidden
  16182. */
  16183. delayLoad(): void;
  16184. private _prepareRowForTextureGeneration;
  16185. /**
  16186. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16187. * @returns the transform matrix of the texture.
  16188. */
  16189. getTextureMatrix(): Matrix;
  16190. /**
  16191. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16192. * @returns The reflection texture transform
  16193. */
  16194. getReflectionTextureMatrix(): Matrix;
  16195. /**
  16196. * Clones the texture.
  16197. * @returns the cloned texture
  16198. */
  16199. clone(): Texture;
  16200. /**
  16201. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16202. * @returns The JSON representation of the texture
  16203. */
  16204. serialize(): any;
  16205. /**
  16206. * Get the current class name of the texture useful for serialization or dynamic coding.
  16207. * @returns "Texture"
  16208. */
  16209. getClassName(): string;
  16210. /**
  16211. * Dispose the texture and release its associated resources.
  16212. */
  16213. dispose(): void;
  16214. /**
  16215. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16216. * @param parsedTexture Define the JSON representation of the texture
  16217. * @param scene Define the scene the parsed texture should be instantiated in
  16218. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16219. * @returns The parsed texture if successful
  16220. */
  16221. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16222. /**
  16223. * Creates a texture from its base 64 representation.
  16224. * @param data Define the base64 payload without the data: prefix
  16225. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16226. * @param scene Define the scene the texture should belong to
  16227. * @param noMipmap Forces the texture to not create mip map information if true
  16228. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16229. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16230. * @param onLoad define a callback triggered when the texture has been loaded
  16231. * @param onError define a callback triggered when an error occurred during the loading session
  16232. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16233. * @returns the created texture
  16234. */
  16235. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16236. /**
  16237. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16238. * @param data Define the base64 payload without the data: prefix
  16239. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16240. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16241. * @param scene Define the scene the texture should belong to
  16242. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16243. * @param noMipmap Forces the texture to not create mip map information if true
  16244. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16245. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16246. * @param onLoad define a callback triggered when the texture has been loaded
  16247. * @param onError define a callback triggered when an error occurred during the loading session
  16248. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16249. * @returns the created texture
  16250. */
  16251. 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;
  16252. }
  16253. }
  16254. declare module "babylonjs/PostProcesses/postProcessManager" {
  16255. import { Nullable } from "babylonjs/types";
  16256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16257. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16258. import { Scene } from "babylonjs/scene";
  16259. /**
  16260. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16261. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16262. */
  16263. export class PostProcessManager {
  16264. private _scene;
  16265. private _indexBuffer;
  16266. private _vertexBuffers;
  16267. /**
  16268. * Creates a new instance PostProcess
  16269. * @param scene The scene that the post process is associated with.
  16270. */
  16271. constructor(scene: Scene);
  16272. private _prepareBuffers;
  16273. private _buildIndexBuffer;
  16274. /**
  16275. * Rebuilds the vertex buffers of the manager.
  16276. * @hidden
  16277. */
  16278. _rebuild(): void;
  16279. /**
  16280. * Prepares a frame to be run through a post process.
  16281. * @param sourceTexture The input texture to the post procesess. (default: null)
  16282. * @param postProcesses An array of post processes to be run. (default: null)
  16283. * @returns True if the post processes were able to be run.
  16284. * @hidden
  16285. */
  16286. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16287. /**
  16288. * Manually render a set of post processes to a texture.
  16289. * @param postProcesses An array of post processes to be run.
  16290. * @param targetTexture The target texture to render to.
  16291. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16292. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16293. * @param lodLevel defines which lod of the texture to render to
  16294. */
  16295. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16296. /**
  16297. * Finalize the result of the output of the postprocesses.
  16298. * @param doNotPresent If true the result will not be displayed to the screen.
  16299. * @param targetTexture The target texture to render to.
  16300. * @param faceIndex The index of the face to bind the target texture to.
  16301. * @param postProcesses The array of post processes to render.
  16302. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16303. * @hidden
  16304. */
  16305. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16306. /**
  16307. * Disposes of the post process manager.
  16308. */
  16309. dispose(): void;
  16310. }
  16311. }
  16312. declare module "babylonjs/Misc/gradients" {
  16313. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16314. /** Interface used by value gradients (color, factor, ...) */
  16315. export interface IValueGradient {
  16316. /**
  16317. * Gets or sets the gradient value (between 0 and 1)
  16318. */
  16319. gradient: number;
  16320. }
  16321. /** Class used to store color4 gradient */
  16322. export class ColorGradient implements IValueGradient {
  16323. /**
  16324. * Gets or sets the gradient value (between 0 and 1)
  16325. */
  16326. gradient: number;
  16327. /**
  16328. * Gets or sets first associated color
  16329. */
  16330. color1: Color4;
  16331. /**
  16332. * Gets or sets second associated color
  16333. */
  16334. color2?: Color4;
  16335. /**
  16336. * Will get a color picked randomly between color1 and color2.
  16337. * If color2 is undefined then color1 will be used
  16338. * @param result defines the target Color4 to store the result in
  16339. */
  16340. getColorToRef(result: Color4): void;
  16341. }
  16342. /** Class used to store color 3 gradient */
  16343. export class Color3Gradient implements IValueGradient {
  16344. /**
  16345. * Gets or sets the gradient value (between 0 and 1)
  16346. */
  16347. gradient: number;
  16348. /**
  16349. * Gets or sets the associated color
  16350. */
  16351. color: Color3;
  16352. }
  16353. /** Class used to store factor gradient */
  16354. export class FactorGradient implements IValueGradient {
  16355. /**
  16356. * Gets or sets the gradient value (between 0 and 1)
  16357. */
  16358. gradient: number;
  16359. /**
  16360. * Gets or sets first associated factor
  16361. */
  16362. factor1: number;
  16363. /**
  16364. * Gets or sets second associated factor
  16365. */
  16366. factor2?: number;
  16367. /**
  16368. * Will get a number picked randomly between factor1 and factor2.
  16369. * If factor2 is undefined then factor1 will be used
  16370. * @returns the picked number
  16371. */
  16372. getFactor(): number;
  16373. }
  16374. /**
  16375. * Helper used to simplify some generic gradient tasks
  16376. */
  16377. export class GradientHelper {
  16378. /**
  16379. * Gets the current gradient from an array of IValueGradient
  16380. * @param ratio defines the current ratio to get
  16381. * @param gradients defines the array of IValueGradient
  16382. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16383. */
  16384. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16385. }
  16386. }
  16387. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16389. import { Nullable } from "babylonjs/types";
  16390. module "babylonjs/Engines/thinEngine" {
  16391. interface ThinEngine {
  16392. /**
  16393. * Creates a dynamic texture
  16394. * @param width defines the width of the texture
  16395. * @param height defines the height of the texture
  16396. * @param generateMipMaps defines if the engine should generate the mip levels
  16397. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16398. * @returns the dynamic texture inside an InternalTexture
  16399. */
  16400. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16401. /**
  16402. * Update the content of a dynamic texture
  16403. * @param texture defines the texture to update
  16404. * @param canvas defines the canvas containing the source
  16405. * @param invertY defines if data must be stored with Y axis inverted
  16406. * @param premulAlpha defines if alpha is stored as premultiplied
  16407. * @param format defines the format of the data
  16408. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16409. */
  16410. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16411. }
  16412. }
  16413. }
  16414. declare module "babylonjs/Misc/canvasGenerator" {
  16415. /**
  16416. * Helper class used to generate a canvas to manipulate images
  16417. */
  16418. export class CanvasGenerator {
  16419. /**
  16420. * Create a new canvas (or offscreen canvas depending on the context)
  16421. * @param width defines the expected width
  16422. * @param height defines the expected height
  16423. * @return a new canvas or offscreen canvas
  16424. */
  16425. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16426. }
  16427. }
  16428. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16429. import { Scene } from "babylonjs/scene";
  16430. import { Texture } from "babylonjs/Materials/Textures/texture";
  16431. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16432. /**
  16433. * A class extending Texture allowing drawing on a texture
  16434. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16435. */
  16436. export class DynamicTexture extends Texture {
  16437. private _generateMipMaps;
  16438. private _canvas;
  16439. private _context;
  16440. private _engine;
  16441. /**
  16442. * Creates a DynamicTexture
  16443. * @param name defines the name of the texture
  16444. * @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
  16445. * @param scene defines the scene where you want the texture
  16446. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16447. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16448. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16449. */
  16450. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16451. /**
  16452. * Get the current class name of the texture useful for serialization or dynamic coding.
  16453. * @returns "DynamicTexture"
  16454. */
  16455. getClassName(): string;
  16456. /**
  16457. * Gets the current state of canRescale
  16458. */
  16459. readonly canRescale: boolean;
  16460. private _recreate;
  16461. /**
  16462. * Scales the texture
  16463. * @param ratio the scale factor to apply to both width and height
  16464. */
  16465. scale(ratio: number): void;
  16466. /**
  16467. * Resizes the texture
  16468. * @param width the new width
  16469. * @param height the new height
  16470. */
  16471. scaleTo(width: number, height: number): void;
  16472. /**
  16473. * Gets the context of the canvas used by the texture
  16474. * @returns the canvas context of the dynamic texture
  16475. */
  16476. getContext(): CanvasRenderingContext2D;
  16477. /**
  16478. * Clears the texture
  16479. */
  16480. clear(): void;
  16481. /**
  16482. * Updates the texture
  16483. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16484. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16485. */
  16486. update(invertY?: boolean, premulAlpha?: boolean): void;
  16487. /**
  16488. * Draws text onto the texture
  16489. * @param text defines the text to be drawn
  16490. * @param x defines the placement of the text from the left
  16491. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16492. * @param font defines the font to be used with font-style, font-size, font-name
  16493. * @param color defines the color used for the text
  16494. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16495. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16496. * @param update defines whether texture is immediately update (default is true)
  16497. */
  16498. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16499. /**
  16500. * Clones the texture
  16501. * @returns the clone of the texture.
  16502. */
  16503. clone(): DynamicTexture;
  16504. /**
  16505. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16506. * @returns a serialized dynamic texture object
  16507. */
  16508. serialize(): any;
  16509. /** @hidden */
  16510. _rebuild(): void;
  16511. }
  16512. }
  16513. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16514. import { Scene } from "babylonjs/scene";
  16515. import { ISceneComponent } from "babylonjs/sceneComponent";
  16516. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16517. module "babylonjs/abstractScene" {
  16518. interface AbstractScene {
  16519. /**
  16520. * The list of procedural textures added to the scene
  16521. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16522. */
  16523. proceduralTextures: Array<ProceduralTexture>;
  16524. }
  16525. }
  16526. /**
  16527. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16528. * in a given scene.
  16529. */
  16530. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16531. /**
  16532. * The component name helpfull to identify the component in the list of scene components.
  16533. */
  16534. readonly name: string;
  16535. /**
  16536. * The scene the component belongs to.
  16537. */
  16538. scene: Scene;
  16539. /**
  16540. * Creates a new instance of the component for the given scene
  16541. * @param scene Defines the scene to register the component in
  16542. */
  16543. constructor(scene: Scene);
  16544. /**
  16545. * Registers the component in a given scene
  16546. */
  16547. register(): void;
  16548. /**
  16549. * Rebuilds the elements related to this component in case of
  16550. * context lost for instance.
  16551. */
  16552. rebuild(): void;
  16553. /**
  16554. * Disposes the component and the associated ressources.
  16555. */
  16556. dispose(): void;
  16557. private _beforeClear;
  16558. }
  16559. }
  16560. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16561. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16562. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16563. module "babylonjs/Engines/thinEngine" {
  16564. interface ThinEngine {
  16565. /**
  16566. * Creates a new render target cube texture
  16567. * @param size defines the size of the texture
  16568. * @param options defines the options used to create the texture
  16569. * @returns a new render target cube texture stored in an InternalTexture
  16570. */
  16571. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16572. }
  16573. }
  16574. }
  16575. declare module "babylonjs/Shaders/procedural.vertex" {
  16576. /** @hidden */
  16577. export var proceduralVertexShader: {
  16578. name: string;
  16579. shader: string;
  16580. };
  16581. }
  16582. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16583. import { Observable } from "babylonjs/Misc/observable";
  16584. import { Nullable } from "babylonjs/types";
  16585. import { Scene } from "babylonjs/scene";
  16586. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16587. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16588. import { Effect } from "babylonjs/Materials/effect";
  16589. import { Texture } from "babylonjs/Materials/Textures/texture";
  16590. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16591. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16592. import "babylonjs/Shaders/procedural.vertex";
  16593. /**
  16594. * 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.
  16595. * This is the base class of any Procedural texture and contains most of the shareable code.
  16596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16597. */
  16598. export class ProceduralTexture extends Texture {
  16599. isCube: boolean;
  16600. /**
  16601. * Define if the texture is enabled or not (disabled texture will not render)
  16602. */
  16603. isEnabled: boolean;
  16604. /**
  16605. * Define if the texture must be cleared before rendering (default is true)
  16606. */
  16607. autoClear: boolean;
  16608. /**
  16609. * Callback called when the texture is generated
  16610. */
  16611. onGenerated: () => void;
  16612. /**
  16613. * Event raised when the texture is generated
  16614. */
  16615. onGeneratedObservable: Observable<ProceduralTexture>;
  16616. /** @hidden */
  16617. _generateMipMaps: boolean;
  16618. /** @hidden **/
  16619. _effect: Effect;
  16620. /** @hidden */
  16621. _textures: {
  16622. [key: string]: Texture;
  16623. };
  16624. private _size;
  16625. private _currentRefreshId;
  16626. private _refreshRate;
  16627. private _vertexBuffers;
  16628. private _indexBuffer;
  16629. private _uniforms;
  16630. private _samplers;
  16631. private _fragment;
  16632. private _floats;
  16633. private _ints;
  16634. private _floatsArrays;
  16635. private _colors3;
  16636. private _colors4;
  16637. private _vectors2;
  16638. private _vectors3;
  16639. private _matrices;
  16640. private _fallbackTexture;
  16641. private _fallbackTextureUsed;
  16642. private _engine;
  16643. private _cachedDefines;
  16644. private _contentUpdateId;
  16645. private _contentData;
  16646. /**
  16647. * Instantiates a new procedural texture.
  16648. * 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.
  16649. * This is the base class of any Procedural texture and contains most of the shareable code.
  16650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16651. * @param name Define the name of the texture
  16652. * @param size Define the size of the texture to create
  16653. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16654. * @param scene Define the scene the texture belongs to
  16655. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16656. * @param generateMipMaps Define if the texture should creates mip maps or not
  16657. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16658. */
  16659. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16660. /**
  16661. * The effect that is created when initializing the post process.
  16662. * @returns The created effect corresponding the the postprocess.
  16663. */
  16664. getEffect(): Effect;
  16665. /**
  16666. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16667. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16668. */
  16669. getContent(): Nullable<ArrayBufferView>;
  16670. private _createIndexBuffer;
  16671. /** @hidden */
  16672. _rebuild(): void;
  16673. /**
  16674. * Resets the texture in order to recreate its associated resources.
  16675. * This can be called in case of context loss
  16676. */
  16677. reset(): void;
  16678. protected _getDefines(): string;
  16679. /**
  16680. * Is the texture ready to be used ? (rendered at least once)
  16681. * @returns true if ready, otherwise, false.
  16682. */
  16683. isReady(): boolean;
  16684. /**
  16685. * Resets the refresh counter of the texture and start bak from scratch.
  16686. * Could be useful to regenerate the texture if it is setup to render only once.
  16687. */
  16688. resetRefreshCounter(): void;
  16689. /**
  16690. * Set the fragment shader to use in order to render the texture.
  16691. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16692. */
  16693. setFragment(fragment: any): void;
  16694. /**
  16695. * Define the refresh rate of the texture or the rendering frequency.
  16696. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16697. */
  16698. refreshRate: number;
  16699. /** @hidden */
  16700. _shouldRender(): boolean;
  16701. /**
  16702. * Get the size the texture is rendering at.
  16703. * @returns the size (texture is always squared)
  16704. */
  16705. getRenderSize(): number;
  16706. /**
  16707. * Resize the texture to new value.
  16708. * @param size Define the new size the texture should have
  16709. * @param generateMipMaps Define whether the new texture should create mip maps
  16710. */
  16711. resize(size: number, generateMipMaps: boolean): void;
  16712. private _checkUniform;
  16713. /**
  16714. * Set a texture in the shader program used to render.
  16715. * @param name Define the name of the uniform samplers as defined in the shader
  16716. * @param texture Define the texture to bind to this sampler
  16717. * @return the texture itself allowing "fluent" like uniform updates
  16718. */
  16719. setTexture(name: string, texture: Texture): ProceduralTexture;
  16720. /**
  16721. * Set a float in the shader.
  16722. * @param name Define the name of the uniform as defined in the shader
  16723. * @param value Define the value to give to the uniform
  16724. * @return the texture itself allowing "fluent" like uniform updates
  16725. */
  16726. setFloat(name: string, value: number): ProceduralTexture;
  16727. /**
  16728. * Set a int in the shader.
  16729. * @param name Define the name of the uniform as defined in the shader
  16730. * @param value Define the value to give to the uniform
  16731. * @return the texture itself allowing "fluent" like uniform updates
  16732. */
  16733. setInt(name: string, value: number): ProceduralTexture;
  16734. /**
  16735. * Set an array of floats in the shader.
  16736. * @param name Define the name of the uniform as defined in the shader
  16737. * @param value Define the value to give to the uniform
  16738. * @return the texture itself allowing "fluent" like uniform updates
  16739. */
  16740. setFloats(name: string, value: number[]): ProceduralTexture;
  16741. /**
  16742. * Set a vec3 in the shader from a Color3.
  16743. * @param name Define the name of the uniform as defined in the shader
  16744. * @param value Define the value to give to the uniform
  16745. * @return the texture itself allowing "fluent" like uniform updates
  16746. */
  16747. setColor3(name: string, value: Color3): ProceduralTexture;
  16748. /**
  16749. * Set a vec4 in the shader from a Color4.
  16750. * @param name Define the name of the uniform as defined in the shader
  16751. * @param value Define the value to give to the uniform
  16752. * @return the texture itself allowing "fluent" like uniform updates
  16753. */
  16754. setColor4(name: string, value: Color4): ProceduralTexture;
  16755. /**
  16756. * Set a vec2 in the shader from a Vector2.
  16757. * @param name Define the name of the uniform as defined in the shader
  16758. * @param value Define the value to give to the uniform
  16759. * @return the texture itself allowing "fluent" like uniform updates
  16760. */
  16761. setVector2(name: string, value: Vector2): ProceduralTexture;
  16762. /**
  16763. * Set a vec3 in the shader from a Vector3.
  16764. * @param name Define the name of the uniform as defined in the shader
  16765. * @param value Define the value to give to the uniform
  16766. * @return the texture itself allowing "fluent" like uniform updates
  16767. */
  16768. setVector3(name: string, value: Vector3): ProceduralTexture;
  16769. /**
  16770. * Set a mat4 in the shader from a MAtrix.
  16771. * @param name Define the name of the uniform as defined in the shader
  16772. * @param value Define the value to give to the uniform
  16773. * @return the texture itself allowing "fluent" like uniform updates
  16774. */
  16775. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16776. /**
  16777. * Render the texture to its associated render target.
  16778. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16779. */
  16780. render(useCameraPostProcess?: boolean): void;
  16781. /**
  16782. * Clone the texture.
  16783. * @returns the cloned texture
  16784. */
  16785. clone(): ProceduralTexture;
  16786. /**
  16787. * Dispose the texture and release its asoociated resources.
  16788. */
  16789. dispose(): void;
  16790. }
  16791. }
  16792. declare module "babylonjs/Particles/baseParticleSystem" {
  16793. import { Nullable } from "babylonjs/types";
  16794. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16796. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16797. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16798. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16799. import { Scene } from "babylonjs/scene";
  16800. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16801. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16802. import { Texture } from "babylonjs/Materials/Textures/texture";
  16803. import { Color4 } from "babylonjs/Maths/math.color";
  16804. import { Animation } from "babylonjs/Animations/animation";
  16805. /**
  16806. * This represents the base class for particle system in Babylon.
  16807. * 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.
  16808. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16809. * @example https://doc.babylonjs.com/babylon101/particles
  16810. */
  16811. export class BaseParticleSystem {
  16812. /**
  16813. * Source color is added to the destination color without alpha affecting the result
  16814. */
  16815. static BLENDMODE_ONEONE: number;
  16816. /**
  16817. * Blend current color and particle color using particle’s alpha
  16818. */
  16819. static BLENDMODE_STANDARD: number;
  16820. /**
  16821. * Add current color and particle color multiplied by particle’s alpha
  16822. */
  16823. static BLENDMODE_ADD: number;
  16824. /**
  16825. * Multiply current color with particle color
  16826. */
  16827. static BLENDMODE_MULTIPLY: number;
  16828. /**
  16829. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16830. */
  16831. static BLENDMODE_MULTIPLYADD: number;
  16832. /**
  16833. * List of animations used by the particle system.
  16834. */
  16835. animations: Animation[];
  16836. /**
  16837. * The id of the Particle system.
  16838. */
  16839. id: string;
  16840. /**
  16841. * The friendly name of the Particle system.
  16842. */
  16843. name: string;
  16844. /**
  16845. * The rendering group used by the Particle system to chose when to render.
  16846. */
  16847. renderingGroupId: number;
  16848. /**
  16849. * The emitter represents the Mesh or position we are attaching the particle system to.
  16850. */
  16851. emitter: Nullable<AbstractMesh | Vector3>;
  16852. /**
  16853. * The maximum number of particles to emit per frame
  16854. */
  16855. emitRate: number;
  16856. /**
  16857. * If you want to launch only a few particles at once, that can be done, as well.
  16858. */
  16859. manualEmitCount: number;
  16860. /**
  16861. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16862. */
  16863. updateSpeed: number;
  16864. /**
  16865. * The amount of time the particle system is running (depends of the overall update speed).
  16866. */
  16867. targetStopDuration: number;
  16868. /**
  16869. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16870. */
  16871. disposeOnStop: boolean;
  16872. /**
  16873. * Minimum power of emitting particles.
  16874. */
  16875. minEmitPower: number;
  16876. /**
  16877. * Maximum power of emitting particles.
  16878. */
  16879. maxEmitPower: number;
  16880. /**
  16881. * Minimum life time of emitting particles.
  16882. */
  16883. minLifeTime: number;
  16884. /**
  16885. * Maximum life time of emitting particles.
  16886. */
  16887. maxLifeTime: number;
  16888. /**
  16889. * Minimum Size of emitting particles.
  16890. */
  16891. minSize: number;
  16892. /**
  16893. * Maximum Size of emitting particles.
  16894. */
  16895. maxSize: number;
  16896. /**
  16897. * Minimum scale of emitting particles on X axis.
  16898. */
  16899. minScaleX: number;
  16900. /**
  16901. * Maximum scale of emitting particles on X axis.
  16902. */
  16903. maxScaleX: number;
  16904. /**
  16905. * Minimum scale of emitting particles on Y axis.
  16906. */
  16907. minScaleY: number;
  16908. /**
  16909. * Maximum scale of emitting particles on Y axis.
  16910. */
  16911. maxScaleY: number;
  16912. /**
  16913. * Gets or sets the minimal initial rotation in radians.
  16914. */
  16915. minInitialRotation: number;
  16916. /**
  16917. * Gets or sets the maximal initial rotation in radians.
  16918. */
  16919. maxInitialRotation: number;
  16920. /**
  16921. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16922. */
  16923. minAngularSpeed: number;
  16924. /**
  16925. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16926. */
  16927. maxAngularSpeed: number;
  16928. /**
  16929. * The texture used to render each particle. (this can be a spritesheet)
  16930. */
  16931. particleTexture: Nullable<Texture>;
  16932. /**
  16933. * The layer mask we are rendering the particles through.
  16934. */
  16935. layerMask: number;
  16936. /**
  16937. * This can help using your own shader to render the particle system.
  16938. * The according effect will be created
  16939. */
  16940. customShader: any;
  16941. /**
  16942. * By default particle system starts as soon as they are created. This prevents the
  16943. * automatic start to happen and let you decide when to start emitting particles.
  16944. */
  16945. preventAutoStart: boolean;
  16946. private _noiseTexture;
  16947. /**
  16948. * Gets or sets a texture used to add random noise to particle positions
  16949. */
  16950. noiseTexture: Nullable<ProceduralTexture>;
  16951. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16952. noiseStrength: Vector3;
  16953. /**
  16954. * Callback triggered when the particle animation is ending.
  16955. */
  16956. onAnimationEnd: Nullable<() => void>;
  16957. /**
  16958. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16959. */
  16960. blendMode: number;
  16961. /**
  16962. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16963. * to override the particles.
  16964. */
  16965. forceDepthWrite: boolean;
  16966. /** 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 */
  16967. preWarmCycles: number;
  16968. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16969. preWarmStepOffset: number;
  16970. /**
  16971. * 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)
  16972. */
  16973. spriteCellChangeSpeed: number;
  16974. /**
  16975. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16976. */
  16977. startSpriteCellID: number;
  16978. /**
  16979. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16980. */
  16981. endSpriteCellID: number;
  16982. /**
  16983. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16984. */
  16985. spriteCellWidth: number;
  16986. /**
  16987. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16988. */
  16989. spriteCellHeight: number;
  16990. /**
  16991. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16992. */
  16993. spriteRandomStartCell: boolean;
  16994. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16995. translationPivot: Vector2;
  16996. /** @hidden */
  16997. protected _isAnimationSheetEnabled: boolean;
  16998. /**
  16999. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17000. */
  17001. beginAnimationOnStart: boolean;
  17002. /**
  17003. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17004. */
  17005. beginAnimationFrom: number;
  17006. /**
  17007. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17008. */
  17009. beginAnimationTo: number;
  17010. /**
  17011. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17012. */
  17013. beginAnimationLoop: boolean;
  17014. /**
  17015. * Gets or sets a world offset applied to all particles
  17016. */
  17017. worldOffset: Vector3;
  17018. /**
  17019. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17020. */
  17021. isAnimationSheetEnabled: boolean;
  17022. /**
  17023. * Get hosting scene
  17024. * @returns the scene
  17025. */
  17026. getScene(): Scene;
  17027. /**
  17028. * You can use gravity if you want to give an orientation to your particles.
  17029. */
  17030. gravity: Vector3;
  17031. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17032. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17033. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17034. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17035. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17036. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17037. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17038. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17039. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17040. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17041. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17042. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17043. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17044. /**
  17045. * Defines the delay in milliseconds before starting the system (0 by default)
  17046. */
  17047. startDelay: number;
  17048. /**
  17049. * Gets the current list of drag gradients.
  17050. * You must use addDragGradient and removeDragGradient to udpate this list
  17051. * @returns the list of drag gradients
  17052. */
  17053. getDragGradients(): Nullable<Array<FactorGradient>>;
  17054. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17055. limitVelocityDamping: number;
  17056. /**
  17057. * Gets the current list of limit velocity gradients.
  17058. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17059. * @returns the list of limit velocity gradients
  17060. */
  17061. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17062. /**
  17063. * Gets the current list of color gradients.
  17064. * You must use addColorGradient and removeColorGradient to udpate this list
  17065. * @returns the list of color gradients
  17066. */
  17067. getColorGradients(): Nullable<Array<ColorGradient>>;
  17068. /**
  17069. * Gets the current list of size gradients.
  17070. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17071. * @returns the list of size gradients
  17072. */
  17073. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17074. /**
  17075. * Gets the current list of color remap gradients.
  17076. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17077. * @returns the list of color remap gradients
  17078. */
  17079. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Gets the current list of alpha remap gradients.
  17082. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17083. * @returns the list of alpha remap gradients
  17084. */
  17085. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17086. /**
  17087. * Gets the current list of life time gradients.
  17088. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17089. * @returns the list of life time gradients
  17090. */
  17091. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17092. /**
  17093. * Gets the current list of angular speed gradients.
  17094. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17095. * @returns the list of angular speed gradients
  17096. */
  17097. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17098. /**
  17099. * Gets the current list of velocity gradients.
  17100. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17101. * @returns the list of velocity gradients
  17102. */
  17103. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17104. /**
  17105. * Gets the current list of start size gradients.
  17106. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17107. * @returns the list of start size gradients
  17108. */
  17109. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17110. /**
  17111. * Gets the current list of emit rate gradients.
  17112. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17113. * @returns the list of emit rate gradients
  17114. */
  17115. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17116. /**
  17117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17118. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17119. */
  17120. direction1: Vector3;
  17121. /**
  17122. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17124. */
  17125. direction2: Vector3;
  17126. /**
  17127. * 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.
  17128. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17129. */
  17130. minEmitBox: Vector3;
  17131. /**
  17132. * 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.
  17133. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17134. */
  17135. maxEmitBox: Vector3;
  17136. /**
  17137. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17138. */
  17139. color1: Color4;
  17140. /**
  17141. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17142. */
  17143. color2: Color4;
  17144. /**
  17145. * Color the particle will have at the end of its lifetime
  17146. */
  17147. colorDead: Color4;
  17148. /**
  17149. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17150. */
  17151. textureMask: Color4;
  17152. /**
  17153. * The particle emitter type defines the emitter used by the particle system.
  17154. * It can be for example box, sphere, or cone...
  17155. */
  17156. particleEmitterType: IParticleEmitterType;
  17157. /** @hidden */
  17158. _isSubEmitter: boolean;
  17159. /**
  17160. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17161. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17162. */
  17163. billboardMode: number;
  17164. protected _isBillboardBased: boolean;
  17165. /**
  17166. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17167. */
  17168. isBillboardBased: boolean;
  17169. /**
  17170. * The scene the particle system belongs to.
  17171. */
  17172. protected _scene: Scene;
  17173. /**
  17174. * Local cache of defines for image processing.
  17175. */
  17176. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17177. /**
  17178. * Default configuration related to image processing available in the standard Material.
  17179. */
  17180. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17181. /**
  17182. * Gets the image processing configuration used either in this material.
  17183. */
  17184. /**
  17185. * Sets the Default image processing configuration used either in the this material.
  17186. *
  17187. * If sets to null, the scene one is in use.
  17188. */
  17189. imageProcessingConfiguration: ImageProcessingConfiguration;
  17190. /**
  17191. * Attaches a new image processing configuration to the Standard Material.
  17192. * @param configuration
  17193. */
  17194. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17195. /** @hidden */
  17196. protected _reset(): void;
  17197. /** @hidden */
  17198. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17199. /**
  17200. * Instantiates a particle system.
  17201. * 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.
  17202. * @param name The name of the particle system
  17203. */
  17204. constructor(name: string);
  17205. /**
  17206. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17209. * @returns the emitter
  17210. */
  17211. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17212. /**
  17213. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17214. * @param radius The radius of the hemisphere to emit from
  17215. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17216. * @returns the emitter
  17217. */
  17218. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17219. /**
  17220. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17221. * @param radius The radius of the sphere to emit from
  17222. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17223. * @returns the emitter
  17224. */
  17225. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17226. /**
  17227. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17228. * @param radius The radius of the sphere to emit from
  17229. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17230. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17231. * @returns the emitter
  17232. */
  17233. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17234. /**
  17235. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17236. * @param radius The radius of the emission cylinder
  17237. * @param height The height of the emission cylinder
  17238. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17239. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17240. * @returns the emitter
  17241. */
  17242. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17243. /**
  17244. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17245. * @param radius The radius of the cylinder to emit from
  17246. * @param height The height of the emission cylinder
  17247. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17248. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17249. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17250. * @returns the emitter
  17251. */
  17252. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17253. /**
  17254. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17255. * @param radius The radius of the cone to emit from
  17256. * @param angle The base angle of the cone
  17257. * @returns the emitter
  17258. */
  17259. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17260. /**
  17261. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17262. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17263. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17264. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17265. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17266. * @returns the emitter
  17267. */
  17268. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17269. }
  17270. }
  17271. declare module "babylonjs/Particles/subEmitter" {
  17272. import { Scene } from "babylonjs/scene";
  17273. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17274. /**
  17275. * Type of sub emitter
  17276. */
  17277. export enum SubEmitterType {
  17278. /**
  17279. * Attached to the particle over it's lifetime
  17280. */
  17281. ATTACHED = 0,
  17282. /**
  17283. * Created when the particle dies
  17284. */
  17285. END = 1
  17286. }
  17287. /**
  17288. * Sub emitter class used to emit particles from an existing particle
  17289. */
  17290. export class SubEmitter {
  17291. /**
  17292. * the particle system to be used by the sub emitter
  17293. */
  17294. particleSystem: ParticleSystem;
  17295. /**
  17296. * Type of the submitter (Default: END)
  17297. */
  17298. type: SubEmitterType;
  17299. /**
  17300. * 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)
  17301. * Note: This only is supported when using an emitter of type Mesh
  17302. */
  17303. inheritDirection: boolean;
  17304. /**
  17305. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17306. */
  17307. inheritedVelocityAmount: number;
  17308. /**
  17309. * Creates a sub emitter
  17310. * @param particleSystem the particle system to be used by the sub emitter
  17311. */
  17312. constructor(
  17313. /**
  17314. * the particle system to be used by the sub emitter
  17315. */
  17316. particleSystem: ParticleSystem);
  17317. /**
  17318. * Clones the sub emitter
  17319. * @returns the cloned sub emitter
  17320. */
  17321. clone(): SubEmitter;
  17322. /**
  17323. * Serialize current object to a JSON object
  17324. * @returns the serialized object
  17325. */
  17326. serialize(): any;
  17327. /** @hidden */
  17328. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17329. /**
  17330. * Creates a new SubEmitter from a serialized JSON version
  17331. * @param serializationObject defines the JSON object to read from
  17332. * @param scene defines the hosting scene
  17333. * @param rootUrl defines the rootUrl for data loading
  17334. * @returns a new SubEmitter
  17335. */
  17336. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17337. /** Release associated resources */
  17338. dispose(): void;
  17339. }
  17340. }
  17341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17342. /** @hidden */
  17343. export var clipPlaneFragmentDeclaration: {
  17344. name: string;
  17345. shader: string;
  17346. };
  17347. }
  17348. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17349. /** @hidden */
  17350. export var imageProcessingDeclaration: {
  17351. name: string;
  17352. shader: string;
  17353. };
  17354. }
  17355. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17356. /** @hidden */
  17357. export var imageProcessingFunctions: {
  17358. name: string;
  17359. shader: string;
  17360. };
  17361. }
  17362. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17363. /** @hidden */
  17364. export var clipPlaneFragment: {
  17365. name: string;
  17366. shader: string;
  17367. };
  17368. }
  17369. declare module "babylonjs/Shaders/particles.fragment" {
  17370. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17371. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17372. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17373. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17375. /** @hidden */
  17376. export var particlesPixelShader: {
  17377. name: string;
  17378. shader: string;
  17379. };
  17380. }
  17381. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17382. /** @hidden */
  17383. export var clipPlaneVertexDeclaration: {
  17384. name: string;
  17385. shader: string;
  17386. };
  17387. }
  17388. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17389. /** @hidden */
  17390. export var clipPlaneVertex: {
  17391. name: string;
  17392. shader: string;
  17393. };
  17394. }
  17395. declare module "babylonjs/Shaders/particles.vertex" {
  17396. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17398. /** @hidden */
  17399. export var particlesVertexShader: {
  17400. name: string;
  17401. shader: string;
  17402. };
  17403. }
  17404. declare module "babylonjs/Particles/particleSystem" {
  17405. import { Nullable } from "babylonjs/types";
  17406. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17407. import { Observable } from "babylonjs/Misc/observable";
  17408. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17409. import { Effect } from "babylonjs/Materials/effect";
  17410. import { Scene, IDisposable } from "babylonjs/scene";
  17411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17412. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17413. import { Particle } from "babylonjs/Particles/particle";
  17414. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17415. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17416. import "babylonjs/Shaders/particles.fragment";
  17417. import "babylonjs/Shaders/particles.vertex";
  17418. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17419. /**
  17420. * This represents a particle system in Babylon.
  17421. * 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.
  17422. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17423. * @example https://doc.babylonjs.com/babylon101/particles
  17424. */
  17425. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17426. /**
  17427. * Billboard mode will only apply to Y axis
  17428. */
  17429. static readonly BILLBOARDMODE_Y: number;
  17430. /**
  17431. * Billboard mode will apply to all axes
  17432. */
  17433. static readonly BILLBOARDMODE_ALL: number;
  17434. /**
  17435. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17436. */
  17437. static readonly BILLBOARDMODE_STRETCHED: number;
  17438. /**
  17439. * This function can be defined to provide custom update for active particles.
  17440. * This function will be called instead of regular update (age, position, color, etc.).
  17441. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17442. */
  17443. updateFunction: (particles: Particle[]) => void;
  17444. private _emitterWorldMatrix;
  17445. /**
  17446. * This function can be defined to specify initial direction for every new particle.
  17447. * It by default use the emitterType defined function
  17448. */
  17449. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17450. /**
  17451. * This function can be defined to specify initial position for every new particle.
  17452. * It by default use the emitterType defined function
  17453. */
  17454. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17455. /**
  17456. * @hidden
  17457. */
  17458. _inheritedVelocityOffset: Vector3;
  17459. /**
  17460. * An event triggered when the system is disposed
  17461. */
  17462. onDisposeObservable: Observable<ParticleSystem>;
  17463. private _onDisposeObserver;
  17464. /**
  17465. * Sets a callback that will be triggered when the system is disposed
  17466. */
  17467. onDispose: () => void;
  17468. private _particles;
  17469. private _epsilon;
  17470. private _capacity;
  17471. private _stockParticles;
  17472. private _newPartsExcess;
  17473. private _vertexData;
  17474. private _vertexBuffer;
  17475. private _vertexBuffers;
  17476. private _spriteBuffer;
  17477. private _indexBuffer;
  17478. private _effect;
  17479. private _customEffect;
  17480. private _cachedDefines;
  17481. private _scaledColorStep;
  17482. private _colorDiff;
  17483. private _scaledDirection;
  17484. private _scaledGravity;
  17485. private _currentRenderId;
  17486. private _alive;
  17487. private _useInstancing;
  17488. private _started;
  17489. private _stopped;
  17490. private _actualFrame;
  17491. private _scaledUpdateSpeed;
  17492. private _vertexBufferSize;
  17493. /** @hidden */
  17494. _currentEmitRateGradient: Nullable<FactorGradient>;
  17495. /** @hidden */
  17496. _currentEmitRate1: number;
  17497. /** @hidden */
  17498. _currentEmitRate2: number;
  17499. /** @hidden */
  17500. _currentStartSizeGradient: Nullable<FactorGradient>;
  17501. /** @hidden */
  17502. _currentStartSize1: number;
  17503. /** @hidden */
  17504. _currentStartSize2: number;
  17505. private readonly _rawTextureWidth;
  17506. private _rampGradientsTexture;
  17507. private _useRampGradients;
  17508. /** Gets or sets a boolean indicating that ramp gradients must be used
  17509. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17510. */
  17511. useRampGradients: boolean;
  17512. /**
  17513. * 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.
  17514. * 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: [])
  17515. */
  17516. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17517. private _subEmitters;
  17518. /**
  17519. * @hidden
  17520. * If the particle systems emitter should be disposed when the particle system is disposed
  17521. */
  17522. _disposeEmitterOnDispose: boolean;
  17523. /**
  17524. * The current active Sub-systems, this property is used by the root particle system only.
  17525. */
  17526. activeSubSystems: Array<ParticleSystem>;
  17527. private _rootParticleSystem;
  17528. /**
  17529. * Gets the current list of active particles
  17530. */
  17531. readonly particles: Particle[];
  17532. /**
  17533. * Returns the string "ParticleSystem"
  17534. * @returns a string containing the class name
  17535. */
  17536. getClassName(): string;
  17537. /**
  17538. * Instantiates a particle system.
  17539. * 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.
  17540. * @param name The name of the particle system
  17541. * @param capacity The max number of particles alive at the same time
  17542. * @param scene The scene the particle system belongs to
  17543. * @param customEffect a custom effect used to change the way particles are rendered by default
  17544. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17545. * @param epsilon Offset used to render the particles
  17546. */
  17547. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17548. private _addFactorGradient;
  17549. private _removeFactorGradient;
  17550. /**
  17551. * Adds a new life time gradient
  17552. * @param gradient defines the gradient to use (between 0 and 1)
  17553. * @param factor defines the life time factor to affect to the specified gradient
  17554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17555. * @returns the current particle system
  17556. */
  17557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17558. /**
  17559. * Remove a specific life time gradient
  17560. * @param gradient defines the gradient to remove
  17561. * @returns the current particle system
  17562. */
  17563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17564. /**
  17565. * Adds a new size gradient
  17566. * @param gradient defines the gradient to use (between 0 and 1)
  17567. * @param factor defines the size factor to affect to the specified gradient
  17568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17569. * @returns the current particle system
  17570. */
  17571. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17572. /**
  17573. * Remove a specific size gradient
  17574. * @param gradient defines the gradient to remove
  17575. * @returns the current particle system
  17576. */
  17577. removeSizeGradient(gradient: number): IParticleSystem;
  17578. /**
  17579. * Adds a new color remap gradient
  17580. * @param gradient defines the gradient to use (between 0 and 1)
  17581. * @param min defines the color remap minimal range
  17582. * @param max defines the color remap maximal range
  17583. * @returns the current particle system
  17584. */
  17585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17586. /**
  17587. * Remove a specific color remap gradient
  17588. * @param gradient defines the gradient to remove
  17589. * @returns the current particle system
  17590. */
  17591. removeColorRemapGradient(gradient: number): IParticleSystem;
  17592. /**
  17593. * Adds a new alpha remap gradient
  17594. * @param gradient defines the gradient to use (between 0 and 1)
  17595. * @param min defines the alpha remap minimal range
  17596. * @param max defines the alpha remap maximal range
  17597. * @returns the current particle system
  17598. */
  17599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17600. /**
  17601. * Remove a specific alpha remap gradient
  17602. * @param gradient defines the gradient to remove
  17603. * @returns the current particle system
  17604. */
  17605. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17606. /**
  17607. * Adds a new angular speed gradient
  17608. * @param gradient defines the gradient to use (between 0 and 1)
  17609. * @param factor defines the angular speed to affect to the specified gradient
  17610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17611. * @returns the current particle system
  17612. */
  17613. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17614. /**
  17615. * Remove a specific angular speed gradient
  17616. * @param gradient defines the gradient to remove
  17617. * @returns the current particle system
  17618. */
  17619. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17620. /**
  17621. * Adds a new velocity gradient
  17622. * @param gradient defines the gradient to use (between 0 and 1)
  17623. * @param factor defines the velocity to affect to the specified gradient
  17624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17625. * @returns the current particle system
  17626. */
  17627. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17628. /**
  17629. * Remove a specific velocity gradient
  17630. * @param gradient defines the gradient to remove
  17631. * @returns the current particle system
  17632. */
  17633. removeVelocityGradient(gradient: number): IParticleSystem;
  17634. /**
  17635. * Adds a new limit velocity gradient
  17636. * @param gradient defines the gradient to use (between 0 and 1)
  17637. * @param factor defines the limit velocity value to affect to the specified gradient
  17638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17639. * @returns the current particle system
  17640. */
  17641. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17642. /**
  17643. * Remove a specific limit velocity gradient
  17644. * @param gradient defines the gradient to remove
  17645. * @returns the current particle system
  17646. */
  17647. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17648. /**
  17649. * Adds a new drag gradient
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param factor defines the drag value to affect to the specified gradient
  17652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17653. * @returns the current particle system
  17654. */
  17655. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17656. /**
  17657. * Remove a specific drag gradient
  17658. * @param gradient defines the gradient to remove
  17659. * @returns the current particle system
  17660. */
  17661. removeDragGradient(gradient: number): IParticleSystem;
  17662. /**
  17663. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param factor defines the emit rate value to affect to the specified gradient
  17666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17667. * @returns the current particle system
  17668. */
  17669. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17670. /**
  17671. * Remove a specific emit rate gradient
  17672. * @param gradient defines the gradient to remove
  17673. * @returns the current particle system
  17674. */
  17675. removeEmitRateGradient(gradient: number): IParticleSystem;
  17676. /**
  17677. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17678. * @param gradient defines the gradient to use (between 0 and 1)
  17679. * @param factor defines the start size value to affect to the specified gradient
  17680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17681. * @returns the current particle system
  17682. */
  17683. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17684. /**
  17685. * Remove a specific start size gradient
  17686. * @param gradient defines the gradient to remove
  17687. * @returns the current particle system
  17688. */
  17689. removeStartSizeGradient(gradient: number): IParticleSystem;
  17690. private _createRampGradientTexture;
  17691. /**
  17692. * Gets the current list of ramp gradients.
  17693. * You must use addRampGradient and removeRampGradient to udpate this list
  17694. * @returns the list of ramp gradients
  17695. */
  17696. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17697. /**
  17698. * Adds a new ramp gradient used to remap particle colors
  17699. * @param gradient defines the gradient to use (between 0 and 1)
  17700. * @param color defines the color to affect to the specified gradient
  17701. * @returns the current particle system
  17702. */
  17703. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17704. /**
  17705. * Remove a specific ramp gradient
  17706. * @param gradient defines the gradient to remove
  17707. * @returns the current particle system
  17708. */
  17709. removeRampGradient(gradient: number): ParticleSystem;
  17710. /**
  17711. * Adds a new color gradient
  17712. * @param gradient defines the gradient to use (between 0 and 1)
  17713. * @param color1 defines the color to affect to the specified gradient
  17714. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17715. * @returns this particle system
  17716. */
  17717. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17718. /**
  17719. * Remove a specific color gradient
  17720. * @param gradient defines the gradient to remove
  17721. * @returns this particle system
  17722. */
  17723. removeColorGradient(gradient: number): IParticleSystem;
  17724. private _fetchR;
  17725. protected _reset(): void;
  17726. private _resetEffect;
  17727. private _createVertexBuffers;
  17728. private _createIndexBuffer;
  17729. /**
  17730. * Gets the maximum number of particles active at the same time.
  17731. * @returns The max number of active particles.
  17732. */
  17733. getCapacity(): number;
  17734. /**
  17735. * Gets whether there are still active particles in the system.
  17736. * @returns True if it is alive, otherwise false.
  17737. */
  17738. isAlive(): boolean;
  17739. /**
  17740. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17741. * @returns True if it has been started, otherwise false.
  17742. */
  17743. isStarted(): boolean;
  17744. private _prepareSubEmitterInternalArray;
  17745. /**
  17746. * Starts the particle system and begins to emit
  17747. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17748. */
  17749. start(delay?: number): void;
  17750. /**
  17751. * Stops the particle system.
  17752. * @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.
  17753. */
  17754. stop(stopSubEmitters?: boolean): void;
  17755. /**
  17756. * Remove all active particles
  17757. */
  17758. reset(): void;
  17759. /**
  17760. * @hidden (for internal use only)
  17761. */
  17762. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17763. /**
  17764. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17765. * Its lifetime will start back at 0.
  17766. */
  17767. recycleParticle: (particle: Particle) => void;
  17768. private _stopSubEmitters;
  17769. private _createParticle;
  17770. private _removeFromRoot;
  17771. private _emitFromParticle;
  17772. private _update;
  17773. /** @hidden */
  17774. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17775. /** @hidden */
  17776. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17777. /** @hidden */
  17778. private _getEffect;
  17779. /**
  17780. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17781. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17782. */
  17783. animate(preWarmOnly?: boolean): void;
  17784. private _appendParticleVertices;
  17785. /**
  17786. * Rebuilds the particle system.
  17787. */
  17788. rebuild(): void;
  17789. /**
  17790. * Is this system ready to be used/rendered
  17791. * @return true if the system is ready
  17792. */
  17793. isReady(): boolean;
  17794. private _render;
  17795. /**
  17796. * Renders the particle system in its current state.
  17797. * @returns the current number of particles
  17798. */
  17799. render(): number;
  17800. /**
  17801. * Disposes the particle system and free the associated resources
  17802. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17803. */
  17804. dispose(disposeTexture?: boolean): void;
  17805. /**
  17806. * Clones the particle system.
  17807. * @param name The name of the cloned object
  17808. * @param newEmitter The new emitter to use
  17809. * @returns the cloned particle system
  17810. */
  17811. clone(name: string, newEmitter: any): ParticleSystem;
  17812. /**
  17813. * Serializes the particle system to a JSON object.
  17814. * @returns the JSON object
  17815. */
  17816. serialize(): any;
  17817. /** @hidden */
  17818. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17819. /** @hidden */
  17820. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17821. /**
  17822. * Parses a JSON object to create a particle system.
  17823. * @param parsedParticleSystem The JSON object to parse
  17824. * @param scene The scene to create the particle system in
  17825. * @param rootUrl The root url to use to load external dependencies like texture
  17826. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17827. * @returns the Parsed particle system
  17828. */
  17829. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17830. }
  17831. }
  17832. declare module "babylonjs/Particles/particle" {
  17833. import { Nullable } from "babylonjs/types";
  17834. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17835. import { Color4 } from "babylonjs/Maths/math.color";
  17836. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17837. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17838. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17839. /**
  17840. * A particle represents one of the element emitted by a particle system.
  17841. * This is mainly define by its coordinates, direction, velocity and age.
  17842. */
  17843. export class Particle {
  17844. /**
  17845. * The particle system the particle belongs to.
  17846. */
  17847. particleSystem: ParticleSystem;
  17848. private static _Count;
  17849. /**
  17850. * Unique ID of the particle
  17851. */
  17852. id: number;
  17853. /**
  17854. * The world position of the particle in the scene.
  17855. */
  17856. position: Vector3;
  17857. /**
  17858. * The world direction of the particle in the scene.
  17859. */
  17860. direction: Vector3;
  17861. /**
  17862. * The color of the particle.
  17863. */
  17864. color: Color4;
  17865. /**
  17866. * The color change of the particle per step.
  17867. */
  17868. colorStep: Color4;
  17869. /**
  17870. * Defines how long will the life of the particle be.
  17871. */
  17872. lifeTime: number;
  17873. /**
  17874. * The current age of the particle.
  17875. */
  17876. age: number;
  17877. /**
  17878. * The current size of the particle.
  17879. */
  17880. size: number;
  17881. /**
  17882. * The current scale of the particle.
  17883. */
  17884. scale: Vector2;
  17885. /**
  17886. * The current angle of the particle.
  17887. */
  17888. angle: number;
  17889. /**
  17890. * Defines how fast is the angle changing.
  17891. */
  17892. angularSpeed: number;
  17893. /**
  17894. * Defines the cell index used by the particle to be rendered from a sprite.
  17895. */
  17896. cellIndex: number;
  17897. /**
  17898. * The information required to support color remapping
  17899. */
  17900. remapData: Vector4;
  17901. /** @hidden */
  17902. _randomCellOffset?: number;
  17903. /** @hidden */
  17904. _initialDirection: Nullable<Vector3>;
  17905. /** @hidden */
  17906. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17907. /** @hidden */
  17908. _initialStartSpriteCellID: number;
  17909. /** @hidden */
  17910. _initialEndSpriteCellID: number;
  17911. /** @hidden */
  17912. _currentColorGradient: Nullable<ColorGradient>;
  17913. /** @hidden */
  17914. _currentColor1: Color4;
  17915. /** @hidden */
  17916. _currentColor2: Color4;
  17917. /** @hidden */
  17918. _currentSizeGradient: Nullable<FactorGradient>;
  17919. /** @hidden */
  17920. _currentSize1: number;
  17921. /** @hidden */
  17922. _currentSize2: number;
  17923. /** @hidden */
  17924. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17925. /** @hidden */
  17926. _currentAngularSpeed1: number;
  17927. /** @hidden */
  17928. _currentAngularSpeed2: number;
  17929. /** @hidden */
  17930. _currentVelocityGradient: Nullable<FactorGradient>;
  17931. /** @hidden */
  17932. _currentVelocity1: number;
  17933. /** @hidden */
  17934. _currentVelocity2: number;
  17935. /** @hidden */
  17936. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17937. /** @hidden */
  17938. _currentLimitVelocity1: number;
  17939. /** @hidden */
  17940. _currentLimitVelocity2: number;
  17941. /** @hidden */
  17942. _currentDragGradient: Nullable<FactorGradient>;
  17943. /** @hidden */
  17944. _currentDrag1: number;
  17945. /** @hidden */
  17946. _currentDrag2: number;
  17947. /** @hidden */
  17948. _randomNoiseCoordinates1: Vector3;
  17949. /** @hidden */
  17950. _randomNoiseCoordinates2: Vector3;
  17951. /**
  17952. * Creates a new instance Particle
  17953. * @param particleSystem the particle system the particle belongs to
  17954. */
  17955. constructor(
  17956. /**
  17957. * The particle system the particle belongs to.
  17958. */
  17959. particleSystem: ParticleSystem);
  17960. private updateCellInfoFromSystem;
  17961. /**
  17962. * Defines how the sprite cell index is updated for the particle
  17963. */
  17964. updateCellIndex(): void;
  17965. /** @hidden */
  17966. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17967. /** @hidden */
  17968. _inheritParticleInfoToSubEmitters(): void;
  17969. /** @hidden */
  17970. _reset(): void;
  17971. /**
  17972. * Copy the properties of particle to another one.
  17973. * @param other the particle to copy the information to.
  17974. */
  17975. copyTo(other: Particle): void;
  17976. }
  17977. }
  17978. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17979. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17980. import { Effect } from "babylonjs/Materials/effect";
  17981. import { Particle } from "babylonjs/Particles/particle";
  17982. /**
  17983. * Particle emitter represents a volume emitting particles.
  17984. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17985. */
  17986. export interface IParticleEmitterType {
  17987. /**
  17988. * Called by the particle System when the direction is computed for the created particle.
  17989. * @param worldMatrix is the world matrix of the particle system
  17990. * @param directionToUpdate is the direction vector to update with the result
  17991. * @param particle is the particle we are computed the direction for
  17992. */
  17993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17994. /**
  17995. * Called by the particle System when the position is computed for the created particle.
  17996. * @param worldMatrix is the world matrix of the particle system
  17997. * @param positionToUpdate is the position vector to update with the result
  17998. * @param particle is the particle we are computed the position for
  17999. */
  18000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18001. /**
  18002. * Clones the current emitter and returns a copy of it
  18003. * @returns the new emitter
  18004. */
  18005. clone(): IParticleEmitterType;
  18006. /**
  18007. * Called by the GPUParticleSystem to setup the update shader
  18008. * @param effect defines the update shader
  18009. */
  18010. applyToShader(effect: Effect): void;
  18011. /**
  18012. * Returns a string to use to update the GPU particles update shader
  18013. * @returns the effect defines string
  18014. */
  18015. getEffectDefines(): string;
  18016. /**
  18017. * Returns a string representing the class name
  18018. * @returns a string containing the class name
  18019. */
  18020. getClassName(): string;
  18021. /**
  18022. * Serializes the particle system to a JSON object.
  18023. * @returns the JSON object
  18024. */
  18025. serialize(): any;
  18026. /**
  18027. * Parse properties from a JSON object
  18028. * @param serializationObject defines the JSON object
  18029. */
  18030. parse(serializationObject: any): void;
  18031. }
  18032. }
  18033. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18034. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18035. import { Effect } from "babylonjs/Materials/effect";
  18036. import { Particle } from "babylonjs/Particles/particle";
  18037. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18038. /**
  18039. * Particle emitter emitting particles from the inside of a box.
  18040. * It emits the particles randomly between 2 given directions.
  18041. */
  18042. export class BoxParticleEmitter implements IParticleEmitterType {
  18043. /**
  18044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18045. */
  18046. direction1: Vector3;
  18047. /**
  18048. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18049. */
  18050. direction2: Vector3;
  18051. /**
  18052. * 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.
  18053. */
  18054. minEmitBox: Vector3;
  18055. /**
  18056. * 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.
  18057. */
  18058. maxEmitBox: Vector3;
  18059. /**
  18060. * Creates a new instance BoxParticleEmitter
  18061. */
  18062. constructor();
  18063. /**
  18064. * Called by the particle System when the direction is computed for the created particle.
  18065. * @param worldMatrix is the world matrix of the particle system
  18066. * @param directionToUpdate is the direction vector to update with the result
  18067. * @param particle is the particle we are computed the direction for
  18068. */
  18069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18070. /**
  18071. * Called by the particle System when the position is computed for the created particle.
  18072. * @param worldMatrix is the world matrix of the particle system
  18073. * @param positionToUpdate is the position vector to update with the result
  18074. * @param particle is the particle we are computed the position for
  18075. */
  18076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18077. /**
  18078. * Clones the current emitter and returns a copy of it
  18079. * @returns the new emitter
  18080. */
  18081. clone(): BoxParticleEmitter;
  18082. /**
  18083. * Called by the GPUParticleSystem to setup the update shader
  18084. * @param effect defines the update shader
  18085. */
  18086. applyToShader(effect: Effect): void;
  18087. /**
  18088. * Returns a string to use to update the GPU particles update shader
  18089. * @returns a string containng the defines string
  18090. */
  18091. getEffectDefines(): string;
  18092. /**
  18093. * Returns the string "BoxParticleEmitter"
  18094. * @returns a string containing the class name
  18095. */
  18096. getClassName(): string;
  18097. /**
  18098. * Serializes the particle system to a JSON object.
  18099. * @returns the JSON object
  18100. */
  18101. serialize(): any;
  18102. /**
  18103. * Parse properties from a JSON object
  18104. * @param serializationObject defines the JSON object
  18105. */
  18106. parse(serializationObject: any): void;
  18107. }
  18108. }
  18109. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18110. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18111. import { Effect } from "babylonjs/Materials/effect";
  18112. import { Particle } from "babylonjs/Particles/particle";
  18113. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18114. /**
  18115. * Particle emitter emitting particles from the inside of a cone.
  18116. * It emits the particles alongside the cone volume from the base to the particle.
  18117. * The emission direction might be randomized.
  18118. */
  18119. export class ConeParticleEmitter implements IParticleEmitterType {
  18120. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18121. directionRandomizer: number;
  18122. private _radius;
  18123. private _angle;
  18124. private _height;
  18125. /**
  18126. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18127. */
  18128. radiusRange: number;
  18129. /**
  18130. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18131. */
  18132. heightRange: number;
  18133. /**
  18134. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18135. */
  18136. emitFromSpawnPointOnly: boolean;
  18137. /**
  18138. * Gets or sets the radius of the emission cone
  18139. */
  18140. radius: number;
  18141. /**
  18142. * Gets or sets the angle of the emission cone
  18143. */
  18144. angle: number;
  18145. private _buildHeight;
  18146. /**
  18147. * Creates a new instance ConeParticleEmitter
  18148. * @param radius the radius of the emission cone (1 by default)
  18149. * @param angle the cone base angle (PI by default)
  18150. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18151. */
  18152. constructor(radius?: number, angle?: number,
  18153. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18154. directionRandomizer?: number);
  18155. /**
  18156. * Called by the particle System when the direction is computed for the created particle.
  18157. * @param worldMatrix is the world matrix of the particle system
  18158. * @param directionToUpdate is the direction vector to update with the result
  18159. * @param particle is the particle we are computed the direction for
  18160. */
  18161. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18162. /**
  18163. * Called by the particle System when the position is computed for the created particle.
  18164. * @param worldMatrix is the world matrix of the particle system
  18165. * @param positionToUpdate is the position vector to update with the result
  18166. * @param particle is the particle we are computed the position for
  18167. */
  18168. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18169. /**
  18170. * Clones the current emitter and returns a copy of it
  18171. * @returns the new emitter
  18172. */
  18173. clone(): ConeParticleEmitter;
  18174. /**
  18175. * Called by the GPUParticleSystem to setup the update shader
  18176. * @param effect defines the update shader
  18177. */
  18178. applyToShader(effect: Effect): void;
  18179. /**
  18180. * Returns a string to use to update the GPU particles update shader
  18181. * @returns a string containng the defines string
  18182. */
  18183. getEffectDefines(): string;
  18184. /**
  18185. * Returns the string "ConeParticleEmitter"
  18186. * @returns a string containing the class name
  18187. */
  18188. getClassName(): string;
  18189. /**
  18190. * Serializes the particle system to a JSON object.
  18191. * @returns the JSON object
  18192. */
  18193. serialize(): any;
  18194. /**
  18195. * Parse properties from a JSON object
  18196. * @param serializationObject defines the JSON object
  18197. */
  18198. parse(serializationObject: any): void;
  18199. }
  18200. }
  18201. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18202. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18203. import { Effect } from "babylonjs/Materials/effect";
  18204. import { Particle } from "babylonjs/Particles/particle";
  18205. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18206. /**
  18207. * Particle emitter emitting particles from the inside of a cylinder.
  18208. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18209. */
  18210. export class CylinderParticleEmitter implements IParticleEmitterType {
  18211. /**
  18212. * The radius of the emission cylinder.
  18213. */
  18214. radius: number;
  18215. /**
  18216. * The height of the emission cylinder.
  18217. */
  18218. height: number;
  18219. /**
  18220. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18221. */
  18222. radiusRange: number;
  18223. /**
  18224. * How much to randomize the particle direction [0-1].
  18225. */
  18226. directionRandomizer: number;
  18227. /**
  18228. * Creates a new instance CylinderParticleEmitter
  18229. * @param radius the radius of the emission cylinder (1 by default)
  18230. * @param height the height of the emission cylinder (1 by default)
  18231. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18232. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18233. */
  18234. constructor(
  18235. /**
  18236. * The radius of the emission cylinder.
  18237. */
  18238. radius?: number,
  18239. /**
  18240. * The height of the emission cylinder.
  18241. */
  18242. height?: number,
  18243. /**
  18244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18245. */
  18246. radiusRange?: number,
  18247. /**
  18248. * How much to randomize the particle direction [0-1].
  18249. */
  18250. directionRandomizer?: number);
  18251. /**
  18252. * Called by the particle System when the direction is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param directionToUpdate is the direction vector to update with the result
  18255. * @param particle is the particle we are computed the direction for
  18256. */
  18257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Called by the particle System when the position is computed for the created particle.
  18260. * @param worldMatrix is the world matrix of the particle system
  18261. * @param positionToUpdate is the position vector to update with the result
  18262. * @param particle is the particle we are computed the position for
  18263. */
  18264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18265. /**
  18266. * Clones the current emitter and returns a copy of it
  18267. * @returns the new emitter
  18268. */
  18269. clone(): CylinderParticleEmitter;
  18270. /**
  18271. * Called by the GPUParticleSystem to setup the update shader
  18272. * @param effect defines the update shader
  18273. */
  18274. applyToShader(effect: Effect): void;
  18275. /**
  18276. * Returns a string to use to update the GPU particles update shader
  18277. * @returns a string containng the defines string
  18278. */
  18279. getEffectDefines(): string;
  18280. /**
  18281. * Returns the string "CylinderParticleEmitter"
  18282. * @returns a string containing the class name
  18283. */
  18284. getClassName(): string;
  18285. /**
  18286. * Serializes the particle system to a JSON object.
  18287. * @returns the JSON object
  18288. */
  18289. serialize(): any;
  18290. /**
  18291. * Parse properties from a JSON object
  18292. * @param serializationObject defines the JSON object
  18293. */
  18294. parse(serializationObject: any): void;
  18295. }
  18296. /**
  18297. * Particle emitter emitting particles from the inside of a cylinder.
  18298. * It emits the particles randomly between two vectors.
  18299. */
  18300. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18301. /**
  18302. * The min limit of the emission direction.
  18303. */
  18304. direction1: Vector3;
  18305. /**
  18306. * The max limit of the emission direction.
  18307. */
  18308. direction2: Vector3;
  18309. /**
  18310. * Creates a new instance CylinderDirectedParticleEmitter
  18311. * @param radius the radius of the emission cylinder (1 by default)
  18312. * @param height the height of the emission cylinder (1 by default)
  18313. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18314. * @param direction1 the min limit of the emission direction (up vector by default)
  18315. * @param direction2 the max limit of the emission direction (up vector by default)
  18316. */
  18317. constructor(radius?: number, height?: number, radiusRange?: number,
  18318. /**
  18319. * The min limit of the emission direction.
  18320. */
  18321. direction1?: Vector3,
  18322. /**
  18323. * The max limit of the emission direction.
  18324. */
  18325. direction2?: Vector3);
  18326. /**
  18327. * Called by the particle System when the direction is computed for the created particle.
  18328. * @param worldMatrix is the world matrix of the particle system
  18329. * @param directionToUpdate is the direction vector to update with the result
  18330. * @param particle is the particle we are computed the direction for
  18331. */
  18332. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18333. /**
  18334. * Clones the current emitter and returns a copy of it
  18335. * @returns the new emitter
  18336. */
  18337. clone(): CylinderDirectedParticleEmitter;
  18338. /**
  18339. * Called by the GPUParticleSystem to setup the update shader
  18340. * @param effect defines the update shader
  18341. */
  18342. applyToShader(effect: Effect): void;
  18343. /**
  18344. * Returns a string to use to update the GPU particles update shader
  18345. * @returns a string containng the defines string
  18346. */
  18347. getEffectDefines(): string;
  18348. /**
  18349. * Returns the string "CylinderDirectedParticleEmitter"
  18350. * @returns a string containing the class name
  18351. */
  18352. getClassName(): string;
  18353. /**
  18354. * Serializes the particle system to a JSON object.
  18355. * @returns the JSON object
  18356. */
  18357. serialize(): any;
  18358. /**
  18359. * Parse properties from a JSON object
  18360. * @param serializationObject defines the JSON object
  18361. */
  18362. parse(serializationObject: any): void;
  18363. }
  18364. }
  18365. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18366. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18367. import { Effect } from "babylonjs/Materials/effect";
  18368. import { Particle } from "babylonjs/Particles/particle";
  18369. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18370. /**
  18371. * Particle emitter emitting particles from the inside of a hemisphere.
  18372. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18373. */
  18374. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18375. /**
  18376. * The radius of the emission hemisphere.
  18377. */
  18378. radius: number;
  18379. /**
  18380. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18381. */
  18382. radiusRange: number;
  18383. /**
  18384. * How much to randomize the particle direction [0-1].
  18385. */
  18386. directionRandomizer: number;
  18387. /**
  18388. * Creates a new instance HemisphericParticleEmitter
  18389. * @param radius the radius of the emission hemisphere (1 by default)
  18390. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18391. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18392. */
  18393. constructor(
  18394. /**
  18395. * The radius of the emission hemisphere.
  18396. */
  18397. radius?: number,
  18398. /**
  18399. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18400. */
  18401. radiusRange?: number,
  18402. /**
  18403. * How much to randomize the particle direction [0-1].
  18404. */
  18405. directionRandomizer?: number);
  18406. /**
  18407. * Called by the particle System when the direction is computed for the created particle.
  18408. * @param worldMatrix is the world matrix of the particle system
  18409. * @param directionToUpdate is the direction vector to update with the result
  18410. * @param particle is the particle we are computed the direction for
  18411. */
  18412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18413. /**
  18414. * Called by the particle System when the position is computed for the created particle.
  18415. * @param worldMatrix is the world matrix of the particle system
  18416. * @param positionToUpdate is the position vector to update with the result
  18417. * @param particle is the particle we are computed the position for
  18418. */
  18419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18420. /**
  18421. * Clones the current emitter and returns a copy of it
  18422. * @returns the new emitter
  18423. */
  18424. clone(): HemisphericParticleEmitter;
  18425. /**
  18426. * Called by the GPUParticleSystem to setup the update shader
  18427. * @param effect defines the update shader
  18428. */
  18429. applyToShader(effect: Effect): void;
  18430. /**
  18431. * Returns a string to use to update the GPU particles update shader
  18432. * @returns a string containng the defines string
  18433. */
  18434. getEffectDefines(): string;
  18435. /**
  18436. * Returns the string "HemisphericParticleEmitter"
  18437. * @returns a string containing the class name
  18438. */
  18439. getClassName(): string;
  18440. /**
  18441. * Serializes the particle system to a JSON object.
  18442. * @returns the JSON object
  18443. */
  18444. serialize(): any;
  18445. /**
  18446. * Parse properties from a JSON object
  18447. * @param serializationObject defines the JSON object
  18448. */
  18449. parse(serializationObject: any): void;
  18450. }
  18451. }
  18452. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18453. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18454. import { Effect } from "babylonjs/Materials/effect";
  18455. import { Particle } from "babylonjs/Particles/particle";
  18456. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18457. /**
  18458. * Particle emitter emitting particles from a point.
  18459. * It emits the particles randomly between 2 given directions.
  18460. */
  18461. export class PointParticleEmitter implements IParticleEmitterType {
  18462. /**
  18463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18464. */
  18465. direction1: Vector3;
  18466. /**
  18467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18468. */
  18469. direction2: Vector3;
  18470. /**
  18471. * Creates a new instance PointParticleEmitter
  18472. */
  18473. constructor();
  18474. /**
  18475. * Called by the particle System when the direction is computed for the created particle.
  18476. * @param worldMatrix is the world matrix of the particle system
  18477. * @param directionToUpdate is the direction vector to update with the result
  18478. * @param particle is the particle we are computed the direction for
  18479. */
  18480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18481. /**
  18482. * Called by the particle System when the position is computed for the created particle.
  18483. * @param worldMatrix is the world matrix of the particle system
  18484. * @param positionToUpdate is the position vector to update with the result
  18485. * @param particle is the particle we are computed the position for
  18486. */
  18487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18488. /**
  18489. * Clones the current emitter and returns a copy of it
  18490. * @returns the new emitter
  18491. */
  18492. clone(): PointParticleEmitter;
  18493. /**
  18494. * Called by the GPUParticleSystem to setup the update shader
  18495. * @param effect defines the update shader
  18496. */
  18497. applyToShader(effect: Effect): void;
  18498. /**
  18499. * Returns a string to use to update the GPU particles update shader
  18500. * @returns a string containng the defines string
  18501. */
  18502. getEffectDefines(): string;
  18503. /**
  18504. * Returns the string "PointParticleEmitter"
  18505. * @returns a string containing the class name
  18506. */
  18507. getClassName(): string;
  18508. /**
  18509. * Serializes the particle system to a JSON object.
  18510. * @returns the JSON object
  18511. */
  18512. serialize(): any;
  18513. /**
  18514. * Parse properties from a JSON object
  18515. * @param serializationObject defines the JSON object
  18516. */
  18517. parse(serializationObject: any): void;
  18518. }
  18519. }
  18520. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18521. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18522. import { Effect } from "babylonjs/Materials/effect";
  18523. import { Particle } from "babylonjs/Particles/particle";
  18524. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18525. /**
  18526. * Particle emitter emitting particles from the inside of a sphere.
  18527. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18528. */
  18529. export class SphereParticleEmitter implements IParticleEmitterType {
  18530. /**
  18531. * The radius of the emission sphere.
  18532. */
  18533. radius: number;
  18534. /**
  18535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18536. */
  18537. radiusRange: number;
  18538. /**
  18539. * How much to randomize the particle direction [0-1].
  18540. */
  18541. directionRandomizer: number;
  18542. /**
  18543. * Creates a new instance SphereParticleEmitter
  18544. * @param radius the radius of the emission sphere (1 by default)
  18545. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18547. */
  18548. constructor(
  18549. /**
  18550. * The radius of the emission sphere.
  18551. */
  18552. radius?: number,
  18553. /**
  18554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18555. */
  18556. radiusRange?: number,
  18557. /**
  18558. * How much to randomize the particle direction [0-1].
  18559. */
  18560. directionRandomizer?: number);
  18561. /**
  18562. * Called by the particle System when the direction is computed for the created particle.
  18563. * @param worldMatrix is the world matrix of the particle system
  18564. * @param directionToUpdate is the direction vector to update with the result
  18565. * @param particle is the particle we are computed the direction for
  18566. */
  18567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18568. /**
  18569. * Called by the particle System when the position is computed for the created particle.
  18570. * @param worldMatrix is the world matrix of the particle system
  18571. * @param positionToUpdate is the position vector to update with the result
  18572. * @param particle is the particle we are computed the position for
  18573. */
  18574. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18575. /**
  18576. * Clones the current emitter and returns a copy of it
  18577. * @returns the new emitter
  18578. */
  18579. clone(): SphereParticleEmitter;
  18580. /**
  18581. * Called by the GPUParticleSystem to setup the update shader
  18582. * @param effect defines the update shader
  18583. */
  18584. applyToShader(effect: Effect): void;
  18585. /**
  18586. * Returns a string to use to update the GPU particles update shader
  18587. * @returns a string containng the defines string
  18588. */
  18589. getEffectDefines(): string;
  18590. /**
  18591. * Returns the string "SphereParticleEmitter"
  18592. * @returns a string containing the class name
  18593. */
  18594. getClassName(): string;
  18595. /**
  18596. * Serializes the particle system to a JSON object.
  18597. * @returns the JSON object
  18598. */
  18599. serialize(): any;
  18600. /**
  18601. * Parse properties from a JSON object
  18602. * @param serializationObject defines the JSON object
  18603. */
  18604. parse(serializationObject: any): void;
  18605. }
  18606. /**
  18607. * Particle emitter emitting particles from the inside of a sphere.
  18608. * It emits the particles randomly between two vectors.
  18609. */
  18610. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18611. /**
  18612. * The min limit of the emission direction.
  18613. */
  18614. direction1: Vector3;
  18615. /**
  18616. * The max limit of the emission direction.
  18617. */
  18618. direction2: Vector3;
  18619. /**
  18620. * Creates a new instance SphereDirectedParticleEmitter
  18621. * @param radius the radius of the emission sphere (1 by default)
  18622. * @param direction1 the min limit of the emission direction (up vector by default)
  18623. * @param direction2 the max limit of the emission direction (up vector by default)
  18624. */
  18625. constructor(radius?: number,
  18626. /**
  18627. * The min limit of the emission direction.
  18628. */
  18629. direction1?: Vector3,
  18630. /**
  18631. * The max limit of the emission direction.
  18632. */
  18633. direction2?: Vector3);
  18634. /**
  18635. * Called by the particle System when the direction is computed for the created particle.
  18636. * @param worldMatrix is the world matrix of the particle system
  18637. * @param directionToUpdate is the direction vector to update with the result
  18638. * @param particle is the particle we are computed the direction for
  18639. */
  18640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18641. /**
  18642. * Clones the current emitter and returns a copy of it
  18643. * @returns the new emitter
  18644. */
  18645. clone(): SphereDirectedParticleEmitter;
  18646. /**
  18647. * Called by the GPUParticleSystem to setup the update shader
  18648. * @param effect defines the update shader
  18649. */
  18650. applyToShader(effect: Effect): void;
  18651. /**
  18652. * Returns a string to use to update the GPU particles update shader
  18653. * @returns a string containng the defines string
  18654. */
  18655. getEffectDefines(): string;
  18656. /**
  18657. * Returns the string "SphereDirectedParticleEmitter"
  18658. * @returns a string containing the class name
  18659. */
  18660. getClassName(): string;
  18661. /**
  18662. * Serializes the particle system to a JSON object.
  18663. * @returns the JSON object
  18664. */
  18665. serialize(): any;
  18666. /**
  18667. * Parse properties from a JSON object
  18668. * @param serializationObject defines the JSON object
  18669. */
  18670. parse(serializationObject: any): void;
  18671. }
  18672. }
  18673. declare module "babylonjs/Particles/EmitterTypes/index" {
  18674. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18675. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18676. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18677. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18678. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18679. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18680. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18681. }
  18682. declare module "babylonjs/Particles/IParticleSystem" {
  18683. import { Nullable } from "babylonjs/types";
  18684. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18685. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18687. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18688. import { Texture } from "babylonjs/Materials/Textures/texture";
  18689. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18690. import { Scene } from "babylonjs/scene";
  18691. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18692. import { Animation } from "babylonjs/Animations/animation";
  18693. /**
  18694. * Interface representing a particle system in Babylon.js.
  18695. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18696. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18697. */
  18698. export interface IParticleSystem {
  18699. /**
  18700. * List of animations used by the particle system.
  18701. */
  18702. animations: Animation[];
  18703. /**
  18704. * The id of the Particle system.
  18705. */
  18706. id: string;
  18707. /**
  18708. * The name of the Particle system.
  18709. */
  18710. name: string;
  18711. /**
  18712. * The emitter represents the Mesh or position we are attaching the particle system to.
  18713. */
  18714. emitter: Nullable<AbstractMesh | Vector3>;
  18715. /**
  18716. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18717. */
  18718. isBillboardBased: boolean;
  18719. /**
  18720. * The rendering group used by the Particle system to chose when to render.
  18721. */
  18722. renderingGroupId: number;
  18723. /**
  18724. * The layer mask we are rendering the particles through.
  18725. */
  18726. layerMask: number;
  18727. /**
  18728. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18729. */
  18730. updateSpeed: number;
  18731. /**
  18732. * The amount of time the particle system is running (depends of the overall update speed).
  18733. */
  18734. targetStopDuration: number;
  18735. /**
  18736. * The texture used to render each particle. (this can be a spritesheet)
  18737. */
  18738. particleTexture: Nullable<Texture>;
  18739. /**
  18740. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18741. */
  18742. blendMode: number;
  18743. /**
  18744. * Minimum life time of emitting particles.
  18745. */
  18746. minLifeTime: number;
  18747. /**
  18748. * Maximum life time of emitting particles.
  18749. */
  18750. maxLifeTime: number;
  18751. /**
  18752. * Minimum Size of emitting particles.
  18753. */
  18754. minSize: number;
  18755. /**
  18756. * Maximum Size of emitting particles.
  18757. */
  18758. maxSize: number;
  18759. /**
  18760. * Minimum scale of emitting particles on X axis.
  18761. */
  18762. minScaleX: number;
  18763. /**
  18764. * Maximum scale of emitting particles on X axis.
  18765. */
  18766. maxScaleX: number;
  18767. /**
  18768. * Minimum scale of emitting particles on Y axis.
  18769. */
  18770. minScaleY: number;
  18771. /**
  18772. * Maximum scale of emitting particles on Y axis.
  18773. */
  18774. maxScaleY: number;
  18775. /**
  18776. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18777. */
  18778. color1: Color4;
  18779. /**
  18780. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18781. */
  18782. color2: Color4;
  18783. /**
  18784. * Color the particle will have at the end of its lifetime.
  18785. */
  18786. colorDead: Color4;
  18787. /**
  18788. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18789. */
  18790. emitRate: number;
  18791. /**
  18792. * You can use gravity if you want to give an orientation to your particles.
  18793. */
  18794. gravity: Vector3;
  18795. /**
  18796. * Minimum power of emitting particles.
  18797. */
  18798. minEmitPower: number;
  18799. /**
  18800. * Maximum power of emitting particles.
  18801. */
  18802. maxEmitPower: number;
  18803. /**
  18804. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18805. */
  18806. minAngularSpeed: number;
  18807. /**
  18808. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18809. */
  18810. maxAngularSpeed: number;
  18811. /**
  18812. * Gets or sets the minimal initial rotation in radians.
  18813. */
  18814. minInitialRotation: number;
  18815. /**
  18816. * Gets or sets the maximal initial rotation in radians.
  18817. */
  18818. maxInitialRotation: number;
  18819. /**
  18820. * The particle emitter type defines the emitter used by the particle system.
  18821. * It can be for example box, sphere, or cone...
  18822. */
  18823. particleEmitterType: Nullable<IParticleEmitterType>;
  18824. /**
  18825. * Defines the delay in milliseconds before starting the system (0 by default)
  18826. */
  18827. startDelay: number;
  18828. /**
  18829. * 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
  18830. */
  18831. preWarmCycles: number;
  18832. /**
  18833. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18834. */
  18835. preWarmStepOffset: number;
  18836. /**
  18837. * 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)
  18838. */
  18839. spriteCellChangeSpeed: number;
  18840. /**
  18841. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18842. */
  18843. startSpriteCellID: number;
  18844. /**
  18845. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18846. */
  18847. endSpriteCellID: number;
  18848. /**
  18849. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18850. */
  18851. spriteCellWidth: number;
  18852. /**
  18853. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18854. */
  18855. spriteCellHeight: number;
  18856. /**
  18857. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18858. */
  18859. spriteRandomStartCell: boolean;
  18860. /**
  18861. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18862. */
  18863. isAnimationSheetEnabled: boolean;
  18864. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18865. translationPivot: Vector2;
  18866. /**
  18867. * Gets or sets a texture used to add random noise to particle positions
  18868. */
  18869. noiseTexture: Nullable<BaseTexture>;
  18870. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18871. noiseStrength: Vector3;
  18872. /**
  18873. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18874. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18875. */
  18876. billboardMode: number;
  18877. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18878. limitVelocityDamping: number;
  18879. /**
  18880. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18881. */
  18882. beginAnimationOnStart: boolean;
  18883. /**
  18884. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18885. */
  18886. beginAnimationFrom: number;
  18887. /**
  18888. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18889. */
  18890. beginAnimationTo: number;
  18891. /**
  18892. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18893. */
  18894. beginAnimationLoop: boolean;
  18895. /**
  18896. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18897. */
  18898. disposeOnStop: boolean;
  18899. /**
  18900. * Gets the maximum number of particles active at the same time.
  18901. * @returns The max number of active particles.
  18902. */
  18903. getCapacity(): number;
  18904. /**
  18905. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18906. * @returns True if it has been started, otherwise false.
  18907. */
  18908. isStarted(): boolean;
  18909. /**
  18910. * Animates the particle system for this frame.
  18911. */
  18912. animate(): void;
  18913. /**
  18914. * Renders the particle system in its current state.
  18915. * @returns the current number of particles
  18916. */
  18917. render(): number;
  18918. /**
  18919. * Dispose the particle system and frees its associated resources.
  18920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18921. */
  18922. dispose(disposeTexture?: boolean): void;
  18923. /**
  18924. * Clones the particle system.
  18925. * @param name The name of the cloned object
  18926. * @param newEmitter The new emitter to use
  18927. * @returns the cloned particle system
  18928. */
  18929. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18930. /**
  18931. * Serializes the particle system to a JSON object.
  18932. * @returns the JSON object
  18933. */
  18934. serialize(): any;
  18935. /**
  18936. * Rebuild the particle system
  18937. */
  18938. rebuild(): void;
  18939. /**
  18940. * Starts the particle system and begins to emit
  18941. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18942. */
  18943. start(delay?: number): void;
  18944. /**
  18945. * Stops the particle system.
  18946. */
  18947. stop(): void;
  18948. /**
  18949. * Remove all active particles
  18950. */
  18951. reset(): void;
  18952. /**
  18953. * Is this system ready to be used/rendered
  18954. * @return true if the system is ready
  18955. */
  18956. isReady(): boolean;
  18957. /**
  18958. * Adds a new color gradient
  18959. * @param gradient defines the gradient to use (between 0 and 1)
  18960. * @param color1 defines the color to affect to the specified gradient
  18961. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18962. * @returns the current particle system
  18963. */
  18964. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18965. /**
  18966. * Remove a specific color gradient
  18967. * @param gradient defines the gradient to remove
  18968. * @returns the current particle system
  18969. */
  18970. removeColorGradient(gradient: number): IParticleSystem;
  18971. /**
  18972. * Adds a new size gradient
  18973. * @param gradient defines the gradient to use (between 0 and 1)
  18974. * @param factor defines the size factor to affect to the specified gradient
  18975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18976. * @returns the current particle system
  18977. */
  18978. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18979. /**
  18980. * Remove a specific size gradient
  18981. * @param gradient defines the gradient to remove
  18982. * @returns the current particle system
  18983. */
  18984. removeSizeGradient(gradient: number): IParticleSystem;
  18985. /**
  18986. * Gets the current list of color gradients.
  18987. * You must use addColorGradient and removeColorGradient to udpate this list
  18988. * @returns the list of color gradients
  18989. */
  18990. getColorGradients(): Nullable<Array<ColorGradient>>;
  18991. /**
  18992. * Gets the current list of size gradients.
  18993. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18994. * @returns the list of size gradients
  18995. */
  18996. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18997. /**
  18998. * Gets the current list of angular speed gradients.
  18999. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19000. * @returns the list of angular speed gradients
  19001. */
  19002. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19003. /**
  19004. * Adds a new angular speed gradient
  19005. * @param gradient defines the gradient to use (between 0 and 1)
  19006. * @param factor defines the angular speed to affect to the specified gradient
  19007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19008. * @returns the current particle system
  19009. */
  19010. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19011. /**
  19012. * Remove a specific angular speed gradient
  19013. * @param gradient defines the gradient to remove
  19014. * @returns the current particle system
  19015. */
  19016. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19017. /**
  19018. * Gets the current list of velocity gradients.
  19019. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19020. * @returns the list of velocity gradients
  19021. */
  19022. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19023. /**
  19024. * Adds a new velocity gradient
  19025. * @param gradient defines the gradient to use (between 0 and 1)
  19026. * @param factor defines the velocity to affect to the specified gradient
  19027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19028. * @returns the current particle system
  19029. */
  19030. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19031. /**
  19032. * Remove a specific velocity gradient
  19033. * @param gradient defines the gradient to remove
  19034. * @returns the current particle system
  19035. */
  19036. removeVelocityGradient(gradient: number): IParticleSystem;
  19037. /**
  19038. * Gets the current list of limit velocity gradients.
  19039. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19040. * @returns the list of limit velocity gradients
  19041. */
  19042. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19043. /**
  19044. * Adds a new limit velocity gradient
  19045. * @param gradient defines the gradient to use (between 0 and 1)
  19046. * @param factor defines the limit velocity to affect to the specified gradient
  19047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19048. * @returns the current particle system
  19049. */
  19050. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19051. /**
  19052. * Remove a specific limit velocity gradient
  19053. * @param gradient defines the gradient to remove
  19054. * @returns the current particle system
  19055. */
  19056. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19057. /**
  19058. * Adds a new drag gradient
  19059. * @param gradient defines the gradient to use (between 0 and 1)
  19060. * @param factor defines the drag to affect to the specified gradient
  19061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19062. * @returns the current particle system
  19063. */
  19064. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19065. /**
  19066. * Remove a specific drag gradient
  19067. * @param gradient defines the gradient to remove
  19068. * @returns the current particle system
  19069. */
  19070. removeDragGradient(gradient: number): IParticleSystem;
  19071. /**
  19072. * Gets the current list of drag gradients.
  19073. * You must use addDragGradient and removeDragGradient to udpate this list
  19074. * @returns the list of drag gradients
  19075. */
  19076. getDragGradients(): Nullable<Array<FactorGradient>>;
  19077. /**
  19078. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19079. * @param gradient defines the gradient to use (between 0 and 1)
  19080. * @param factor defines the emit rate to affect to the specified gradient
  19081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19082. * @returns the current particle system
  19083. */
  19084. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19085. /**
  19086. * Remove a specific emit rate gradient
  19087. * @param gradient defines the gradient to remove
  19088. * @returns the current particle system
  19089. */
  19090. removeEmitRateGradient(gradient: number): IParticleSystem;
  19091. /**
  19092. * Gets the current list of emit rate gradients.
  19093. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19094. * @returns the list of emit rate gradients
  19095. */
  19096. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19097. /**
  19098. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19099. * @param gradient defines the gradient to use (between 0 and 1)
  19100. * @param factor defines the start size to affect to the specified gradient
  19101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19102. * @returns the current particle system
  19103. */
  19104. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19105. /**
  19106. * Remove a specific start size gradient
  19107. * @param gradient defines the gradient to remove
  19108. * @returns the current particle system
  19109. */
  19110. removeStartSizeGradient(gradient: number): IParticleSystem;
  19111. /**
  19112. * Gets the current list of start size gradients.
  19113. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19114. * @returns the list of start size gradients
  19115. */
  19116. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19117. /**
  19118. * Adds a new life time gradient
  19119. * @param gradient defines the gradient to use (between 0 and 1)
  19120. * @param factor defines the life time factor to affect to the specified gradient
  19121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19122. * @returns the current particle system
  19123. */
  19124. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19125. /**
  19126. * Remove a specific life time gradient
  19127. * @param gradient defines the gradient to remove
  19128. * @returns the current particle system
  19129. */
  19130. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19131. /**
  19132. * Gets the current list of life time gradients.
  19133. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19134. * @returns the list of life time gradients
  19135. */
  19136. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19137. /**
  19138. * Gets the current list of color gradients.
  19139. * You must use addColorGradient and removeColorGradient to udpate this list
  19140. * @returns the list of color gradients
  19141. */
  19142. getColorGradients(): Nullable<Array<ColorGradient>>;
  19143. /**
  19144. * Adds a new ramp gradient used to remap particle colors
  19145. * @param gradient defines the gradient to use (between 0 and 1)
  19146. * @param color defines the color to affect to the specified gradient
  19147. * @returns the current particle system
  19148. */
  19149. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19150. /**
  19151. * Gets the current list of ramp gradients.
  19152. * You must use addRampGradient and removeRampGradient to udpate this list
  19153. * @returns the list of ramp gradients
  19154. */
  19155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19156. /** Gets or sets a boolean indicating that ramp gradients must be used
  19157. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19158. */
  19159. useRampGradients: boolean;
  19160. /**
  19161. * Adds a new color remap gradient
  19162. * @param gradient defines the gradient to use (between 0 and 1)
  19163. * @param min defines the color remap minimal range
  19164. * @param max defines the color remap maximal range
  19165. * @returns the current particle system
  19166. */
  19167. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19168. /**
  19169. * Gets the current list of color remap gradients.
  19170. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19171. * @returns the list of color remap gradients
  19172. */
  19173. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19174. /**
  19175. * Adds a new alpha remap gradient
  19176. * @param gradient defines the gradient to use (between 0 and 1)
  19177. * @param min defines the alpha remap minimal range
  19178. * @param max defines the alpha remap maximal range
  19179. * @returns the current particle system
  19180. */
  19181. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19182. /**
  19183. * Gets the current list of alpha remap gradients.
  19184. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19185. * @returns the list of alpha remap gradients
  19186. */
  19187. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19188. /**
  19189. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19190. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19191. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19192. * @returns the emitter
  19193. */
  19194. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19195. /**
  19196. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19197. * @param radius The radius of the hemisphere to emit from
  19198. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19199. * @returns the emitter
  19200. */
  19201. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19202. /**
  19203. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19204. * @param radius The radius of the sphere to emit from
  19205. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19206. * @returns the emitter
  19207. */
  19208. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19209. /**
  19210. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19211. * @param radius The radius of the sphere to emit from
  19212. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19213. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19214. * @returns the emitter
  19215. */
  19216. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19217. /**
  19218. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19219. * @param radius The radius of the emission cylinder
  19220. * @param height The height of the emission cylinder
  19221. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19222. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19223. * @returns the emitter
  19224. */
  19225. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19226. /**
  19227. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19228. * @param radius The radius of the cylinder to emit from
  19229. * @param height The height of the emission cylinder
  19230. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19231. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19232. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19233. * @returns the emitter
  19234. */
  19235. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19236. /**
  19237. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19238. * @param radius The radius of the cone to emit from
  19239. * @param angle The base angle of the cone
  19240. * @returns the emitter
  19241. */
  19242. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19243. /**
  19244. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19245. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19246. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19247. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19248. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19249. * @returns the emitter
  19250. */
  19251. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19252. /**
  19253. * Get hosting scene
  19254. * @returns the scene
  19255. */
  19256. getScene(): Scene;
  19257. }
  19258. }
  19259. declare module "babylonjs/Meshes/instancedMesh" {
  19260. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19261. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19262. import { Camera } from "babylonjs/Cameras/camera";
  19263. import { Node } from "babylonjs/node";
  19264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19265. import { Mesh } from "babylonjs/Meshes/mesh";
  19266. import { Material } from "babylonjs/Materials/material";
  19267. import { Skeleton } from "babylonjs/Bones/skeleton";
  19268. import { Light } from "babylonjs/Lights/light";
  19269. /**
  19270. * Creates an instance based on a source mesh.
  19271. */
  19272. export class InstancedMesh extends AbstractMesh {
  19273. private _sourceMesh;
  19274. private _currentLOD;
  19275. /** @hidden */
  19276. _indexInSourceMeshInstanceArray: number;
  19277. constructor(name: string, source: Mesh);
  19278. /**
  19279. * Returns the string "InstancedMesh".
  19280. */
  19281. getClassName(): string;
  19282. /** Gets the list of lights affecting that mesh */
  19283. readonly lightSources: Light[];
  19284. _resyncLightSources(): void;
  19285. _resyncLighSource(light: Light): void;
  19286. _removeLightSource(light: Light, dispose: boolean): void;
  19287. /**
  19288. * If the source mesh receives shadows
  19289. */
  19290. readonly receiveShadows: boolean;
  19291. /**
  19292. * The material of the source mesh
  19293. */
  19294. readonly material: Nullable<Material>;
  19295. /**
  19296. * Visibility of the source mesh
  19297. */
  19298. readonly visibility: number;
  19299. /**
  19300. * Skeleton of the source mesh
  19301. */
  19302. readonly skeleton: Nullable<Skeleton>;
  19303. /**
  19304. * Rendering ground id of the source mesh
  19305. */
  19306. renderingGroupId: number;
  19307. /**
  19308. * Returns the total number of vertices (integer).
  19309. */
  19310. getTotalVertices(): number;
  19311. /**
  19312. * Returns a positive integer : the total number of indices in this mesh geometry.
  19313. * @returns the numner of indices or zero if the mesh has no geometry.
  19314. */
  19315. getTotalIndices(): number;
  19316. /**
  19317. * The source mesh of the instance
  19318. */
  19319. readonly sourceMesh: Mesh;
  19320. /**
  19321. * Is this node ready to be used/rendered
  19322. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19323. * @return {boolean} is it ready
  19324. */
  19325. isReady(completeCheck?: boolean): boolean;
  19326. /**
  19327. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19328. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19329. * @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.
  19330. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19331. */
  19332. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19333. /**
  19334. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19335. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19336. * The `data` are either a numeric array either a Float32Array.
  19337. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19338. * 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).
  19339. * Note that a new underlying VertexBuffer object is created each call.
  19340. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19341. *
  19342. * Possible `kind` values :
  19343. * - VertexBuffer.PositionKind
  19344. * - VertexBuffer.UVKind
  19345. * - VertexBuffer.UV2Kind
  19346. * - VertexBuffer.UV3Kind
  19347. * - VertexBuffer.UV4Kind
  19348. * - VertexBuffer.UV5Kind
  19349. * - VertexBuffer.UV6Kind
  19350. * - VertexBuffer.ColorKind
  19351. * - VertexBuffer.MatricesIndicesKind
  19352. * - VertexBuffer.MatricesIndicesExtraKind
  19353. * - VertexBuffer.MatricesWeightsKind
  19354. * - VertexBuffer.MatricesWeightsExtraKind
  19355. *
  19356. * Returns the Mesh.
  19357. */
  19358. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19359. /**
  19360. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19361. * If the mesh has no geometry, it is simply returned as it is.
  19362. * The `data` are either a numeric array either a Float32Array.
  19363. * No new underlying VertexBuffer object is created.
  19364. * 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.
  19365. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19366. *
  19367. * Possible `kind` values :
  19368. * - VertexBuffer.PositionKind
  19369. * - VertexBuffer.UVKind
  19370. * - VertexBuffer.UV2Kind
  19371. * - VertexBuffer.UV3Kind
  19372. * - VertexBuffer.UV4Kind
  19373. * - VertexBuffer.UV5Kind
  19374. * - VertexBuffer.UV6Kind
  19375. * - VertexBuffer.ColorKind
  19376. * - VertexBuffer.MatricesIndicesKind
  19377. * - VertexBuffer.MatricesIndicesExtraKind
  19378. * - VertexBuffer.MatricesWeightsKind
  19379. * - VertexBuffer.MatricesWeightsExtraKind
  19380. *
  19381. * Returns the Mesh.
  19382. */
  19383. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19384. /**
  19385. * Sets the mesh indices.
  19386. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19387. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19388. * This method creates a new index buffer each call.
  19389. * Returns the Mesh.
  19390. */
  19391. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19392. /**
  19393. * Boolean : True if the mesh owns the requested kind of data.
  19394. */
  19395. isVerticesDataPresent(kind: string): boolean;
  19396. /**
  19397. * Returns an array of indices (IndicesArray).
  19398. */
  19399. getIndices(): Nullable<IndicesArray>;
  19400. readonly _positions: Nullable<Vector3[]>;
  19401. /**
  19402. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19403. * This means the mesh underlying bounding box and sphere are recomputed.
  19404. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19405. * @returns the current mesh
  19406. */
  19407. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19408. /** @hidden */
  19409. _preActivate(): InstancedMesh;
  19410. /** @hidden */
  19411. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19412. /** @hidden */
  19413. _postActivate(): void;
  19414. getWorldMatrix(): Matrix;
  19415. readonly isAnInstance: boolean;
  19416. /**
  19417. * Returns the current associated LOD AbstractMesh.
  19418. */
  19419. getLOD(camera: Camera): AbstractMesh;
  19420. /** @hidden */
  19421. _syncSubMeshes(): InstancedMesh;
  19422. /** @hidden */
  19423. _generatePointsArray(): boolean;
  19424. /**
  19425. * Creates a new InstancedMesh from the current mesh.
  19426. * - name (string) : the cloned mesh name
  19427. * - newParent (optional Node) : the optional Node to parent the clone to.
  19428. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19429. *
  19430. * Returns the clone.
  19431. */
  19432. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19433. /**
  19434. * Disposes the InstancedMesh.
  19435. * Returns nothing.
  19436. */
  19437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19438. }
  19439. }
  19440. declare module "babylonjs/Materials/shaderMaterial" {
  19441. import { Scene } from "babylonjs/scene";
  19442. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19444. import { Mesh } from "babylonjs/Meshes/mesh";
  19445. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19447. import { Texture } from "babylonjs/Materials/Textures/texture";
  19448. import { Material } from "babylonjs/Materials/material";
  19449. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19450. /**
  19451. * Defines the options associated with the creation of a shader material.
  19452. */
  19453. export interface IShaderMaterialOptions {
  19454. /**
  19455. * Does the material work in alpha blend mode
  19456. */
  19457. needAlphaBlending: boolean;
  19458. /**
  19459. * Does the material work in alpha test mode
  19460. */
  19461. needAlphaTesting: boolean;
  19462. /**
  19463. * The list of attribute names used in the shader
  19464. */
  19465. attributes: string[];
  19466. /**
  19467. * The list of unifrom names used in the shader
  19468. */
  19469. uniforms: string[];
  19470. /**
  19471. * The list of UBO names used in the shader
  19472. */
  19473. uniformBuffers: string[];
  19474. /**
  19475. * The list of sampler names used in the shader
  19476. */
  19477. samplers: string[];
  19478. /**
  19479. * The list of defines used in the shader
  19480. */
  19481. defines: string[];
  19482. }
  19483. /**
  19484. * 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.
  19485. *
  19486. * This returned material effects how the mesh will look based on the code in the shaders.
  19487. *
  19488. * @see http://doc.babylonjs.com/how_to/shader_material
  19489. */
  19490. export class ShaderMaterial extends Material {
  19491. private _shaderPath;
  19492. private _options;
  19493. private _textures;
  19494. private _textureArrays;
  19495. private _floats;
  19496. private _ints;
  19497. private _floatsArrays;
  19498. private _colors3;
  19499. private _colors3Arrays;
  19500. private _colors4;
  19501. private _colors4Arrays;
  19502. private _vectors2;
  19503. private _vectors3;
  19504. private _vectors4;
  19505. private _matrices;
  19506. private _matrices3x3;
  19507. private _matrices2x2;
  19508. private _vectors2Arrays;
  19509. private _vectors3Arrays;
  19510. private _vectors4Arrays;
  19511. private _cachedWorldViewMatrix;
  19512. private _cachedWorldViewProjectionMatrix;
  19513. private _renderId;
  19514. /**
  19515. * Instantiate a new shader material.
  19516. * 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.
  19517. * This returned material effects how the mesh will look based on the code in the shaders.
  19518. * @see http://doc.babylonjs.com/how_to/shader_material
  19519. * @param name Define the name of the material in the scene
  19520. * @param scene Define the scene the material belongs to
  19521. * @param shaderPath Defines the route to the shader code in one of three ways:
  19522. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19523. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19524. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19525. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19526. * @param options Define the options used to create the shader
  19527. */
  19528. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19529. /**
  19530. * Gets the options used to compile the shader.
  19531. * They can be modified to trigger a new compilation
  19532. */
  19533. readonly options: IShaderMaterialOptions;
  19534. /**
  19535. * Gets the current class name of the material e.g. "ShaderMaterial"
  19536. * Mainly use in serialization.
  19537. * @returns the class name
  19538. */
  19539. getClassName(): string;
  19540. /**
  19541. * Specifies if the material will require alpha blending
  19542. * @returns a boolean specifying if alpha blending is needed
  19543. */
  19544. needAlphaBlending(): boolean;
  19545. /**
  19546. * Specifies if this material should be rendered in alpha test mode
  19547. * @returns a boolean specifying if an alpha test is needed.
  19548. */
  19549. needAlphaTesting(): boolean;
  19550. private _checkUniform;
  19551. /**
  19552. * Set a texture in the shader.
  19553. * @param name Define the name of the uniform samplers as defined in the shader
  19554. * @param texture Define the texture to bind to this sampler
  19555. * @return the material itself allowing "fluent" like uniform updates
  19556. */
  19557. setTexture(name: string, texture: Texture): ShaderMaterial;
  19558. /**
  19559. * Set a texture array in the shader.
  19560. * @param name Define the name of the uniform sampler array as defined in the shader
  19561. * @param textures Define the list of textures to bind to this sampler
  19562. * @return the material itself allowing "fluent" like uniform updates
  19563. */
  19564. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19565. /**
  19566. * Set a float in the shader.
  19567. * @param name Define the name of the uniform as defined in the shader
  19568. * @param value Define the value to give to the uniform
  19569. * @return the material itself allowing "fluent" like uniform updates
  19570. */
  19571. setFloat(name: string, value: number): ShaderMaterial;
  19572. /**
  19573. * Set a int in the shader.
  19574. * @param name Define the name of the uniform as defined in the shader
  19575. * @param value Define the value to give to the uniform
  19576. * @return the material itself allowing "fluent" like uniform updates
  19577. */
  19578. setInt(name: string, value: number): ShaderMaterial;
  19579. /**
  19580. * Set an array of floats in the shader.
  19581. * @param name Define the name of the uniform as defined in the shader
  19582. * @param value Define the value to give to the uniform
  19583. * @return the material itself allowing "fluent" like uniform updates
  19584. */
  19585. setFloats(name: string, value: number[]): ShaderMaterial;
  19586. /**
  19587. * Set a vec3 in the shader from a Color3.
  19588. * @param name Define the name of the uniform as defined in the shader
  19589. * @param value Define the value to give to the uniform
  19590. * @return the material itself allowing "fluent" like uniform updates
  19591. */
  19592. setColor3(name: string, value: Color3): ShaderMaterial;
  19593. /**
  19594. * Set a vec3 array in the shader from a Color3 array.
  19595. * @param name Define the name of the uniform as defined in the shader
  19596. * @param value Define the value to give to the uniform
  19597. * @return the material itself allowing "fluent" like uniform updates
  19598. */
  19599. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19600. /**
  19601. * Set a vec4 in the shader from a Color4.
  19602. * @param name Define the name of the uniform as defined in the shader
  19603. * @param value Define the value to give to the uniform
  19604. * @return the material itself allowing "fluent" like uniform updates
  19605. */
  19606. setColor4(name: string, value: Color4): ShaderMaterial;
  19607. /**
  19608. * Set a vec4 array in the shader from a Color4 array.
  19609. * @param name Define the name of the uniform as defined in the shader
  19610. * @param value Define the value to give to the uniform
  19611. * @return the material itself allowing "fluent" like uniform updates
  19612. */
  19613. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19614. /**
  19615. * Set a vec2 in the shader from a Vector2.
  19616. * @param name Define the name of the uniform as defined in the shader
  19617. * @param value Define the value to give to the uniform
  19618. * @return the material itself allowing "fluent" like uniform updates
  19619. */
  19620. setVector2(name: string, value: Vector2): ShaderMaterial;
  19621. /**
  19622. * Set a vec3 in the shader from a Vector3.
  19623. * @param name Define the name of the uniform as defined in the shader
  19624. * @param value Define the value to give to the uniform
  19625. * @return the material itself allowing "fluent" like uniform updates
  19626. */
  19627. setVector3(name: string, value: Vector3): ShaderMaterial;
  19628. /**
  19629. * Set a vec4 in the shader from a Vector4.
  19630. * @param name Define the name of the uniform as defined in the shader
  19631. * @param value Define the value to give to the uniform
  19632. * @return the material itself allowing "fluent" like uniform updates
  19633. */
  19634. setVector4(name: string, value: Vector4): ShaderMaterial;
  19635. /**
  19636. * Set a mat4 in the shader from a Matrix.
  19637. * @param name Define the name of the uniform as defined in the shader
  19638. * @param value Define the value to give to the uniform
  19639. * @return the material itself allowing "fluent" like uniform updates
  19640. */
  19641. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19642. /**
  19643. * Set a mat3 in the shader from a Float32Array.
  19644. * @param name Define the name of the uniform as defined in the shader
  19645. * @param value Define the value to give to the uniform
  19646. * @return the material itself allowing "fluent" like uniform updates
  19647. */
  19648. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19649. /**
  19650. * Set a mat2 in the shader from a Float32Array.
  19651. * @param name Define the name of the uniform as defined in the shader
  19652. * @param value Define the value to give to the uniform
  19653. * @return the material itself allowing "fluent" like uniform updates
  19654. */
  19655. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19656. /**
  19657. * Set a vec2 array in the shader from a number array.
  19658. * @param name Define the name of the uniform as defined in the shader
  19659. * @param value Define the value to give to the uniform
  19660. * @return the material itself allowing "fluent" like uniform updates
  19661. */
  19662. setArray2(name: string, value: number[]): ShaderMaterial;
  19663. /**
  19664. * Set a vec3 array in the shader from a number array.
  19665. * @param name Define the name of the uniform as defined in the shader
  19666. * @param value Define the value to give to the uniform
  19667. * @return the material itself allowing "fluent" like uniform updates
  19668. */
  19669. setArray3(name: string, value: number[]): ShaderMaterial;
  19670. /**
  19671. * Set a vec4 array in the shader from a number array.
  19672. * @param name Define the name of the uniform as defined in the shader
  19673. * @param value Define the value to give to the uniform
  19674. * @return the material itself allowing "fluent" like uniform updates
  19675. */
  19676. setArray4(name: string, value: number[]): ShaderMaterial;
  19677. private _checkCache;
  19678. /**
  19679. * Specifies that the submesh is ready to be used
  19680. * @param mesh defines the mesh to check
  19681. * @param subMesh defines which submesh to check
  19682. * @param useInstances specifies that instances should be used
  19683. * @returns a boolean indicating that the submesh is ready or not
  19684. */
  19685. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19686. /**
  19687. * Checks if the material is ready to render the requested mesh
  19688. * @param mesh Define the mesh to render
  19689. * @param useInstances Define whether or not the material is used with instances
  19690. * @returns true if ready, otherwise false
  19691. */
  19692. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19693. /**
  19694. * Binds the world matrix to the material
  19695. * @param world defines the world transformation matrix
  19696. */
  19697. bindOnlyWorldMatrix(world: Matrix): void;
  19698. /**
  19699. * Binds the material to the mesh
  19700. * @param world defines the world transformation matrix
  19701. * @param mesh defines the mesh to bind the material to
  19702. */
  19703. bind(world: Matrix, mesh?: Mesh): void;
  19704. /**
  19705. * Gets the active textures from the material
  19706. * @returns an array of textures
  19707. */
  19708. getActiveTextures(): BaseTexture[];
  19709. /**
  19710. * Specifies if the material uses a texture
  19711. * @param texture defines the texture to check against the material
  19712. * @returns a boolean specifying if the material uses the texture
  19713. */
  19714. hasTexture(texture: BaseTexture): boolean;
  19715. /**
  19716. * Makes a duplicate of the material, and gives it a new name
  19717. * @param name defines the new name for the duplicated material
  19718. * @returns the cloned material
  19719. */
  19720. clone(name: string): ShaderMaterial;
  19721. /**
  19722. * Disposes the material
  19723. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19724. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19725. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19726. */
  19727. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19728. /**
  19729. * Serializes this material in a JSON representation
  19730. * @returns the serialized material object
  19731. */
  19732. serialize(): any;
  19733. /**
  19734. * Creates a shader material from parsed shader material data
  19735. * @param source defines the JSON represnetation of the material
  19736. * @param scene defines the hosting scene
  19737. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19738. * @returns a new material
  19739. */
  19740. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19741. }
  19742. }
  19743. declare module "babylonjs/Shaders/color.fragment" {
  19744. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19745. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19746. /** @hidden */
  19747. export var colorPixelShader: {
  19748. name: string;
  19749. shader: string;
  19750. };
  19751. }
  19752. declare module "babylonjs/Shaders/color.vertex" {
  19753. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19754. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19755. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19756. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19757. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19758. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19759. /** @hidden */
  19760. export var colorVertexShader: {
  19761. name: string;
  19762. shader: string;
  19763. };
  19764. }
  19765. declare module "babylonjs/Meshes/linesMesh" {
  19766. import { Nullable } from "babylonjs/types";
  19767. import { Scene } from "babylonjs/scene";
  19768. import { Color3 } from "babylonjs/Maths/math.color";
  19769. import { Node } from "babylonjs/node";
  19770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19771. import { Mesh } from "babylonjs/Meshes/mesh";
  19772. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19773. import { Effect } from "babylonjs/Materials/effect";
  19774. import { Material } from "babylonjs/Materials/material";
  19775. import "babylonjs/Shaders/color.fragment";
  19776. import "babylonjs/Shaders/color.vertex";
  19777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19778. /**
  19779. * Line mesh
  19780. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19781. */
  19782. export class LinesMesh extends Mesh {
  19783. /**
  19784. * If vertex color should be applied to the mesh
  19785. */
  19786. readonly useVertexColor?: boolean | undefined;
  19787. /**
  19788. * If vertex alpha should be applied to the mesh
  19789. */
  19790. readonly useVertexAlpha?: boolean | undefined;
  19791. /**
  19792. * Color of the line (Default: White)
  19793. */
  19794. color: Color3;
  19795. /**
  19796. * Alpha of the line (Default: 1)
  19797. */
  19798. alpha: number;
  19799. /**
  19800. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19801. * This margin is expressed in world space coordinates, so its value may vary.
  19802. * Default value is 0.1
  19803. */
  19804. intersectionThreshold: number;
  19805. private _colorShader;
  19806. private color4;
  19807. /**
  19808. * Creates a new LinesMesh
  19809. * @param name defines the name
  19810. * @param scene defines the hosting scene
  19811. * @param parent defines the parent mesh if any
  19812. * @param source defines the optional source LinesMesh used to clone data from
  19813. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19814. * When false, achieved by calling a clone(), also passing False.
  19815. * This will make creation of children, recursive.
  19816. * @param useVertexColor defines if this LinesMesh supports vertex color
  19817. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19818. */
  19819. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19820. /**
  19821. * If vertex color should be applied to the mesh
  19822. */
  19823. useVertexColor?: boolean | undefined,
  19824. /**
  19825. * If vertex alpha should be applied to the mesh
  19826. */
  19827. useVertexAlpha?: boolean | undefined);
  19828. private _addClipPlaneDefine;
  19829. private _removeClipPlaneDefine;
  19830. isReady(): boolean;
  19831. /**
  19832. * Returns the string "LineMesh"
  19833. */
  19834. getClassName(): string;
  19835. /**
  19836. * @hidden
  19837. */
  19838. /**
  19839. * @hidden
  19840. */
  19841. material: Material;
  19842. /**
  19843. * @hidden
  19844. */
  19845. readonly checkCollisions: boolean;
  19846. /** @hidden */
  19847. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19848. /** @hidden */
  19849. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19850. /**
  19851. * Disposes of the line mesh
  19852. * @param doNotRecurse If children should be disposed
  19853. */
  19854. dispose(doNotRecurse?: boolean): void;
  19855. /**
  19856. * Returns a new LineMesh object cloned from the current one.
  19857. */
  19858. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19859. /**
  19860. * Creates a new InstancedLinesMesh object from the mesh model.
  19861. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19862. * @param name defines the name of the new instance
  19863. * @returns a new InstancedLinesMesh
  19864. */
  19865. createInstance(name: string): InstancedLinesMesh;
  19866. }
  19867. /**
  19868. * Creates an instance based on a source LinesMesh
  19869. */
  19870. export class InstancedLinesMesh extends InstancedMesh {
  19871. /**
  19872. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19873. * This margin is expressed in world space coordinates, so its value may vary.
  19874. * Initilized with the intersectionThreshold value of the source LinesMesh
  19875. */
  19876. intersectionThreshold: number;
  19877. constructor(name: string, source: LinesMesh);
  19878. /**
  19879. * Returns the string "InstancedLinesMesh".
  19880. */
  19881. getClassName(): string;
  19882. }
  19883. }
  19884. declare module "babylonjs/Shaders/line.fragment" {
  19885. /** @hidden */
  19886. export var linePixelShader: {
  19887. name: string;
  19888. shader: string;
  19889. };
  19890. }
  19891. declare module "babylonjs/Shaders/line.vertex" {
  19892. /** @hidden */
  19893. export var lineVertexShader: {
  19894. name: string;
  19895. shader: string;
  19896. };
  19897. }
  19898. declare module "babylonjs/Rendering/edgesRenderer" {
  19899. import { Nullable } from "babylonjs/types";
  19900. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19902. import { Vector3 } from "babylonjs/Maths/math.vector";
  19903. import { IDisposable } from "babylonjs/scene";
  19904. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19905. import "babylonjs/Shaders/line.fragment";
  19906. import "babylonjs/Shaders/line.vertex";
  19907. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19908. module "babylonjs/Meshes/abstractMesh" {
  19909. interface AbstractMesh {
  19910. /**
  19911. * Gets the edgesRenderer associated with the mesh
  19912. */
  19913. edgesRenderer: Nullable<EdgesRenderer>;
  19914. }
  19915. }
  19916. module "babylonjs/Meshes/linesMesh" {
  19917. interface LinesMesh {
  19918. /**
  19919. * Enables the edge rendering mode on the mesh.
  19920. * This mode makes the mesh edges visible
  19921. * @param epsilon defines the maximal distance between two angles to detect a face
  19922. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19923. * @returns the currentAbstractMesh
  19924. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19925. */
  19926. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19927. }
  19928. }
  19929. module "babylonjs/Meshes/linesMesh" {
  19930. interface InstancedLinesMesh {
  19931. /**
  19932. * Enables the edge rendering mode on the mesh.
  19933. * This mode makes the mesh edges visible
  19934. * @param epsilon defines the maximal distance between two angles to detect a face
  19935. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19936. * @returns the current InstancedLinesMesh
  19937. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19938. */
  19939. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19940. }
  19941. }
  19942. /**
  19943. * Defines the minimum contract an Edges renderer should follow.
  19944. */
  19945. export interface IEdgesRenderer extends IDisposable {
  19946. /**
  19947. * Gets or sets a boolean indicating if the edgesRenderer is active
  19948. */
  19949. isEnabled: boolean;
  19950. /**
  19951. * Renders the edges of the attached mesh,
  19952. */
  19953. render(): void;
  19954. /**
  19955. * Checks wether or not the edges renderer is ready to render.
  19956. * @return true if ready, otherwise false.
  19957. */
  19958. isReady(): boolean;
  19959. }
  19960. /**
  19961. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19962. */
  19963. export class EdgesRenderer implements IEdgesRenderer {
  19964. /**
  19965. * Define the size of the edges with an orthographic camera
  19966. */
  19967. edgesWidthScalerForOrthographic: number;
  19968. /**
  19969. * Define the size of the edges with a perspective camera
  19970. */
  19971. edgesWidthScalerForPerspective: number;
  19972. protected _source: AbstractMesh;
  19973. protected _linesPositions: number[];
  19974. protected _linesNormals: number[];
  19975. protected _linesIndices: number[];
  19976. protected _epsilon: number;
  19977. protected _indicesCount: number;
  19978. protected _lineShader: ShaderMaterial;
  19979. protected _ib: DataBuffer;
  19980. protected _buffers: {
  19981. [key: string]: Nullable<VertexBuffer>;
  19982. };
  19983. protected _checkVerticesInsteadOfIndices: boolean;
  19984. private _meshRebuildObserver;
  19985. private _meshDisposeObserver;
  19986. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19987. isEnabled: boolean;
  19988. /**
  19989. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19990. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19991. * @param source Mesh used to create edges
  19992. * @param epsilon sum of angles in adjacency to check for edge
  19993. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19994. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19995. */
  19996. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19997. protected _prepareRessources(): void;
  19998. /** @hidden */
  19999. _rebuild(): void;
  20000. /**
  20001. * Releases the required resources for the edges renderer
  20002. */
  20003. dispose(): void;
  20004. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20005. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20006. /**
  20007. * Checks if the pair of p0 and p1 is en edge
  20008. * @param faceIndex
  20009. * @param edge
  20010. * @param faceNormals
  20011. * @param p0
  20012. * @param p1
  20013. * @private
  20014. */
  20015. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20016. /**
  20017. * push line into the position, normal and index buffer
  20018. * @protected
  20019. */
  20020. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20021. /**
  20022. * Generates lines edges from adjacencjes
  20023. * @private
  20024. */
  20025. _generateEdgesLines(): void;
  20026. /**
  20027. * Checks wether or not the edges renderer is ready to render.
  20028. * @return true if ready, otherwise false.
  20029. */
  20030. isReady(): boolean;
  20031. /**
  20032. * Renders the edges of the attached mesh,
  20033. */
  20034. render(): void;
  20035. }
  20036. /**
  20037. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20038. */
  20039. export class LineEdgesRenderer extends EdgesRenderer {
  20040. /**
  20041. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20042. * @param source LineMesh used to generate edges
  20043. * @param epsilon not important (specified angle for edge detection)
  20044. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20045. */
  20046. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20047. /**
  20048. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20049. */
  20050. _generateEdgesLines(): void;
  20051. }
  20052. }
  20053. declare module "babylonjs/Rendering/renderingGroup" {
  20054. import { SmartArray } from "babylonjs/Misc/smartArray";
  20055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20057. import { Nullable } from "babylonjs/types";
  20058. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20059. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20060. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20061. import { Material } from "babylonjs/Materials/material";
  20062. import { Scene } from "babylonjs/scene";
  20063. /**
  20064. * This represents the object necessary to create a rendering group.
  20065. * This is exclusively used and created by the rendering manager.
  20066. * To modify the behavior, you use the available helpers in your scene or meshes.
  20067. * @hidden
  20068. */
  20069. export class RenderingGroup {
  20070. index: number;
  20071. private static _zeroVector;
  20072. private _scene;
  20073. private _opaqueSubMeshes;
  20074. private _transparentSubMeshes;
  20075. private _alphaTestSubMeshes;
  20076. private _depthOnlySubMeshes;
  20077. private _particleSystems;
  20078. private _spriteManagers;
  20079. private _opaqueSortCompareFn;
  20080. private _alphaTestSortCompareFn;
  20081. private _transparentSortCompareFn;
  20082. private _renderOpaque;
  20083. private _renderAlphaTest;
  20084. private _renderTransparent;
  20085. /** @hidden */
  20086. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20087. onBeforeTransparentRendering: () => void;
  20088. /**
  20089. * Set the opaque sort comparison function.
  20090. * If null the sub meshes will be render in the order they were created
  20091. */
  20092. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20093. /**
  20094. * Set the alpha test sort comparison function.
  20095. * If null the sub meshes will be render in the order they were created
  20096. */
  20097. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20098. /**
  20099. * Set the transparent sort comparison function.
  20100. * If null the sub meshes will be render in the order they were created
  20101. */
  20102. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20103. /**
  20104. * Creates a new rendering group.
  20105. * @param index The rendering group index
  20106. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20107. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20108. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20109. */
  20110. 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>);
  20111. /**
  20112. * Render all the sub meshes contained in the group.
  20113. * @param customRenderFunction Used to override the default render behaviour of the group.
  20114. * @returns true if rendered some submeshes.
  20115. */
  20116. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20117. /**
  20118. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20119. * @param subMeshes The submeshes to render
  20120. */
  20121. private renderOpaqueSorted;
  20122. /**
  20123. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20124. * @param subMeshes The submeshes to render
  20125. */
  20126. private renderAlphaTestSorted;
  20127. /**
  20128. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20129. * @param subMeshes The submeshes to render
  20130. */
  20131. private renderTransparentSorted;
  20132. /**
  20133. * Renders the submeshes in a specified order.
  20134. * @param subMeshes The submeshes to sort before render
  20135. * @param sortCompareFn The comparison function use to sort
  20136. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20137. * @param transparent Specifies to activate blending if true
  20138. */
  20139. private static renderSorted;
  20140. /**
  20141. * Renders the submeshes in the order they were dispatched (no sort applied).
  20142. * @param subMeshes The submeshes to render
  20143. */
  20144. private static renderUnsorted;
  20145. /**
  20146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20147. * are rendered back to front if in the same alpha index.
  20148. *
  20149. * @param a The first submesh
  20150. * @param b The second submesh
  20151. * @returns The result of the comparison
  20152. */
  20153. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20154. /**
  20155. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20156. * are rendered back to front.
  20157. *
  20158. * @param a The first submesh
  20159. * @param b The second submesh
  20160. * @returns The result of the comparison
  20161. */
  20162. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20163. /**
  20164. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20165. * are rendered front to back (prevent overdraw).
  20166. *
  20167. * @param a The first submesh
  20168. * @param b The second submesh
  20169. * @returns The result of the comparison
  20170. */
  20171. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20172. /**
  20173. * Resets the different lists of submeshes to prepare a new frame.
  20174. */
  20175. prepare(): void;
  20176. dispose(): void;
  20177. /**
  20178. * Inserts the submesh in its correct queue depending on its material.
  20179. * @param subMesh The submesh to dispatch
  20180. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20181. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20182. */
  20183. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20184. dispatchSprites(spriteManager: ISpriteManager): void;
  20185. dispatchParticles(particleSystem: IParticleSystem): void;
  20186. private _renderParticles;
  20187. private _renderSprites;
  20188. }
  20189. }
  20190. declare module "babylonjs/Rendering/renderingManager" {
  20191. import { Nullable } from "babylonjs/types";
  20192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20193. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20194. import { SmartArray } from "babylonjs/Misc/smartArray";
  20195. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20196. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20197. import { Material } from "babylonjs/Materials/material";
  20198. import { Scene } from "babylonjs/scene";
  20199. import { Camera } from "babylonjs/Cameras/camera";
  20200. /**
  20201. * Interface describing the different options available in the rendering manager
  20202. * regarding Auto Clear between groups.
  20203. */
  20204. export interface IRenderingManagerAutoClearSetup {
  20205. /**
  20206. * Defines whether or not autoclear is enable.
  20207. */
  20208. autoClear: boolean;
  20209. /**
  20210. * Defines whether or not to autoclear the depth buffer.
  20211. */
  20212. depth: boolean;
  20213. /**
  20214. * Defines whether or not to autoclear the stencil buffer.
  20215. */
  20216. stencil: boolean;
  20217. }
  20218. /**
  20219. * This class is used by the onRenderingGroupObservable
  20220. */
  20221. export class RenderingGroupInfo {
  20222. /**
  20223. * The Scene that being rendered
  20224. */
  20225. scene: Scene;
  20226. /**
  20227. * The camera currently used for the rendering pass
  20228. */
  20229. camera: Nullable<Camera>;
  20230. /**
  20231. * The ID of the renderingGroup being processed
  20232. */
  20233. renderingGroupId: number;
  20234. }
  20235. /**
  20236. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20237. * It is enable to manage the different groups as well as the different necessary sort functions.
  20238. * This should not be used directly aside of the few static configurations
  20239. */
  20240. export class RenderingManager {
  20241. /**
  20242. * The max id used for rendering groups (not included)
  20243. */
  20244. static MAX_RENDERINGGROUPS: number;
  20245. /**
  20246. * The min id used for rendering groups (included)
  20247. */
  20248. static MIN_RENDERINGGROUPS: number;
  20249. /**
  20250. * Used to globally prevent autoclearing scenes.
  20251. */
  20252. static AUTOCLEAR: boolean;
  20253. /**
  20254. * @hidden
  20255. */
  20256. _useSceneAutoClearSetup: boolean;
  20257. private _scene;
  20258. private _renderingGroups;
  20259. private _depthStencilBufferAlreadyCleaned;
  20260. private _autoClearDepthStencil;
  20261. private _customOpaqueSortCompareFn;
  20262. private _customAlphaTestSortCompareFn;
  20263. private _customTransparentSortCompareFn;
  20264. private _renderingGroupInfo;
  20265. /**
  20266. * Instantiates a new rendering group for a particular scene
  20267. * @param scene Defines the scene the groups belongs to
  20268. */
  20269. constructor(scene: Scene);
  20270. private _clearDepthStencilBuffer;
  20271. /**
  20272. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20273. * @hidden
  20274. */
  20275. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20276. /**
  20277. * Resets the different information of the group to prepare a new frame
  20278. * @hidden
  20279. */
  20280. reset(): void;
  20281. /**
  20282. * Dispose and release the group and its associated resources.
  20283. * @hidden
  20284. */
  20285. dispose(): void;
  20286. /**
  20287. * Clear the info related to rendering groups preventing retention points during dispose.
  20288. */
  20289. freeRenderingGroups(): void;
  20290. private _prepareRenderingGroup;
  20291. /**
  20292. * Add a sprite manager to the rendering manager in order to render it this frame.
  20293. * @param spriteManager Define the sprite manager to render
  20294. */
  20295. dispatchSprites(spriteManager: ISpriteManager): void;
  20296. /**
  20297. * Add a particle system to the rendering manager in order to render it this frame.
  20298. * @param particleSystem Define the particle system to render
  20299. */
  20300. dispatchParticles(particleSystem: IParticleSystem): void;
  20301. /**
  20302. * Add a submesh to the manager in order to render it this frame
  20303. * @param subMesh The submesh to dispatch
  20304. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20305. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20306. */
  20307. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20308. /**
  20309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20310. * This allowed control for front to back rendering or reversly depending of the special needs.
  20311. *
  20312. * @param renderingGroupId The rendering group id corresponding to its index
  20313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20316. */
  20317. 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;
  20318. /**
  20319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20320. *
  20321. * @param renderingGroupId The rendering group id corresponding to its index
  20322. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20323. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20324. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20325. */
  20326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20327. /**
  20328. * Gets the current auto clear configuration for one rendering group of the rendering
  20329. * manager.
  20330. * @param index the rendering group index to get the information for
  20331. * @returns The auto clear setup for the requested rendering group
  20332. */
  20333. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20334. }
  20335. }
  20336. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20337. import { Observable } from "babylonjs/Misc/observable";
  20338. import { SmartArray } from "babylonjs/Misc/smartArray";
  20339. import { Nullable } from "babylonjs/types";
  20340. import { Camera } from "babylonjs/Cameras/camera";
  20341. import { Scene } from "babylonjs/scene";
  20342. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20343. import { Color4 } from "babylonjs/Maths/math.color";
  20344. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20346. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20347. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20348. import { Texture } from "babylonjs/Materials/Textures/texture";
  20349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20350. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20351. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20352. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20353. import { Engine } from "babylonjs/Engines/engine";
  20354. /**
  20355. * This Helps creating a texture that will be created from a camera in your scene.
  20356. * It is basically a dynamic texture that could be used to create special effects for instance.
  20357. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20358. */
  20359. export class RenderTargetTexture extends Texture {
  20360. isCube: boolean;
  20361. /**
  20362. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20363. */
  20364. static readonly REFRESHRATE_RENDER_ONCE: number;
  20365. /**
  20366. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20367. */
  20368. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20369. /**
  20370. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20371. * the central point of your effect and can save a lot of performances.
  20372. */
  20373. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20374. /**
  20375. * Use this predicate to dynamically define the list of mesh you want to render.
  20376. * If set, the renderList property will be overwritten.
  20377. */
  20378. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20379. private _renderList;
  20380. /**
  20381. * Use this list to define the list of mesh you want to render.
  20382. */
  20383. renderList: Nullable<Array<AbstractMesh>>;
  20384. private _hookArray;
  20385. /**
  20386. * Define if particles should be rendered in your texture.
  20387. */
  20388. renderParticles: boolean;
  20389. /**
  20390. * Define if sprites should be rendered in your texture.
  20391. */
  20392. renderSprites: boolean;
  20393. /**
  20394. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20395. */
  20396. coordinatesMode: number;
  20397. /**
  20398. * Define the camera used to render the texture.
  20399. */
  20400. activeCamera: Nullable<Camera>;
  20401. /**
  20402. * Override the render function of the texture with your own one.
  20403. */
  20404. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20405. /**
  20406. * Define if camera post processes should be use while rendering the texture.
  20407. */
  20408. useCameraPostProcesses: boolean;
  20409. /**
  20410. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20411. */
  20412. ignoreCameraViewport: boolean;
  20413. private _postProcessManager;
  20414. private _postProcesses;
  20415. private _resizeObserver;
  20416. /**
  20417. * An event triggered when the texture is unbind.
  20418. */
  20419. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20420. /**
  20421. * An event triggered when the texture is unbind.
  20422. */
  20423. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20424. private _onAfterUnbindObserver;
  20425. /**
  20426. * Set a after unbind callback in the texture.
  20427. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20428. */
  20429. onAfterUnbind: () => void;
  20430. /**
  20431. * An event triggered before rendering the texture
  20432. */
  20433. onBeforeRenderObservable: Observable<number>;
  20434. private _onBeforeRenderObserver;
  20435. /**
  20436. * Set a before render callback in the texture.
  20437. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20438. */
  20439. onBeforeRender: (faceIndex: number) => void;
  20440. /**
  20441. * An event triggered after rendering the texture
  20442. */
  20443. onAfterRenderObservable: Observable<number>;
  20444. private _onAfterRenderObserver;
  20445. /**
  20446. * Set a after render callback in the texture.
  20447. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20448. */
  20449. onAfterRender: (faceIndex: number) => void;
  20450. /**
  20451. * An event triggered after the texture clear
  20452. */
  20453. onClearObservable: Observable<Engine>;
  20454. private _onClearObserver;
  20455. /**
  20456. * Set a clear callback in the texture.
  20457. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20458. */
  20459. onClear: (Engine: Engine) => void;
  20460. /**
  20461. * An event triggered when the texture is resized.
  20462. */
  20463. onResizeObservable: Observable<RenderTargetTexture>;
  20464. /**
  20465. * Define the clear color of the Render Target if it should be different from the scene.
  20466. */
  20467. clearColor: Color4;
  20468. protected _size: number | {
  20469. width: number;
  20470. height: number;
  20471. };
  20472. protected _initialSizeParameter: number | {
  20473. width: number;
  20474. height: number;
  20475. } | {
  20476. ratio: number;
  20477. };
  20478. protected _sizeRatio: Nullable<number>;
  20479. /** @hidden */
  20480. _generateMipMaps: boolean;
  20481. protected _renderingManager: RenderingManager;
  20482. /** @hidden */
  20483. _waitingRenderList: string[];
  20484. protected _doNotChangeAspectRatio: boolean;
  20485. protected _currentRefreshId: number;
  20486. protected _refreshRate: number;
  20487. protected _textureMatrix: Matrix;
  20488. protected _samples: number;
  20489. protected _renderTargetOptions: RenderTargetCreationOptions;
  20490. /**
  20491. * Gets render target creation options that were used.
  20492. */
  20493. readonly renderTargetOptions: RenderTargetCreationOptions;
  20494. protected _engine: Engine;
  20495. protected _onRatioRescale(): void;
  20496. /**
  20497. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20498. * It must define where the camera used to render the texture is set
  20499. */
  20500. boundingBoxPosition: Vector3;
  20501. private _boundingBoxSize;
  20502. /**
  20503. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20504. * When defined, the cubemap will switch to local mode
  20505. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20506. * @example https://www.babylonjs-playground.com/#RNASML
  20507. */
  20508. boundingBoxSize: Vector3;
  20509. /**
  20510. * In case the RTT has been created with a depth texture, get the associated
  20511. * depth texture.
  20512. * Otherwise, return null.
  20513. */
  20514. depthStencilTexture: Nullable<InternalTexture>;
  20515. /**
  20516. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20517. * or used a shadow, depth texture...
  20518. * @param name The friendly name of the texture
  20519. * @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)
  20520. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20521. * @param generateMipMaps True if mip maps need to be generated after render.
  20522. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20523. * @param type The type of the buffer in the RTT (int, half float, float...)
  20524. * @param isCube True if a cube texture needs to be created
  20525. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20526. * @param generateDepthBuffer True to generate a depth buffer
  20527. * @param generateStencilBuffer True to generate a stencil buffer
  20528. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20529. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20530. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20531. */
  20532. constructor(name: string, size: number | {
  20533. width: number;
  20534. height: number;
  20535. } | {
  20536. ratio: number;
  20537. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20538. /**
  20539. * Creates a depth stencil texture.
  20540. * This is only available in WebGL 2 or with the depth texture extension available.
  20541. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20542. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20543. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20544. */
  20545. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20546. private _processSizeParameter;
  20547. /**
  20548. * Define the number of samples to use in case of MSAA.
  20549. * It defaults to one meaning no MSAA has been enabled.
  20550. */
  20551. samples: number;
  20552. /**
  20553. * Resets the refresh counter of the texture and start bak from scratch.
  20554. * Could be useful to regenerate the texture if it is setup to render only once.
  20555. */
  20556. resetRefreshCounter(): void;
  20557. /**
  20558. * Define the refresh rate of the texture or the rendering frequency.
  20559. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20560. */
  20561. refreshRate: number;
  20562. /**
  20563. * Adds a post process to the render target rendering passes.
  20564. * @param postProcess define the post process to add
  20565. */
  20566. addPostProcess(postProcess: PostProcess): void;
  20567. /**
  20568. * Clear all the post processes attached to the render target
  20569. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20570. */
  20571. clearPostProcesses(dispose?: boolean): void;
  20572. /**
  20573. * Remove one of the post process from the list of attached post processes to the texture
  20574. * @param postProcess define the post process to remove from the list
  20575. */
  20576. removePostProcess(postProcess: PostProcess): void;
  20577. /** @hidden */
  20578. _shouldRender(): boolean;
  20579. /**
  20580. * Gets the actual render size of the texture.
  20581. * @returns the width of the render size
  20582. */
  20583. getRenderSize(): number;
  20584. /**
  20585. * Gets the actual render width of the texture.
  20586. * @returns the width of the render size
  20587. */
  20588. getRenderWidth(): number;
  20589. /**
  20590. * Gets the actual render height of the texture.
  20591. * @returns the height of the render size
  20592. */
  20593. getRenderHeight(): number;
  20594. /**
  20595. * Get if the texture can be rescaled or not.
  20596. */
  20597. readonly canRescale: boolean;
  20598. /**
  20599. * Resize the texture using a ratio.
  20600. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20601. */
  20602. scale(ratio: number): void;
  20603. /**
  20604. * Get the texture reflection matrix used to rotate/transform the reflection.
  20605. * @returns the reflection matrix
  20606. */
  20607. getReflectionTextureMatrix(): Matrix;
  20608. /**
  20609. * Resize the texture to a new desired size.
  20610. * Be carrefull as it will recreate all the data in the new texture.
  20611. * @param size Define the new size. It can be:
  20612. * - a number for squared texture,
  20613. * - an object containing { width: number, height: number }
  20614. * - or an object containing a ratio { ratio: number }
  20615. */
  20616. resize(size: number | {
  20617. width: number;
  20618. height: number;
  20619. } | {
  20620. ratio: number;
  20621. }): void;
  20622. /**
  20623. * Renders all the objects from the render list into the texture.
  20624. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20625. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20626. */
  20627. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20628. private _bestReflectionRenderTargetDimension;
  20629. /**
  20630. * @hidden
  20631. * @param faceIndex face index to bind to if this is a cubetexture
  20632. */
  20633. _bindFrameBuffer(faceIndex?: number): void;
  20634. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20635. private renderToTarget;
  20636. /**
  20637. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20638. * This allowed control for front to back rendering or reversly depending of the special needs.
  20639. *
  20640. * @param renderingGroupId The rendering group id corresponding to its index
  20641. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20642. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20643. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20644. */
  20645. 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;
  20646. /**
  20647. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20648. *
  20649. * @param renderingGroupId The rendering group id corresponding to its index
  20650. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20651. */
  20652. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20653. /**
  20654. * Clones the texture.
  20655. * @returns the cloned texture
  20656. */
  20657. clone(): RenderTargetTexture;
  20658. /**
  20659. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20660. * @returns The JSON representation of the texture
  20661. */
  20662. serialize(): any;
  20663. /**
  20664. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20665. */
  20666. disposeFramebufferObjects(): void;
  20667. /**
  20668. * Dispose the texture and release its associated resources.
  20669. */
  20670. dispose(): void;
  20671. /** @hidden */
  20672. _rebuild(): void;
  20673. /**
  20674. * Clear the info related to rendering groups preventing retention point in material dispose.
  20675. */
  20676. freeRenderingGroups(): void;
  20677. /**
  20678. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20679. * @returns the view count
  20680. */
  20681. getViewCount(): number;
  20682. }
  20683. }
  20684. declare module "babylonjs/Materials/material" {
  20685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20686. import { SmartArray } from "babylonjs/Misc/smartArray";
  20687. import { Observable } from "babylonjs/Misc/observable";
  20688. import { Nullable } from "babylonjs/types";
  20689. import { Scene } from "babylonjs/scene";
  20690. import { Matrix } from "babylonjs/Maths/math.vector";
  20691. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20693. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20694. import { Effect } from "babylonjs/Materials/effect";
  20695. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20696. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20697. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20698. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20699. import { Mesh } from "babylonjs/Meshes/mesh";
  20700. import { Animation } from "babylonjs/Animations/animation";
  20701. /**
  20702. * Base class for the main features of a material in Babylon.js
  20703. */
  20704. export class Material implements IAnimatable {
  20705. /**
  20706. * Returns the triangle fill mode
  20707. */
  20708. static readonly TriangleFillMode: number;
  20709. /**
  20710. * Returns the wireframe mode
  20711. */
  20712. static readonly WireFrameFillMode: number;
  20713. /**
  20714. * Returns the point fill mode
  20715. */
  20716. static readonly PointFillMode: number;
  20717. /**
  20718. * Returns the point list draw mode
  20719. */
  20720. static readonly PointListDrawMode: number;
  20721. /**
  20722. * Returns the line list draw mode
  20723. */
  20724. static readonly LineListDrawMode: number;
  20725. /**
  20726. * Returns the line loop draw mode
  20727. */
  20728. static readonly LineLoopDrawMode: number;
  20729. /**
  20730. * Returns the line strip draw mode
  20731. */
  20732. static readonly LineStripDrawMode: number;
  20733. /**
  20734. * Returns the triangle strip draw mode
  20735. */
  20736. static readonly TriangleStripDrawMode: number;
  20737. /**
  20738. * Returns the triangle fan draw mode
  20739. */
  20740. static readonly TriangleFanDrawMode: number;
  20741. /**
  20742. * Stores the clock-wise side orientation
  20743. */
  20744. static readonly ClockWiseSideOrientation: number;
  20745. /**
  20746. * Stores the counter clock-wise side orientation
  20747. */
  20748. static readonly CounterClockWiseSideOrientation: number;
  20749. /**
  20750. * The dirty texture flag value
  20751. */
  20752. static readonly TextureDirtyFlag: number;
  20753. /**
  20754. * The dirty light flag value
  20755. */
  20756. static readonly LightDirtyFlag: number;
  20757. /**
  20758. * The dirty fresnel flag value
  20759. */
  20760. static readonly FresnelDirtyFlag: number;
  20761. /**
  20762. * The dirty attribute flag value
  20763. */
  20764. static readonly AttributesDirtyFlag: number;
  20765. /**
  20766. * The dirty misc flag value
  20767. */
  20768. static readonly MiscDirtyFlag: number;
  20769. /**
  20770. * The all dirty flag value
  20771. */
  20772. static readonly AllDirtyFlag: number;
  20773. /**
  20774. * The ID of the material
  20775. */
  20776. id: string;
  20777. /**
  20778. * Gets or sets the unique id of the material
  20779. */
  20780. uniqueId: number;
  20781. /**
  20782. * The name of the material
  20783. */
  20784. name: string;
  20785. /**
  20786. * Gets or sets user defined metadata
  20787. */
  20788. metadata: any;
  20789. /**
  20790. * For internal use only. Please do not use.
  20791. */
  20792. reservedDataStore: any;
  20793. /**
  20794. * Specifies if the ready state should be checked on each call
  20795. */
  20796. checkReadyOnEveryCall: boolean;
  20797. /**
  20798. * Specifies if the ready state should be checked once
  20799. */
  20800. checkReadyOnlyOnce: boolean;
  20801. /**
  20802. * The state of the material
  20803. */
  20804. state: string;
  20805. /**
  20806. * The alpha value of the material
  20807. */
  20808. protected _alpha: number;
  20809. /**
  20810. * List of inspectable custom properties (used by the Inspector)
  20811. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20812. */
  20813. inspectableCustomProperties: IInspectable[];
  20814. /**
  20815. * Sets the alpha value of the material
  20816. */
  20817. /**
  20818. * Gets the alpha value of the material
  20819. */
  20820. alpha: number;
  20821. /**
  20822. * Specifies if back face culling is enabled
  20823. */
  20824. protected _backFaceCulling: boolean;
  20825. /**
  20826. * Sets the back-face culling state
  20827. */
  20828. /**
  20829. * Gets the back-face culling state
  20830. */
  20831. backFaceCulling: boolean;
  20832. /**
  20833. * Stores the value for side orientation
  20834. */
  20835. sideOrientation: number;
  20836. /**
  20837. * Callback triggered when the material is compiled
  20838. */
  20839. onCompiled: Nullable<(effect: Effect) => void>;
  20840. /**
  20841. * Callback triggered when an error occurs
  20842. */
  20843. onError: Nullable<(effect: Effect, errors: string) => void>;
  20844. /**
  20845. * Callback triggered to get the render target textures
  20846. */
  20847. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20848. /**
  20849. * Gets a boolean indicating that current material needs to register RTT
  20850. */
  20851. readonly hasRenderTargetTextures: boolean;
  20852. /**
  20853. * Specifies if the material should be serialized
  20854. */
  20855. doNotSerialize: boolean;
  20856. /**
  20857. * @hidden
  20858. */
  20859. _storeEffectOnSubMeshes: boolean;
  20860. /**
  20861. * Stores the animations for the material
  20862. */
  20863. animations: Nullable<Array<Animation>>;
  20864. /**
  20865. * An event triggered when the material is disposed
  20866. */
  20867. onDisposeObservable: Observable<Material>;
  20868. /**
  20869. * An observer which watches for dispose events
  20870. */
  20871. private _onDisposeObserver;
  20872. private _onUnBindObservable;
  20873. /**
  20874. * Called during a dispose event
  20875. */
  20876. onDispose: () => void;
  20877. private _onBindObservable;
  20878. /**
  20879. * An event triggered when the material is bound
  20880. */
  20881. readonly onBindObservable: Observable<AbstractMesh>;
  20882. /**
  20883. * An observer which watches for bind events
  20884. */
  20885. private _onBindObserver;
  20886. /**
  20887. * Called during a bind event
  20888. */
  20889. onBind: (Mesh: AbstractMesh) => void;
  20890. /**
  20891. * An event triggered when the material is unbound
  20892. */
  20893. readonly onUnBindObservable: Observable<Material>;
  20894. /**
  20895. * Stores the value of the alpha mode
  20896. */
  20897. private _alphaMode;
  20898. /**
  20899. * Sets the value of the alpha mode.
  20900. *
  20901. * | Value | Type | Description |
  20902. * | --- | --- | --- |
  20903. * | 0 | ALPHA_DISABLE | |
  20904. * | 1 | ALPHA_ADD | |
  20905. * | 2 | ALPHA_COMBINE | |
  20906. * | 3 | ALPHA_SUBTRACT | |
  20907. * | 4 | ALPHA_MULTIPLY | |
  20908. * | 5 | ALPHA_MAXIMIZED | |
  20909. * | 6 | ALPHA_ONEONE | |
  20910. * | 7 | ALPHA_PREMULTIPLIED | |
  20911. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20912. * | 9 | ALPHA_INTERPOLATE | |
  20913. * | 10 | ALPHA_SCREENMODE | |
  20914. *
  20915. */
  20916. /**
  20917. * Gets the value of the alpha mode
  20918. */
  20919. alphaMode: number;
  20920. /**
  20921. * Stores the state of the need depth pre-pass value
  20922. */
  20923. private _needDepthPrePass;
  20924. /**
  20925. * Sets the need depth pre-pass value
  20926. */
  20927. /**
  20928. * Gets the depth pre-pass value
  20929. */
  20930. needDepthPrePass: boolean;
  20931. /**
  20932. * Specifies if depth writing should be disabled
  20933. */
  20934. disableDepthWrite: boolean;
  20935. /**
  20936. * Specifies if depth writing should be forced
  20937. */
  20938. forceDepthWrite: boolean;
  20939. /**
  20940. * Specifies if there should be a separate pass for culling
  20941. */
  20942. separateCullingPass: boolean;
  20943. /**
  20944. * Stores the state specifing if fog should be enabled
  20945. */
  20946. private _fogEnabled;
  20947. /**
  20948. * Sets the state for enabling fog
  20949. */
  20950. /**
  20951. * Gets the value of the fog enabled state
  20952. */
  20953. fogEnabled: boolean;
  20954. /**
  20955. * Stores the size of points
  20956. */
  20957. pointSize: number;
  20958. /**
  20959. * Stores the z offset value
  20960. */
  20961. zOffset: number;
  20962. /**
  20963. * Gets a value specifying if wireframe mode is enabled
  20964. */
  20965. /**
  20966. * Sets the state of wireframe mode
  20967. */
  20968. wireframe: boolean;
  20969. /**
  20970. * Gets the value specifying if point clouds are enabled
  20971. */
  20972. /**
  20973. * Sets the state of point cloud mode
  20974. */
  20975. pointsCloud: boolean;
  20976. /**
  20977. * Gets the material fill mode
  20978. */
  20979. /**
  20980. * Sets the material fill mode
  20981. */
  20982. fillMode: number;
  20983. /**
  20984. * @hidden
  20985. * Stores the effects for the material
  20986. */
  20987. _effect: Nullable<Effect>;
  20988. /**
  20989. * @hidden
  20990. * Specifies if the material was previously ready
  20991. */
  20992. _wasPreviouslyReady: boolean;
  20993. /**
  20994. * Specifies if uniform buffers should be used
  20995. */
  20996. private _useUBO;
  20997. /**
  20998. * Stores a reference to the scene
  20999. */
  21000. private _scene;
  21001. /**
  21002. * Stores the fill mode state
  21003. */
  21004. private _fillMode;
  21005. /**
  21006. * Specifies if the depth write state should be cached
  21007. */
  21008. private _cachedDepthWriteState;
  21009. /**
  21010. * Stores the uniform buffer
  21011. */
  21012. protected _uniformBuffer: UniformBuffer;
  21013. /** @hidden */
  21014. _indexInSceneMaterialArray: number;
  21015. /** @hidden */
  21016. meshMap: Nullable<{
  21017. [id: string]: AbstractMesh | undefined;
  21018. }>;
  21019. /**
  21020. * Creates a material instance
  21021. * @param name defines the name of the material
  21022. * @param scene defines the scene to reference
  21023. * @param doNotAdd specifies if the material should be added to the scene
  21024. */
  21025. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21026. /**
  21027. * Returns a string representation of the current material
  21028. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21029. * @returns a string with material information
  21030. */
  21031. toString(fullDetails?: boolean): string;
  21032. /**
  21033. * Gets the class name of the material
  21034. * @returns a string with the class name of the material
  21035. */
  21036. getClassName(): string;
  21037. /**
  21038. * Specifies if updates for the material been locked
  21039. */
  21040. readonly isFrozen: boolean;
  21041. /**
  21042. * Locks updates for the material
  21043. */
  21044. freeze(): void;
  21045. /**
  21046. * Unlocks updates for the material
  21047. */
  21048. unfreeze(): void;
  21049. /**
  21050. * Specifies if the material is ready to be used
  21051. * @param mesh defines the mesh to check
  21052. * @param useInstances specifies if instances should be used
  21053. * @returns a boolean indicating if the material is ready to be used
  21054. */
  21055. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21056. /**
  21057. * Specifies that the submesh is ready to be used
  21058. * @param mesh defines the mesh to check
  21059. * @param subMesh defines which submesh to check
  21060. * @param useInstances specifies that instances should be used
  21061. * @returns a boolean indicating that the submesh is ready or not
  21062. */
  21063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21064. /**
  21065. * Returns the material effect
  21066. * @returns the effect associated with the material
  21067. */
  21068. getEffect(): Nullable<Effect>;
  21069. /**
  21070. * Returns the current scene
  21071. * @returns a Scene
  21072. */
  21073. getScene(): Scene;
  21074. /**
  21075. * Specifies if the material will require alpha blending
  21076. * @returns a boolean specifying if alpha blending is needed
  21077. */
  21078. needAlphaBlending(): boolean;
  21079. /**
  21080. * Specifies if the mesh will require alpha blending
  21081. * @param mesh defines the mesh to check
  21082. * @returns a boolean specifying if alpha blending is needed for the mesh
  21083. */
  21084. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21085. /**
  21086. * Specifies if this material should be rendered in alpha test mode
  21087. * @returns a boolean specifying if an alpha test is needed.
  21088. */
  21089. needAlphaTesting(): boolean;
  21090. /**
  21091. * Gets the texture used for the alpha test
  21092. * @returns the texture to use for alpha testing
  21093. */
  21094. getAlphaTestTexture(): Nullable<BaseTexture>;
  21095. /**
  21096. * Marks the material to indicate that it needs to be re-calculated
  21097. */
  21098. markDirty(): void;
  21099. /** @hidden */
  21100. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21101. /**
  21102. * Binds the material to the mesh
  21103. * @param world defines the world transformation matrix
  21104. * @param mesh defines the mesh to bind the material to
  21105. */
  21106. bind(world: Matrix, mesh?: Mesh): void;
  21107. /**
  21108. * Binds the submesh to the material
  21109. * @param world defines the world transformation matrix
  21110. * @param mesh defines the mesh containing the submesh
  21111. * @param subMesh defines the submesh to bind the material to
  21112. */
  21113. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21114. /**
  21115. * Binds the world matrix to the material
  21116. * @param world defines the world transformation matrix
  21117. */
  21118. bindOnlyWorldMatrix(world: Matrix): void;
  21119. /**
  21120. * Binds the scene's uniform buffer to the effect.
  21121. * @param effect defines the effect to bind to the scene uniform buffer
  21122. * @param sceneUbo defines the uniform buffer storing scene data
  21123. */
  21124. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21125. /**
  21126. * Binds the view matrix to the effect
  21127. * @param effect defines the effect to bind the view matrix to
  21128. */
  21129. bindView(effect: Effect): void;
  21130. /**
  21131. * Binds the view projection matrix to the effect
  21132. * @param effect defines the effect to bind the view projection matrix to
  21133. */
  21134. bindViewProjection(effect: Effect): void;
  21135. /**
  21136. * Specifies if material alpha testing should be turned on for the mesh
  21137. * @param mesh defines the mesh to check
  21138. */
  21139. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21140. /**
  21141. * Processes to execute after binding the material to a mesh
  21142. * @param mesh defines the rendered mesh
  21143. */
  21144. protected _afterBind(mesh?: Mesh): void;
  21145. /**
  21146. * Unbinds the material from the mesh
  21147. */
  21148. unbind(): void;
  21149. /**
  21150. * Gets the active textures from the material
  21151. * @returns an array of textures
  21152. */
  21153. getActiveTextures(): BaseTexture[];
  21154. /**
  21155. * Specifies if the material uses a texture
  21156. * @param texture defines the texture to check against the material
  21157. * @returns a boolean specifying if the material uses the texture
  21158. */
  21159. hasTexture(texture: BaseTexture): boolean;
  21160. /**
  21161. * Makes a duplicate of the material, and gives it a new name
  21162. * @param name defines the new name for the duplicated material
  21163. * @returns the cloned material
  21164. */
  21165. clone(name: string): Nullable<Material>;
  21166. /**
  21167. * Gets the meshes bound to the material
  21168. * @returns an array of meshes bound to the material
  21169. */
  21170. getBindedMeshes(): AbstractMesh[];
  21171. /**
  21172. * Force shader compilation
  21173. * @param mesh defines the mesh associated with this material
  21174. * @param onCompiled defines a function to execute once the material is compiled
  21175. * @param options defines the options to configure the compilation
  21176. * @param onError defines a function to execute if the material fails compiling
  21177. */
  21178. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21179. clipPlane: boolean;
  21180. }>, onError?: (reason: string) => void): void;
  21181. /**
  21182. * Force shader compilation
  21183. * @param mesh defines the mesh that will use this material
  21184. * @param options defines additional options for compiling the shaders
  21185. * @returns a promise that resolves when the compilation completes
  21186. */
  21187. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21188. clipPlane: boolean;
  21189. }>): Promise<void>;
  21190. private static readonly _AllDirtyCallBack;
  21191. private static readonly _ImageProcessingDirtyCallBack;
  21192. private static readonly _TextureDirtyCallBack;
  21193. private static readonly _FresnelDirtyCallBack;
  21194. private static readonly _MiscDirtyCallBack;
  21195. private static readonly _LightsDirtyCallBack;
  21196. private static readonly _AttributeDirtyCallBack;
  21197. private static _FresnelAndMiscDirtyCallBack;
  21198. private static _TextureAndMiscDirtyCallBack;
  21199. private static readonly _DirtyCallbackArray;
  21200. private static readonly _RunDirtyCallBacks;
  21201. /**
  21202. * Marks a define in the material to indicate that it needs to be re-computed
  21203. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21204. */
  21205. markAsDirty(flag: number): void;
  21206. /**
  21207. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21208. * @param func defines a function which checks material defines against the submeshes
  21209. */
  21210. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21211. /**
  21212. * Indicates that we need to re-calculated for all submeshes
  21213. */
  21214. protected _markAllSubMeshesAsAllDirty(): void;
  21215. /**
  21216. * Indicates that image processing needs to be re-calculated for all submeshes
  21217. */
  21218. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21219. /**
  21220. * Indicates that textures need to be re-calculated for all submeshes
  21221. */
  21222. protected _markAllSubMeshesAsTexturesDirty(): void;
  21223. /**
  21224. * Indicates that fresnel needs to be re-calculated for all submeshes
  21225. */
  21226. protected _markAllSubMeshesAsFresnelDirty(): void;
  21227. /**
  21228. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21229. */
  21230. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21231. /**
  21232. * Indicates that lights need to be re-calculated for all submeshes
  21233. */
  21234. protected _markAllSubMeshesAsLightsDirty(): void;
  21235. /**
  21236. * Indicates that attributes need to be re-calculated for all submeshes
  21237. */
  21238. protected _markAllSubMeshesAsAttributesDirty(): void;
  21239. /**
  21240. * Indicates that misc needs to be re-calculated for all submeshes
  21241. */
  21242. protected _markAllSubMeshesAsMiscDirty(): void;
  21243. /**
  21244. * Indicates that textures and misc need to be re-calculated for all submeshes
  21245. */
  21246. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21247. /**
  21248. * Disposes the material
  21249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21252. */
  21253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21254. /** @hidden */
  21255. private releaseVertexArrayObject;
  21256. /**
  21257. * Serializes this material
  21258. * @returns the serialized material object
  21259. */
  21260. serialize(): any;
  21261. /**
  21262. * Creates a material from parsed material data
  21263. * @param parsedMaterial defines parsed material data
  21264. * @param scene defines the hosting scene
  21265. * @param rootUrl defines the root URL to use to load textures
  21266. * @returns a new material
  21267. */
  21268. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21269. }
  21270. }
  21271. declare module "babylonjs/Materials/multiMaterial" {
  21272. import { Nullable } from "babylonjs/types";
  21273. import { Scene } from "babylonjs/scene";
  21274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21275. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21277. import { Material } from "babylonjs/Materials/material";
  21278. /**
  21279. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21280. * separate meshes. This can be use to improve performances.
  21281. * @see http://doc.babylonjs.com/how_to/multi_materials
  21282. */
  21283. export class MultiMaterial extends Material {
  21284. private _subMaterials;
  21285. /**
  21286. * Gets or Sets the list of Materials used within the multi material.
  21287. * They need to be ordered according to the submeshes order in the associated mesh
  21288. */
  21289. subMaterials: Nullable<Material>[];
  21290. /**
  21291. * Function used to align with Node.getChildren()
  21292. * @returns the list of Materials used within the multi material
  21293. */
  21294. getChildren(): Nullable<Material>[];
  21295. /**
  21296. * Instantiates a new Multi Material
  21297. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21298. * separate meshes. This can be use to improve performances.
  21299. * @see http://doc.babylonjs.com/how_to/multi_materials
  21300. * @param name Define the name in the scene
  21301. * @param scene Define the scene the material belongs to
  21302. */
  21303. constructor(name: string, scene: Scene);
  21304. private _hookArray;
  21305. /**
  21306. * Get one of the submaterial by its index in the submaterials array
  21307. * @param index The index to look the sub material at
  21308. * @returns The Material if the index has been defined
  21309. */
  21310. getSubMaterial(index: number): Nullable<Material>;
  21311. /**
  21312. * Get the list of active textures for the whole sub materials list.
  21313. * @returns All the textures that will be used during the rendering
  21314. */
  21315. getActiveTextures(): BaseTexture[];
  21316. /**
  21317. * Gets the current class name of the material e.g. "MultiMaterial"
  21318. * Mainly use in serialization.
  21319. * @returns the class name
  21320. */
  21321. getClassName(): string;
  21322. /**
  21323. * Checks if the material is ready to render the requested sub mesh
  21324. * @param mesh Define the mesh the submesh belongs to
  21325. * @param subMesh Define the sub mesh to look readyness for
  21326. * @param useInstances Define whether or not the material is used with instances
  21327. * @returns true if ready, otherwise false
  21328. */
  21329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21330. /**
  21331. * Clones the current material and its related sub materials
  21332. * @param name Define the name of the newly cloned material
  21333. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21334. * @returns the cloned material
  21335. */
  21336. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21337. /**
  21338. * Serializes the materials into a JSON representation.
  21339. * @returns the JSON representation
  21340. */
  21341. serialize(): any;
  21342. /**
  21343. * Dispose the material and release its associated resources
  21344. * @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)
  21345. * @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)
  21346. * @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)
  21347. */
  21348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21349. /**
  21350. * Creates a MultiMaterial from parsed MultiMaterial data.
  21351. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21352. * @param scene defines the hosting scene
  21353. * @returns a new MultiMaterial
  21354. */
  21355. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21356. }
  21357. }
  21358. declare module "babylonjs/Meshes/subMesh" {
  21359. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21360. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21361. import { Engine } from "babylonjs/Engines/engine";
  21362. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21363. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21364. import { Effect } from "babylonjs/Materials/effect";
  21365. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21366. import { Plane } from "babylonjs/Maths/math.plane";
  21367. import { Collider } from "babylonjs/Collisions/collider";
  21368. import { Material } from "babylonjs/Materials/material";
  21369. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21371. import { Mesh } from "babylonjs/Meshes/mesh";
  21372. import { Ray } from "babylonjs/Culling/ray";
  21373. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21374. /**
  21375. * Base class for submeshes
  21376. */
  21377. export class BaseSubMesh {
  21378. /** @hidden */
  21379. _materialDefines: Nullable<MaterialDefines>;
  21380. /** @hidden */
  21381. _materialEffect: Nullable<Effect>;
  21382. /**
  21383. * Gets associated effect
  21384. */
  21385. readonly effect: Nullable<Effect>;
  21386. /**
  21387. * Sets associated effect (effect used to render this submesh)
  21388. * @param effect defines the effect to associate with
  21389. * @param defines defines the set of defines used to compile this effect
  21390. */
  21391. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21392. }
  21393. /**
  21394. * Defines a subdivision inside a mesh
  21395. */
  21396. export class SubMesh extends BaseSubMesh implements ICullable {
  21397. /** the material index to use */
  21398. materialIndex: number;
  21399. /** vertex index start */
  21400. verticesStart: number;
  21401. /** vertices count */
  21402. verticesCount: number;
  21403. /** index start */
  21404. indexStart: number;
  21405. /** indices count */
  21406. indexCount: number;
  21407. /** @hidden */
  21408. _linesIndexCount: number;
  21409. private _mesh;
  21410. private _renderingMesh;
  21411. private _boundingInfo;
  21412. private _linesIndexBuffer;
  21413. /** @hidden */
  21414. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21415. /** @hidden */
  21416. _trianglePlanes: Plane[];
  21417. /** @hidden */
  21418. _lastColliderTransformMatrix: Nullable<Matrix>;
  21419. /** @hidden */
  21420. _renderId: number;
  21421. /** @hidden */
  21422. _alphaIndex: number;
  21423. /** @hidden */
  21424. _distanceToCamera: number;
  21425. /** @hidden */
  21426. _id: number;
  21427. private _currentMaterial;
  21428. /**
  21429. * Add a new submesh to a mesh
  21430. * @param materialIndex defines the material index to use
  21431. * @param verticesStart defines vertex index start
  21432. * @param verticesCount defines vertices count
  21433. * @param indexStart defines index start
  21434. * @param indexCount defines indices count
  21435. * @param mesh defines the parent mesh
  21436. * @param renderingMesh defines an optional rendering mesh
  21437. * @param createBoundingBox defines if bounding box should be created for this submesh
  21438. * @returns the new submesh
  21439. */
  21440. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21441. /**
  21442. * Creates a new submesh
  21443. * @param materialIndex defines the material index to use
  21444. * @param verticesStart defines vertex index start
  21445. * @param verticesCount defines vertices count
  21446. * @param indexStart defines index start
  21447. * @param indexCount defines indices count
  21448. * @param mesh defines the parent mesh
  21449. * @param renderingMesh defines an optional rendering mesh
  21450. * @param createBoundingBox defines if bounding box should be created for this submesh
  21451. */
  21452. constructor(
  21453. /** the material index to use */
  21454. materialIndex: number,
  21455. /** vertex index start */
  21456. verticesStart: number,
  21457. /** vertices count */
  21458. verticesCount: number,
  21459. /** index start */
  21460. indexStart: number,
  21461. /** indices count */
  21462. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21463. /**
  21464. * Returns true if this submesh covers the entire parent mesh
  21465. * @ignorenaming
  21466. */
  21467. readonly IsGlobal: boolean;
  21468. /**
  21469. * Returns the submesh BoudingInfo object
  21470. * @returns current bounding info (or mesh's one if the submesh is global)
  21471. */
  21472. getBoundingInfo(): BoundingInfo;
  21473. /**
  21474. * Sets the submesh BoundingInfo
  21475. * @param boundingInfo defines the new bounding info to use
  21476. * @returns the SubMesh
  21477. */
  21478. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21479. /**
  21480. * Returns the mesh of the current submesh
  21481. * @return the parent mesh
  21482. */
  21483. getMesh(): AbstractMesh;
  21484. /**
  21485. * Returns the rendering mesh of the submesh
  21486. * @returns the rendering mesh (could be different from parent mesh)
  21487. */
  21488. getRenderingMesh(): Mesh;
  21489. /**
  21490. * Returns the submesh material
  21491. * @returns null or the current material
  21492. */
  21493. getMaterial(): Nullable<Material>;
  21494. /**
  21495. * Sets a new updated BoundingInfo object to the submesh
  21496. * @param data defines an optional position array to use to determine the bounding info
  21497. * @returns the SubMesh
  21498. */
  21499. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21500. /** @hidden */
  21501. _checkCollision(collider: Collider): boolean;
  21502. /**
  21503. * Updates the submesh BoundingInfo
  21504. * @param world defines the world matrix to use to update the bounding info
  21505. * @returns the submesh
  21506. */
  21507. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21508. /**
  21509. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21510. * @param frustumPlanes defines the frustum planes
  21511. * @returns true if the submesh is intersecting with the frustum
  21512. */
  21513. isInFrustum(frustumPlanes: Plane[]): boolean;
  21514. /**
  21515. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21516. * @param frustumPlanes defines the frustum planes
  21517. * @returns true if the submesh is inside the frustum
  21518. */
  21519. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21520. /**
  21521. * Renders the submesh
  21522. * @param enableAlphaMode defines if alpha needs to be used
  21523. * @returns the submesh
  21524. */
  21525. render(enableAlphaMode: boolean): SubMesh;
  21526. /**
  21527. * @hidden
  21528. */
  21529. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21530. /**
  21531. * Checks if the submesh intersects with a ray
  21532. * @param ray defines the ray to test
  21533. * @returns true is the passed ray intersects the submesh bounding box
  21534. */
  21535. canIntersects(ray: Ray): boolean;
  21536. /**
  21537. * Intersects current submesh with a ray
  21538. * @param ray defines the ray to test
  21539. * @param positions defines mesh's positions array
  21540. * @param indices defines mesh's indices array
  21541. * @param fastCheck defines if only bounding info should be used
  21542. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21543. * @returns intersection info or null if no intersection
  21544. */
  21545. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21546. /** @hidden */
  21547. private _intersectLines;
  21548. /** @hidden */
  21549. private _intersectUnIndexedLines;
  21550. /** @hidden */
  21551. private _intersectTriangles;
  21552. /** @hidden */
  21553. private _intersectUnIndexedTriangles;
  21554. /** @hidden */
  21555. _rebuild(): void;
  21556. /**
  21557. * Creates a new submesh from the passed mesh
  21558. * @param newMesh defines the new hosting mesh
  21559. * @param newRenderingMesh defines an optional rendering mesh
  21560. * @returns the new submesh
  21561. */
  21562. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21563. /**
  21564. * Release associated resources
  21565. */
  21566. dispose(): void;
  21567. /**
  21568. * Gets the class name
  21569. * @returns the string "SubMesh".
  21570. */
  21571. getClassName(): string;
  21572. /**
  21573. * Creates a new submesh from indices data
  21574. * @param materialIndex the index of the main mesh material
  21575. * @param startIndex the index where to start the copy in the mesh indices array
  21576. * @param indexCount the number of indices to copy then from the startIndex
  21577. * @param mesh the main mesh to create the submesh from
  21578. * @param renderingMesh the optional rendering mesh
  21579. * @returns a new submesh
  21580. */
  21581. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21582. }
  21583. }
  21584. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21585. /**
  21586. * Class used to represent data loading progression
  21587. */
  21588. export class SceneLoaderFlags {
  21589. private static _ForceFullSceneLoadingForIncremental;
  21590. private static _ShowLoadingScreen;
  21591. private static _CleanBoneMatrixWeights;
  21592. private static _loggingLevel;
  21593. /**
  21594. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21595. */
  21596. static ForceFullSceneLoadingForIncremental: boolean;
  21597. /**
  21598. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21599. */
  21600. static ShowLoadingScreen: boolean;
  21601. /**
  21602. * Defines the current logging level (while loading the scene)
  21603. * @ignorenaming
  21604. */
  21605. static loggingLevel: number;
  21606. /**
  21607. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21608. */
  21609. static CleanBoneMatrixWeights: boolean;
  21610. }
  21611. }
  21612. declare module "babylonjs/Meshes/geometry" {
  21613. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21614. import { Scene } from "babylonjs/scene";
  21615. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21616. import { Engine } from "babylonjs/Engines/engine";
  21617. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21618. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21619. import { Effect } from "babylonjs/Materials/effect";
  21620. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21621. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21622. import { Mesh } from "babylonjs/Meshes/mesh";
  21623. /**
  21624. * Class used to store geometry data (vertex buffers + index buffer)
  21625. */
  21626. export class Geometry implements IGetSetVerticesData {
  21627. /**
  21628. * Gets or sets the ID of the geometry
  21629. */
  21630. id: string;
  21631. /**
  21632. * Gets or sets the unique ID of the geometry
  21633. */
  21634. uniqueId: number;
  21635. /**
  21636. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21637. */
  21638. delayLoadState: number;
  21639. /**
  21640. * Gets the file containing the data to load when running in delay load state
  21641. */
  21642. delayLoadingFile: Nullable<string>;
  21643. /**
  21644. * Callback called when the geometry is updated
  21645. */
  21646. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21647. private _scene;
  21648. private _engine;
  21649. private _meshes;
  21650. private _totalVertices;
  21651. /** @hidden */
  21652. _indices: IndicesArray;
  21653. /** @hidden */
  21654. _vertexBuffers: {
  21655. [key: string]: VertexBuffer;
  21656. };
  21657. private _isDisposed;
  21658. private _extend;
  21659. private _boundingBias;
  21660. /** @hidden */
  21661. _delayInfo: Array<string>;
  21662. private _indexBuffer;
  21663. private _indexBufferIsUpdatable;
  21664. /** @hidden */
  21665. _boundingInfo: Nullable<BoundingInfo>;
  21666. /** @hidden */
  21667. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21668. /** @hidden */
  21669. _softwareSkinningFrameId: number;
  21670. private _vertexArrayObjects;
  21671. private _updatable;
  21672. /** @hidden */
  21673. _positions: Nullable<Vector3[]>;
  21674. /**
  21675. * 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
  21676. */
  21677. /**
  21678. * 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
  21679. */
  21680. boundingBias: Vector2;
  21681. /**
  21682. * Static function used to attach a new empty geometry to a mesh
  21683. * @param mesh defines the mesh to attach the geometry to
  21684. * @returns the new Geometry
  21685. */
  21686. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21687. /**
  21688. * Creates a new geometry
  21689. * @param id defines the unique ID
  21690. * @param scene defines the hosting scene
  21691. * @param vertexData defines the VertexData used to get geometry data
  21692. * @param updatable defines if geometry must be updatable (false by default)
  21693. * @param mesh defines the mesh that will be associated with the geometry
  21694. */
  21695. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21696. /**
  21697. * Gets the current extend of the geometry
  21698. */
  21699. readonly extend: {
  21700. minimum: Vector3;
  21701. maximum: Vector3;
  21702. };
  21703. /**
  21704. * Gets the hosting scene
  21705. * @returns the hosting Scene
  21706. */
  21707. getScene(): Scene;
  21708. /**
  21709. * Gets the hosting engine
  21710. * @returns the hosting Engine
  21711. */
  21712. getEngine(): Engine;
  21713. /**
  21714. * Defines if the geometry is ready to use
  21715. * @returns true if the geometry is ready to be used
  21716. */
  21717. isReady(): boolean;
  21718. /**
  21719. * Gets a value indicating that the geometry should not be serialized
  21720. */
  21721. readonly doNotSerialize: boolean;
  21722. /** @hidden */
  21723. _rebuild(): void;
  21724. /**
  21725. * Affects all geometry data in one call
  21726. * @param vertexData defines the geometry data
  21727. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21728. */
  21729. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21730. /**
  21731. * Set specific vertex data
  21732. * @param kind defines the data kind (Position, normal, etc...)
  21733. * @param data defines the vertex data to use
  21734. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21735. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21736. */
  21737. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21738. /**
  21739. * Removes a specific vertex data
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. */
  21742. removeVerticesData(kind: string): void;
  21743. /**
  21744. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21745. * @param buffer defines the vertex buffer to use
  21746. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21747. */
  21748. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21749. /**
  21750. * Update a specific vertex buffer
  21751. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21752. * It will do nothing if the buffer is not updatable
  21753. * @param kind defines the data kind (Position, normal, etc...)
  21754. * @param data defines the data to use
  21755. * @param offset defines the offset in the target buffer where to store the data
  21756. * @param useBytes set to true if the offset is in bytes
  21757. */
  21758. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21759. /**
  21760. * Update a specific vertex buffer
  21761. * This function will create a new buffer if the current one is not updatable
  21762. * @param kind defines the data kind (Position, normal, etc...)
  21763. * @param data defines the data to use
  21764. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21765. */
  21766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21767. private _updateBoundingInfo;
  21768. /** @hidden */
  21769. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21770. /**
  21771. * Gets total number of vertices
  21772. * @returns the total number of vertices
  21773. */
  21774. getTotalVertices(): number;
  21775. /**
  21776. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21779. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21780. * @returns a float array containing vertex data
  21781. */
  21782. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21783. /**
  21784. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21785. * @param kind defines the data kind (Position, normal, etc...)
  21786. * @returns true if the vertex buffer with the specified kind is updatable
  21787. */
  21788. isVertexBufferUpdatable(kind: string): boolean;
  21789. /**
  21790. * Gets a specific vertex buffer
  21791. * @param kind defines the data kind (Position, normal, etc...)
  21792. * @returns a VertexBuffer
  21793. */
  21794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21795. /**
  21796. * Returns all vertex buffers
  21797. * @return an object holding all vertex buffers indexed by kind
  21798. */
  21799. getVertexBuffers(): Nullable<{
  21800. [key: string]: VertexBuffer;
  21801. }>;
  21802. /**
  21803. * Gets a boolean indicating if specific vertex buffer is present
  21804. * @param kind defines the data kind (Position, normal, etc...)
  21805. * @returns true if data is present
  21806. */
  21807. isVerticesDataPresent(kind: string): boolean;
  21808. /**
  21809. * Gets a list of all attached data kinds (Position, normal, etc...)
  21810. * @returns a list of string containing all kinds
  21811. */
  21812. getVerticesDataKinds(): string[];
  21813. /**
  21814. * Update index buffer
  21815. * @param indices defines the indices to store in the index buffer
  21816. * @param offset defines the offset in the target buffer where to store the data
  21817. * @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)
  21818. */
  21819. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21820. /**
  21821. * Creates a new index buffer
  21822. * @param indices defines the indices to store in the index buffer
  21823. * @param totalVertices defines the total number of vertices (could be null)
  21824. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21825. */
  21826. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21827. /**
  21828. * Return the total number of indices
  21829. * @returns the total number of indices
  21830. */
  21831. getTotalIndices(): number;
  21832. /**
  21833. * Gets the index buffer array
  21834. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21836. * @returns the index buffer array
  21837. */
  21838. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21839. /**
  21840. * Gets the index buffer
  21841. * @return the index buffer
  21842. */
  21843. getIndexBuffer(): Nullable<DataBuffer>;
  21844. /** @hidden */
  21845. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21846. /**
  21847. * Release the associated resources for a specific mesh
  21848. * @param mesh defines the source mesh
  21849. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21850. */
  21851. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21852. /**
  21853. * Apply current geometry to a given mesh
  21854. * @param mesh defines the mesh to apply geometry to
  21855. */
  21856. applyToMesh(mesh: Mesh): void;
  21857. private _updateExtend;
  21858. private _applyToMesh;
  21859. private notifyUpdate;
  21860. /**
  21861. * Load the geometry if it was flagged as delay loaded
  21862. * @param scene defines the hosting scene
  21863. * @param onLoaded defines a callback called when the geometry is loaded
  21864. */
  21865. load(scene: Scene, onLoaded?: () => void): void;
  21866. private _queueLoad;
  21867. /**
  21868. * Invert the geometry to move from a right handed system to a left handed one.
  21869. */
  21870. toLeftHanded(): void;
  21871. /** @hidden */
  21872. _resetPointsArrayCache(): void;
  21873. /** @hidden */
  21874. _generatePointsArray(): boolean;
  21875. /**
  21876. * Gets a value indicating if the geometry is disposed
  21877. * @returns true if the geometry was disposed
  21878. */
  21879. isDisposed(): boolean;
  21880. private _disposeVertexArrayObjects;
  21881. /**
  21882. * Free all associated resources
  21883. */
  21884. dispose(): void;
  21885. /**
  21886. * Clone the current geometry into a new geometry
  21887. * @param id defines the unique ID of the new geometry
  21888. * @returns a new geometry object
  21889. */
  21890. copy(id: string): Geometry;
  21891. /**
  21892. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21893. * @return a JSON representation of the current geometry data (without the vertices data)
  21894. */
  21895. serialize(): any;
  21896. private toNumberArray;
  21897. /**
  21898. * Serialize all vertices data into a JSON oject
  21899. * @returns a JSON representation of the current geometry data
  21900. */
  21901. serializeVerticeData(): any;
  21902. /**
  21903. * Extracts a clone of a mesh geometry
  21904. * @param mesh defines the source mesh
  21905. * @param id defines the unique ID of the new geometry object
  21906. * @returns the new geometry object
  21907. */
  21908. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21909. /**
  21910. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21911. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21912. * Be aware Math.random() could cause collisions, but:
  21913. * "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"
  21914. * @returns a string containing a new GUID
  21915. */
  21916. static RandomId(): string;
  21917. /** @hidden */
  21918. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21919. private static _CleanMatricesWeights;
  21920. /**
  21921. * Create a new geometry from persisted data (Using .babylon file format)
  21922. * @param parsedVertexData defines the persisted data
  21923. * @param scene defines the hosting scene
  21924. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21925. * @returns the new geometry object
  21926. */
  21927. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21928. }
  21929. }
  21930. declare module "babylonjs/Meshes/mesh.vertexData" {
  21931. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21932. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21933. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21934. import { Geometry } from "babylonjs/Meshes/geometry";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. /**
  21937. * Define an interface for all classes that will get and set the data on vertices
  21938. */
  21939. export interface IGetSetVerticesData {
  21940. /**
  21941. * Gets a boolean indicating if specific vertex data is present
  21942. * @param kind defines the vertex data kind to use
  21943. * @returns true is data kind is present
  21944. */
  21945. isVerticesDataPresent(kind: string): boolean;
  21946. /**
  21947. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21948. * @param kind defines the data kind (Position, normal, etc...)
  21949. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21950. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21951. * @returns a float array containing vertex data
  21952. */
  21953. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21954. /**
  21955. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21956. * @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.
  21957. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21958. * @returns the indices array or an empty array if the mesh has no geometry
  21959. */
  21960. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21961. /**
  21962. * Set specific vertex data
  21963. * @param kind defines the data kind (Position, normal, etc...)
  21964. * @param data defines the vertex data to use
  21965. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21966. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21967. */
  21968. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21969. /**
  21970. * Update a specific associated vertex buffer
  21971. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21972. * - VertexBuffer.PositionKind
  21973. * - VertexBuffer.UVKind
  21974. * - VertexBuffer.UV2Kind
  21975. * - VertexBuffer.UV3Kind
  21976. * - VertexBuffer.UV4Kind
  21977. * - VertexBuffer.UV5Kind
  21978. * - VertexBuffer.UV6Kind
  21979. * - VertexBuffer.ColorKind
  21980. * - VertexBuffer.MatricesIndicesKind
  21981. * - VertexBuffer.MatricesIndicesExtraKind
  21982. * - VertexBuffer.MatricesWeightsKind
  21983. * - VertexBuffer.MatricesWeightsExtraKind
  21984. * @param data defines the data source
  21985. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21986. * @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)
  21987. */
  21988. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21989. /**
  21990. * Creates a new index buffer
  21991. * @param indices defines the indices to store in the index buffer
  21992. * @param totalVertices defines the total number of vertices (could be null)
  21993. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21994. */
  21995. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21996. }
  21997. /**
  21998. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21999. */
  22000. export class VertexData {
  22001. /**
  22002. * Mesh side orientation : usually the external or front surface
  22003. */
  22004. static readonly FRONTSIDE: number;
  22005. /**
  22006. * Mesh side orientation : usually the internal or back surface
  22007. */
  22008. static readonly BACKSIDE: number;
  22009. /**
  22010. * Mesh side orientation : both internal and external or front and back surfaces
  22011. */
  22012. static readonly DOUBLESIDE: number;
  22013. /**
  22014. * Mesh side orientation : by default, `FRONTSIDE`
  22015. */
  22016. static readonly DEFAULTSIDE: number;
  22017. /**
  22018. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22019. */
  22020. positions: Nullable<FloatArray>;
  22021. /**
  22022. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22023. */
  22024. normals: Nullable<FloatArray>;
  22025. /**
  22026. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22027. */
  22028. tangents: Nullable<FloatArray>;
  22029. /**
  22030. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22031. */
  22032. uvs: Nullable<FloatArray>;
  22033. /**
  22034. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22035. */
  22036. uvs2: Nullable<FloatArray>;
  22037. /**
  22038. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22039. */
  22040. uvs3: Nullable<FloatArray>;
  22041. /**
  22042. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22043. */
  22044. uvs4: Nullable<FloatArray>;
  22045. /**
  22046. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22047. */
  22048. uvs5: Nullable<FloatArray>;
  22049. /**
  22050. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22051. */
  22052. uvs6: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22055. */
  22056. colors: Nullable<FloatArray>;
  22057. /**
  22058. * 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).
  22059. */
  22060. matricesIndices: Nullable<FloatArray>;
  22061. /**
  22062. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22063. */
  22064. matricesWeights: Nullable<FloatArray>;
  22065. /**
  22066. * An array extending the number of possible indices
  22067. */
  22068. matricesIndicesExtra: Nullable<FloatArray>;
  22069. /**
  22070. * An array extending the number of possible weights when the number of indices is extended
  22071. */
  22072. matricesWeightsExtra: Nullable<FloatArray>;
  22073. /**
  22074. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22075. */
  22076. indices: Nullable<IndicesArray>;
  22077. /**
  22078. * Uses the passed data array to set the set the values for the specified kind of data
  22079. * @param data a linear array of floating numbers
  22080. * @param kind the type of data that is being set, eg positions, colors etc
  22081. */
  22082. set(data: FloatArray, kind: string): void;
  22083. /**
  22084. * Associates the vertexData to the passed Mesh.
  22085. * Sets it as updatable or not (default `false`)
  22086. * @param mesh the mesh the vertexData is applied to
  22087. * @param updatable when used and having the value true allows new data to update the vertexData
  22088. * @returns the VertexData
  22089. */
  22090. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22091. /**
  22092. * Associates the vertexData to the passed Geometry.
  22093. * Sets it as updatable or not (default `false`)
  22094. * @param geometry the geometry the vertexData is applied to
  22095. * @param updatable when used and having the value true allows new data to update the vertexData
  22096. * @returns VertexData
  22097. */
  22098. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22099. /**
  22100. * Updates the associated mesh
  22101. * @param mesh the mesh to be updated
  22102. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22103. * @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
  22104. * @returns VertexData
  22105. */
  22106. updateMesh(mesh: Mesh): VertexData;
  22107. /**
  22108. * Updates the associated geometry
  22109. * @param geometry the geometry to be updated
  22110. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22111. * @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
  22112. * @returns VertexData.
  22113. */
  22114. updateGeometry(geometry: Geometry): VertexData;
  22115. private _applyTo;
  22116. private _update;
  22117. /**
  22118. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22119. * @param matrix the transforming matrix
  22120. * @returns the VertexData
  22121. */
  22122. transform(matrix: Matrix): VertexData;
  22123. /**
  22124. * Merges the passed VertexData into the current one
  22125. * @param other the VertexData to be merged into the current one
  22126. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22127. * @returns the modified VertexData
  22128. */
  22129. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22130. private _mergeElement;
  22131. private _validate;
  22132. /**
  22133. * Serializes the VertexData
  22134. * @returns a serialized object
  22135. */
  22136. serialize(): any;
  22137. /**
  22138. * Extracts the vertexData from a mesh
  22139. * @param mesh the mesh from which to extract the VertexData
  22140. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22141. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22142. * @returns the object VertexData associated to the passed mesh
  22143. */
  22144. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22145. /**
  22146. * Extracts the vertexData from the geometry
  22147. * @param geometry the geometry from which to extract the VertexData
  22148. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22149. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22150. * @returns the object VertexData associated to the passed mesh
  22151. */
  22152. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22153. private static _ExtractFrom;
  22154. /**
  22155. * Creates the VertexData for a Ribbon
  22156. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22157. * * pathArray array of paths, each of which an array of successive Vector3
  22158. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22159. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22160. * * 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
  22161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22162. * * 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)
  22163. * * 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)
  22164. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22165. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22166. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22167. * @returns the VertexData of the ribbon
  22168. */
  22169. static CreateRibbon(options: {
  22170. pathArray: Vector3[][];
  22171. closeArray?: boolean;
  22172. closePath?: boolean;
  22173. offset?: number;
  22174. sideOrientation?: number;
  22175. frontUVs?: Vector4;
  22176. backUVs?: Vector4;
  22177. invertUV?: boolean;
  22178. uvs?: Vector2[];
  22179. colors?: Color4[];
  22180. }): VertexData;
  22181. /**
  22182. * Creates the VertexData for a box
  22183. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22184. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22185. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22186. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22187. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  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. * * 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)
  22192. * * 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)
  22193. * @returns the VertexData of the box
  22194. */
  22195. static CreateBox(options: {
  22196. size?: number;
  22197. width?: number;
  22198. height?: number;
  22199. depth?: number;
  22200. faceUV?: Vector4[];
  22201. faceColors?: Color4[];
  22202. sideOrientation?: number;
  22203. frontUVs?: Vector4;
  22204. backUVs?: Vector4;
  22205. }): VertexData;
  22206. /**
  22207. * Creates the VertexData for a tiled box
  22208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22209. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22210. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22211. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22213. * @returns the VertexData of the box
  22214. */
  22215. static CreateTiledBox(options: {
  22216. pattern?: number;
  22217. width?: number;
  22218. height?: number;
  22219. depth?: number;
  22220. tileSize?: number;
  22221. tileWidth?: number;
  22222. tileHeight?: number;
  22223. alignHorizontal?: number;
  22224. alignVertical?: number;
  22225. faceUV?: Vector4[];
  22226. faceColors?: Color4[];
  22227. sideOrientation?: number;
  22228. }): VertexData;
  22229. /**
  22230. * Creates the VertexData for a tiled plane
  22231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22232. * * pattern a limited pattern arrangement depending on the number
  22233. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22234. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22235. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22237. * * 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)
  22238. * * 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)
  22239. * @returns the VertexData of the tiled plane
  22240. */
  22241. static CreateTiledPlane(options: {
  22242. pattern?: number;
  22243. tileSize?: number;
  22244. tileWidth?: number;
  22245. tileHeight?: number;
  22246. size?: number;
  22247. width?: number;
  22248. height?: number;
  22249. alignHorizontal?: number;
  22250. alignVertical?: number;
  22251. sideOrientation?: number;
  22252. frontUVs?: Vector4;
  22253. backUVs?: Vector4;
  22254. }): VertexData;
  22255. /**
  22256. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22258. * * segments sets the number of horizontal strips optional, default 32
  22259. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22260. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22261. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22262. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22263. * * 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
  22264. * * 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
  22265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22266. * * 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)
  22267. * * 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)
  22268. * @returns the VertexData of the ellipsoid
  22269. */
  22270. static CreateSphere(options: {
  22271. segments?: number;
  22272. diameter?: number;
  22273. diameterX?: number;
  22274. diameterY?: number;
  22275. diameterZ?: number;
  22276. arc?: number;
  22277. slice?: number;
  22278. sideOrientation?: number;
  22279. frontUVs?: Vector4;
  22280. backUVs?: Vector4;
  22281. }): VertexData;
  22282. /**
  22283. * Creates the VertexData for a cylinder, cone or prism
  22284. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22285. * * height sets the height (y direction) of the cylinder, optional, default 2
  22286. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22287. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22288. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22289. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22290. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22291. * * 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
  22292. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22293. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22294. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22295. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22297. * * 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)
  22298. * * 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)
  22299. * @returns the VertexData of the cylinder, cone or prism
  22300. */
  22301. static CreateCylinder(options: {
  22302. height?: number;
  22303. diameterTop?: number;
  22304. diameterBottom?: number;
  22305. diameter?: number;
  22306. tessellation?: number;
  22307. subdivisions?: number;
  22308. arc?: number;
  22309. faceColors?: Color4[];
  22310. faceUV?: Vector4[];
  22311. hasRings?: boolean;
  22312. enclose?: boolean;
  22313. sideOrientation?: number;
  22314. frontUVs?: Vector4;
  22315. backUVs?: Vector4;
  22316. }): VertexData;
  22317. /**
  22318. * Creates the VertexData for a torus
  22319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22320. * * diameter the diameter of the torus, optional default 1
  22321. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22322. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22324. * * 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)
  22325. * * 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)
  22326. * @returns the VertexData of the torus
  22327. */
  22328. static CreateTorus(options: {
  22329. diameter?: number;
  22330. thickness?: number;
  22331. tessellation?: number;
  22332. sideOrientation?: number;
  22333. frontUVs?: Vector4;
  22334. backUVs?: Vector4;
  22335. }): VertexData;
  22336. /**
  22337. * Creates the VertexData of the LineSystem
  22338. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22339. * - lines an array of lines, each line being an array of successive Vector3
  22340. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22341. * @returns the VertexData of the LineSystem
  22342. */
  22343. static CreateLineSystem(options: {
  22344. lines: Vector3[][];
  22345. colors?: Nullable<Color4[][]>;
  22346. }): VertexData;
  22347. /**
  22348. * Create the VertexData for a DashedLines
  22349. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22350. * - points an array successive Vector3
  22351. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22352. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22353. * - dashNb the intended total number of dashes, optional, default 200
  22354. * @returns the VertexData for the DashedLines
  22355. */
  22356. static CreateDashedLines(options: {
  22357. points: Vector3[];
  22358. dashSize?: number;
  22359. gapSize?: number;
  22360. dashNb?: number;
  22361. }): VertexData;
  22362. /**
  22363. * Creates the VertexData for a Ground
  22364. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22365. * - width the width (x direction) of the ground, optional, default 1
  22366. * - height the height (z direction) of the ground, optional, default 1
  22367. * - subdivisions the number of subdivisions per side, optional, default 1
  22368. * @returns the VertexData of the Ground
  22369. */
  22370. static CreateGround(options: {
  22371. width?: number;
  22372. height?: number;
  22373. subdivisions?: number;
  22374. subdivisionsX?: number;
  22375. subdivisionsY?: number;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22379. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22380. * * xmin the ground minimum X coordinate, optional, default -1
  22381. * * zmin the ground minimum Z coordinate, optional, default -1
  22382. * * xmax the ground maximum X coordinate, optional, default 1
  22383. * * zmax the ground maximum Z coordinate, optional, default 1
  22384. * * 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}
  22385. * * 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}
  22386. * @returns the VertexData of the TiledGround
  22387. */
  22388. static CreateTiledGround(options: {
  22389. xmin: number;
  22390. zmin: number;
  22391. xmax: number;
  22392. zmax: number;
  22393. subdivisions?: {
  22394. w: number;
  22395. h: number;
  22396. };
  22397. precision?: {
  22398. w: number;
  22399. h: number;
  22400. };
  22401. }): VertexData;
  22402. /**
  22403. * Creates the VertexData of the Ground designed from a heightmap
  22404. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22405. * * width the width (x direction) of the ground
  22406. * * height the height (z direction) of the ground
  22407. * * subdivisions the number of subdivisions per side
  22408. * * minHeight the minimum altitude on the ground, optional, default 0
  22409. * * maxHeight the maximum altitude on the ground, optional default 1
  22410. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22411. * * buffer the array holding the image color data
  22412. * * bufferWidth the width of image
  22413. * * bufferHeight the height of image
  22414. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22415. * @returns the VertexData of the Ground designed from a heightmap
  22416. */
  22417. static CreateGroundFromHeightMap(options: {
  22418. width: number;
  22419. height: number;
  22420. subdivisions: number;
  22421. minHeight: number;
  22422. maxHeight: number;
  22423. colorFilter: Color3;
  22424. buffer: Uint8Array;
  22425. bufferWidth: number;
  22426. bufferHeight: number;
  22427. alphaFilter: number;
  22428. }): VertexData;
  22429. /**
  22430. * Creates the VertexData for a Plane
  22431. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22432. * * size sets the width and height of the plane to the value of size, optional default 1
  22433. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22434. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22435. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22436. * * 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)
  22437. * * 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)
  22438. * @returns the VertexData of the box
  22439. */
  22440. static CreatePlane(options: {
  22441. size?: number;
  22442. width?: number;
  22443. height?: number;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData of the Disc or regular Polygon
  22450. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22451. * * radius the radius of the disc, optional default 0.5
  22452. * * tessellation the number of polygon sides, optional, default 64
  22453. * * 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
  22454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22455. * * 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)
  22456. * * 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)
  22457. * @returns the VertexData of the box
  22458. */
  22459. static CreateDisc(options: {
  22460. radius?: number;
  22461. tessellation?: number;
  22462. arc?: number;
  22463. sideOrientation?: number;
  22464. frontUVs?: Vector4;
  22465. backUVs?: Vector4;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22469. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22470. * @param polygon a mesh built from polygonTriangulation.build()
  22471. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22472. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22473. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22474. * @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)
  22475. * @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)
  22476. * @returns the VertexData of the Polygon
  22477. */
  22478. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22479. /**
  22480. * Creates the VertexData of the IcoSphere
  22481. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22482. * * radius the radius of the IcoSphere, optional default 1
  22483. * * radiusX allows stretching in the x direction, optional, default radius
  22484. * * radiusY allows stretching in the y direction, optional, default radius
  22485. * * radiusZ allows stretching in the z direction, optional, default radius
  22486. * * flat when true creates a flat shaded mesh, optional, default true
  22487. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22489. * * 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)
  22490. * * 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)
  22491. * @returns the VertexData of the IcoSphere
  22492. */
  22493. static CreateIcoSphere(options: {
  22494. radius?: number;
  22495. radiusX?: number;
  22496. radiusY?: number;
  22497. radiusZ?: number;
  22498. flat?: boolean;
  22499. subdivisions?: number;
  22500. sideOrientation?: number;
  22501. frontUVs?: Vector4;
  22502. backUVs?: Vector4;
  22503. }): VertexData;
  22504. /**
  22505. * Creates the VertexData for a Polyhedron
  22506. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22507. * * type provided types are:
  22508. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22509. * * 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)
  22510. * * size the size of the IcoSphere, optional default 1
  22511. * * sizeX allows stretching in the x direction, optional, default size
  22512. * * sizeY allows stretching in the y direction, optional, default size
  22513. * * sizeZ allows stretching in the z direction, optional, default size
  22514. * * 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
  22515. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22516. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22517. * * flat when true creates a flat shaded mesh, optional, default true
  22518. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22520. * * 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)
  22521. * * 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)
  22522. * @returns the VertexData of the Polyhedron
  22523. */
  22524. static CreatePolyhedron(options: {
  22525. type?: number;
  22526. size?: number;
  22527. sizeX?: number;
  22528. sizeY?: number;
  22529. sizeZ?: number;
  22530. custom?: any;
  22531. faceUV?: Vector4[];
  22532. faceColors?: Color4[];
  22533. flat?: boolean;
  22534. sideOrientation?: number;
  22535. frontUVs?: Vector4;
  22536. backUVs?: Vector4;
  22537. }): VertexData;
  22538. /**
  22539. * Creates the VertexData for a TorusKnot
  22540. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22541. * * radius the radius of the torus knot, optional, default 2
  22542. * * tube the thickness of the tube, optional, default 0.5
  22543. * * radialSegments the number of sides on each tube segments, optional, default 32
  22544. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22545. * * p the number of windings around the z axis, optional, default 2
  22546. * * q the number of windings around the x axis, optional, default 3
  22547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22548. * * 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)
  22549. * * 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)
  22550. * @returns the VertexData of the Torus Knot
  22551. */
  22552. static CreateTorusKnot(options: {
  22553. radius?: number;
  22554. tube?: number;
  22555. radialSegments?: number;
  22556. tubularSegments?: number;
  22557. p?: number;
  22558. q?: number;
  22559. sideOrientation?: number;
  22560. frontUVs?: Vector4;
  22561. backUVs?: Vector4;
  22562. }): VertexData;
  22563. /**
  22564. * Compute normals for given positions and indices
  22565. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22566. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22567. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22568. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22569. * * facetNormals : optional array of facet normals (vector3)
  22570. * * facetPositions : optional array of facet positions (vector3)
  22571. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22572. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22573. * * bInfo : optional bounding info, required for facetPartitioning computation
  22574. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22575. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22576. * * useRightHandedSystem: optional boolean to for right handed system computation
  22577. * * depthSort : optional boolean to enable the facet depth sort computation
  22578. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22579. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22580. */
  22581. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22582. facetNormals?: any;
  22583. facetPositions?: any;
  22584. facetPartitioning?: any;
  22585. ratio?: number;
  22586. bInfo?: any;
  22587. bbSize?: Vector3;
  22588. subDiv?: any;
  22589. useRightHandedSystem?: boolean;
  22590. depthSort?: boolean;
  22591. distanceTo?: Vector3;
  22592. depthSortedFacets?: any;
  22593. }): void;
  22594. /** @hidden */
  22595. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22596. /**
  22597. * Applies VertexData created from the imported parameters to the geometry
  22598. * @param parsedVertexData the parsed data from an imported file
  22599. * @param geometry the geometry to apply the VertexData to
  22600. */
  22601. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22602. }
  22603. }
  22604. declare module "babylonjs/Morph/morphTarget" {
  22605. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22606. import { Observable } from "babylonjs/Misc/observable";
  22607. import { Nullable, FloatArray } from "babylonjs/types";
  22608. import { Scene } from "babylonjs/scene";
  22609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22610. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22611. /**
  22612. * Defines a target to use with MorphTargetManager
  22613. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22614. */
  22615. export class MorphTarget implements IAnimatable {
  22616. /** defines the name of the target */
  22617. name: string;
  22618. /**
  22619. * Gets or sets the list of animations
  22620. */
  22621. animations: import("babylonjs/Animations/animation").Animation[];
  22622. private _scene;
  22623. private _positions;
  22624. private _normals;
  22625. private _tangents;
  22626. private _uvs;
  22627. private _influence;
  22628. /**
  22629. * Observable raised when the influence changes
  22630. */
  22631. onInfluenceChanged: Observable<boolean>;
  22632. /** @hidden */
  22633. _onDataLayoutChanged: Observable<void>;
  22634. /**
  22635. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22636. */
  22637. influence: number;
  22638. /**
  22639. * Gets or sets the id of the morph Target
  22640. */
  22641. id: string;
  22642. private _animationPropertiesOverride;
  22643. /**
  22644. * Gets or sets the animation properties override
  22645. */
  22646. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22647. /**
  22648. * Creates a new MorphTarget
  22649. * @param name defines the name of the target
  22650. * @param influence defines the influence to use
  22651. * @param scene defines the scene the morphtarget belongs to
  22652. */
  22653. constructor(
  22654. /** defines the name of the target */
  22655. name: string, influence?: number, scene?: Nullable<Scene>);
  22656. /**
  22657. * Gets a boolean defining if the target contains position data
  22658. */
  22659. readonly hasPositions: boolean;
  22660. /**
  22661. * Gets a boolean defining if the target contains normal data
  22662. */
  22663. readonly hasNormals: boolean;
  22664. /**
  22665. * Gets a boolean defining if the target contains tangent data
  22666. */
  22667. readonly hasTangents: boolean;
  22668. /**
  22669. * Gets a boolean defining if the target contains texture coordinates data
  22670. */
  22671. readonly hasUVs: boolean;
  22672. /**
  22673. * Affects position data to this target
  22674. * @param data defines the position data to use
  22675. */
  22676. setPositions(data: Nullable<FloatArray>): void;
  22677. /**
  22678. * Gets the position data stored in this target
  22679. * @returns a FloatArray containing the position data (or null if not present)
  22680. */
  22681. getPositions(): Nullable<FloatArray>;
  22682. /**
  22683. * Affects normal data to this target
  22684. * @param data defines the normal data to use
  22685. */
  22686. setNormals(data: Nullable<FloatArray>): void;
  22687. /**
  22688. * Gets the normal data stored in this target
  22689. * @returns a FloatArray containing the normal data (or null if not present)
  22690. */
  22691. getNormals(): Nullable<FloatArray>;
  22692. /**
  22693. * Affects tangent data to this target
  22694. * @param data defines the tangent data to use
  22695. */
  22696. setTangents(data: Nullable<FloatArray>): void;
  22697. /**
  22698. * Gets the tangent data stored in this target
  22699. * @returns a FloatArray containing the tangent data (or null if not present)
  22700. */
  22701. getTangents(): Nullable<FloatArray>;
  22702. /**
  22703. * Affects texture coordinates data to this target
  22704. * @param data defines the texture coordinates data to use
  22705. */
  22706. setUVs(data: Nullable<FloatArray>): void;
  22707. /**
  22708. * Gets the texture coordinates data stored in this target
  22709. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22710. */
  22711. getUVs(): Nullable<FloatArray>;
  22712. /**
  22713. * Serializes the current target into a Serialization object
  22714. * @returns the serialized object
  22715. */
  22716. serialize(): any;
  22717. /**
  22718. * Returns the string "MorphTarget"
  22719. * @returns "MorphTarget"
  22720. */
  22721. getClassName(): string;
  22722. /**
  22723. * Creates a new target from serialized data
  22724. * @param serializationObject defines the serialized data to use
  22725. * @returns a new MorphTarget
  22726. */
  22727. static Parse(serializationObject: any): MorphTarget;
  22728. /**
  22729. * Creates a MorphTarget from mesh data
  22730. * @param mesh defines the source mesh
  22731. * @param name defines the name to use for the new target
  22732. * @param influence defines the influence to attach to the target
  22733. * @returns a new MorphTarget
  22734. */
  22735. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22736. }
  22737. }
  22738. declare module "babylonjs/Morph/morphTargetManager" {
  22739. import { Nullable } from "babylonjs/types";
  22740. import { Scene } from "babylonjs/scene";
  22741. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22742. /**
  22743. * This class is used to deform meshes using morphing between different targets
  22744. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22745. */
  22746. export class MorphTargetManager {
  22747. private _targets;
  22748. private _targetInfluenceChangedObservers;
  22749. private _targetDataLayoutChangedObservers;
  22750. private _activeTargets;
  22751. private _scene;
  22752. private _influences;
  22753. private _supportsNormals;
  22754. private _supportsTangents;
  22755. private _supportsUVs;
  22756. private _vertexCount;
  22757. private _uniqueId;
  22758. private _tempInfluences;
  22759. /**
  22760. * Gets or sets a boolean indicating if normals must be morphed
  22761. */
  22762. enableNormalMorphing: boolean;
  22763. /**
  22764. * Gets or sets a boolean indicating if tangents must be morphed
  22765. */
  22766. enableTangentMorphing: boolean;
  22767. /**
  22768. * Gets or sets a boolean indicating if UV must be morphed
  22769. */
  22770. enableUVMorphing: boolean;
  22771. /**
  22772. * Creates a new MorphTargetManager
  22773. * @param scene defines the current scene
  22774. */
  22775. constructor(scene?: Nullable<Scene>);
  22776. /**
  22777. * Gets the unique ID of this manager
  22778. */
  22779. readonly uniqueId: number;
  22780. /**
  22781. * Gets the number of vertices handled by this manager
  22782. */
  22783. readonly vertexCount: number;
  22784. /**
  22785. * Gets a boolean indicating if this manager supports morphing of normals
  22786. */
  22787. readonly supportsNormals: boolean;
  22788. /**
  22789. * Gets a boolean indicating if this manager supports morphing of tangents
  22790. */
  22791. readonly supportsTangents: boolean;
  22792. /**
  22793. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22794. */
  22795. readonly supportsUVs: boolean;
  22796. /**
  22797. * Gets the number of targets stored in this manager
  22798. */
  22799. readonly numTargets: number;
  22800. /**
  22801. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22802. */
  22803. readonly numInfluencers: number;
  22804. /**
  22805. * Gets the list of influences (one per target)
  22806. */
  22807. readonly influences: Float32Array;
  22808. /**
  22809. * Gets the active target at specified index. An active target is a target with an influence > 0
  22810. * @param index defines the index to check
  22811. * @returns the requested target
  22812. */
  22813. getActiveTarget(index: number): MorphTarget;
  22814. /**
  22815. * Gets the target at specified index
  22816. * @param index defines the index to check
  22817. * @returns the requested target
  22818. */
  22819. getTarget(index: number): MorphTarget;
  22820. /**
  22821. * Add a new target to this manager
  22822. * @param target defines the target to add
  22823. */
  22824. addTarget(target: MorphTarget): void;
  22825. /**
  22826. * Removes a target from the manager
  22827. * @param target defines the target to remove
  22828. */
  22829. removeTarget(target: MorphTarget): void;
  22830. /**
  22831. * Serializes the current manager into a Serialization object
  22832. * @returns the serialized object
  22833. */
  22834. serialize(): any;
  22835. private _syncActiveTargets;
  22836. /**
  22837. * Syncrhonize the targets with all the meshes using this morph target manager
  22838. */
  22839. synchronize(): void;
  22840. /**
  22841. * Creates a new MorphTargetManager from serialized data
  22842. * @param serializationObject defines the serialized data
  22843. * @param scene defines the hosting scene
  22844. * @returns the new MorphTargetManager
  22845. */
  22846. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22847. }
  22848. }
  22849. declare module "babylonjs/Meshes/meshLODLevel" {
  22850. import { Mesh } from "babylonjs/Meshes/mesh";
  22851. import { Nullable } from "babylonjs/types";
  22852. /**
  22853. * Class used to represent a specific level of detail of a mesh
  22854. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22855. */
  22856. export class MeshLODLevel {
  22857. /** Defines the distance where this level should start being displayed */
  22858. distance: number;
  22859. /** Defines the mesh to use to render this level */
  22860. mesh: Nullable<Mesh>;
  22861. /**
  22862. * Creates a new LOD level
  22863. * @param distance defines the distance where this level should star being displayed
  22864. * @param mesh defines the mesh to use to render this level
  22865. */
  22866. constructor(
  22867. /** Defines the distance where this level should start being displayed */
  22868. distance: number,
  22869. /** Defines the mesh to use to render this level */
  22870. mesh: Nullable<Mesh>);
  22871. }
  22872. }
  22873. declare module "babylonjs/Meshes/groundMesh" {
  22874. import { Scene } from "babylonjs/scene";
  22875. import { Vector3 } from "babylonjs/Maths/math.vector";
  22876. import { Mesh } from "babylonjs/Meshes/mesh";
  22877. /**
  22878. * Mesh representing the gorund
  22879. */
  22880. export class GroundMesh extends Mesh {
  22881. /** If octree should be generated */
  22882. generateOctree: boolean;
  22883. private _heightQuads;
  22884. /** @hidden */
  22885. _subdivisionsX: number;
  22886. /** @hidden */
  22887. _subdivisionsY: number;
  22888. /** @hidden */
  22889. _width: number;
  22890. /** @hidden */
  22891. _height: number;
  22892. /** @hidden */
  22893. _minX: number;
  22894. /** @hidden */
  22895. _maxX: number;
  22896. /** @hidden */
  22897. _minZ: number;
  22898. /** @hidden */
  22899. _maxZ: number;
  22900. constructor(name: string, scene: Scene);
  22901. /**
  22902. * "GroundMesh"
  22903. * @returns "GroundMesh"
  22904. */
  22905. getClassName(): string;
  22906. /**
  22907. * The minimum of x and y subdivisions
  22908. */
  22909. readonly subdivisions: number;
  22910. /**
  22911. * X subdivisions
  22912. */
  22913. readonly subdivisionsX: number;
  22914. /**
  22915. * Y subdivisions
  22916. */
  22917. readonly subdivisionsY: number;
  22918. /**
  22919. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22920. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22921. * @param chunksCount the number of subdivisions for x and y
  22922. * @param octreeBlocksSize (Default: 32)
  22923. */
  22924. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22925. /**
  22926. * Returns a height (y) value in the Worl system :
  22927. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22928. * @param x x coordinate
  22929. * @param z z coordinate
  22930. * @returns the ground y position if (x, z) are outside the ground surface.
  22931. */
  22932. getHeightAtCoordinates(x: number, z: number): number;
  22933. /**
  22934. * Returns a normalized vector (Vector3) orthogonal to the ground
  22935. * at the ground coordinates (x, z) expressed in the World system.
  22936. * @param x x coordinate
  22937. * @param z z coordinate
  22938. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22939. */
  22940. getNormalAtCoordinates(x: number, z: number): Vector3;
  22941. /**
  22942. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22943. * at the ground coordinates (x, z) expressed in the World system.
  22944. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22945. * @param x x coordinate
  22946. * @param z z coordinate
  22947. * @param ref vector to store the result
  22948. * @returns the GroundMesh.
  22949. */
  22950. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22951. /**
  22952. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22953. * if the ground has been updated.
  22954. * This can be used in the render loop.
  22955. * @returns the GroundMesh.
  22956. */
  22957. updateCoordinateHeights(): GroundMesh;
  22958. private _getFacetAt;
  22959. private _initHeightQuads;
  22960. private _computeHeightQuads;
  22961. /**
  22962. * Serializes this ground mesh
  22963. * @param serializationObject object to write serialization to
  22964. */
  22965. serialize(serializationObject: any): void;
  22966. /**
  22967. * Parses a serialized ground mesh
  22968. * @param parsedMesh the serialized mesh
  22969. * @param scene the scene to create the ground mesh in
  22970. * @returns the created ground mesh
  22971. */
  22972. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22973. }
  22974. }
  22975. declare module "babylonjs/Physics/physicsJoint" {
  22976. import { Vector3 } from "babylonjs/Maths/math.vector";
  22977. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22978. /**
  22979. * Interface for Physics-Joint data
  22980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22981. */
  22982. export interface PhysicsJointData {
  22983. /**
  22984. * The main pivot of the joint
  22985. */
  22986. mainPivot?: Vector3;
  22987. /**
  22988. * The connected pivot of the joint
  22989. */
  22990. connectedPivot?: Vector3;
  22991. /**
  22992. * The main axis of the joint
  22993. */
  22994. mainAxis?: Vector3;
  22995. /**
  22996. * The connected axis of the joint
  22997. */
  22998. connectedAxis?: Vector3;
  22999. /**
  23000. * The collision of the joint
  23001. */
  23002. collision?: boolean;
  23003. /**
  23004. * Native Oimo/Cannon/Energy data
  23005. */
  23006. nativeParams?: any;
  23007. }
  23008. /**
  23009. * This is a holder class for the physics joint created by the physics plugin
  23010. * It holds a set of functions to control the underlying joint
  23011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23012. */
  23013. export class PhysicsJoint {
  23014. /**
  23015. * The type of the physics joint
  23016. */
  23017. type: number;
  23018. /**
  23019. * The data for the physics joint
  23020. */
  23021. jointData: PhysicsJointData;
  23022. private _physicsJoint;
  23023. protected _physicsPlugin: IPhysicsEnginePlugin;
  23024. /**
  23025. * Initializes the physics joint
  23026. * @param type The type of the physics joint
  23027. * @param jointData The data for the physics joint
  23028. */
  23029. constructor(
  23030. /**
  23031. * The type of the physics joint
  23032. */
  23033. type: number,
  23034. /**
  23035. * The data for the physics joint
  23036. */
  23037. jointData: PhysicsJointData);
  23038. /**
  23039. * Gets the physics joint
  23040. */
  23041. /**
  23042. * Sets the physics joint
  23043. */
  23044. physicsJoint: any;
  23045. /**
  23046. * Sets the physics plugin
  23047. */
  23048. physicsPlugin: IPhysicsEnginePlugin;
  23049. /**
  23050. * Execute a function that is physics-plugin specific.
  23051. * @param {Function} func the function that will be executed.
  23052. * It accepts two parameters: the physics world and the physics joint
  23053. */
  23054. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23055. /**
  23056. * Distance-Joint type
  23057. */
  23058. static DistanceJoint: number;
  23059. /**
  23060. * Hinge-Joint type
  23061. */
  23062. static HingeJoint: number;
  23063. /**
  23064. * Ball-and-Socket joint type
  23065. */
  23066. static BallAndSocketJoint: number;
  23067. /**
  23068. * Wheel-Joint type
  23069. */
  23070. static WheelJoint: number;
  23071. /**
  23072. * Slider-Joint type
  23073. */
  23074. static SliderJoint: number;
  23075. /**
  23076. * Prismatic-Joint type
  23077. */
  23078. static PrismaticJoint: number;
  23079. /**
  23080. * Universal-Joint type
  23081. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23082. */
  23083. static UniversalJoint: number;
  23084. /**
  23085. * Hinge-Joint 2 type
  23086. */
  23087. static Hinge2Joint: number;
  23088. /**
  23089. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23090. */
  23091. static PointToPointJoint: number;
  23092. /**
  23093. * Spring-Joint type
  23094. */
  23095. static SpringJoint: number;
  23096. /**
  23097. * Lock-Joint type
  23098. */
  23099. static LockJoint: number;
  23100. }
  23101. /**
  23102. * A class representing a physics distance joint
  23103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23104. */
  23105. export class DistanceJoint extends PhysicsJoint {
  23106. /**
  23107. *
  23108. * @param jointData The data for the Distance-Joint
  23109. */
  23110. constructor(jointData: DistanceJointData);
  23111. /**
  23112. * Update the predefined distance.
  23113. * @param maxDistance The maximum preferred distance
  23114. * @param minDistance The minimum preferred distance
  23115. */
  23116. updateDistance(maxDistance: number, minDistance?: number): void;
  23117. }
  23118. /**
  23119. * Represents a Motor-Enabled Joint
  23120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23121. */
  23122. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23123. /**
  23124. * Initializes the Motor-Enabled Joint
  23125. * @param type The type of the joint
  23126. * @param jointData The physica joint data for the joint
  23127. */
  23128. constructor(type: number, jointData: PhysicsJointData);
  23129. /**
  23130. * Set the motor values.
  23131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23132. * @param force the force to apply
  23133. * @param maxForce max force for this motor.
  23134. */
  23135. setMotor(force?: number, maxForce?: number): void;
  23136. /**
  23137. * Set the motor's limits.
  23138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23139. * @param upperLimit The upper limit of the motor
  23140. * @param lowerLimit The lower limit of the motor
  23141. */
  23142. setLimit(upperLimit: number, lowerLimit?: number): void;
  23143. }
  23144. /**
  23145. * This class represents a single physics Hinge-Joint
  23146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23147. */
  23148. export class HingeJoint extends MotorEnabledJoint {
  23149. /**
  23150. * Initializes the Hinge-Joint
  23151. * @param jointData The joint data for the Hinge-Joint
  23152. */
  23153. constructor(jointData: PhysicsJointData);
  23154. /**
  23155. * Set the motor values.
  23156. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23157. * @param {number} force the force to apply
  23158. * @param {number} maxForce max force for this motor.
  23159. */
  23160. setMotor(force?: number, maxForce?: number): void;
  23161. /**
  23162. * Set the motor's limits.
  23163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23164. * @param upperLimit The upper limit of the motor
  23165. * @param lowerLimit The lower limit of the motor
  23166. */
  23167. setLimit(upperLimit: number, lowerLimit?: number): void;
  23168. }
  23169. /**
  23170. * This class represents a dual hinge physics joint (same as wheel joint)
  23171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23172. */
  23173. export class Hinge2Joint extends MotorEnabledJoint {
  23174. /**
  23175. * Initializes the Hinge2-Joint
  23176. * @param jointData The joint data for the Hinge2-Joint
  23177. */
  23178. constructor(jointData: PhysicsJointData);
  23179. /**
  23180. * Set the motor values.
  23181. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23182. * @param {number} targetSpeed the speed the motor is to reach
  23183. * @param {number} maxForce max force for this motor.
  23184. * @param {motorIndex} the motor's index, 0 or 1.
  23185. */
  23186. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23187. /**
  23188. * Set the motor limits.
  23189. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23190. * @param {number} upperLimit the upper limit
  23191. * @param {number} lowerLimit lower limit
  23192. * @param {motorIndex} the motor's index, 0 or 1.
  23193. */
  23194. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23195. }
  23196. /**
  23197. * Interface for a motor enabled joint
  23198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23199. */
  23200. export interface IMotorEnabledJoint {
  23201. /**
  23202. * Physics joint
  23203. */
  23204. physicsJoint: any;
  23205. /**
  23206. * Sets the motor of the motor-enabled joint
  23207. * @param force The force of the motor
  23208. * @param maxForce The maximum force of the motor
  23209. * @param motorIndex The index of the motor
  23210. */
  23211. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23212. /**
  23213. * Sets the limit of the motor
  23214. * @param upperLimit The upper limit of the motor
  23215. * @param lowerLimit The lower limit of the motor
  23216. * @param motorIndex The index of the motor
  23217. */
  23218. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23219. }
  23220. /**
  23221. * Joint data for a Distance-Joint
  23222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23223. */
  23224. export interface DistanceJointData extends PhysicsJointData {
  23225. /**
  23226. * Max distance the 2 joint objects can be apart
  23227. */
  23228. maxDistance: number;
  23229. }
  23230. /**
  23231. * Joint data from a spring joint
  23232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23233. */
  23234. export interface SpringJointData extends PhysicsJointData {
  23235. /**
  23236. * Length of the spring
  23237. */
  23238. length: number;
  23239. /**
  23240. * Stiffness of the spring
  23241. */
  23242. stiffness: number;
  23243. /**
  23244. * Damping of the spring
  23245. */
  23246. damping: number;
  23247. /** this callback will be called when applying the force to the impostors. */
  23248. forceApplicationCallback: () => void;
  23249. }
  23250. }
  23251. declare module "babylonjs/Physics/physicsRaycastResult" {
  23252. import { Vector3 } from "babylonjs/Maths/math.vector";
  23253. /**
  23254. * Holds the data for the raycast result
  23255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23256. */
  23257. export class PhysicsRaycastResult {
  23258. private _hasHit;
  23259. private _hitDistance;
  23260. private _hitNormalWorld;
  23261. private _hitPointWorld;
  23262. private _rayFromWorld;
  23263. private _rayToWorld;
  23264. /**
  23265. * Gets if there was a hit
  23266. */
  23267. readonly hasHit: boolean;
  23268. /**
  23269. * Gets the distance from the hit
  23270. */
  23271. readonly hitDistance: number;
  23272. /**
  23273. * Gets the hit normal/direction in the world
  23274. */
  23275. readonly hitNormalWorld: Vector3;
  23276. /**
  23277. * Gets the hit point in the world
  23278. */
  23279. readonly hitPointWorld: Vector3;
  23280. /**
  23281. * Gets the ray "start point" of the ray in the world
  23282. */
  23283. readonly rayFromWorld: Vector3;
  23284. /**
  23285. * Gets the ray "end point" of the ray in the world
  23286. */
  23287. readonly rayToWorld: Vector3;
  23288. /**
  23289. * Sets the hit data (normal & point in world space)
  23290. * @param hitNormalWorld defines the normal in world space
  23291. * @param hitPointWorld defines the point in world space
  23292. */
  23293. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23294. /**
  23295. * Sets the distance from the start point to the hit point
  23296. * @param distance
  23297. */
  23298. setHitDistance(distance: number): void;
  23299. /**
  23300. * Calculates the distance manually
  23301. */
  23302. calculateHitDistance(): void;
  23303. /**
  23304. * Resets all the values to default
  23305. * @param from The from point on world space
  23306. * @param to The to point on world space
  23307. */
  23308. reset(from?: Vector3, to?: Vector3): void;
  23309. }
  23310. /**
  23311. * Interface for the size containing width and height
  23312. */
  23313. interface IXYZ {
  23314. /**
  23315. * X
  23316. */
  23317. x: number;
  23318. /**
  23319. * Y
  23320. */
  23321. y: number;
  23322. /**
  23323. * Z
  23324. */
  23325. z: number;
  23326. }
  23327. }
  23328. declare module "babylonjs/Physics/IPhysicsEngine" {
  23329. import { Nullable } from "babylonjs/types";
  23330. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23332. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23333. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23334. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23335. /**
  23336. * Interface used to describe a physics joint
  23337. */
  23338. export interface PhysicsImpostorJoint {
  23339. /** Defines the main impostor to which the joint is linked */
  23340. mainImpostor: PhysicsImpostor;
  23341. /** Defines the impostor that is connected to the main impostor using this joint */
  23342. connectedImpostor: PhysicsImpostor;
  23343. /** Defines the joint itself */
  23344. joint: PhysicsJoint;
  23345. }
  23346. /** @hidden */
  23347. export interface IPhysicsEnginePlugin {
  23348. world: any;
  23349. name: string;
  23350. setGravity(gravity: Vector3): void;
  23351. setTimeStep(timeStep: number): void;
  23352. getTimeStep(): number;
  23353. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23354. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23355. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23356. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23357. removePhysicsBody(impostor: PhysicsImpostor): void;
  23358. generateJoint(joint: PhysicsImpostorJoint): void;
  23359. removeJoint(joint: PhysicsImpostorJoint): void;
  23360. isSupported(): boolean;
  23361. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23362. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23363. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23364. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23365. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23366. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23367. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23368. getBodyMass(impostor: PhysicsImpostor): number;
  23369. getBodyFriction(impostor: PhysicsImpostor): number;
  23370. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23371. getBodyRestitution(impostor: PhysicsImpostor): number;
  23372. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23373. getBodyPressure?(impostor: PhysicsImpostor): number;
  23374. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23375. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23376. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23377. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23378. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23379. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23380. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23381. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23382. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23383. sleepBody(impostor: PhysicsImpostor): void;
  23384. wakeUpBody(impostor: PhysicsImpostor): void;
  23385. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23386. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23387. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23388. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23389. getRadius(impostor: PhysicsImpostor): number;
  23390. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23391. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23392. dispose(): void;
  23393. }
  23394. /**
  23395. * Interface used to define a physics engine
  23396. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23397. */
  23398. export interface IPhysicsEngine {
  23399. /**
  23400. * Gets the gravity vector used by the simulation
  23401. */
  23402. gravity: Vector3;
  23403. /**
  23404. * Sets the gravity vector used by the simulation
  23405. * @param gravity defines the gravity vector to use
  23406. */
  23407. setGravity(gravity: Vector3): void;
  23408. /**
  23409. * Set the time step of the physics engine.
  23410. * Default is 1/60.
  23411. * To slow it down, enter 1/600 for example.
  23412. * To speed it up, 1/30
  23413. * @param newTimeStep the new timestep to apply to this world.
  23414. */
  23415. setTimeStep(newTimeStep: number): void;
  23416. /**
  23417. * Get the time step of the physics engine.
  23418. * @returns the current time step
  23419. */
  23420. getTimeStep(): number;
  23421. /**
  23422. * Release all resources
  23423. */
  23424. dispose(): void;
  23425. /**
  23426. * Gets the name of the current physics plugin
  23427. * @returns the name of the plugin
  23428. */
  23429. getPhysicsPluginName(): string;
  23430. /**
  23431. * Adding a new impostor for the impostor tracking.
  23432. * This will be done by the impostor itself.
  23433. * @param impostor the impostor to add
  23434. */
  23435. addImpostor(impostor: PhysicsImpostor): void;
  23436. /**
  23437. * Remove an impostor from the engine.
  23438. * This impostor and its mesh will not longer be updated by the physics engine.
  23439. * @param impostor the impostor to remove
  23440. */
  23441. removeImpostor(impostor: PhysicsImpostor): void;
  23442. /**
  23443. * Add a joint to the physics engine
  23444. * @param mainImpostor defines the main impostor to which the joint is added.
  23445. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23446. * @param joint defines the joint that will connect both impostors.
  23447. */
  23448. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23449. /**
  23450. * Removes a joint from the simulation
  23451. * @param mainImpostor defines the impostor used with the joint
  23452. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23453. * @param joint defines the joint to remove
  23454. */
  23455. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23456. /**
  23457. * Gets the current plugin used to run the simulation
  23458. * @returns current plugin
  23459. */
  23460. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23461. /**
  23462. * Gets the list of physic impostors
  23463. * @returns an array of PhysicsImpostor
  23464. */
  23465. getImpostors(): Array<PhysicsImpostor>;
  23466. /**
  23467. * Gets the impostor for a physics enabled object
  23468. * @param object defines the object impersonated by the impostor
  23469. * @returns the PhysicsImpostor or null if not found
  23470. */
  23471. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23472. /**
  23473. * Gets the impostor for a physics body object
  23474. * @param body defines physics body used by the impostor
  23475. * @returns the PhysicsImpostor or null if not found
  23476. */
  23477. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23478. /**
  23479. * Does a raycast in the physics world
  23480. * @param from when should the ray start?
  23481. * @param to when should the ray end?
  23482. * @returns PhysicsRaycastResult
  23483. */
  23484. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23485. /**
  23486. * Called by the scene. No need to call it.
  23487. * @param delta defines the timespam between frames
  23488. */
  23489. _step(delta: number): void;
  23490. }
  23491. }
  23492. declare module "babylonjs/Physics/physicsImpostor" {
  23493. import { Nullable, IndicesArray } from "babylonjs/types";
  23494. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23497. import { Scene } from "babylonjs/scene";
  23498. import { Bone } from "babylonjs/Bones/bone";
  23499. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23500. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23501. import { Space } from "babylonjs/Maths/math.axis";
  23502. /**
  23503. * The interface for the physics imposter parameters
  23504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23505. */
  23506. export interface PhysicsImpostorParameters {
  23507. /**
  23508. * The mass of the physics imposter
  23509. */
  23510. mass: number;
  23511. /**
  23512. * The friction of the physics imposter
  23513. */
  23514. friction?: number;
  23515. /**
  23516. * The coefficient of restitution of the physics imposter
  23517. */
  23518. restitution?: number;
  23519. /**
  23520. * The native options of the physics imposter
  23521. */
  23522. nativeOptions?: any;
  23523. /**
  23524. * Specifies if the parent should be ignored
  23525. */
  23526. ignoreParent?: boolean;
  23527. /**
  23528. * Specifies if bi-directional transformations should be disabled
  23529. */
  23530. disableBidirectionalTransformation?: boolean;
  23531. /**
  23532. * The pressure inside the physics imposter, soft object only
  23533. */
  23534. pressure?: number;
  23535. /**
  23536. * The stiffness the physics imposter, soft object only
  23537. */
  23538. stiffness?: number;
  23539. /**
  23540. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23541. */
  23542. velocityIterations?: number;
  23543. /**
  23544. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23545. */
  23546. positionIterations?: number;
  23547. /**
  23548. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23549. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23550. * Add to fix multiple points
  23551. */
  23552. fixedPoints?: number;
  23553. /**
  23554. * The collision margin around a soft object
  23555. */
  23556. margin?: number;
  23557. /**
  23558. * The collision margin around a soft object
  23559. */
  23560. damping?: number;
  23561. /**
  23562. * The path for a rope based on an extrusion
  23563. */
  23564. path?: any;
  23565. /**
  23566. * The shape of an extrusion used for a rope based on an extrusion
  23567. */
  23568. shape?: any;
  23569. }
  23570. /**
  23571. * Interface for a physics-enabled object
  23572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23573. */
  23574. export interface IPhysicsEnabledObject {
  23575. /**
  23576. * The position of the physics-enabled object
  23577. */
  23578. position: Vector3;
  23579. /**
  23580. * The rotation of the physics-enabled object
  23581. */
  23582. rotationQuaternion: Nullable<Quaternion>;
  23583. /**
  23584. * The scale of the physics-enabled object
  23585. */
  23586. scaling: Vector3;
  23587. /**
  23588. * The rotation of the physics-enabled object
  23589. */
  23590. rotation?: Vector3;
  23591. /**
  23592. * The parent of the physics-enabled object
  23593. */
  23594. parent?: any;
  23595. /**
  23596. * The bounding info of the physics-enabled object
  23597. * @returns The bounding info of the physics-enabled object
  23598. */
  23599. getBoundingInfo(): BoundingInfo;
  23600. /**
  23601. * Computes the world matrix
  23602. * @param force Specifies if the world matrix should be computed by force
  23603. * @returns A world matrix
  23604. */
  23605. computeWorldMatrix(force: boolean): Matrix;
  23606. /**
  23607. * Gets the world matrix
  23608. * @returns A world matrix
  23609. */
  23610. getWorldMatrix?(): Matrix;
  23611. /**
  23612. * Gets the child meshes
  23613. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23614. * @returns An array of abstract meshes
  23615. */
  23616. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23617. /**
  23618. * Gets the vertex data
  23619. * @param kind The type of vertex data
  23620. * @returns A nullable array of numbers, or a float32 array
  23621. */
  23622. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23623. /**
  23624. * Gets the indices from the mesh
  23625. * @returns A nullable array of index arrays
  23626. */
  23627. getIndices?(): Nullable<IndicesArray>;
  23628. /**
  23629. * Gets the scene from the mesh
  23630. * @returns the indices array or null
  23631. */
  23632. getScene?(): Scene;
  23633. /**
  23634. * Gets the absolute position from the mesh
  23635. * @returns the absolute position
  23636. */
  23637. getAbsolutePosition(): Vector3;
  23638. /**
  23639. * Gets the absolute pivot point from the mesh
  23640. * @returns the absolute pivot point
  23641. */
  23642. getAbsolutePivotPoint(): Vector3;
  23643. /**
  23644. * Rotates the mesh
  23645. * @param axis The axis of rotation
  23646. * @param amount The amount of rotation
  23647. * @param space The space of the rotation
  23648. * @returns The rotation transform node
  23649. */
  23650. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23651. /**
  23652. * Translates the mesh
  23653. * @param axis The axis of translation
  23654. * @param distance The distance of translation
  23655. * @param space The space of the translation
  23656. * @returns The transform node
  23657. */
  23658. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23659. /**
  23660. * Sets the absolute position of the mesh
  23661. * @param absolutePosition The absolute position of the mesh
  23662. * @returns The transform node
  23663. */
  23664. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23665. /**
  23666. * Gets the class name of the mesh
  23667. * @returns The class name
  23668. */
  23669. getClassName(): string;
  23670. }
  23671. /**
  23672. * Represents a physics imposter
  23673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23674. */
  23675. export class PhysicsImpostor {
  23676. /**
  23677. * The physics-enabled object used as the physics imposter
  23678. */
  23679. object: IPhysicsEnabledObject;
  23680. /**
  23681. * The type of the physics imposter
  23682. */
  23683. type: number;
  23684. private _options;
  23685. private _scene?;
  23686. /**
  23687. * The default object size of the imposter
  23688. */
  23689. static DEFAULT_OBJECT_SIZE: Vector3;
  23690. /**
  23691. * The identity quaternion of the imposter
  23692. */
  23693. static IDENTITY_QUATERNION: Quaternion;
  23694. /** @hidden */
  23695. _pluginData: any;
  23696. private _physicsEngine;
  23697. private _physicsBody;
  23698. private _bodyUpdateRequired;
  23699. private _onBeforePhysicsStepCallbacks;
  23700. private _onAfterPhysicsStepCallbacks;
  23701. /** @hidden */
  23702. _onPhysicsCollideCallbacks: Array<{
  23703. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23704. otherImpostors: Array<PhysicsImpostor>;
  23705. }>;
  23706. private _deltaPosition;
  23707. private _deltaRotation;
  23708. private _deltaRotationConjugated;
  23709. /** @hidden */
  23710. _isFromLine: boolean;
  23711. private _parent;
  23712. private _isDisposed;
  23713. private static _tmpVecs;
  23714. private static _tmpQuat;
  23715. /**
  23716. * Specifies if the physics imposter is disposed
  23717. */
  23718. readonly isDisposed: boolean;
  23719. /**
  23720. * Gets the mass of the physics imposter
  23721. */
  23722. mass: number;
  23723. /**
  23724. * Gets the coefficient of friction
  23725. */
  23726. /**
  23727. * Sets the coefficient of friction
  23728. */
  23729. friction: number;
  23730. /**
  23731. * Gets the coefficient of restitution
  23732. */
  23733. /**
  23734. * Sets the coefficient of restitution
  23735. */
  23736. restitution: number;
  23737. /**
  23738. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23739. */
  23740. /**
  23741. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23742. */
  23743. pressure: number;
  23744. /**
  23745. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23746. */
  23747. /**
  23748. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23749. */
  23750. stiffness: number;
  23751. /**
  23752. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23753. */
  23754. /**
  23755. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23756. */
  23757. velocityIterations: number;
  23758. /**
  23759. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23760. */
  23761. /**
  23762. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23763. */
  23764. positionIterations: number;
  23765. /**
  23766. * The unique id of the physics imposter
  23767. * set by the physics engine when adding this impostor to the array
  23768. */
  23769. uniqueId: number;
  23770. /**
  23771. * @hidden
  23772. */
  23773. soft: boolean;
  23774. /**
  23775. * @hidden
  23776. */
  23777. segments: number;
  23778. private _joints;
  23779. /**
  23780. * Initializes the physics imposter
  23781. * @param object The physics-enabled object used as the physics imposter
  23782. * @param type The type of the physics imposter
  23783. * @param _options The options for the physics imposter
  23784. * @param _scene The Babylon scene
  23785. */
  23786. constructor(
  23787. /**
  23788. * The physics-enabled object used as the physics imposter
  23789. */
  23790. object: IPhysicsEnabledObject,
  23791. /**
  23792. * The type of the physics imposter
  23793. */
  23794. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23795. /**
  23796. * This function will completly initialize this impostor.
  23797. * It will create a new body - but only if this mesh has no parent.
  23798. * If it has, this impostor will not be used other than to define the impostor
  23799. * of the child mesh.
  23800. * @hidden
  23801. */
  23802. _init(): void;
  23803. private _getPhysicsParent;
  23804. /**
  23805. * Should a new body be generated.
  23806. * @returns boolean specifying if body initialization is required
  23807. */
  23808. isBodyInitRequired(): boolean;
  23809. /**
  23810. * Sets the updated scaling
  23811. * @param updated Specifies if the scaling is updated
  23812. */
  23813. setScalingUpdated(): void;
  23814. /**
  23815. * Force a regeneration of this or the parent's impostor's body.
  23816. * Use under cautious - This will remove all joints already implemented.
  23817. */
  23818. forceUpdate(): void;
  23819. /**
  23820. * Gets the body that holds this impostor. Either its own, or its parent.
  23821. */
  23822. /**
  23823. * Set the physics body. Used mainly by the physics engine/plugin
  23824. */
  23825. physicsBody: any;
  23826. /**
  23827. * Get the parent of the physics imposter
  23828. * @returns Physics imposter or null
  23829. */
  23830. /**
  23831. * Sets the parent of the physics imposter
  23832. */
  23833. parent: Nullable<PhysicsImpostor>;
  23834. /**
  23835. * Resets the update flags
  23836. */
  23837. resetUpdateFlags(): void;
  23838. /**
  23839. * Gets the object extend size
  23840. * @returns the object extend size
  23841. */
  23842. getObjectExtendSize(): Vector3;
  23843. /**
  23844. * Gets the object center
  23845. * @returns The object center
  23846. */
  23847. getObjectCenter(): Vector3;
  23848. /**
  23849. * Get a specific parametes from the options parameter
  23850. * @param paramName The object parameter name
  23851. * @returns The object parameter
  23852. */
  23853. getParam(paramName: string): any;
  23854. /**
  23855. * Sets a specific parameter in the options given to the physics plugin
  23856. * @param paramName The parameter name
  23857. * @param value The value of the parameter
  23858. */
  23859. setParam(paramName: string, value: number): void;
  23860. /**
  23861. * Specifically change the body's mass option. Won't recreate the physics body object
  23862. * @param mass The mass of the physics imposter
  23863. */
  23864. setMass(mass: number): void;
  23865. /**
  23866. * Gets the linear velocity
  23867. * @returns linear velocity or null
  23868. */
  23869. getLinearVelocity(): Nullable<Vector3>;
  23870. /**
  23871. * Sets the linear velocity
  23872. * @param velocity linear velocity or null
  23873. */
  23874. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23875. /**
  23876. * Gets the angular velocity
  23877. * @returns angular velocity or null
  23878. */
  23879. getAngularVelocity(): Nullable<Vector3>;
  23880. /**
  23881. * Sets the angular velocity
  23882. * @param velocity The velocity or null
  23883. */
  23884. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23885. /**
  23886. * Execute a function with the physics plugin native code
  23887. * Provide a function the will have two variables - the world object and the physics body object
  23888. * @param func The function to execute with the physics plugin native code
  23889. */
  23890. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23891. /**
  23892. * Register a function that will be executed before the physics world is stepping forward
  23893. * @param func The function to execute before the physics world is stepped forward
  23894. */
  23895. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23896. /**
  23897. * Unregister a function that will be executed before the physics world is stepping forward
  23898. * @param func The function to execute before the physics world is stepped forward
  23899. */
  23900. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23901. /**
  23902. * Register a function that will be executed after the physics step
  23903. * @param func The function to execute after physics step
  23904. */
  23905. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23906. /**
  23907. * Unregisters a function that will be executed after the physics step
  23908. * @param func The function to execute after physics step
  23909. */
  23910. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23911. /**
  23912. * register a function that will be executed when this impostor collides against a different body
  23913. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23914. * @param func Callback that is executed on collision
  23915. */
  23916. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23917. /**
  23918. * Unregisters the physics imposter on contact
  23919. * @param collideAgainst The physics object to collide against
  23920. * @param func Callback to execute on collision
  23921. */
  23922. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23923. private _tmpQuat;
  23924. private _tmpQuat2;
  23925. /**
  23926. * Get the parent rotation
  23927. * @returns The parent rotation
  23928. */
  23929. getParentsRotation(): Quaternion;
  23930. /**
  23931. * this function is executed by the physics engine.
  23932. */
  23933. beforeStep: () => void;
  23934. /**
  23935. * this function is executed by the physics engine
  23936. */
  23937. afterStep: () => void;
  23938. /**
  23939. * Legacy collision detection event support
  23940. */
  23941. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23942. /**
  23943. * event and body object due to cannon's event-based architecture.
  23944. */
  23945. onCollide: (e: {
  23946. body: any;
  23947. }) => void;
  23948. /**
  23949. * Apply a force
  23950. * @param force The force to apply
  23951. * @param contactPoint The contact point for the force
  23952. * @returns The physics imposter
  23953. */
  23954. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23955. /**
  23956. * Apply an impulse
  23957. * @param force The impulse force
  23958. * @param contactPoint The contact point for the impulse force
  23959. * @returns The physics imposter
  23960. */
  23961. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23962. /**
  23963. * A help function to create a joint
  23964. * @param otherImpostor A physics imposter used to create a joint
  23965. * @param jointType The type of joint
  23966. * @param jointData The data for the joint
  23967. * @returns The physics imposter
  23968. */
  23969. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23970. /**
  23971. * Add a joint to this impostor with a different impostor
  23972. * @param otherImpostor A physics imposter used to add a joint
  23973. * @param joint The joint to add
  23974. * @returns The physics imposter
  23975. */
  23976. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23977. /**
  23978. * Add an anchor to a cloth impostor
  23979. * @param otherImpostor rigid impostor to anchor to
  23980. * @param width ratio across width from 0 to 1
  23981. * @param height ratio up height from 0 to 1
  23982. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23983. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23984. * @returns impostor the soft imposter
  23985. */
  23986. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23987. /**
  23988. * Add a hook to a rope impostor
  23989. * @param otherImpostor rigid impostor to anchor to
  23990. * @param length ratio across rope from 0 to 1
  23991. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23992. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23993. * @returns impostor the rope imposter
  23994. */
  23995. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23996. /**
  23997. * Will keep this body still, in a sleep mode.
  23998. * @returns the physics imposter
  23999. */
  24000. sleep(): PhysicsImpostor;
  24001. /**
  24002. * Wake the body up.
  24003. * @returns The physics imposter
  24004. */
  24005. wakeUp(): PhysicsImpostor;
  24006. /**
  24007. * Clones the physics imposter
  24008. * @param newObject The physics imposter clones to this physics-enabled object
  24009. * @returns A nullable physics imposter
  24010. */
  24011. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24012. /**
  24013. * Disposes the physics imposter
  24014. */
  24015. dispose(): void;
  24016. /**
  24017. * Sets the delta position
  24018. * @param position The delta position amount
  24019. */
  24020. setDeltaPosition(position: Vector3): void;
  24021. /**
  24022. * Sets the delta rotation
  24023. * @param rotation The delta rotation amount
  24024. */
  24025. setDeltaRotation(rotation: Quaternion): void;
  24026. /**
  24027. * Gets the box size of the physics imposter and stores the result in the input parameter
  24028. * @param result Stores the box size
  24029. * @returns The physics imposter
  24030. */
  24031. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24032. /**
  24033. * Gets the radius of the physics imposter
  24034. * @returns Radius of the physics imposter
  24035. */
  24036. getRadius(): number;
  24037. /**
  24038. * Sync a bone with this impostor
  24039. * @param bone The bone to sync to the impostor.
  24040. * @param boneMesh The mesh that the bone is influencing.
  24041. * @param jointPivot The pivot of the joint / bone in local space.
  24042. * @param distToJoint Optional distance from the impostor to the joint.
  24043. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24044. */
  24045. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24046. /**
  24047. * Sync impostor to a bone
  24048. * @param bone The bone that the impostor will be synced to.
  24049. * @param boneMesh The mesh that the bone is influencing.
  24050. * @param jointPivot The pivot of the joint / bone in local space.
  24051. * @param distToJoint Optional distance from the impostor to the joint.
  24052. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24053. * @param boneAxis Optional vector3 axis the bone is aligned with
  24054. */
  24055. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24056. /**
  24057. * No-Imposter type
  24058. */
  24059. static NoImpostor: number;
  24060. /**
  24061. * Sphere-Imposter type
  24062. */
  24063. static SphereImpostor: number;
  24064. /**
  24065. * Box-Imposter type
  24066. */
  24067. static BoxImpostor: number;
  24068. /**
  24069. * Plane-Imposter type
  24070. */
  24071. static PlaneImpostor: number;
  24072. /**
  24073. * Mesh-imposter type
  24074. */
  24075. static MeshImpostor: number;
  24076. /**
  24077. * Capsule-Impostor type (Ammo.js plugin only)
  24078. */
  24079. static CapsuleImpostor: number;
  24080. /**
  24081. * Cylinder-Imposter type
  24082. */
  24083. static CylinderImpostor: number;
  24084. /**
  24085. * Particle-Imposter type
  24086. */
  24087. static ParticleImpostor: number;
  24088. /**
  24089. * Heightmap-Imposter type
  24090. */
  24091. static HeightmapImpostor: number;
  24092. /**
  24093. * ConvexHull-Impostor type (Ammo.js plugin only)
  24094. */
  24095. static ConvexHullImpostor: number;
  24096. /**
  24097. * Rope-Imposter type
  24098. */
  24099. static RopeImpostor: number;
  24100. /**
  24101. * Cloth-Imposter type
  24102. */
  24103. static ClothImpostor: number;
  24104. /**
  24105. * Softbody-Imposter type
  24106. */
  24107. static SoftbodyImpostor: number;
  24108. }
  24109. }
  24110. declare module "babylonjs/Meshes/mesh" {
  24111. import { Observable } from "babylonjs/Misc/observable";
  24112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24113. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24114. import { Camera } from "babylonjs/Cameras/camera";
  24115. import { Scene } from "babylonjs/scene";
  24116. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24117. import { Color4 } from "babylonjs/Maths/math.color";
  24118. import { Engine } from "babylonjs/Engines/engine";
  24119. import { Node } from "babylonjs/node";
  24120. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24121. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24122. import { Buffer } from "babylonjs/Meshes/buffer";
  24123. import { Geometry } from "babylonjs/Meshes/geometry";
  24124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24126. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24127. import { Effect } from "babylonjs/Materials/effect";
  24128. import { Material } from "babylonjs/Materials/material";
  24129. import { Skeleton } from "babylonjs/Bones/skeleton";
  24130. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24131. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24132. import { Path3D } from "babylonjs/Maths/math.path";
  24133. import { Plane } from "babylonjs/Maths/math.plane";
  24134. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24135. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24136. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24137. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24138. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24139. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24140. /**
  24141. * @hidden
  24142. **/
  24143. export class _CreationDataStorage {
  24144. closePath?: boolean;
  24145. closeArray?: boolean;
  24146. idx: number[];
  24147. dashSize: number;
  24148. gapSize: number;
  24149. path3D: Path3D;
  24150. pathArray: Vector3[][];
  24151. arc: number;
  24152. radius: number;
  24153. cap: number;
  24154. tessellation: number;
  24155. }
  24156. /**
  24157. * @hidden
  24158. **/
  24159. class _InstanceDataStorage {
  24160. visibleInstances: any;
  24161. batchCache: _InstancesBatch;
  24162. instancesBufferSize: number;
  24163. instancesBuffer: Nullable<Buffer>;
  24164. instancesData: Float32Array;
  24165. overridenInstanceCount: number;
  24166. isFrozen: boolean;
  24167. previousBatch: Nullable<_InstancesBatch>;
  24168. hardwareInstancedRendering: boolean;
  24169. sideOrientation: number;
  24170. }
  24171. /**
  24172. * @hidden
  24173. **/
  24174. export class _InstancesBatch {
  24175. mustReturn: boolean;
  24176. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24177. renderSelf: boolean[];
  24178. hardwareInstancedRendering: boolean[];
  24179. }
  24180. /**
  24181. * Class used to represent renderable models
  24182. */
  24183. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24184. /**
  24185. * Mesh side orientation : usually the external or front surface
  24186. */
  24187. static readonly FRONTSIDE: number;
  24188. /**
  24189. * Mesh side orientation : usually the internal or back surface
  24190. */
  24191. static readonly BACKSIDE: number;
  24192. /**
  24193. * Mesh side orientation : both internal and external or front and back surfaces
  24194. */
  24195. static readonly DOUBLESIDE: number;
  24196. /**
  24197. * Mesh side orientation : by default, `FRONTSIDE`
  24198. */
  24199. static readonly DEFAULTSIDE: number;
  24200. /**
  24201. * Mesh cap setting : no cap
  24202. */
  24203. static readonly NO_CAP: number;
  24204. /**
  24205. * Mesh cap setting : one cap at the beginning of the mesh
  24206. */
  24207. static readonly CAP_START: number;
  24208. /**
  24209. * Mesh cap setting : one cap at the end of the mesh
  24210. */
  24211. static readonly CAP_END: number;
  24212. /**
  24213. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24214. */
  24215. static readonly CAP_ALL: number;
  24216. /**
  24217. * Mesh pattern setting : no flip or rotate
  24218. */
  24219. static readonly NO_FLIP: number;
  24220. /**
  24221. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24222. */
  24223. static readonly FLIP_TILE: number;
  24224. /**
  24225. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24226. */
  24227. static readonly ROTATE_TILE: number;
  24228. /**
  24229. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24230. */
  24231. static readonly FLIP_ROW: number;
  24232. /**
  24233. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24234. */
  24235. static readonly ROTATE_ROW: number;
  24236. /**
  24237. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24238. */
  24239. static readonly FLIP_N_ROTATE_TILE: number;
  24240. /**
  24241. * Mesh pattern setting : rotate pattern and rotate
  24242. */
  24243. static readonly FLIP_N_ROTATE_ROW: number;
  24244. /**
  24245. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24246. */
  24247. static readonly CENTER: number;
  24248. /**
  24249. * Mesh tile positioning : part tiles on left
  24250. */
  24251. static readonly LEFT: number;
  24252. /**
  24253. * Mesh tile positioning : part tiles on right
  24254. */
  24255. static readonly RIGHT: number;
  24256. /**
  24257. * Mesh tile positioning : part tiles on top
  24258. */
  24259. static readonly TOP: number;
  24260. /**
  24261. * Mesh tile positioning : part tiles on bottom
  24262. */
  24263. static readonly BOTTOM: number;
  24264. /**
  24265. * Gets the default side orientation.
  24266. * @param orientation the orientation to value to attempt to get
  24267. * @returns the default orientation
  24268. * @hidden
  24269. */
  24270. static _GetDefaultSideOrientation(orientation?: number): number;
  24271. private _internalMeshDataInfo;
  24272. /**
  24273. * An event triggered before rendering the mesh
  24274. */
  24275. readonly onBeforeRenderObservable: Observable<Mesh>;
  24276. /**
  24277. * An event triggered before binding the mesh
  24278. */
  24279. readonly onBeforeBindObservable: Observable<Mesh>;
  24280. /**
  24281. * An event triggered after rendering the mesh
  24282. */
  24283. readonly onAfterRenderObservable: Observable<Mesh>;
  24284. /**
  24285. * An event triggered before drawing the mesh
  24286. */
  24287. readonly onBeforeDrawObservable: Observable<Mesh>;
  24288. private _onBeforeDrawObserver;
  24289. /**
  24290. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24291. */
  24292. onBeforeDraw: () => void;
  24293. readonly hasInstances: boolean;
  24294. /**
  24295. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24296. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24297. */
  24298. delayLoadState: number;
  24299. /**
  24300. * Gets the list of instances created from this mesh
  24301. * it is not supposed to be modified manually.
  24302. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24303. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24304. */
  24305. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24306. /**
  24307. * Gets the file containing delay loading data for this mesh
  24308. */
  24309. delayLoadingFile: string;
  24310. /** @hidden */
  24311. _binaryInfo: any;
  24312. /**
  24313. * User defined function used to change how LOD level selection is done
  24314. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24315. */
  24316. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24317. /**
  24318. * Gets or sets the morph target manager
  24319. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24320. */
  24321. morphTargetManager: Nullable<MorphTargetManager>;
  24322. /** @hidden */
  24323. _creationDataStorage: Nullable<_CreationDataStorage>;
  24324. /** @hidden */
  24325. _geometry: Nullable<Geometry>;
  24326. /** @hidden */
  24327. _delayInfo: Array<string>;
  24328. /** @hidden */
  24329. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24330. /** @hidden */
  24331. _instanceDataStorage: _InstanceDataStorage;
  24332. private _effectiveMaterial;
  24333. /** @hidden */
  24334. _shouldGenerateFlatShading: boolean;
  24335. /** @hidden */
  24336. _originalBuilderSideOrientation: number;
  24337. /**
  24338. * Use this property to change the original side orientation defined at construction time
  24339. */
  24340. overrideMaterialSideOrientation: Nullable<number>;
  24341. /**
  24342. * Gets the source mesh (the one used to clone this one from)
  24343. */
  24344. readonly source: Nullable<Mesh>;
  24345. /**
  24346. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24347. */
  24348. isUnIndexed: boolean;
  24349. /**
  24350. * @constructor
  24351. * @param name The value used by scene.getMeshByName() to do a lookup.
  24352. * @param scene The scene to add this mesh to.
  24353. * @param parent The parent of this mesh, if it has one
  24354. * @param source An optional Mesh from which geometry is shared, cloned.
  24355. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24356. * When false, achieved by calling a clone(), also passing False.
  24357. * This will make creation of children, recursive.
  24358. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24359. */
  24360. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24361. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24362. /**
  24363. * Gets the class name
  24364. * @returns the string "Mesh".
  24365. */
  24366. getClassName(): string;
  24367. /** @hidden */
  24368. readonly _isMesh: boolean;
  24369. /**
  24370. * Returns a description of this mesh
  24371. * @param fullDetails define if full details about this mesh must be used
  24372. * @returns a descriptive string representing this mesh
  24373. */
  24374. toString(fullDetails?: boolean): string;
  24375. /** @hidden */
  24376. _unBindEffect(): void;
  24377. /**
  24378. * Gets a boolean indicating if this mesh has LOD
  24379. */
  24380. readonly hasLODLevels: boolean;
  24381. /**
  24382. * Gets the list of MeshLODLevel associated with the current mesh
  24383. * @returns an array of MeshLODLevel
  24384. */
  24385. getLODLevels(): MeshLODLevel[];
  24386. private _sortLODLevels;
  24387. /**
  24388. * Add a mesh as LOD level triggered at the given distance.
  24389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24390. * @param distance The distance from the center of the object to show this level
  24391. * @param mesh The mesh to be added as LOD level (can be null)
  24392. * @return This mesh (for chaining)
  24393. */
  24394. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24395. /**
  24396. * Returns the LOD level mesh at the passed distance or null if not found.
  24397. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24398. * @param distance The distance from the center of the object to show this level
  24399. * @returns a Mesh or `null`
  24400. */
  24401. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24402. /**
  24403. * Remove a mesh from the LOD array
  24404. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24405. * @param mesh defines the mesh to be removed
  24406. * @return This mesh (for chaining)
  24407. */
  24408. removeLODLevel(mesh: Mesh): Mesh;
  24409. /**
  24410. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24411. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24412. * @param camera defines the camera to use to compute distance
  24413. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24414. * @return This mesh (for chaining)
  24415. */
  24416. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24417. /**
  24418. * Gets the mesh internal Geometry object
  24419. */
  24420. readonly geometry: Nullable<Geometry>;
  24421. /**
  24422. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24423. * @returns the total number of vertices
  24424. */
  24425. getTotalVertices(): number;
  24426. /**
  24427. * Returns the content of an associated vertex buffer
  24428. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24429. * - VertexBuffer.PositionKind
  24430. * - VertexBuffer.UVKind
  24431. * - VertexBuffer.UV2Kind
  24432. * - VertexBuffer.UV3Kind
  24433. * - VertexBuffer.UV4Kind
  24434. * - VertexBuffer.UV5Kind
  24435. * - VertexBuffer.UV6Kind
  24436. * - VertexBuffer.ColorKind
  24437. * - VertexBuffer.MatricesIndicesKind
  24438. * - VertexBuffer.MatricesIndicesExtraKind
  24439. * - VertexBuffer.MatricesWeightsKind
  24440. * - VertexBuffer.MatricesWeightsExtraKind
  24441. * @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
  24442. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24443. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24444. */
  24445. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24446. /**
  24447. * Returns the mesh VertexBuffer object from the requested `kind`
  24448. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24449. * - VertexBuffer.PositionKind
  24450. * - VertexBuffer.NormalKind
  24451. * - VertexBuffer.UVKind
  24452. * - VertexBuffer.UV2Kind
  24453. * - VertexBuffer.UV3Kind
  24454. * - VertexBuffer.UV4Kind
  24455. * - VertexBuffer.UV5Kind
  24456. * - VertexBuffer.UV6Kind
  24457. * - VertexBuffer.ColorKind
  24458. * - VertexBuffer.MatricesIndicesKind
  24459. * - VertexBuffer.MatricesIndicesExtraKind
  24460. * - VertexBuffer.MatricesWeightsKind
  24461. * - VertexBuffer.MatricesWeightsExtraKind
  24462. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24463. */
  24464. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24465. /**
  24466. * Tests if a specific vertex buffer is associated with this mesh
  24467. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24468. * - VertexBuffer.PositionKind
  24469. * - VertexBuffer.NormalKind
  24470. * - VertexBuffer.UVKind
  24471. * - VertexBuffer.UV2Kind
  24472. * - VertexBuffer.UV3Kind
  24473. * - VertexBuffer.UV4Kind
  24474. * - VertexBuffer.UV5Kind
  24475. * - VertexBuffer.UV6Kind
  24476. * - VertexBuffer.ColorKind
  24477. * - VertexBuffer.MatricesIndicesKind
  24478. * - VertexBuffer.MatricesIndicesExtraKind
  24479. * - VertexBuffer.MatricesWeightsKind
  24480. * - VertexBuffer.MatricesWeightsExtraKind
  24481. * @returns a boolean
  24482. */
  24483. isVerticesDataPresent(kind: string): boolean;
  24484. /**
  24485. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24486. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24487. * - VertexBuffer.PositionKind
  24488. * - VertexBuffer.UVKind
  24489. * - VertexBuffer.UV2Kind
  24490. * - VertexBuffer.UV3Kind
  24491. * - VertexBuffer.UV4Kind
  24492. * - VertexBuffer.UV5Kind
  24493. * - VertexBuffer.UV6Kind
  24494. * - VertexBuffer.ColorKind
  24495. * - VertexBuffer.MatricesIndicesKind
  24496. * - VertexBuffer.MatricesIndicesExtraKind
  24497. * - VertexBuffer.MatricesWeightsKind
  24498. * - VertexBuffer.MatricesWeightsExtraKind
  24499. * @returns a boolean
  24500. */
  24501. isVertexBufferUpdatable(kind: string): boolean;
  24502. /**
  24503. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24505. * - VertexBuffer.PositionKind
  24506. * - VertexBuffer.NormalKind
  24507. * - VertexBuffer.UVKind
  24508. * - VertexBuffer.UV2Kind
  24509. * - VertexBuffer.UV3Kind
  24510. * - VertexBuffer.UV4Kind
  24511. * - VertexBuffer.UV5Kind
  24512. * - VertexBuffer.UV6Kind
  24513. * - VertexBuffer.ColorKind
  24514. * - VertexBuffer.MatricesIndicesKind
  24515. * - VertexBuffer.MatricesIndicesExtraKind
  24516. * - VertexBuffer.MatricesWeightsKind
  24517. * - VertexBuffer.MatricesWeightsExtraKind
  24518. * @returns an array of strings
  24519. */
  24520. getVerticesDataKinds(): string[];
  24521. /**
  24522. * Returns a positive integer : the total number of indices in this mesh geometry.
  24523. * @returns the numner of indices or zero if the mesh has no geometry.
  24524. */
  24525. getTotalIndices(): number;
  24526. /**
  24527. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24528. * @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.
  24529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24530. * @returns the indices array or an empty array if the mesh has no geometry
  24531. */
  24532. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24533. readonly isBlocked: boolean;
  24534. /**
  24535. * Determine if the current mesh is ready to be rendered
  24536. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24537. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24538. * @returns true if all associated assets are ready (material, textures, shaders)
  24539. */
  24540. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24541. /**
  24542. * 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.
  24543. */
  24544. readonly areNormalsFrozen: boolean;
  24545. /**
  24546. * 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.
  24547. * @returns the current mesh
  24548. */
  24549. freezeNormals(): Mesh;
  24550. /**
  24551. * 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
  24552. * @returns the current mesh
  24553. */
  24554. unfreezeNormals(): Mesh;
  24555. /**
  24556. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24557. */
  24558. overridenInstanceCount: number;
  24559. /** @hidden */
  24560. _preActivate(): Mesh;
  24561. /** @hidden */
  24562. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24563. /** @hidden */
  24564. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24565. /**
  24566. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24567. * This means the mesh underlying bounding box and sphere are recomputed.
  24568. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24569. * @returns the current mesh
  24570. */
  24571. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24572. /** @hidden */
  24573. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24574. /**
  24575. * This function will subdivide the mesh into multiple submeshes
  24576. * @param count defines the expected number of submeshes
  24577. */
  24578. subdivide(count: number): void;
  24579. /**
  24580. * Copy a FloatArray into a specific associated vertex buffer
  24581. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24582. * - VertexBuffer.PositionKind
  24583. * - VertexBuffer.UVKind
  24584. * - VertexBuffer.UV2Kind
  24585. * - VertexBuffer.UV3Kind
  24586. * - VertexBuffer.UV4Kind
  24587. * - VertexBuffer.UV5Kind
  24588. * - VertexBuffer.UV6Kind
  24589. * - VertexBuffer.ColorKind
  24590. * - VertexBuffer.MatricesIndicesKind
  24591. * - VertexBuffer.MatricesIndicesExtraKind
  24592. * - VertexBuffer.MatricesWeightsKind
  24593. * - VertexBuffer.MatricesWeightsExtraKind
  24594. * @param data defines the data source
  24595. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24596. * @param stride defines the data stride size (can be null)
  24597. * @returns the current mesh
  24598. */
  24599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24600. /**
  24601. * Flags an associated vertex buffer as updatable
  24602. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24603. * - VertexBuffer.PositionKind
  24604. * - VertexBuffer.UVKind
  24605. * - VertexBuffer.UV2Kind
  24606. * - VertexBuffer.UV3Kind
  24607. * - VertexBuffer.UV4Kind
  24608. * - VertexBuffer.UV5Kind
  24609. * - VertexBuffer.UV6Kind
  24610. * - VertexBuffer.ColorKind
  24611. * - VertexBuffer.MatricesIndicesKind
  24612. * - VertexBuffer.MatricesIndicesExtraKind
  24613. * - VertexBuffer.MatricesWeightsKind
  24614. * - VertexBuffer.MatricesWeightsExtraKind
  24615. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24616. */
  24617. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24618. /**
  24619. * Sets the mesh global Vertex Buffer
  24620. * @param buffer defines the buffer to use
  24621. * @returns the current mesh
  24622. */
  24623. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24624. /**
  24625. * Update a specific associated vertex buffer
  24626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24627. * - VertexBuffer.PositionKind
  24628. * - VertexBuffer.UVKind
  24629. * - VertexBuffer.UV2Kind
  24630. * - VertexBuffer.UV3Kind
  24631. * - VertexBuffer.UV4Kind
  24632. * - VertexBuffer.UV5Kind
  24633. * - VertexBuffer.UV6Kind
  24634. * - VertexBuffer.ColorKind
  24635. * - VertexBuffer.MatricesIndicesKind
  24636. * - VertexBuffer.MatricesIndicesExtraKind
  24637. * - VertexBuffer.MatricesWeightsKind
  24638. * - VertexBuffer.MatricesWeightsExtraKind
  24639. * @param data defines the data source
  24640. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24641. * @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)
  24642. * @returns the current mesh
  24643. */
  24644. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24645. /**
  24646. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24647. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24648. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24649. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24650. * @returns the current mesh
  24651. */
  24652. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24653. /**
  24654. * Creates a un-shared specific occurence of the geometry for the mesh.
  24655. * @returns the current mesh
  24656. */
  24657. makeGeometryUnique(): Mesh;
  24658. /**
  24659. * Set the index buffer of this mesh
  24660. * @param indices defines the source data
  24661. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24662. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24663. * @returns the current mesh
  24664. */
  24665. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24666. /**
  24667. * Update the current index buffer
  24668. * @param indices defines the source data
  24669. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24670. * @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)
  24671. * @returns the current mesh
  24672. */
  24673. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24674. /**
  24675. * Invert the geometry to move from a right handed system to a left handed one.
  24676. * @returns the current mesh
  24677. */
  24678. toLeftHanded(): Mesh;
  24679. /** @hidden */
  24680. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24681. /** @hidden */
  24682. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24683. /**
  24684. * Registers for this mesh a javascript function called just before the rendering process
  24685. * @param func defines the function to call before rendering this mesh
  24686. * @returns the current mesh
  24687. */
  24688. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24689. /**
  24690. * Disposes a previously registered javascript function called before the rendering
  24691. * @param func defines the function to remove
  24692. * @returns the current mesh
  24693. */
  24694. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24695. /**
  24696. * Registers for this mesh a javascript function called just after the rendering is complete
  24697. * @param func defines the function to call after rendering this mesh
  24698. * @returns the current mesh
  24699. */
  24700. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24701. /**
  24702. * Disposes a previously registered javascript function called after the rendering.
  24703. * @param func defines the function to remove
  24704. * @returns the current mesh
  24705. */
  24706. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24707. /** @hidden */
  24708. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24709. /** @hidden */
  24710. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24711. /** @hidden */
  24712. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24713. /** @hidden */
  24714. _rebuild(): void;
  24715. /** @hidden */
  24716. _freeze(): void;
  24717. /** @hidden */
  24718. _unFreeze(): void;
  24719. /**
  24720. * 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
  24721. * @param subMesh defines the subMesh to render
  24722. * @param enableAlphaMode defines if alpha mode can be changed
  24723. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24724. * @returns the current mesh
  24725. */
  24726. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24727. private _onBeforeDraw;
  24728. /**
  24729. * Renormalize the mesh and patch it up if there are no weights
  24730. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24731. * However in the case of zero weights then we set just a single influence to 1.
  24732. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24733. */
  24734. cleanMatrixWeights(): void;
  24735. private normalizeSkinFourWeights;
  24736. private normalizeSkinWeightsAndExtra;
  24737. /**
  24738. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24739. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24740. * the user know there was an issue with importing the mesh
  24741. * @returns a validation object with skinned, valid and report string
  24742. */
  24743. validateSkinning(): {
  24744. skinned: boolean;
  24745. valid: boolean;
  24746. report: string;
  24747. };
  24748. /** @hidden */
  24749. _checkDelayState(): Mesh;
  24750. private _queueLoad;
  24751. /**
  24752. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24753. * A mesh is in the frustum if its bounding box intersects the frustum
  24754. * @param frustumPlanes defines the frustum to test
  24755. * @returns true if the mesh is in the frustum planes
  24756. */
  24757. isInFrustum(frustumPlanes: Plane[]): boolean;
  24758. /**
  24759. * Sets the mesh material by the material or multiMaterial `id` property
  24760. * @param id is a string identifying the material or the multiMaterial
  24761. * @returns the current mesh
  24762. */
  24763. setMaterialByID(id: string): Mesh;
  24764. /**
  24765. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24766. * @returns an array of IAnimatable
  24767. */
  24768. getAnimatables(): IAnimatable[];
  24769. /**
  24770. * Modifies the mesh geometry according to the passed transformation matrix.
  24771. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24772. * The mesh normals are modified using the same transformation.
  24773. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24774. * @param transform defines the transform matrix to use
  24775. * @see http://doc.babylonjs.com/resources/baking_transformations
  24776. * @returns the current mesh
  24777. */
  24778. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24779. /**
  24780. * Modifies the mesh geometry according to its own current World Matrix.
  24781. * The mesh World Matrix is then reset.
  24782. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24783. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24784. * @see http://doc.babylonjs.com/resources/baking_transformations
  24785. * @returns the current mesh
  24786. */
  24787. bakeCurrentTransformIntoVertices(): Mesh;
  24788. /** @hidden */
  24789. readonly _positions: Nullable<Vector3[]>;
  24790. /** @hidden */
  24791. _resetPointsArrayCache(): Mesh;
  24792. /** @hidden */
  24793. _generatePointsArray(): boolean;
  24794. /**
  24795. * Returns a new Mesh object generated from the current mesh properties.
  24796. * This method must not get confused with createInstance()
  24797. * @param name is a string, the name given to the new mesh
  24798. * @param newParent can be any Node object (default `null`)
  24799. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24800. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24801. * @returns a new mesh
  24802. */
  24803. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24804. /**
  24805. * Releases resources associated with this mesh.
  24806. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24807. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24808. */
  24809. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24810. /**
  24811. * Modifies the mesh geometry according to a displacement map.
  24812. * 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.
  24813. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24814. * @param url is a string, the URL from the image file is to be downloaded.
  24815. * @param minHeight is the lower limit of the displacement.
  24816. * @param maxHeight is the upper limit of the displacement.
  24817. * @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.
  24818. * @param uvOffset is an optional vector2 used to offset UV.
  24819. * @param uvScale is an optional vector2 used to scale UV.
  24820. * @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.
  24821. * @returns the Mesh.
  24822. */
  24823. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24824. /**
  24825. * Modifies the mesh geometry according to a displacementMap buffer.
  24826. * 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.
  24827. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24828. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24829. * @param heightMapWidth is the width of the buffer image.
  24830. * @param heightMapHeight is the height of the buffer image.
  24831. * @param minHeight is the lower limit of the displacement.
  24832. * @param maxHeight is the upper limit of the displacement.
  24833. * @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.
  24834. * @param uvOffset is an optional vector2 used to offset UV.
  24835. * @param uvScale is an optional vector2 used to scale UV.
  24836. * @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.
  24837. * @returns the Mesh.
  24838. */
  24839. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24840. /**
  24841. * Modify the mesh to get a flat shading rendering.
  24842. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24843. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24844. * @returns current mesh
  24845. */
  24846. convertToFlatShadedMesh(): Mesh;
  24847. /**
  24848. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24849. * In other words, more vertices, no more indices and a single bigger VBO.
  24850. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24851. * @returns current mesh
  24852. */
  24853. convertToUnIndexedMesh(): Mesh;
  24854. /**
  24855. * Inverses facet orientations.
  24856. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24857. * @param flipNormals will also inverts the normals
  24858. * @returns current mesh
  24859. */
  24860. flipFaces(flipNormals?: boolean): Mesh;
  24861. /**
  24862. * Increase the number of facets and hence vertices in a mesh
  24863. * Vertex normals are interpolated from existing vertex normals
  24864. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24865. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24866. */
  24867. increaseVertices(numberPerEdge: number): void;
  24868. /**
  24869. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24870. * This will undo any application of covertToFlatShadedMesh
  24871. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24872. */
  24873. forceSharedVertices(): void;
  24874. /** @hidden */
  24875. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24876. /** @hidden */
  24877. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24878. /**
  24879. * Creates a new InstancedMesh object from the mesh model.
  24880. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24881. * @param name defines the name of the new instance
  24882. * @returns a new InstancedMesh
  24883. */
  24884. createInstance(name: string): InstancedMesh;
  24885. /**
  24886. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24887. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24888. * @returns the current mesh
  24889. */
  24890. synchronizeInstances(): Mesh;
  24891. /**
  24892. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24893. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24894. * This should be used together with the simplification to avoid disappearing triangles.
  24895. * @param successCallback an optional success callback to be called after the optimization finished.
  24896. * @returns the current mesh
  24897. */
  24898. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24899. /**
  24900. * Serialize current mesh
  24901. * @param serializationObject defines the object which will receive the serialization data
  24902. */
  24903. serialize(serializationObject: any): void;
  24904. /** @hidden */
  24905. _syncGeometryWithMorphTargetManager(): void;
  24906. /** @hidden */
  24907. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24908. /**
  24909. * Returns a new Mesh object parsed from the source provided.
  24910. * @param parsedMesh is the source
  24911. * @param scene defines the hosting scene
  24912. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24913. * @returns a new Mesh
  24914. */
  24915. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24916. /**
  24917. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24918. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24919. * @param name defines the name of the mesh to create
  24920. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24921. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24922. * @param closePath creates a seam between the first and the last points of each path of the path array
  24923. * @param offset is taken in account only if the `pathArray` is containing a single path
  24924. * @param scene defines the hosting scene
  24925. * @param updatable defines if the mesh must be flagged as updatable
  24926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24927. * @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)
  24928. * @returns a new Mesh
  24929. */
  24930. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24931. /**
  24932. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24933. * @param name defines the name of the mesh to create
  24934. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24935. * @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
  24936. * @param scene defines the hosting scene
  24937. * @param updatable defines if the mesh must be flagged as updatable
  24938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24939. * @returns a new Mesh
  24940. */
  24941. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24942. /**
  24943. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24944. * @param name defines the name of the mesh to create
  24945. * @param size sets the size (float) of each box side (default 1)
  24946. * @param scene defines the hosting scene
  24947. * @param updatable defines if the mesh must be flagged as updatable
  24948. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24949. * @returns a new Mesh
  24950. */
  24951. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24952. /**
  24953. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24954. * @param name defines the name of the mesh to create
  24955. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24956. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24963. /**
  24964. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24967. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24968. * @param scene defines the hosting scene
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24972. /**
  24973. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24974. * @param name defines the name of the mesh to create
  24975. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24976. * @param diameterTop set the top cap diameter (floats, default 1)
  24977. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24978. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24979. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24980. * @param scene defines the hosting scene
  24981. * @param updatable defines if the mesh must be flagged as updatable
  24982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24983. * @returns a new Mesh
  24984. */
  24985. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24986. /**
  24987. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24988. * @param name defines the name of the mesh to create
  24989. * @param diameter sets the diameter size (float) of the torus (default 1)
  24990. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24991. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24992. * @param scene defines the hosting scene
  24993. * @param updatable defines if the mesh must be flagged as updatable
  24994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24995. * @returns a new Mesh
  24996. */
  24997. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24998. /**
  24999. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25000. * @param name defines the name of the mesh to create
  25001. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25002. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25003. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25004. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25005. * @param p the number of windings on X axis (positive integers, default 2)
  25006. * @param q the number of windings on Y axis (positive integers, default 3)
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25010. * @returns a new Mesh
  25011. */
  25012. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25013. /**
  25014. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25015. * @param name defines the name of the mesh to create
  25016. * @param points is an array successive Vector3
  25017. * @param scene defines the hosting scene
  25018. * @param updatable defines if the mesh must be flagged as updatable
  25019. * @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).
  25020. * @returns a new Mesh
  25021. */
  25022. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25023. /**
  25024. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25025. * @param name defines the name of the mesh to create
  25026. * @param points is an array successive Vector3
  25027. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25028. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25029. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25030. * @param scene defines the hosting scene
  25031. * @param updatable defines if the mesh must be flagged as updatable
  25032. * @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)
  25033. * @returns a new Mesh
  25034. */
  25035. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25036. /**
  25037. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25038. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25039. * 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.
  25040. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25041. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25042. * Remember you can only change the shape positions, not their number when updating a polygon.
  25043. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25044. * @param name defines the name of the mesh to create
  25045. * @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
  25046. * @param scene defines the hosting scene
  25047. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25050. * @param earcutInjection can be used to inject your own earcut reference
  25051. * @returns a new Mesh
  25052. */
  25053. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25054. /**
  25055. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25056. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25057. * @param name defines the name of the mesh to create
  25058. * @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
  25059. * @param depth defines the height of extrusion
  25060. * @param scene defines the hosting scene
  25061. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @param earcutInjection can be used to inject your own earcut reference
  25065. * @returns a new Mesh
  25066. */
  25067. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25068. /**
  25069. * Creates an extruded shape mesh.
  25070. * 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
  25071. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25072. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25073. * @param name defines the name of the mesh to create
  25074. * @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
  25075. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25076. * @param scale is the value to scale the shape
  25077. * @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
  25078. * @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
  25079. * @param scene defines the hosting scene
  25080. * @param updatable defines if the mesh must be flagged as updatable
  25081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25082. * @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)
  25083. * @returns a new Mesh
  25084. */
  25085. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25086. /**
  25087. * Creates an custom extruded shape mesh.
  25088. * The custom extrusion is a parametric shape.
  25089. * It has no predefined shape. Its final shape will depend on the input parameters.
  25090. * Please consider using the same method from the MeshBuilder class instead
  25091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25092. * @param name defines the name of the mesh to create
  25093. * @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
  25094. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25095. * @param scaleFunction is a custom Javascript function called on each path point
  25096. * @param rotationFunction is a custom Javascript function called on each path point
  25097. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25098. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25099. * @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
  25100. * @param scene defines the hosting scene
  25101. * @param updatable defines if the mesh must be flagged as updatable
  25102. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25103. * @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)
  25104. * @returns a new Mesh
  25105. */
  25106. 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;
  25107. /**
  25108. * Creates lathe mesh.
  25109. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  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 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
  25113. * @param radius is the radius value of the lathe
  25114. * @param tessellation is the side number of the lathe.
  25115. * @param scene defines the hosting scene
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25121. /**
  25122. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25123. * @param name defines the name of the mesh to create
  25124. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25125. * @param scene defines the hosting scene
  25126. * @param updatable defines if the mesh must be flagged as updatable
  25127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25128. * @returns a new Mesh
  25129. */
  25130. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25131. /**
  25132. * Creates a ground mesh.
  25133. * Please consider using the same method from the MeshBuilder class instead
  25134. * @param name defines the name of the mesh to create
  25135. * @param width set the width of the ground
  25136. * @param height set the height of the ground
  25137. * @param subdivisions sets the number of subdivisions per side
  25138. * @param scene defines the hosting scene
  25139. * @param updatable defines if the mesh must be flagged as updatable
  25140. * @returns a new Mesh
  25141. */
  25142. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25143. /**
  25144. * Creates a tiled ground mesh.
  25145. * Please consider using the same method from the MeshBuilder class instead
  25146. * @param name defines the name of the mesh to create
  25147. * @param xmin set the ground minimum X coordinate
  25148. * @param zmin set the ground minimum Y coordinate
  25149. * @param xmax set the ground maximum X coordinate
  25150. * @param zmax set the ground maximum Z coordinate
  25151. * @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
  25152. * @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
  25153. * @param scene defines the hosting scene
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @returns a new Mesh
  25156. */
  25157. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25158. w: number;
  25159. h: number;
  25160. }, precision: {
  25161. w: number;
  25162. h: number;
  25163. }, scene: Scene, updatable?: boolean): Mesh;
  25164. /**
  25165. * Creates a ground mesh from a height map.
  25166. * Please consider using the same method from the MeshBuilder class instead
  25167. * @see http://doc.babylonjs.com/babylon101/height_map
  25168. * @param name defines the name of the mesh to create
  25169. * @param url sets the URL of the height map image resource
  25170. * @param width set the ground width size
  25171. * @param height set the ground height size
  25172. * @param subdivisions sets the number of subdivision per side
  25173. * @param minHeight is the minimum altitude on the ground
  25174. * @param maxHeight is the maximum altitude on the ground
  25175. * @param scene defines the hosting scene
  25176. * @param updatable defines if the mesh must be flagged as updatable
  25177. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25178. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25179. * @returns a new Mesh
  25180. */
  25181. 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;
  25182. /**
  25183. * Creates a tube mesh.
  25184. * The tube is a parametric shape.
  25185. * It has no predefined shape. Its final shape will depend on the input parameters.
  25186. * Please consider using the same method from the MeshBuilder class instead
  25187. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25188. * @param name defines the name of the mesh to create
  25189. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25190. * @param radius sets the tube radius size
  25191. * @param tessellation is the number of sides on the tubular surface
  25192. * @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
  25193. * @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
  25194. * @param scene defines the hosting scene
  25195. * @param updatable defines if the mesh must be flagged as updatable
  25196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25197. * @param 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)
  25198. * @returns a new Mesh
  25199. */
  25200. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25201. (i: number, distance: number): number;
  25202. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25203. /**
  25204. * Creates a polyhedron mesh.
  25205. * Please consider using the same method from the MeshBuilder class instead.
  25206. * * 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
  25207. * * The parameter `size` (positive float, default 1) sets the polygon size
  25208. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25209. * * 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`
  25210. * * 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
  25211. * * 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)`)
  25212. * * 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
  25213. * * 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
  25214. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25215. * * If you create a double-sided mesh, you can choose what parts of 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
  25216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25217. * @param name defines the name of the mesh to create
  25218. * @param options defines the options used to create the mesh
  25219. * @param scene defines the hosting scene
  25220. * @returns a new Mesh
  25221. */
  25222. static CreatePolyhedron(name: string, options: {
  25223. type?: number;
  25224. size?: number;
  25225. sizeX?: number;
  25226. sizeY?: number;
  25227. sizeZ?: number;
  25228. custom?: any;
  25229. faceUV?: Vector4[];
  25230. faceColors?: Color4[];
  25231. updatable?: boolean;
  25232. sideOrientation?: number;
  25233. }, scene: Scene): Mesh;
  25234. /**
  25235. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25236. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25237. * * 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`)
  25238. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25239. * * 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
  25240. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25241. * * If you create a double-sided mesh, you can choose what parts of 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
  25242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25243. * @param name defines the name of the mesh
  25244. * @param options defines the options used to create the mesh
  25245. * @param scene defines the hosting scene
  25246. * @returns a new Mesh
  25247. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25248. */
  25249. static CreateIcoSphere(name: string, options: {
  25250. radius?: number;
  25251. flat?: boolean;
  25252. subdivisions?: number;
  25253. sideOrientation?: number;
  25254. updatable?: boolean;
  25255. }, scene: Scene): Mesh;
  25256. /**
  25257. * Creates a decal mesh.
  25258. * Please consider using the same method from the MeshBuilder class instead.
  25259. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25260. * @param name defines the name of the mesh
  25261. * @param sourceMesh defines the mesh receiving the decal
  25262. * @param position sets the position of the decal in world coordinates
  25263. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25264. * @param size sets the decal scaling
  25265. * @param angle sets the angle to rotate the decal
  25266. * @returns a new Mesh
  25267. */
  25268. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25269. /**
  25270. * Prepare internal position array for software CPU skinning
  25271. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25272. */
  25273. setPositionsForCPUSkinning(): Float32Array;
  25274. /**
  25275. * Prepare internal normal array for software CPU skinning
  25276. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25277. */
  25278. setNormalsForCPUSkinning(): Float32Array;
  25279. /**
  25280. * Updates the vertex buffer by applying transformation from the bones
  25281. * @param skeleton defines the skeleton to apply to current mesh
  25282. * @returns the current mesh
  25283. */
  25284. applySkeleton(skeleton: Skeleton): Mesh;
  25285. /**
  25286. * 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
  25287. * @param meshes defines the list of meshes to scan
  25288. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25289. */
  25290. static MinMax(meshes: AbstractMesh[]): {
  25291. min: Vector3;
  25292. max: Vector3;
  25293. };
  25294. /**
  25295. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25296. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25297. * @returns a vector3
  25298. */
  25299. static Center(meshesOrMinMaxVector: {
  25300. min: Vector3;
  25301. max: Vector3;
  25302. } | AbstractMesh[]): Vector3;
  25303. /**
  25304. * Merge the array of meshes into a single mesh for performance reasons.
  25305. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25306. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25307. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25308. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25309. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25310. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25311. * @returns a new mesh
  25312. */
  25313. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25314. /** @hidden */
  25315. addInstance(instance: InstancedMesh): void;
  25316. /** @hidden */
  25317. removeInstance(instance: InstancedMesh): void;
  25318. }
  25319. }
  25320. declare module "babylonjs/Cameras/camera" {
  25321. import { SmartArray } from "babylonjs/Misc/smartArray";
  25322. import { Observable } from "babylonjs/Misc/observable";
  25323. import { Nullable } from "babylonjs/types";
  25324. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25325. import { Scene } from "babylonjs/scene";
  25326. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25327. import { Node } from "babylonjs/node";
  25328. import { Mesh } from "babylonjs/Meshes/mesh";
  25329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25330. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25331. import { Viewport } from "babylonjs/Maths/math.viewport";
  25332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25335. import { Ray } from "babylonjs/Culling/ray";
  25336. /**
  25337. * This is the base class of all the camera used in the application.
  25338. * @see http://doc.babylonjs.com/features/cameras
  25339. */
  25340. export class Camera extends Node {
  25341. /** @hidden */
  25342. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25343. /**
  25344. * This is the default projection mode used by the cameras.
  25345. * It helps recreating a feeling of perspective and better appreciate depth.
  25346. * This is the best way to simulate real life cameras.
  25347. */
  25348. static readonly PERSPECTIVE_CAMERA: number;
  25349. /**
  25350. * This helps creating camera with an orthographic mode.
  25351. * 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.
  25352. */
  25353. static readonly ORTHOGRAPHIC_CAMERA: number;
  25354. /**
  25355. * This is the default FOV mode for perspective cameras.
  25356. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25357. */
  25358. static readonly FOVMODE_VERTICAL_FIXED: number;
  25359. /**
  25360. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25361. */
  25362. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25363. /**
  25364. * This specifies ther is no need for a camera rig.
  25365. * Basically only one eye is rendered corresponding to the camera.
  25366. */
  25367. static readonly RIG_MODE_NONE: number;
  25368. /**
  25369. * Simulates a camera Rig with one blue eye and one red eye.
  25370. * This can be use with 3d blue and red glasses.
  25371. */
  25372. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25373. /**
  25374. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25375. */
  25376. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25377. /**
  25378. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25379. */
  25380. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25381. /**
  25382. * Defines that both eyes of the camera will be rendered over under each other.
  25383. */
  25384. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25385. /**
  25386. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25387. */
  25388. static readonly RIG_MODE_VR: number;
  25389. /**
  25390. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25391. */
  25392. static readonly RIG_MODE_WEBVR: number;
  25393. /**
  25394. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25395. */
  25396. static readonly RIG_MODE_CUSTOM: number;
  25397. /**
  25398. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25399. */
  25400. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25401. /**
  25402. * Define the input manager associated with the camera.
  25403. */
  25404. inputs: CameraInputsManager<Camera>;
  25405. /** @hidden */
  25406. _position: Vector3;
  25407. /**
  25408. * Define the current local position of the camera in the scene
  25409. */
  25410. position: Vector3;
  25411. /**
  25412. * The vector the camera should consider as up.
  25413. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25414. */
  25415. upVector: Vector3;
  25416. /**
  25417. * Define the current limit on the left side for an orthographic camera
  25418. * In scene unit
  25419. */
  25420. orthoLeft: Nullable<number>;
  25421. /**
  25422. * Define the current limit on the right side for an orthographic camera
  25423. * In scene unit
  25424. */
  25425. orthoRight: Nullable<number>;
  25426. /**
  25427. * Define the current limit on the bottom side for an orthographic camera
  25428. * In scene unit
  25429. */
  25430. orthoBottom: Nullable<number>;
  25431. /**
  25432. * Define the current limit on the top side for an orthographic camera
  25433. * In scene unit
  25434. */
  25435. orthoTop: Nullable<number>;
  25436. /**
  25437. * Field Of View is set in Radians. (default is 0.8)
  25438. */
  25439. fov: number;
  25440. /**
  25441. * Define the minimum distance the camera can see from.
  25442. * This is important to note that the depth buffer are not infinite and the closer it starts
  25443. * the more your scene might encounter depth fighting issue.
  25444. */
  25445. minZ: number;
  25446. /**
  25447. * Define the maximum distance the camera can see to.
  25448. * This is important to note that the depth buffer are not infinite and the further it end
  25449. * the more your scene might encounter depth fighting issue.
  25450. */
  25451. maxZ: number;
  25452. /**
  25453. * Define the default inertia of the camera.
  25454. * This helps giving a smooth feeling to the camera movement.
  25455. */
  25456. inertia: number;
  25457. /**
  25458. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25459. */
  25460. mode: number;
  25461. /**
  25462. * Define wether the camera is intermediate.
  25463. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25464. */
  25465. isIntermediate: boolean;
  25466. /**
  25467. * Define the viewport of the camera.
  25468. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25469. */
  25470. viewport: Viewport;
  25471. /**
  25472. * Restricts the camera to viewing objects with the same layerMask.
  25473. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25474. */
  25475. layerMask: number;
  25476. /**
  25477. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25478. */
  25479. fovMode: number;
  25480. /**
  25481. * Rig mode of the camera.
  25482. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25483. * This is normally controlled byt the camera themselves as internal use.
  25484. */
  25485. cameraRigMode: number;
  25486. /**
  25487. * Defines the distance between both "eyes" in case of a RIG
  25488. */
  25489. interaxialDistance: number;
  25490. /**
  25491. * Defines if stereoscopic rendering is done side by side or over under.
  25492. */
  25493. isStereoscopicSideBySide: boolean;
  25494. /**
  25495. * 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
  25496. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25497. * else in the scene. (Eg. security camera)
  25498. *
  25499. * 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)
  25500. */
  25501. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25502. /**
  25503. * When set, the camera will render to this render target instead of the default canvas
  25504. *
  25505. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25506. */
  25507. outputRenderTarget: Nullable<RenderTargetTexture>;
  25508. /**
  25509. * Observable triggered when the camera view matrix has changed.
  25510. */
  25511. onViewMatrixChangedObservable: Observable<Camera>;
  25512. /**
  25513. * Observable triggered when the camera Projection matrix has changed.
  25514. */
  25515. onProjectionMatrixChangedObservable: Observable<Camera>;
  25516. /**
  25517. * Observable triggered when the inputs have been processed.
  25518. */
  25519. onAfterCheckInputsObservable: Observable<Camera>;
  25520. /**
  25521. * Observable triggered when reset has been called and applied to the camera.
  25522. */
  25523. onRestoreStateObservable: Observable<Camera>;
  25524. /** @hidden */
  25525. _cameraRigParams: any;
  25526. /** @hidden */
  25527. _rigCameras: Camera[];
  25528. /** @hidden */
  25529. _rigPostProcess: Nullable<PostProcess>;
  25530. protected _webvrViewMatrix: Matrix;
  25531. /** @hidden */
  25532. _skipRendering: boolean;
  25533. /** @hidden */
  25534. _projectionMatrix: Matrix;
  25535. /** @hidden */
  25536. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25537. /** @hidden */
  25538. _activeMeshes: SmartArray<AbstractMesh>;
  25539. protected _globalPosition: Vector3;
  25540. /** @hidden */
  25541. _computedViewMatrix: Matrix;
  25542. private _doNotComputeProjectionMatrix;
  25543. private _transformMatrix;
  25544. private _frustumPlanes;
  25545. private _refreshFrustumPlanes;
  25546. private _storedFov;
  25547. private _stateStored;
  25548. /**
  25549. * Instantiates a new camera object.
  25550. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25551. * @see http://doc.babylonjs.com/features/cameras
  25552. * @param name Defines the name of the camera in the scene
  25553. * @param position Defines the position of the camera
  25554. * @param scene Defines the scene the camera belongs too
  25555. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25556. */
  25557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25558. /**
  25559. * Store current camera state (fov, position, etc..)
  25560. * @returns the camera
  25561. */
  25562. storeState(): Camera;
  25563. /**
  25564. * Restores the camera state values if it has been stored. You must call storeState() first
  25565. */
  25566. protected _restoreStateValues(): boolean;
  25567. /**
  25568. * Restored camera state. You must call storeState() first.
  25569. * @returns true if restored and false otherwise
  25570. */
  25571. restoreState(): boolean;
  25572. /**
  25573. * Gets the class name of the camera.
  25574. * @returns the class name
  25575. */
  25576. getClassName(): string;
  25577. /** @hidden */
  25578. readonly _isCamera: boolean;
  25579. /**
  25580. * Gets a string representation of the camera useful for debug purpose.
  25581. * @param fullDetails Defines that a more verboe level of logging is required
  25582. * @returns the string representation
  25583. */
  25584. toString(fullDetails?: boolean): string;
  25585. /**
  25586. * Gets the current world space position of the camera.
  25587. */
  25588. readonly globalPosition: Vector3;
  25589. /**
  25590. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25591. * @returns the active meshe list
  25592. */
  25593. getActiveMeshes(): SmartArray<AbstractMesh>;
  25594. /**
  25595. * Check wether a mesh is part of the current active mesh list of the camera
  25596. * @param mesh Defines the mesh to check
  25597. * @returns true if active, false otherwise
  25598. */
  25599. isActiveMesh(mesh: Mesh): boolean;
  25600. /**
  25601. * Is this camera ready to be used/rendered
  25602. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25603. * @return true if the camera is ready
  25604. */
  25605. isReady(completeCheck?: boolean): boolean;
  25606. /** @hidden */
  25607. _initCache(): void;
  25608. /** @hidden */
  25609. _updateCache(ignoreParentClass?: boolean): void;
  25610. /** @hidden */
  25611. _isSynchronized(): boolean;
  25612. /** @hidden */
  25613. _isSynchronizedViewMatrix(): boolean;
  25614. /** @hidden */
  25615. _isSynchronizedProjectionMatrix(): boolean;
  25616. /**
  25617. * Attach the input controls to a specific dom element to get the input from.
  25618. * @param element Defines the element the controls should be listened from
  25619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25620. */
  25621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25622. /**
  25623. * Detach the current controls from the specified dom element.
  25624. * @param element Defines the element to stop listening the inputs from
  25625. */
  25626. detachControl(element: HTMLElement): void;
  25627. /**
  25628. * Update the camera state according to the different inputs gathered during the frame.
  25629. */
  25630. update(): void;
  25631. /** @hidden */
  25632. _checkInputs(): void;
  25633. /** @hidden */
  25634. readonly rigCameras: Camera[];
  25635. /**
  25636. * Gets the post process used by the rig cameras
  25637. */
  25638. readonly rigPostProcess: Nullable<PostProcess>;
  25639. /**
  25640. * Internal, gets the first post proces.
  25641. * @returns the first post process to be run on this camera.
  25642. */
  25643. _getFirstPostProcess(): Nullable<PostProcess>;
  25644. private _cascadePostProcessesToRigCams;
  25645. /**
  25646. * Attach a post process to the camera.
  25647. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25648. * @param postProcess The post process to attach to the camera
  25649. * @param insertAt The position of the post process in case several of them are in use in the scene
  25650. * @returns the position the post process has been inserted at
  25651. */
  25652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25653. /**
  25654. * Detach a post process to the camera.
  25655. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25656. * @param postProcess The post process to detach from the camera
  25657. */
  25658. detachPostProcess(postProcess: PostProcess): void;
  25659. /**
  25660. * Gets the current world matrix of the camera
  25661. */
  25662. getWorldMatrix(): Matrix;
  25663. /** @hidden */
  25664. _getViewMatrix(): Matrix;
  25665. /**
  25666. * Gets the current view matrix of the camera.
  25667. * @param force forces the camera to recompute the matrix without looking at the cached state
  25668. * @returns the view matrix
  25669. */
  25670. getViewMatrix(force?: boolean): Matrix;
  25671. /**
  25672. * Freeze the projection matrix.
  25673. * It will prevent the cache check of the camera projection compute and can speed up perf
  25674. * if no parameter of the camera are meant to change
  25675. * @param projection Defines manually a projection if necessary
  25676. */
  25677. freezeProjectionMatrix(projection?: Matrix): void;
  25678. /**
  25679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25680. */
  25681. unfreezeProjectionMatrix(): void;
  25682. /**
  25683. * Gets the current projection matrix of the camera.
  25684. * @param force forces the camera to recompute the matrix without looking at the cached state
  25685. * @returns the projection matrix
  25686. */
  25687. getProjectionMatrix(force?: boolean): Matrix;
  25688. /**
  25689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25690. * @returns a Matrix
  25691. */
  25692. getTransformationMatrix(): Matrix;
  25693. private _updateFrustumPlanes;
  25694. /**
  25695. * Checks if a cullable object (mesh...) is in the camera frustum
  25696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25697. * @param target The object to check
  25698. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25699. * @returns true if the object is in frustum otherwise false
  25700. */
  25701. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25702. /**
  25703. * Checks if a cullable object (mesh...) is in the camera frustum
  25704. * Unlike isInFrustum this cheks the full bounding box
  25705. * @param target The object to check
  25706. * @returns true if the object is in frustum otherwise false
  25707. */
  25708. isCompletelyInFrustum(target: ICullable): boolean;
  25709. /**
  25710. * Gets a ray in the forward direction from the camera.
  25711. * @param length Defines the length of the ray to create
  25712. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25713. * @param origin Defines the start point of the ray which defaults to the camera position
  25714. * @returns the forward ray
  25715. */
  25716. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25717. /**
  25718. * Releases resources associated with this node.
  25719. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25720. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25721. */
  25722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25723. /** @hidden */
  25724. _isLeftCamera: boolean;
  25725. /**
  25726. * Gets the left camera of a rig setup in case of Rigged Camera
  25727. */
  25728. readonly isLeftCamera: boolean;
  25729. /** @hidden */
  25730. _isRightCamera: boolean;
  25731. /**
  25732. * Gets the right camera of a rig setup in case of Rigged Camera
  25733. */
  25734. readonly isRightCamera: boolean;
  25735. /**
  25736. * Gets the left camera of a rig setup in case of Rigged Camera
  25737. */
  25738. readonly leftCamera: Nullable<FreeCamera>;
  25739. /**
  25740. * Gets the right camera of a rig setup in case of Rigged Camera
  25741. */
  25742. readonly rightCamera: Nullable<FreeCamera>;
  25743. /**
  25744. * Gets the left camera target of a rig setup in case of Rigged Camera
  25745. * @returns the target position
  25746. */
  25747. getLeftTarget(): Nullable<Vector3>;
  25748. /**
  25749. * Gets the right camera target of a rig setup in case of Rigged Camera
  25750. * @returns the target position
  25751. */
  25752. getRightTarget(): Nullable<Vector3>;
  25753. /**
  25754. * @hidden
  25755. */
  25756. setCameraRigMode(mode: number, rigParams: any): void;
  25757. /** @hidden */
  25758. static _setStereoscopicRigMode(camera: Camera): void;
  25759. /** @hidden */
  25760. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25761. /** @hidden */
  25762. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25763. /** @hidden */
  25764. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25765. /** @hidden */
  25766. _getVRProjectionMatrix(): Matrix;
  25767. protected _updateCameraRotationMatrix(): void;
  25768. protected _updateWebVRCameraRotationMatrix(): void;
  25769. /**
  25770. * This function MUST be overwritten by the different WebVR cameras available.
  25771. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25772. * @hidden
  25773. */
  25774. _getWebVRProjectionMatrix(): Matrix;
  25775. /**
  25776. * This function MUST be overwritten by the different WebVR cameras available.
  25777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25778. * @hidden
  25779. */
  25780. _getWebVRViewMatrix(): Matrix;
  25781. /** @hidden */
  25782. setCameraRigParameter(name: string, value: any): void;
  25783. /**
  25784. * needs to be overridden by children so sub has required properties to be copied
  25785. * @hidden
  25786. */
  25787. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25788. /**
  25789. * May need to be overridden by children
  25790. * @hidden
  25791. */
  25792. _updateRigCameras(): void;
  25793. /** @hidden */
  25794. _setupInputs(): void;
  25795. /**
  25796. * Serialiaze the camera setup to a json represention
  25797. * @returns the JSON representation
  25798. */
  25799. serialize(): any;
  25800. /**
  25801. * Clones the current camera.
  25802. * @param name The cloned camera name
  25803. * @returns the cloned camera
  25804. */
  25805. clone(name: string): Camera;
  25806. /**
  25807. * Gets the direction of the camera relative to a given local axis.
  25808. * @param localAxis Defines the reference axis to provide a relative direction.
  25809. * @return the direction
  25810. */
  25811. getDirection(localAxis: Vector3): Vector3;
  25812. /**
  25813. * Returns the current camera absolute rotation
  25814. */
  25815. readonly absoluteRotation: Quaternion;
  25816. /**
  25817. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25818. * @param localAxis Defines the reference axis to provide a relative direction.
  25819. * @param result Defines the vector to store the result in
  25820. */
  25821. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25822. /**
  25823. * Gets a camera constructor for a given camera type
  25824. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25825. * @param name The name of the camera the result will be able to instantiate
  25826. * @param scene The scene the result will construct the camera in
  25827. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25828. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25829. * @returns a factory method to construc the camera
  25830. */
  25831. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25832. /**
  25833. * Compute the world matrix of the camera.
  25834. * @returns the camera workd matrix
  25835. */
  25836. computeWorldMatrix(): Matrix;
  25837. /**
  25838. * Parse a JSON and creates the camera from the parsed information
  25839. * @param parsedCamera The JSON to parse
  25840. * @param scene The scene to instantiate the camera in
  25841. * @returns the newly constructed camera
  25842. */
  25843. static Parse(parsedCamera: any, scene: Scene): Camera;
  25844. }
  25845. }
  25846. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25847. import { Nullable } from "babylonjs/types";
  25848. import { Scene } from "babylonjs/scene";
  25849. import { Vector4 } from "babylonjs/Maths/math.vector";
  25850. import { Mesh } from "babylonjs/Meshes/mesh";
  25851. /**
  25852. * Class containing static functions to help procedurally build meshes
  25853. */
  25854. export class DiscBuilder {
  25855. /**
  25856. * Creates a plane polygonal mesh. By default, this is a disc
  25857. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25858. * * 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
  25859. * * 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
  25860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25863. * @param name defines the name of the mesh
  25864. * @param options defines the options used to create the mesh
  25865. * @param scene defines the hosting scene
  25866. * @returns the plane polygonal mesh
  25867. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25868. */
  25869. static CreateDisc(name: string, options: {
  25870. radius?: number;
  25871. tessellation?: number;
  25872. arc?: number;
  25873. updatable?: boolean;
  25874. sideOrientation?: number;
  25875. frontUVs?: Vector4;
  25876. backUVs?: Vector4;
  25877. }, scene?: Nullable<Scene>): Mesh;
  25878. }
  25879. }
  25880. declare module "babylonjs/Particles/solidParticleSystem" {
  25881. import { Vector3 } from "babylonjs/Maths/math.vector";
  25882. import { Mesh } from "babylonjs/Meshes/mesh";
  25883. import { Scene, IDisposable } from "babylonjs/scene";
  25884. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25885. /**
  25886. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25887. *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.
  25888. * The SPS is also a particle system. It provides some methods to manage the particles.
  25889. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25890. *
  25891. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25892. */
  25893. export class SolidParticleSystem implements IDisposable {
  25894. /**
  25895. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25896. * Example : var p = SPS.particles[i];
  25897. */
  25898. particles: SolidParticle[];
  25899. /**
  25900. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25901. */
  25902. nbParticles: number;
  25903. /**
  25904. * If the particles must ever face the camera (default false). Useful for planar particles.
  25905. */
  25906. billboard: boolean;
  25907. /**
  25908. * Recompute normals when adding a shape
  25909. */
  25910. recomputeNormals: boolean;
  25911. /**
  25912. * This a counter ofr your own usage. It's not set by any SPS functions.
  25913. */
  25914. counter: number;
  25915. /**
  25916. * The SPS name. This name is also given to the underlying mesh.
  25917. */
  25918. name: string;
  25919. /**
  25920. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25921. */
  25922. mesh: Mesh;
  25923. /**
  25924. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25925. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25926. */
  25927. vars: any;
  25928. /**
  25929. * This array is populated when the SPS is set as 'pickable'.
  25930. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25931. * Each element of this array is an object `{idx: int, faceId: int}`.
  25932. * `idx` is the picked particle index in the `SPS.particles` array
  25933. * `faceId` is the picked face index counted within this particle.
  25934. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25935. */
  25936. pickedParticles: {
  25937. idx: number;
  25938. faceId: number;
  25939. }[];
  25940. /**
  25941. * This array is populated when `enableDepthSort` is set to true.
  25942. * Each element of this array is an instance of the class DepthSortedParticle.
  25943. */
  25944. depthSortedParticles: DepthSortedParticle[];
  25945. /**
  25946. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25947. * @hidden
  25948. */
  25949. _bSphereOnly: boolean;
  25950. /**
  25951. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25952. * @hidden
  25953. */
  25954. _bSphereRadiusFactor: number;
  25955. private _scene;
  25956. private _positions;
  25957. private _indices;
  25958. private _normals;
  25959. private _colors;
  25960. private _uvs;
  25961. private _indices32;
  25962. private _positions32;
  25963. private _normals32;
  25964. private _fixedNormal32;
  25965. private _colors32;
  25966. private _uvs32;
  25967. private _index;
  25968. private _updatable;
  25969. private _pickable;
  25970. private _isVisibilityBoxLocked;
  25971. private _alwaysVisible;
  25972. private _depthSort;
  25973. private _expandable;
  25974. private _shapeCounter;
  25975. private _copy;
  25976. private _color;
  25977. private _computeParticleColor;
  25978. private _computeParticleTexture;
  25979. private _computeParticleRotation;
  25980. private _computeParticleVertex;
  25981. private _computeBoundingBox;
  25982. private _depthSortParticles;
  25983. private _camera;
  25984. private _mustUnrotateFixedNormals;
  25985. private _particlesIntersect;
  25986. private _needs32Bits;
  25987. /**
  25988. * Creates a SPS (Solid Particle System) object.
  25989. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25990. * @param scene (Scene) is the scene in which the SPS is added.
  25991. * @param options defines the options of the sps e.g.
  25992. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25993. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25994. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25995. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25996. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25997. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25998. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25999. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26000. */
  26001. constructor(name: string, scene: Scene, options?: {
  26002. updatable?: boolean;
  26003. isPickable?: boolean;
  26004. enableDepthSort?: boolean;
  26005. particleIntersection?: boolean;
  26006. boundingSphereOnly?: boolean;
  26007. bSphereRadiusFactor?: number;
  26008. expandable?: boolean;
  26009. });
  26010. /**
  26011. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26012. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26013. * @returns the created mesh
  26014. */
  26015. buildMesh(): Mesh;
  26016. /**
  26017. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26018. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26019. * Thus the particles generated from `digest()` have their property `position` set yet.
  26020. * @param mesh ( Mesh ) is the mesh to be digested
  26021. * @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
  26022. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26023. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26024. * @returns the current SPS
  26025. */
  26026. digest(mesh: Mesh, options?: {
  26027. facetNb?: number;
  26028. number?: number;
  26029. delta?: number;
  26030. }): SolidParticleSystem;
  26031. private _unrotateFixedNormals;
  26032. private _resetCopy;
  26033. private _meshBuilder;
  26034. private _posToShape;
  26035. private _uvsToShapeUV;
  26036. private _addParticle;
  26037. /**
  26038. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26039. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26040. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26041. * @param nb (positive integer) the number of particles to be created from this model
  26042. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26043. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26044. * @returns the number of shapes in the system
  26045. */
  26046. addShape(mesh: Mesh, nb: number, options?: {
  26047. positionFunction?: any;
  26048. vertexFunction?: any;
  26049. }): number;
  26050. private _rebuildParticle;
  26051. /**
  26052. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26053. * @returns the SPS.
  26054. */
  26055. rebuildMesh(): SolidParticleSystem;
  26056. /**
  26057. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26058. * This method calls `updateParticle()` for each particle of the SPS.
  26059. * For an animated SPS, it is usually called within the render loop.
  26060. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26061. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26062. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26063. * @returns the SPS.
  26064. */
  26065. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26066. /**
  26067. * Disposes the SPS.
  26068. */
  26069. dispose(): void;
  26070. /**
  26071. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26073. * @returns the SPS.
  26074. */
  26075. refreshVisibleSize(): SolidParticleSystem;
  26076. /**
  26077. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26078. * @param size the size (float) of the visibility box
  26079. * note : this doesn't lock the SPS mesh bounding box.
  26080. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26081. */
  26082. setVisibilityBox(size: number): void;
  26083. /**
  26084. * Gets whether the SPS as always visible or not
  26085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26086. */
  26087. /**
  26088. * Sets the SPS as always visible or not
  26089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26090. */
  26091. isAlwaysVisible: boolean;
  26092. /**
  26093. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26095. */
  26096. /**
  26097. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26099. */
  26100. isVisibilityBoxLocked: boolean;
  26101. /**
  26102. * Tells to `setParticles()` to compute the particle rotations or not.
  26103. * Default value : true. The SPS is faster when it's set to false.
  26104. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26105. */
  26106. /**
  26107. * Gets if `setParticles()` computes the particle rotations or not.
  26108. * Default value : true. The SPS is faster when it's set to false.
  26109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26110. */
  26111. computeParticleRotation: boolean;
  26112. /**
  26113. * Tells to `setParticles()` to compute the particle colors or not.
  26114. * Default value : true. The SPS is faster when it's set to false.
  26115. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26116. */
  26117. /**
  26118. * Gets if `setParticles()` computes the particle colors or not.
  26119. * Default value : true. The SPS is faster when it's set to false.
  26120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26121. */
  26122. computeParticleColor: boolean;
  26123. /**
  26124. * Gets if `setParticles()` computes the particle textures or not.
  26125. * Default value : true. The SPS is faster when it's set to false.
  26126. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26127. */
  26128. computeParticleTexture: boolean;
  26129. /**
  26130. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26131. * Default value : false. The SPS is faster when it's set to false.
  26132. * Note : the particle custom vertex positions aren't stored values.
  26133. */
  26134. /**
  26135. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26136. * Default value : false. The SPS is faster when it's set to false.
  26137. * Note : the particle custom vertex positions aren't stored values.
  26138. */
  26139. computeParticleVertex: boolean;
  26140. /**
  26141. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26142. */
  26143. /**
  26144. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26145. */
  26146. computeBoundingBox: boolean;
  26147. /**
  26148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26150. * Default : `true`
  26151. */
  26152. /**
  26153. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26155. * Default : `true`
  26156. */
  26157. depthSortParticles: boolean;
  26158. /**
  26159. * Gets if the SPS is created as expandable at construction time.
  26160. * Default : `false`
  26161. */
  26162. readonly expandable: boolean;
  26163. /**
  26164. * This function does nothing. It may be overwritten to set all the particle first values.
  26165. * The SPS doesn't call this function, you may have to call it by your own.
  26166. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26167. */
  26168. initParticles(): void;
  26169. /**
  26170. * This function does nothing. It may be overwritten to recycle a particle.
  26171. * The SPS doesn't call this function, you may have to call it by your own.
  26172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26173. * @param particle The particle to recycle
  26174. * @returns the recycled particle
  26175. */
  26176. recycleParticle(particle: SolidParticle): SolidParticle;
  26177. /**
  26178. * Updates a particle : this function should be overwritten by the user.
  26179. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26180. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26181. * @example : just set a particle position or velocity and recycle conditions
  26182. * @param particle The particle to update
  26183. * @returns the updated particle
  26184. */
  26185. updateParticle(particle: SolidParticle): SolidParticle;
  26186. /**
  26187. * Updates a vertex of a particle : it can be overwritten by the user.
  26188. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26189. * @param particle the current particle
  26190. * @param vertex the current index of the current particle
  26191. * @param pt the index of the current vertex in the particle shape
  26192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26193. * @example : just set a vertex particle position
  26194. * @returns the updated vertex
  26195. */
  26196. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26197. /**
  26198. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26199. * This does nothing and may be overwritten by the user.
  26200. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26201. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26202. * @param update the boolean update value actually passed to setParticles()
  26203. */
  26204. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26205. /**
  26206. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26207. * This will be passed three parameters.
  26208. * This does nothing and may be overwritten by the user.
  26209. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26210. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26211. * @param update the boolean update value actually passed to setParticles()
  26212. */
  26213. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26214. }
  26215. }
  26216. declare module "babylonjs/Particles/solidParticle" {
  26217. import { Nullable } from "babylonjs/types";
  26218. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26219. import { Color4 } from "babylonjs/Maths/math.color";
  26220. import { Mesh } from "babylonjs/Meshes/mesh";
  26221. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26222. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26223. import { Plane } from "babylonjs/Maths/math.plane";
  26224. /**
  26225. * Represents one particle of a solid particle system.
  26226. */
  26227. export class SolidParticle {
  26228. /**
  26229. * particle global index
  26230. */
  26231. idx: number;
  26232. /**
  26233. * The color of the particle
  26234. */
  26235. color: Nullable<Color4>;
  26236. /**
  26237. * The world space position of the particle.
  26238. */
  26239. position: Vector3;
  26240. /**
  26241. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26242. */
  26243. rotation: Vector3;
  26244. /**
  26245. * The world space rotation quaternion of the particle.
  26246. */
  26247. rotationQuaternion: Nullable<Quaternion>;
  26248. /**
  26249. * The scaling of the particle.
  26250. */
  26251. scaling: Vector3;
  26252. /**
  26253. * The uvs of the particle.
  26254. */
  26255. uvs: Vector4;
  26256. /**
  26257. * The current speed of the particle.
  26258. */
  26259. velocity: Vector3;
  26260. /**
  26261. * The pivot point in the particle local space.
  26262. */
  26263. pivot: Vector3;
  26264. /**
  26265. * Must the particle be translated from its pivot point in its local space ?
  26266. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26267. * Default : false
  26268. */
  26269. translateFromPivot: boolean;
  26270. /**
  26271. * Is the particle active or not ?
  26272. */
  26273. alive: boolean;
  26274. /**
  26275. * Is the particle visible or not ?
  26276. */
  26277. isVisible: boolean;
  26278. /**
  26279. * Index of this particle in the global "positions" array (Internal use)
  26280. * @hidden
  26281. */
  26282. _pos: number;
  26283. /**
  26284. * @hidden Index of this particle in the global "indices" array (Internal use)
  26285. */
  26286. _ind: number;
  26287. /**
  26288. * @hidden ModelShape of this particle (Internal use)
  26289. */
  26290. _model: ModelShape;
  26291. /**
  26292. * ModelShape id of this particle
  26293. */
  26294. shapeId: number;
  26295. /**
  26296. * Index of the particle in its shape id
  26297. */
  26298. idxInShape: number;
  26299. /**
  26300. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26301. */
  26302. _modelBoundingInfo: BoundingInfo;
  26303. /**
  26304. * @hidden Particle BoundingInfo object (Internal use)
  26305. */
  26306. _boundingInfo: BoundingInfo;
  26307. /**
  26308. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26309. */
  26310. _sps: SolidParticleSystem;
  26311. /**
  26312. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26313. */
  26314. _stillInvisible: boolean;
  26315. /**
  26316. * @hidden Last computed particle rotation matrix
  26317. */
  26318. _rotationMatrix: number[];
  26319. /**
  26320. * Parent particle Id, if any.
  26321. * Default null.
  26322. */
  26323. parentId: Nullable<number>;
  26324. /**
  26325. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26326. * The possible values are :
  26327. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26328. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26330. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26331. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26332. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26333. * */
  26334. cullingStrategy: number;
  26335. /**
  26336. * @hidden Internal global position in the SPS.
  26337. */
  26338. _globalPosition: Vector3;
  26339. /**
  26340. * Creates a Solid Particle object.
  26341. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26342. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26343. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26344. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26345. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26346. * @param shapeId (integer) is the model shape identifier in the SPS.
  26347. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26348. * @param sps defines the sps it is associated to
  26349. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26350. */
  26351. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26352. /**
  26353. * Legacy support, changed scale to scaling
  26354. */
  26355. /**
  26356. * Legacy support, changed scale to scaling
  26357. */
  26358. scale: Vector3;
  26359. /**
  26360. * Legacy support, changed quaternion to rotationQuaternion
  26361. */
  26362. /**
  26363. * Legacy support, changed quaternion to rotationQuaternion
  26364. */
  26365. quaternion: Nullable<Quaternion>;
  26366. /**
  26367. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26368. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26369. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26370. * @returns true if it intersects
  26371. */
  26372. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26373. /**
  26374. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26375. * A particle is in the frustum if its bounding box intersects the frustum
  26376. * @param frustumPlanes defines the frustum to test
  26377. * @returns true if the particle is in the frustum planes
  26378. */
  26379. isInFrustum(frustumPlanes: Plane[]): boolean;
  26380. /**
  26381. * get the rotation matrix of the particle
  26382. * @hidden
  26383. */
  26384. getRotationMatrix(m: Matrix): void;
  26385. }
  26386. /**
  26387. * Represents the shape of the model used by one particle of a solid particle system.
  26388. * SPS internal tool, don't use it manually.
  26389. */
  26390. export class ModelShape {
  26391. /**
  26392. * The shape id
  26393. * @hidden
  26394. */
  26395. shapeID: number;
  26396. /**
  26397. * flat array of model positions (internal use)
  26398. * @hidden
  26399. */
  26400. _shape: Vector3[];
  26401. /**
  26402. * flat array of model UVs (internal use)
  26403. * @hidden
  26404. */
  26405. _shapeUV: number[];
  26406. /**
  26407. * length of the shape in the model indices array (internal use)
  26408. * @hidden
  26409. */
  26410. _indicesLength: number;
  26411. /**
  26412. * Custom position function (internal use)
  26413. * @hidden
  26414. */
  26415. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26416. /**
  26417. * Custom vertex function (internal use)
  26418. * @hidden
  26419. */
  26420. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26421. /**
  26422. * 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.
  26423. * SPS internal tool, don't use it manually.
  26424. * @hidden
  26425. */
  26426. 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>);
  26427. }
  26428. /**
  26429. * Represents a Depth Sorted Particle in the solid particle system.
  26430. */
  26431. export class DepthSortedParticle {
  26432. /**
  26433. * Index of the particle in the "indices" array
  26434. */
  26435. ind: number;
  26436. /**
  26437. * Length of the particle shape in the "indices" array
  26438. */
  26439. indicesLength: number;
  26440. /**
  26441. * Squared distance from the particle to the camera
  26442. */
  26443. sqDistance: number;
  26444. }
  26445. }
  26446. declare module "babylonjs/Collisions/meshCollisionData" {
  26447. import { Collider } from "babylonjs/Collisions/collider";
  26448. import { Vector3 } from "babylonjs/Maths/math.vector";
  26449. import { Nullable } from "babylonjs/types";
  26450. import { Observer } from "babylonjs/Misc/observable";
  26451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26452. /**
  26453. * @hidden
  26454. */
  26455. export class _MeshCollisionData {
  26456. _checkCollisions: boolean;
  26457. _collisionMask: number;
  26458. _collisionGroup: number;
  26459. _collider: Nullable<Collider>;
  26460. _oldPositionForCollisions: Vector3;
  26461. _diffPositionForCollisions: Vector3;
  26462. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26463. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26464. }
  26465. }
  26466. declare module "babylonjs/Meshes/abstractMesh" {
  26467. import { Observable } from "babylonjs/Misc/observable";
  26468. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26469. import { Camera } from "babylonjs/Cameras/camera";
  26470. import { Scene, IDisposable } from "babylonjs/scene";
  26471. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26472. import { Node } from "babylonjs/node";
  26473. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26474. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26475. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26476. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26477. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26478. import { Material } from "babylonjs/Materials/material";
  26479. import { Light } from "babylonjs/Lights/light";
  26480. import { Skeleton } from "babylonjs/Bones/skeleton";
  26481. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26482. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26483. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26484. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26485. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26486. import { Plane } from "babylonjs/Maths/math.plane";
  26487. import { Ray } from "babylonjs/Culling/ray";
  26488. import { Collider } from "babylonjs/Collisions/collider";
  26489. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26490. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26491. /** @hidden */
  26492. class _FacetDataStorage {
  26493. facetPositions: Vector3[];
  26494. facetNormals: Vector3[];
  26495. facetPartitioning: number[][];
  26496. facetNb: number;
  26497. partitioningSubdivisions: number;
  26498. partitioningBBoxRatio: number;
  26499. facetDataEnabled: boolean;
  26500. facetParameters: any;
  26501. bbSize: Vector3;
  26502. subDiv: {
  26503. max: number;
  26504. X: number;
  26505. Y: number;
  26506. Z: number;
  26507. };
  26508. facetDepthSort: boolean;
  26509. facetDepthSortEnabled: boolean;
  26510. depthSortedIndices: IndicesArray;
  26511. depthSortedFacets: {
  26512. ind: number;
  26513. sqDistance: number;
  26514. }[];
  26515. facetDepthSortFunction: (f1: {
  26516. ind: number;
  26517. sqDistance: number;
  26518. }, f2: {
  26519. ind: number;
  26520. sqDistance: number;
  26521. }) => number;
  26522. facetDepthSortFrom: Vector3;
  26523. facetDepthSortOrigin: Vector3;
  26524. invertedMatrix: Matrix;
  26525. }
  26526. /**
  26527. * @hidden
  26528. **/
  26529. class _InternalAbstractMeshDataInfo {
  26530. _hasVertexAlpha: boolean;
  26531. _useVertexColors: boolean;
  26532. _numBoneInfluencers: number;
  26533. _applyFog: boolean;
  26534. _receiveShadows: boolean;
  26535. _facetData: _FacetDataStorage;
  26536. _visibility: number;
  26537. _skeleton: Nullable<Skeleton>;
  26538. _layerMask: number;
  26539. _computeBonesUsingShaders: boolean;
  26540. _isActive: boolean;
  26541. _onlyForInstances: boolean;
  26542. _isActiveIntermediate: boolean;
  26543. _onlyForInstancesIntermediate: boolean;
  26544. _actAsRegularMesh: boolean;
  26545. }
  26546. /**
  26547. * Class used to store all common mesh properties
  26548. */
  26549. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26550. /** No occlusion */
  26551. static OCCLUSION_TYPE_NONE: number;
  26552. /** Occlusion set to optimisitic */
  26553. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26554. /** Occlusion set to strict */
  26555. static OCCLUSION_TYPE_STRICT: number;
  26556. /** Use an accurante occlusion algorithm */
  26557. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26558. /** Use a conservative occlusion algorithm */
  26559. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26560. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26561. * Test order :
  26562. * Is the bounding sphere outside the frustum ?
  26563. * If not, are the bounding box vertices outside the frustum ?
  26564. * It not, then the cullable object is in the frustum.
  26565. */
  26566. static readonly CULLINGSTRATEGY_STANDARD: number;
  26567. /** Culling strategy : Bounding Sphere Only.
  26568. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26569. * It's also less accurate than the standard because some not visible objects can still be selected.
  26570. * Test : is the bounding sphere outside the frustum ?
  26571. * If not, then the cullable object is in the frustum.
  26572. */
  26573. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26574. /** Culling strategy : Optimistic Inclusion.
  26575. * This in an inclusion test first, then the standard exclusion test.
  26576. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26577. * 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.
  26578. * Anyway, it's as accurate as the standard strategy.
  26579. * Test :
  26580. * Is the cullable object bounding sphere center in the frustum ?
  26581. * If not, apply the default culling strategy.
  26582. */
  26583. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26584. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26585. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26586. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26587. * 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.
  26588. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26589. * Test :
  26590. * Is the cullable object bounding sphere center in the frustum ?
  26591. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26592. */
  26593. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26594. /**
  26595. * No billboard
  26596. */
  26597. static readonly BILLBOARDMODE_NONE: number;
  26598. /** Billboard on X axis */
  26599. static readonly BILLBOARDMODE_X: number;
  26600. /** Billboard on Y axis */
  26601. static readonly BILLBOARDMODE_Y: number;
  26602. /** Billboard on Z axis */
  26603. static readonly BILLBOARDMODE_Z: number;
  26604. /** Billboard on all axes */
  26605. static readonly BILLBOARDMODE_ALL: number;
  26606. /** Billboard on using position instead of orientation */
  26607. static readonly BILLBOARDMODE_USE_POSITION: number;
  26608. /** @hidden */
  26609. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26610. /**
  26611. * The culling strategy to use to check whether the mesh must be rendered or not.
  26612. * This value can be changed at any time and will be used on the next render mesh selection.
  26613. * The possible values are :
  26614. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26615. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26616. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26617. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26618. * Please read each static variable documentation to get details about the culling process.
  26619. * */
  26620. cullingStrategy: number;
  26621. /**
  26622. * Gets the number of facets in the mesh
  26623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26624. */
  26625. readonly facetNb: number;
  26626. /**
  26627. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26629. */
  26630. partitioningSubdivisions: number;
  26631. /**
  26632. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26633. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26635. */
  26636. partitioningBBoxRatio: number;
  26637. /**
  26638. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26639. * Works only for updatable meshes.
  26640. * Doesn't work with multi-materials
  26641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26642. */
  26643. mustDepthSortFacets: boolean;
  26644. /**
  26645. * The location (Vector3) where the facet depth sort must be computed from.
  26646. * By default, the active camera position.
  26647. * Used only when facet depth sort is enabled
  26648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26649. */
  26650. facetDepthSortFrom: Vector3;
  26651. /**
  26652. * gets a boolean indicating if facetData is enabled
  26653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26654. */
  26655. readonly isFacetDataEnabled: boolean;
  26656. /** @hidden */
  26657. _updateNonUniformScalingState(value: boolean): boolean;
  26658. /**
  26659. * An event triggered when this mesh collides with another one
  26660. */
  26661. onCollideObservable: Observable<AbstractMesh>;
  26662. /** Set a function to call when this mesh collides with another one */
  26663. onCollide: () => void;
  26664. /**
  26665. * An event triggered when the collision's position changes
  26666. */
  26667. onCollisionPositionChangeObservable: Observable<Vector3>;
  26668. /** Set a function to call when the collision's position changes */
  26669. onCollisionPositionChange: () => void;
  26670. /**
  26671. * An event triggered when material is changed
  26672. */
  26673. onMaterialChangedObservable: Observable<AbstractMesh>;
  26674. /**
  26675. * Gets or sets the orientation for POV movement & rotation
  26676. */
  26677. definedFacingForward: boolean;
  26678. /** @hidden */
  26679. _occlusionQuery: Nullable<WebGLQuery>;
  26680. /** @hidden */
  26681. _renderingGroup: Nullable<RenderingGroup>;
  26682. /**
  26683. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26684. */
  26685. /**
  26686. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26687. */
  26688. visibility: number;
  26689. /** Gets or sets the alpha index used to sort transparent meshes
  26690. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26691. */
  26692. alphaIndex: number;
  26693. /**
  26694. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26695. */
  26696. isVisible: boolean;
  26697. /**
  26698. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26699. */
  26700. isPickable: boolean;
  26701. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26702. showSubMeshesBoundingBox: boolean;
  26703. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26704. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26705. */
  26706. isBlocker: boolean;
  26707. /**
  26708. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26709. */
  26710. enablePointerMoveEvents: boolean;
  26711. /**
  26712. * Specifies the rendering group id for this mesh (0 by default)
  26713. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26714. */
  26715. renderingGroupId: number;
  26716. private _material;
  26717. /** Gets or sets current material */
  26718. material: Nullable<Material>;
  26719. /**
  26720. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26721. * @see http://doc.babylonjs.com/babylon101/shadows
  26722. */
  26723. receiveShadows: boolean;
  26724. /** Defines color to use when rendering outline */
  26725. outlineColor: Color3;
  26726. /** Define width to use when rendering outline */
  26727. outlineWidth: number;
  26728. /** Defines color to use when rendering overlay */
  26729. overlayColor: Color3;
  26730. /** Defines alpha to use when rendering overlay */
  26731. overlayAlpha: number;
  26732. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26733. hasVertexAlpha: boolean;
  26734. /** 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) */
  26735. useVertexColors: boolean;
  26736. /**
  26737. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26738. */
  26739. computeBonesUsingShaders: boolean;
  26740. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26741. numBoneInfluencers: number;
  26742. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26743. applyFog: boolean;
  26744. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26745. useOctreeForRenderingSelection: boolean;
  26746. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26747. useOctreeForPicking: boolean;
  26748. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26749. useOctreeForCollisions: boolean;
  26750. /**
  26751. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26752. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26753. */
  26754. layerMask: number;
  26755. /**
  26756. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26757. */
  26758. alwaysSelectAsActiveMesh: boolean;
  26759. /**
  26760. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26761. */
  26762. doNotSyncBoundingInfo: boolean;
  26763. /**
  26764. * Gets or sets the current action manager
  26765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26766. */
  26767. actionManager: Nullable<AbstractActionManager>;
  26768. private _meshCollisionData;
  26769. /**
  26770. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26772. */
  26773. ellipsoid: Vector3;
  26774. /**
  26775. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26777. */
  26778. ellipsoidOffset: Vector3;
  26779. /**
  26780. * Gets or sets a collision mask used to mask collisions (default is -1).
  26781. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26782. */
  26783. collisionMask: number;
  26784. /**
  26785. * Gets or sets the current collision group mask (-1 by default).
  26786. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26787. */
  26788. collisionGroup: number;
  26789. /**
  26790. * Defines edge width used when edgesRenderer is enabled
  26791. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26792. */
  26793. edgesWidth: number;
  26794. /**
  26795. * Defines edge color used when edgesRenderer is enabled
  26796. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26797. */
  26798. edgesColor: Color4;
  26799. /** @hidden */
  26800. _edgesRenderer: Nullable<IEdgesRenderer>;
  26801. /** @hidden */
  26802. _masterMesh: Nullable<AbstractMesh>;
  26803. /** @hidden */
  26804. _boundingInfo: Nullable<BoundingInfo>;
  26805. /** @hidden */
  26806. _renderId: number;
  26807. /**
  26808. * Gets or sets the list of subMeshes
  26809. * @see http://doc.babylonjs.com/how_to/multi_materials
  26810. */
  26811. subMeshes: SubMesh[];
  26812. /** @hidden */
  26813. _intersectionsInProgress: AbstractMesh[];
  26814. /** @hidden */
  26815. _unIndexed: boolean;
  26816. /** @hidden */
  26817. _lightSources: Light[];
  26818. /** Gets the list of lights affecting that mesh */
  26819. readonly lightSources: Light[];
  26820. /** @hidden */
  26821. readonly _positions: Nullable<Vector3[]>;
  26822. /** @hidden */
  26823. _waitingData: {
  26824. lods: Nullable<any>;
  26825. actions: Nullable<any>;
  26826. freezeWorldMatrix: Nullable<boolean>;
  26827. };
  26828. /** @hidden */
  26829. _bonesTransformMatrices: Nullable<Float32Array>;
  26830. /** @hidden */
  26831. _transformMatrixTexture: Nullable<RawTexture>;
  26832. /**
  26833. * Gets or sets a skeleton to apply skining transformations
  26834. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26835. */
  26836. skeleton: Nullable<Skeleton>;
  26837. /**
  26838. * An event triggered when the mesh is rebuilt.
  26839. */
  26840. onRebuildObservable: Observable<AbstractMesh>;
  26841. /**
  26842. * Creates a new AbstractMesh
  26843. * @param name defines the name of the mesh
  26844. * @param scene defines the hosting scene
  26845. */
  26846. constructor(name: string, scene?: Nullable<Scene>);
  26847. /**
  26848. * Returns the string "AbstractMesh"
  26849. * @returns "AbstractMesh"
  26850. */
  26851. getClassName(): string;
  26852. /**
  26853. * Gets a string representation of the current mesh
  26854. * @param fullDetails defines a boolean indicating if full details must be included
  26855. * @returns a string representation of the current mesh
  26856. */
  26857. toString(fullDetails?: boolean): string;
  26858. /**
  26859. * @hidden
  26860. */
  26861. protected _getEffectiveParent(): Nullable<Node>;
  26862. /** @hidden */
  26863. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26864. /** @hidden */
  26865. _rebuild(): void;
  26866. /** @hidden */
  26867. _resyncLightSources(): void;
  26868. /** @hidden */
  26869. _resyncLighSource(light: Light): void;
  26870. /** @hidden */
  26871. _unBindEffect(): void;
  26872. /** @hidden */
  26873. _removeLightSource(light: Light, dispose: boolean): void;
  26874. private _markSubMeshesAsDirty;
  26875. /** @hidden */
  26876. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26877. /** @hidden */
  26878. _markSubMeshesAsAttributesDirty(): void;
  26879. /** @hidden */
  26880. _markSubMeshesAsMiscDirty(): void;
  26881. /**
  26882. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26883. */
  26884. scaling: Vector3;
  26885. /**
  26886. * Returns true if the mesh is blocked. Implemented by child classes
  26887. */
  26888. readonly isBlocked: boolean;
  26889. /**
  26890. * Returns the mesh itself by default. Implemented by child classes
  26891. * @param camera defines the camera to use to pick the right LOD level
  26892. * @returns the currentAbstractMesh
  26893. */
  26894. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26895. /**
  26896. * Returns 0 by default. Implemented by child classes
  26897. * @returns an integer
  26898. */
  26899. getTotalVertices(): number;
  26900. /**
  26901. * Returns a positive integer : the total number of indices in this mesh geometry.
  26902. * @returns the numner of indices or zero if the mesh has no geometry.
  26903. */
  26904. getTotalIndices(): number;
  26905. /**
  26906. * Returns null by default. Implemented by child classes
  26907. * @returns null
  26908. */
  26909. getIndices(): Nullable<IndicesArray>;
  26910. /**
  26911. * Returns the array of the requested vertex data kind. Implemented by child classes
  26912. * @param kind defines the vertex data kind to use
  26913. * @returns null
  26914. */
  26915. getVerticesData(kind: string): Nullable<FloatArray>;
  26916. /**
  26917. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26918. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26919. * Note that a new underlying VertexBuffer object is created each call.
  26920. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26921. * @param kind defines vertex data kind:
  26922. * * VertexBuffer.PositionKind
  26923. * * VertexBuffer.UVKind
  26924. * * VertexBuffer.UV2Kind
  26925. * * VertexBuffer.UV3Kind
  26926. * * VertexBuffer.UV4Kind
  26927. * * VertexBuffer.UV5Kind
  26928. * * VertexBuffer.UV6Kind
  26929. * * VertexBuffer.ColorKind
  26930. * * VertexBuffer.MatricesIndicesKind
  26931. * * VertexBuffer.MatricesIndicesExtraKind
  26932. * * VertexBuffer.MatricesWeightsKind
  26933. * * VertexBuffer.MatricesWeightsExtraKind
  26934. * @param data defines the data source
  26935. * @param updatable defines if the data must be flagged as updatable (or static)
  26936. * @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
  26937. * @returns the current mesh
  26938. */
  26939. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26940. /**
  26941. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26942. * If the mesh has no geometry, it is simply returned as it is.
  26943. * @param kind defines vertex data kind:
  26944. * * VertexBuffer.PositionKind
  26945. * * VertexBuffer.UVKind
  26946. * * VertexBuffer.UV2Kind
  26947. * * VertexBuffer.UV3Kind
  26948. * * VertexBuffer.UV4Kind
  26949. * * VertexBuffer.UV5Kind
  26950. * * VertexBuffer.UV6Kind
  26951. * * VertexBuffer.ColorKind
  26952. * * VertexBuffer.MatricesIndicesKind
  26953. * * VertexBuffer.MatricesIndicesExtraKind
  26954. * * VertexBuffer.MatricesWeightsKind
  26955. * * VertexBuffer.MatricesWeightsExtraKind
  26956. * @param data defines the data source
  26957. * @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
  26958. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26959. * @returns the current mesh
  26960. */
  26961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26962. /**
  26963. * Sets the mesh indices,
  26964. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26965. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26966. * @param totalVertices Defines the total number of vertices
  26967. * @returns the current mesh
  26968. */
  26969. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26970. /**
  26971. * Gets a boolean indicating if specific vertex data is present
  26972. * @param kind defines the vertex data kind to use
  26973. * @returns true is data kind is present
  26974. */
  26975. isVerticesDataPresent(kind: string): boolean;
  26976. /**
  26977. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26978. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26979. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26980. * @returns a BoundingInfo
  26981. */
  26982. getBoundingInfo(): BoundingInfo;
  26983. /**
  26984. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26985. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26986. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26987. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26988. * @returns the current mesh
  26989. */
  26990. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26991. /**
  26992. * Overwrite the current bounding info
  26993. * @param boundingInfo defines the new bounding info
  26994. * @returns the current mesh
  26995. */
  26996. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26997. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26998. readonly useBones: boolean;
  26999. /** @hidden */
  27000. _preActivate(): void;
  27001. /** @hidden */
  27002. _preActivateForIntermediateRendering(renderId: number): void;
  27003. /** @hidden */
  27004. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27005. /** @hidden */
  27006. _postActivate(): void;
  27007. /** @hidden */
  27008. _freeze(): void;
  27009. /** @hidden */
  27010. _unFreeze(): void;
  27011. /**
  27012. * Gets the current world matrix
  27013. * @returns a Matrix
  27014. */
  27015. getWorldMatrix(): Matrix;
  27016. /** @hidden */
  27017. _getWorldMatrixDeterminant(): number;
  27018. /**
  27019. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27020. */
  27021. readonly isAnInstance: boolean;
  27022. /**
  27023. * Gets a boolean indicating if this mesh has instances
  27024. */
  27025. readonly hasInstances: boolean;
  27026. /**
  27027. * Perform relative position change from the point of view of behind the front of the mesh.
  27028. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27029. * Supports definition of mesh facing forward or backward
  27030. * @param amountRight defines the distance on the right axis
  27031. * @param amountUp defines the distance on the up axis
  27032. * @param amountForward defines the distance on the forward axis
  27033. * @returns the current mesh
  27034. */
  27035. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27036. /**
  27037. * Calculate relative position change from the point of view of behind the front of the mesh.
  27038. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27039. * Supports definition of mesh facing forward or backward
  27040. * @param amountRight defines the distance on the right axis
  27041. * @param amountUp defines the distance on the up axis
  27042. * @param amountForward defines the distance on the forward axis
  27043. * @returns the new displacement vector
  27044. */
  27045. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27046. /**
  27047. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27048. * Supports definition of mesh facing forward or backward
  27049. * @param flipBack defines the flip
  27050. * @param twirlClockwise defines the twirl
  27051. * @param tiltRight defines the tilt
  27052. * @returns the current mesh
  27053. */
  27054. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27055. /**
  27056. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27057. * Supports definition of mesh facing forward or backward.
  27058. * @param flipBack defines the flip
  27059. * @param twirlClockwise defines the twirl
  27060. * @param tiltRight defines the tilt
  27061. * @returns the new rotation vector
  27062. */
  27063. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27064. /**
  27065. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27066. * This means the mesh underlying bounding box and sphere are recomputed.
  27067. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27068. * @returns the current mesh
  27069. */
  27070. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27071. /** @hidden */
  27072. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27073. /** @hidden */
  27074. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27075. /** @hidden */
  27076. _updateBoundingInfo(): AbstractMesh;
  27077. /** @hidden */
  27078. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27079. /** @hidden */
  27080. protected _afterComputeWorldMatrix(): void;
  27081. /** @hidden */
  27082. readonly _effectiveMesh: AbstractMesh;
  27083. /**
  27084. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27085. * A mesh is in the frustum if its bounding box intersects the frustum
  27086. * @param frustumPlanes defines the frustum to test
  27087. * @returns true if the mesh is in the frustum planes
  27088. */
  27089. isInFrustum(frustumPlanes: Plane[]): boolean;
  27090. /**
  27091. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27092. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27093. * @param frustumPlanes defines the frustum to test
  27094. * @returns true if the mesh is completely in the frustum planes
  27095. */
  27096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27097. /**
  27098. * True if the mesh intersects another mesh or a SolidParticle object
  27099. * @param mesh defines a target mesh or SolidParticle to test
  27100. * @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)
  27101. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27102. * @returns true if there is an intersection
  27103. */
  27104. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27105. /**
  27106. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27107. * @param point defines the point to test
  27108. * @returns true if there is an intersection
  27109. */
  27110. intersectsPoint(point: Vector3): boolean;
  27111. /**
  27112. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27113. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27114. */
  27115. checkCollisions: boolean;
  27116. /**
  27117. * Gets Collider object used to compute collisions (not physics)
  27118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27119. */
  27120. readonly collider: Nullable<Collider>;
  27121. /**
  27122. * Move the mesh using collision engine
  27123. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27124. * @param displacement defines the requested displacement vector
  27125. * @returns the current mesh
  27126. */
  27127. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27128. private _onCollisionPositionChange;
  27129. /** @hidden */
  27130. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27131. /** @hidden */
  27132. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27133. /** @hidden */
  27134. _checkCollision(collider: Collider): AbstractMesh;
  27135. /** @hidden */
  27136. _generatePointsArray(): boolean;
  27137. /**
  27138. * Checks if the passed Ray intersects with the mesh
  27139. * @param ray defines the ray to use
  27140. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27141. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27142. * @returns the picking info
  27143. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27144. */
  27145. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27146. /**
  27147. * Clones the current mesh
  27148. * @param name defines the mesh name
  27149. * @param newParent defines the new mesh parent
  27150. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27151. * @returns the new mesh
  27152. */
  27153. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27154. /**
  27155. * Disposes all the submeshes of the current meshnp
  27156. * @returns the current mesh
  27157. */
  27158. releaseSubMeshes(): AbstractMesh;
  27159. /**
  27160. * Releases resources associated with this abstract mesh.
  27161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27163. */
  27164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27165. /**
  27166. * Adds the passed mesh as a child to the current mesh
  27167. * @param mesh defines the child mesh
  27168. * @returns the current mesh
  27169. */
  27170. addChild(mesh: AbstractMesh): AbstractMesh;
  27171. /**
  27172. * Removes the passed mesh from the current mesh children list
  27173. * @param mesh defines the child mesh
  27174. * @returns the current mesh
  27175. */
  27176. removeChild(mesh: AbstractMesh): AbstractMesh;
  27177. /** @hidden */
  27178. private _initFacetData;
  27179. /**
  27180. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27181. * This method can be called within the render loop.
  27182. * 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
  27183. * @returns the current mesh
  27184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27185. */
  27186. updateFacetData(): AbstractMesh;
  27187. /**
  27188. * Returns the facetLocalNormals array.
  27189. * The normals are expressed in the mesh local spac
  27190. * @returns an array of Vector3
  27191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27192. */
  27193. getFacetLocalNormals(): Vector3[];
  27194. /**
  27195. * Returns the facetLocalPositions array.
  27196. * The facet positions are expressed in the mesh local space
  27197. * @returns an array of Vector3
  27198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27199. */
  27200. getFacetLocalPositions(): Vector3[];
  27201. /**
  27202. * Returns the facetLocalPartioning array
  27203. * @returns an array of array of numbers
  27204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27205. */
  27206. getFacetLocalPartitioning(): number[][];
  27207. /**
  27208. * Returns the i-th facet position in the world system.
  27209. * This method allocates a new Vector3 per call
  27210. * @param i defines the facet index
  27211. * @returns a new Vector3
  27212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27213. */
  27214. getFacetPosition(i: number): Vector3;
  27215. /**
  27216. * Sets the reference Vector3 with the i-th facet position in the world system
  27217. * @param i defines the facet index
  27218. * @param ref defines the target vector
  27219. * @returns the current mesh
  27220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27221. */
  27222. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27223. /**
  27224. * Returns the i-th facet normal in the world system.
  27225. * This method allocates a new Vector3 per call
  27226. * @param i defines the facet index
  27227. * @returns a new Vector3
  27228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27229. */
  27230. getFacetNormal(i: number): Vector3;
  27231. /**
  27232. * Sets the reference Vector3 with the i-th facet normal in the world system
  27233. * @param i defines the facet index
  27234. * @param ref defines the target vector
  27235. * @returns the current mesh
  27236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27237. */
  27238. getFacetNormalToRef(i: number, ref: Vector3): this;
  27239. /**
  27240. * 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)
  27241. * @param x defines x coordinate
  27242. * @param y defines y coordinate
  27243. * @param z defines z coordinate
  27244. * @returns the array of facet indexes
  27245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27246. */
  27247. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27248. /**
  27249. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27250. * @param projected sets as the (x,y,z) world projection on the facet
  27251. * @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
  27252. * @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
  27253. * @param x defines x coordinate
  27254. * @param y defines y coordinate
  27255. * @param z defines z coordinate
  27256. * @returns the face index if found (or null instead)
  27257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27258. */
  27259. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27260. /**
  27261. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27262. * @param projected sets as the (x,y,z) local projection on the facet
  27263. * @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
  27264. * @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
  27265. * @param x defines x coordinate
  27266. * @param y defines y coordinate
  27267. * @param z defines z coordinate
  27268. * @returns the face index if found (or null instead)
  27269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27270. */
  27271. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27272. /**
  27273. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27274. * @returns the parameters
  27275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27276. */
  27277. getFacetDataParameters(): any;
  27278. /**
  27279. * Disables the feature FacetData and frees the related memory
  27280. * @returns the current mesh
  27281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27282. */
  27283. disableFacetData(): AbstractMesh;
  27284. /**
  27285. * Updates the AbstractMesh indices array
  27286. * @param indices defines the data source
  27287. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27288. * @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)
  27289. * @returns the current mesh
  27290. */
  27291. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27292. /**
  27293. * Creates new normals data for the mesh
  27294. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27295. * @returns the current mesh
  27296. */
  27297. createNormals(updatable: boolean): AbstractMesh;
  27298. /**
  27299. * Align the mesh with a normal
  27300. * @param normal defines the normal to use
  27301. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27302. * @returns the current mesh
  27303. */
  27304. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27305. /** @hidden */
  27306. _checkOcclusionQuery(): boolean;
  27307. /**
  27308. * Disables the mesh edge rendering mode
  27309. * @returns the currentAbstractMesh
  27310. */
  27311. disableEdgesRendering(): AbstractMesh;
  27312. /**
  27313. * Enables the edge rendering mode on the mesh.
  27314. * This mode makes the mesh edges visible
  27315. * @param epsilon defines the maximal distance between two angles to detect a face
  27316. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27317. * @returns the currentAbstractMesh
  27318. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27319. */
  27320. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27321. }
  27322. }
  27323. declare module "babylonjs/Actions/actionEvent" {
  27324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27325. import { Nullable } from "babylonjs/types";
  27326. import { Sprite } from "babylonjs/Sprites/sprite";
  27327. import { Scene } from "babylonjs/scene";
  27328. import { Vector2 } from "babylonjs/Maths/math.vector";
  27329. /**
  27330. * Interface used to define ActionEvent
  27331. */
  27332. export interface IActionEvent {
  27333. /** The mesh or sprite that triggered the action */
  27334. source: any;
  27335. /** The X mouse cursor position at the time of the event */
  27336. pointerX: number;
  27337. /** The Y mouse cursor position at the time of the event */
  27338. pointerY: number;
  27339. /** The mesh that is currently pointed at (can be null) */
  27340. meshUnderPointer: Nullable<AbstractMesh>;
  27341. /** the original (browser) event that triggered the ActionEvent */
  27342. sourceEvent?: any;
  27343. /** additional data for the event */
  27344. additionalData?: any;
  27345. }
  27346. /**
  27347. * ActionEvent is the event being sent when an action is triggered.
  27348. */
  27349. export class ActionEvent implements IActionEvent {
  27350. /** The mesh or sprite that triggered the action */
  27351. source: any;
  27352. /** The X mouse cursor position at the time of the event */
  27353. pointerX: number;
  27354. /** The Y mouse cursor position at the time of the event */
  27355. pointerY: number;
  27356. /** The mesh that is currently pointed at (can be null) */
  27357. meshUnderPointer: Nullable<AbstractMesh>;
  27358. /** the original (browser) event that triggered the ActionEvent */
  27359. sourceEvent?: any;
  27360. /** additional data for the event */
  27361. additionalData?: any;
  27362. /**
  27363. * Creates a new ActionEvent
  27364. * @param source The mesh or sprite that triggered the action
  27365. * @param pointerX The X mouse cursor position at the time of the event
  27366. * @param pointerY The Y mouse cursor position at the time of the event
  27367. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27368. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27369. * @param additionalData additional data for the event
  27370. */
  27371. constructor(
  27372. /** The mesh or sprite that triggered the action */
  27373. source: any,
  27374. /** The X mouse cursor position at the time of the event */
  27375. pointerX: number,
  27376. /** The Y mouse cursor position at the time of the event */
  27377. pointerY: number,
  27378. /** The mesh that is currently pointed at (can be null) */
  27379. meshUnderPointer: Nullable<AbstractMesh>,
  27380. /** the original (browser) event that triggered the ActionEvent */
  27381. sourceEvent?: any,
  27382. /** additional data for the event */
  27383. additionalData?: any);
  27384. /**
  27385. * Helper function to auto-create an ActionEvent from a source mesh.
  27386. * @param source The source mesh that triggered the event
  27387. * @param evt The original (browser) event
  27388. * @param additionalData additional data for the event
  27389. * @returns the new ActionEvent
  27390. */
  27391. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27392. /**
  27393. * Helper function to auto-create an ActionEvent from a source sprite
  27394. * @param source The source sprite that triggered the event
  27395. * @param scene Scene associated with the sprite
  27396. * @param evt The original (browser) event
  27397. * @param additionalData additional data for the event
  27398. * @returns the new ActionEvent
  27399. */
  27400. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27401. /**
  27402. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27403. * @param scene the scene where the event occurred
  27404. * @param evt The original (browser) event
  27405. * @returns the new ActionEvent
  27406. */
  27407. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27408. /**
  27409. * Helper function to auto-create an ActionEvent from a primitive
  27410. * @param prim defines the target primitive
  27411. * @param pointerPos defines the pointer position
  27412. * @param evt The original (browser) event
  27413. * @param additionalData additional data for the event
  27414. * @returns the new ActionEvent
  27415. */
  27416. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27417. }
  27418. }
  27419. declare module "babylonjs/Actions/abstractActionManager" {
  27420. import { IDisposable } from "babylonjs/scene";
  27421. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27422. import { IAction } from "babylonjs/Actions/action";
  27423. import { Nullable } from "babylonjs/types";
  27424. /**
  27425. * Abstract class used to decouple action Manager from scene and meshes.
  27426. * Do not instantiate.
  27427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27428. */
  27429. export abstract class AbstractActionManager implements IDisposable {
  27430. /** Gets the list of active triggers */
  27431. static Triggers: {
  27432. [key: string]: number;
  27433. };
  27434. /** Gets the cursor to use when hovering items */
  27435. hoverCursor: string;
  27436. /** Gets the list of actions */
  27437. actions: IAction[];
  27438. /**
  27439. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27440. */
  27441. isRecursive: boolean;
  27442. /**
  27443. * Releases all associated resources
  27444. */
  27445. abstract dispose(): void;
  27446. /**
  27447. * Does this action manager has pointer triggers
  27448. */
  27449. abstract readonly hasPointerTriggers: boolean;
  27450. /**
  27451. * Does this action manager has pick triggers
  27452. */
  27453. abstract readonly hasPickTriggers: boolean;
  27454. /**
  27455. * Process a specific trigger
  27456. * @param trigger defines the trigger to process
  27457. * @param evt defines the event details to be processed
  27458. */
  27459. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27460. /**
  27461. * Does this action manager handles actions of any of the given triggers
  27462. * @param triggers defines the triggers to be tested
  27463. * @return a boolean indicating whether one (or more) of the triggers is handled
  27464. */
  27465. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27466. /**
  27467. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27468. * speed.
  27469. * @param triggerA defines the trigger to be tested
  27470. * @param triggerB defines the trigger to be tested
  27471. * @return a boolean indicating whether one (or more) of the triggers is handled
  27472. */
  27473. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27474. /**
  27475. * Does this action manager handles actions of a given trigger
  27476. * @param trigger defines the trigger to be tested
  27477. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27478. * @return whether the trigger is handled
  27479. */
  27480. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27481. /**
  27482. * Serialize this manager to a JSON object
  27483. * @param name defines the property name to store this manager
  27484. * @returns a JSON representation of this manager
  27485. */
  27486. abstract serialize(name: string): any;
  27487. /**
  27488. * Registers an action to this action manager
  27489. * @param action defines the action to be registered
  27490. * @return the action amended (prepared) after registration
  27491. */
  27492. abstract registerAction(action: IAction): Nullable<IAction>;
  27493. /**
  27494. * Unregisters an action to this action manager
  27495. * @param action defines the action to be unregistered
  27496. * @return a boolean indicating whether the action has been unregistered
  27497. */
  27498. abstract unregisterAction(action: IAction): Boolean;
  27499. /**
  27500. * Does exist one action manager with at least one trigger
  27501. **/
  27502. static readonly HasTriggers: boolean;
  27503. /**
  27504. * Does exist one action manager with at least one pick trigger
  27505. **/
  27506. static readonly HasPickTriggers: boolean;
  27507. /**
  27508. * Does exist one action manager that handles actions of a given trigger
  27509. * @param trigger defines the trigger to be tested
  27510. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27511. **/
  27512. static HasSpecificTrigger(trigger: number): boolean;
  27513. }
  27514. }
  27515. declare module "babylonjs/node" {
  27516. import { Scene } from "babylonjs/scene";
  27517. import { Nullable } from "babylonjs/types";
  27518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27519. import { Engine } from "babylonjs/Engines/engine";
  27520. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27521. import { Observable } from "babylonjs/Misc/observable";
  27522. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27523. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27524. import { Animatable } from "babylonjs/Animations/animatable";
  27525. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27526. import { Animation } from "babylonjs/Animations/animation";
  27527. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27529. /**
  27530. * Defines how a node can be built from a string name.
  27531. */
  27532. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27533. /**
  27534. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27535. */
  27536. export class Node implements IBehaviorAware<Node> {
  27537. /** @hidden */
  27538. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27539. private static _NodeConstructors;
  27540. /**
  27541. * Add a new node constructor
  27542. * @param type defines the type name of the node to construct
  27543. * @param constructorFunc defines the constructor function
  27544. */
  27545. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27546. /**
  27547. * Returns a node constructor based on type name
  27548. * @param type defines the type name
  27549. * @param name defines the new node name
  27550. * @param scene defines the hosting scene
  27551. * @param options defines optional options to transmit to constructors
  27552. * @returns the new constructor or null
  27553. */
  27554. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27555. /**
  27556. * Gets or sets the name of the node
  27557. */
  27558. name: string;
  27559. /**
  27560. * Gets or sets the id of the node
  27561. */
  27562. id: string;
  27563. /**
  27564. * Gets or sets the unique id of the node
  27565. */
  27566. uniqueId: number;
  27567. /**
  27568. * Gets or sets a string used to store user defined state for the node
  27569. */
  27570. state: string;
  27571. /**
  27572. * Gets or sets an object used to store user defined information for the node
  27573. */
  27574. metadata: any;
  27575. /**
  27576. * For internal use only. Please do not use.
  27577. */
  27578. reservedDataStore: any;
  27579. /**
  27580. * List of inspectable custom properties (used by the Inspector)
  27581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27582. */
  27583. inspectableCustomProperties: IInspectable[];
  27584. private _doNotSerialize;
  27585. /**
  27586. * Gets or sets a boolean used to define if the node must be serialized
  27587. */
  27588. doNotSerialize: boolean;
  27589. /** @hidden */
  27590. _isDisposed: boolean;
  27591. /**
  27592. * Gets a list of Animations associated with the node
  27593. */
  27594. animations: import("babylonjs/Animations/animation").Animation[];
  27595. protected _ranges: {
  27596. [name: string]: Nullable<AnimationRange>;
  27597. };
  27598. /**
  27599. * Callback raised when the node is ready to be used
  27600. */
  27601. onReady: Nullable<(node: Node) => void>;
  27602. private _isEnabled;
  27603. private _isParentEnabled;
  27604. private _isReady;
  27605. /** @hidden */
  27606. _currentRenderId: number;
  27607. private _parentUpdateId;
  27608. /** @hidden */
  27609. _childUpdateId: number;
  27610. /** @hidden */
  27611. _waitingParentId: Nullable<string>;
  27612. /** @hidden */
  27613. _scene: Scene;
  27614. /** @hidden */
  27615. _cache: any;
  27616. private _parentNode;
  27617. private _children;
  27618. /** @hidden */
  27619. _worldMatrix: Matrix;
  27620. /** @hidden */
  27621. _worldMatrixDeterminant: number;
  27622. /** @hidden */
  27623. _worldMatrixDeterminantIsDirty: boolean;
  27624. /** @hidden */
  27625. private _sceneRootNodesIndex;
  27626. /**
  27627. * Gets a boolean indicating if the node has been disposed
  27628. * @returns true if the node was disposed
  27629. */
  27630. isDisposed(): boolean;
  27631. /**
  27632. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27633. * @see https://doc.babylonjs.com/how_to/parenting
  27634. */
  27635. parent: Nullable<Node>;
  27636. private addToSceneRootNodes;
  27637. private removeFromSceneRootNodes;
  27638. private _animationPropertiesOverride;
  27639. /**
  27640. * Gets or sets the animation properties override
  27641. */
  27642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27643. /**
  27644. * Gets a string idenfifying the name of the class
  27645. * @returns "Node" string
  27646. */
  27647. getClassName(): string;
  27648. /** @hidden */
  27649. readonly _isNode: boolean;
  27650. /**
  27651. * An event triggered when the mesh is disposed
  27652. */
  27653. onDisposeObservable: Observable<Node>;
  27654. private _onDisposeObserver;
  27655. /**
  27656. * Sets a callback that will be raised when the node will be disposed
  27657. */
  27658. onDispose: () => void;
  27659. /**
  27660. * Creates a new Node
  27661. * @param name the name and id to be given to this node
  27662. * @param scene the scene this node will be added to
  27663. * @param addToRootNodes the node will be added to scene.rootNodes
  27664. */
  27665. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27666. /**
  27667. * Gets the scene of the node
  27668. * @returns a scene
  27669. */
  27670. getScene(): Scene;
  27671. /**
  27672. * Gets the engine of the node
  27673. * @returns a Engine
  27674. */
  27675. getEngine(): Engine;
  27676. private _behaviors;
  27677. /**
  27678. * Attach a behavior to the node
  27679. * @see http://doc.babylonjs.com/features/behaviour
  27680. * @param behavior defines the behavior to attach
  27681. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27682. * @returns the current Node
  27683. */
  27684. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27685. /**
  27686. * Remove an attached behavior
  27687. * @see http://doc.babylonjs.com/features/behaviour
  27688. * @param behavior defines the behavior to attach
  27689. * @returns the current Node
  27690. */
  27691. removeBehavior(behavior: Behavior<Node>): Node;
  27692. /**
  27693. * Gets the list of attached behaviors
  27694. * @see http://doc.babylonjs.com/features/behaviour
  27695. */
  27696. readonly behaviors: Behavior<Node>[];
  27697. /**
  27698. * Gets an attached behavior by name
  27699. * @param name defines the name of the behavior to look for
  27700. * @see http://doc.babylonjs.com/features/behaviour
  27701. * @returns null if behavior was not found else the requested behavior
  27702. */
  27703. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27704. /**
  27705. * Returns the latest update of the World matrix
  27706. * @returns a Matrix
  27707. */
  27708. getWorldMatrix(): Matrix;
  27709. /** @hidden */
  27710. _getWorldMatrixDeterminant(): number;
  27711. /**
  27712. * Returns directly the latest state of the mesh World matrix.
  27713. * A Matrix is returned.
  27714. */
  27715. readonly worldMatrixFromCache: Matrix;
  27716. /** @hidden */
  27717. _initCache(): void;
  27718. /** @hidden */
  27719. updateCache(force?: boolean): void;
  27720. /** @hidden */
  27721. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27722. /** @hidden */
  27723. _updateCache(ignoreParentClass?: boolean): void;
  27724. /** @hidden */
  27725. _isSynchronized(): boolean;
  27726. /** @hidden */
  27727. _markSyncedWithParent(): void;
  27728. /** @hidden */
  27729. isSynchronizedWithParent(): boolean;
  27730. /** @hidden */
  27731. isSynchronized(): boolean;
  27732. /**
  27733. * Is this node ready to be used/rendered
  27734. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27735. * @return true if the node is ready
  27736. */
  27737. isReady(completeCheck?: boolean): boolean;
  27738. /**
  27739. * Is this node enabled?
  27740. * 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
  27741. * @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
  27742. * @return whether this node (and its parent) is enabled
  27743. */
  27744. isEnabled(checkAncestors?: boolean): boolean;
  27745. /** @hidden */
  27746. protected _syncParentEnabledState(): void;
  27747. /**
  27748. * Set the enabled state of this node
  27749. * @param value defines the new enabled state
  27750. */
  27751. setEnabled(value: boolean): void;
  27752. /**
  27753. * Is this node a descendant of the given node?
  27754. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27755. * @param ancestor defines the parent node to inspect
  27756. * @returns a boolean indicating if this node is a descendant of the given node
  27757. */
  27758. isDescendantOf(ancestor: Node): boolean;
  27759. /** @hidden */
  27760. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27761. /**
  27762. * Will return all nodes that have this node as ascendant
  27763. * @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
  27764. * @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
  27765. * @return all children nodes of all types
  27766. */
  27767. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27768. /**
  27769. * Get all child-meshes of this node
  27770. * @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)
  27771. * @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
  27772. * @returns an array of AbstractMesh
  27773. */
  27774. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27775. /**
  27776. * Get all direct children of this node
  27777. * @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
  27778. * @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)
  27779. * @returns an array of Node
  27780. */
  27781. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27782. /** @hidden */
  27783. _setReady(state: boolean): void;
  27784. /**
  27785. * Get an animation by name
  27786. * @param name defines the name of the animation to look for
  27787. * @returns null if not found else the requested animation
  27788. */
  27789. getAnimationByName(name: string): Nullable<Animation>;
  27790. /**
  27791. * Creates an animation range for this node
  27792. * @param name defines the name of the range
  27793. * @param from defines the starting key
  27794. * @param to defines the end key
  27795. */
  27796. createAnimationRange(name: string, from: number, to: number): void;
  27797. /**
  27798. * Delete a specific animation range
  27799. * @param name defines the name of the range to delete
  27800. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27801. */
  27802. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27803. /**
  27804. * Get an animation range by name
  27805. * @param name defines the name of the animation range to look for
  27806. * @returns null if not found else the requested animation range
  27807. */
  27808. getAnimationRange(name: string): Nullable<AnimationRange>;
  27809. /**
  27810. * Gets the list of all animation ranges defined on this node
  27811. * @returns an array
  27812. */
  27813. getAnimationRanges(): Nullable<AnimationRange>[];
  27814. /**
  27815. * Will start the animation sequence
  27816. * @param name defines the range frames for animation sequence
  27817. * @param loop defines if the animation should loop (false by default)
  27818. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27819. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27820. * @returns the object created for this animation. If range does not exist, it will return null
  27821. */
  27822. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27823. /**
  27824. * Serialize animation ranges into a JSON compatible object
  27825. * @returns serialization object
  27826. */
  27827. serializeAnimationRanges(): any;
  27828. /**
  27829. * Computes the world matrix of the node
  27830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27831. * @returns the world matrix
  27832. */
  27833. computeWorldMatrix(force?: boolean): Matrix;
  27834. /**
  27835. * Releases resources associated with this node.
  27836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27838. */
  27839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27840. /**
  27841. * Parse animation range data from a serialization object and store them into a given node
  27842. * @param node defines where to store the animation ranges
  27843. * @param parsedNode defines the serialization object to read data from
  27844. * @param scene defines the hosting scene
  27845. */
  27846. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27847. /**
  27848. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27849. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27850. * @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
  27851. * @returns the new bounding vectors
  27852. */
  27853. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27854. min: Vector3;
  27855. max: Vector3;
  27856. };
  27857. }
  27858. }
  27859. declare module "babylonjs/Animations/animation" {
  27860. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27861. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27862. import { Color3 } from "babylonjs/Maths/math.color";
  27863. import { Nullable } from "babylonjs/types";
  27864. import { Scene } from "babylonjs/scene";
  27865. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27866. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27867. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27868. import { Node } from "babylonjs/node";
  27869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27870. import { Size } from "babylonjs/Maths/math.size";
  27871. import { Animatable } from "babylonjs/Animations/animatable";
  27872. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27873. /**
  27874. * @hidden
  27875. */
  27876. export class _IAnimationState {
  27877. key: number;
  27878. repeatCount: number;
  27879. workValue?: any;
  27880. loopMode?: number;
  27881. offsetValue?: any;
  27882. highLimitValue?: any;
  27883. }
  27884. /**
  27885. * Class used to store any kind of animation
  27886. */
  27887. export class Animation {
  27888. /**Name of the animation */
  27889. name: string;
  27890. /**Property to animate */
  27891. targetProperty: string;
  27892. /**The frames per second of the animation */
  27893. framePerSecond: number;
  27894. /**The data type of the animation */
  27895. dataType: number;
  27896. /**The loop mode of the animation */
  27897. loopMode?: number | undefined;
  27898. /**Specifies if blending should be enabled */
  27899. enableBlending?: boolean | undefined;
  27900. /**
  27901. * Use matrix interpolation instead of using direct key value when animating matrices
  27902. */
  27903. static AllowMatricesInterpolation: boolean;
  27904. /**
  27905. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27906. */
  27907. static AllowMatrixDecomposeForInterpolation: boolean;
  27908. /**
  27909. * Stores the key frames of the animation
  27910. */
  27911. private _keys;
  27912. /**
  27913. * Stores the easing function of the animation
  27914. */
  27915. private _easingFunction;
  27916. /**
  27917. * @hidden Internal use only
  27918. */
  27919. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27920. /**
  27921. * The set of event that will be linked to this animation
  27922. */
  27923. private _events;
  27924. /**
  27925. * Stores an array of target property paths
  27926. */
  27927. targetPropertyPath: string[];
  27928. /**
  27929. * Stores the blending speed of the animation
  27930. */
  27931. blendingSpeed: number;
  27932. /**
  27933. * Stores the animation ranges for the animation
  27934. */
  27935. private _ranges;
  27936. /**
  27937. * @hidden Internal use
  27938. */
  27939. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27940. /**
  27941. * Sets up an animation
  27942. * @param property The property to animate
  27943. * @param animationType The animation type to apply
  27944. * @param framePerSecond The frames per second of the animation
  27945. * @param easingFunction The easing function used in the animation
  27946. * @returns The created animation
  27947. */
  27948. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27949. /**
  27950. * Create and start an animation on a node
  27951. * @param name defines the name of the global animation that will be run on all nodes
  27952. * @param node defines the root node where the animation will take place
  27953. * @param targetProperty defines property to animate
  27954. * @param framePerSecond defines the number of frame per second yo use
  27955. * @param totalFrame defines the number of frames in total
  27956. * @param from defines the initial value
  27957. * @param to defines the final value
  27958. * @param loopMode defines which loop mode you want to use (off by default)
  27959. * @param easingFunction defines the easing function to use (linear by default)
  27960. * @param onAnimationEnd defines the callback to call when animation end
  27961. * @returns the animatable created for this animation
  27962. */
  27963. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27964. /**
  27965. * Create and start an animation on a node and its descendants
  27966. * @param name defines the name of the global animation that will be run on all nodes
  27967. * @param node defines the root node where the animation will take place
  27968. * @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
  27969. * @param targetProperty defines property to animate
  27970. * @param framePerSecond defines the number of frame per second to use
  27971. * @param totalFrame defines the number of frames in total
  27972. * @param from defines the initial value
  27973. * @param to defines the final value
  27974. * @param loopMode defines which loop mode you want to use (off by default)
  27975. * @param easingFunction defines the easing function to use (linear by default)
  27976. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27977. * @returns the list of animatables created for all nodes
  27978. * @example https://www.babylonjs-playground.com/#MH0VLI
  27979. */
  27980. 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[]>;
  27981. /**
  27982. * Creates a new animation, merges it with the existing animations and starts it
  27983. * @param name Name of the animation
  27984. * @param node Node which contains the scene that begins the animations
  27985. * @param targetProperty Specifies which property to animate
  27986. * @param framePerSecond The frames per second of the animation
  27987. * @param totalFrame The total number of frames
  27988. * @param from The frame at the beginning of the animation
  27989. * @param to The frame at the end of the animation
  27990. * @param loopMode Specifies the loop mode of the animation
  27991. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27992. * @param onAnimationEnd Callback to run once the animation is complete
  27993. * @returns Nullable animation
  27994. */
  27995. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27996. /**
  27997. * Transition property of an host to the target Value
  27998. * @param property The property to transition
  27999. * @param targetValue The target Value of the property
  28000. * @param host The object where the property to animate belongs
  28001. * @param scene Scene used to run the animation
  28002. * @param frameRate Framerate (in frame/s) to use
  28003. * @param transition The transition type we want to use
  28004. * @param duration The duration of the animation, in milliseconds
  28005. * @param onAnimationEnd Callback trigger at the end of the animation
  28006. * @returns Nullable animation
  28007. */
  28008. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28009. /**
  28010. * Return the array of runtime animations currently using this animation
  28011. */
  28012. readonly runtimeAnimations: RuntimeAnimation[];
  28013. /**
  28014. * Specifies if any of the runtime animations are currently running
  28015. */
  28016. readonly hasRunningRuntimeAnimations: boolean;
  28017. /**
  28018. * Initializes the animation
  28019. * @param name Name of the animation
  28020. * @param targetProperty Property to animate
  28021. * @param framePerSecond The frames per second of the animation
  28022. * @param dataType The data type of the animation
  28023. * @param loopMode The loop mode of the animation
  28024. * @param enableBlending Specifies if blending should be enabled
  28025. */
  28026. constructor(
  28027. /**Name of the animation */
  28028. name: string,
  28029. /**Property to animate */
  28030. targetProperty: string,
  28031. /**The frames per second of the animation */
  28032. framePerSecond: number,
  28033. /**The data type of the animation */
  28034. dataType: number,
  28035. /**The loop mode of the animation */
  28036. loopMode?: number | undefined,
  28037. /**Specifies if blending should be enabled */
  28038. enableBlending?: boolean | undefined);
  28039. /**
  28040. * Converts the animation to a string
  28041. * @param fullDetails support for multiple levels of logging within scene loading
  28042. * @returns String form of the animation
  28043. */
  28044. toString(fullDetails?: boolean): string;
  28045. /**
  28046. * Add an event to this animation
  28047. * @param event Event to add
  28048. */
  28049. addEvent(event: AnimationEvent): void;
  28050. /**
  28051. * Remove all events found at the given frame
  28052. * @param frame The frame to remove events from
  28053. */
  28054. removeEvents(frame: number): void;
  28055. /**
  28056. * Retrieves all the events from the animation
  28057. * @returns Events from the animation
  28058. */
  28059. getEvents(): AnimationEvent[];
  28060. /**
  28061. * Creates an animation range
  28062. * @param name Name of the animation range
  28063. * @param from Starting frame of the animation range
  28064. * @param to Ending frame of the animation
  28065. */
  28066. createRange(name: string, from: number, to: number): void;
  28067. /**
  28068. * Deletes an animation range by name
  28069. * @param name Name of the animation range to delete
  28070. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28071. */
  28072. deleteRange(name: string, deleteFrames?: boolean): void;
  28073. /**
  28074. * Gets the animation range by name, or null if not defined
  28075. * @param name Name of the animation range
  28076. * @returns Nullable animation range
  28077. */
  28078. getRange(name: string): Nullable<AnimationRange>;
  28079. /**
  28080. * Gets the key frames from the animation
  28081. * @returns The key frames of the animation
  28082. */
  28083. getKeys(): Array<IAnimationKey>;
  28084. /**
  28085. * Gets the highest frame rate of the animation
  28086. * @returns Highest frame rate of the animation
  28087. */
  28088. getHighestFrame(): number;
  28089. /**
  28090. * Gets the easing function of the animation
  28091. * @returns Easing function of the animation
  28092. */
  28093. getEasingFunction(): IEasingFunction;
  28094. /**
  28095. * Sets the easing function of the animation
  28096. * @param easingFunction A custom mathematical formula for animation
  28097. */
  28098. setEasingFunction(easingFunction: EasingFunction): void;
  28099. /**
  28100. * Interpolates a scalar linearly
  28101. * @param startValue Start value of the animation curve
  28102. * @param endValue End value of the animation curve
  28103. * @param gradient Scalar amount to interpolate
  28104. * @returns Interpolated scalar value
  28105. */
  28106. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28107. /**
  28108. * Interpolates a scalar cubically
  28109. * @param startValue Start value of the animation curve
  28110. * @param outTangent End tangent of the animation
  28111. * @param endValue End value of the animation curve
  28112. * @param inTangent Start tangent of the animation curve
  28113. * @param gradient Scalar amount to interpolate
  28114. * @returns Interpolated scalar value
  28115. */
  28116. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28117. /**
  28118. * Interpolates a quaternion using a spherical linear interpolation
  28119. * @param startValue Start value of the animation curve
  28120. * @param endValue End value of the animation curve
  28121. * @param gradient Scalar amount to interpolate
  28122. * @returns Interpolated quaternion value
  28123. */
  28124. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28125. /**
  28126. * Interpolates a quaternion cubically
  28127. * @param startValue Start value of the animation curve
  28128. * @param outTangent End tangent of the animation curve
  28129. * @param endValue End value of the animation curve
  28130. * @param inTangent Start tangent of the animation curve
  28131. * @param gradient Scalar amount to interpolate
  28132. * @returns Interpolated quaternion value
  28133. */
  28134. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28135. /**
  28136. * Interpolates a Vector3 linearl
  28137. * @param startValue Start value of the animation curve
  28138. * @param endValue End value of the animation curve
  28139. * @param gradient Scalar amount to interpolate
  28140. * @returns Interpolated scalar value
  28141. */
  28142. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28143. /**
  28144. * Interpolates a Vector3 cubically
  28145. * @param startValue Start value of the animation curve
  28146. * @param outTangent End tangent of the animation
  28147. * @param endValue End value of the animation curve
  28148. * @param inTangent Start tangent of the animation curve
  28149. * @param gradient Scalar amount to interpolate
  28150. * @returns InterpolatedVector3 value
  28151. */
  28152. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28153. /**
  28154. * Interpolates a Vector2 linearly
  28155. * @param startValue Start value of the animation curve
  28156. * @param endValue End value of the animation curve
  28157. * @param gradient Scalar amount to interpolate
  28158. * @returns Interpolated Vector2 value
  28159. */
  28160. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28161. /**
  28162. * Interpolates a Vector2 cubically
  28163. * @param startValue Start value of the animation curve
  28164. * @param outTangent End tangent of the animation
  28165. * @param endValue End value of the animation curve
  28166. * @param inTangent Start tangent of the animation curve
  28167. * @param gradient Scalar amount to interpolate
  28168. * @returns Interpolated Vector2 value
  28169. */
  28170. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28171. /**
  28172. * Interpolates a size linearly
  28173. * @param startValue Start value of the animation curve
  28174. * @param endValue End value of the animation curve
  28175. * @param gradient Scalar amount to interpolate
  28176. * @returns Interpolated Size value
  28177. */
  28178. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28179. /**
  28180. * Interpolates a Color3 linearly
  28181. * @param startValue Start value of the animation curve
  28182. * @param endValue End value of the animation curve
  28183. * @param gradient Scalar amount to interpolate
  28184. * @returns Interpolated Color3 value
  28185. */
  28186. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28187. /**
  28188. * @hidden Internal use only
  28189. */
  28190. _getKeyValue(value: any): any;
  28191. /**
  28192. * @hidden Internal use only
  28193. */
  28194. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28195. /**
  28196. * Defines the function to use to interpolate matrices
  28197. * @param startValue defines the start matrix
  28198. * @param endValue defines the end matrix
  28199. * @param gradient defines the gradient between both matrices
  28200. * @param result defines an optional target matrix where to store the interpolation
  28201. * @returns the interpolated matrix
  28202. */
  28203. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28204. /**
  28205. * Makes a copy of the animation
  28206. * @returns Cloned animation
  28207. */
  28208. clone(): Animation;
  28209. /**
  28210. * Sets the key frames of the animation
  28211. * @param values The animation key frames to set
  28212. */
  28213. setKeys(values: Array<IAnimationKey>): void;
  28214. /**
  28215. * Serializes the animation to an object
  28216. * @returns Serialized object
  28217. */
  28218. serialize(): any;
  28219. /**
  28220. * Float animation type
  28221. */
  28222. private static _ANIMATIONTYPE_FLOAT;
  28223. /**
  28224. * Vector3 animation type
  28225. */
  28226. private static _ANIMATIONTYPE_VECTOR3;
  28227. /**
  28228. * Quaternion animation type
  28229. */
  28230. private static _ANIMATIONTYPE_QUATERNION;
  28231. /**
  28232. * Matrix animation type
  28233. */
  28234. private static _ANIMATIONTYPE_MATRIX;
  28235. /**
  28236. * Color3 animation type
  28237. */
  28238. private static _ANIMATIONTYPE_COLOR3;
  28239. /**
  28240. * Vector2 animation type
  28241. */
  28242. private static _ANIMATIONTYPE_VECTOR2;
  28243. /**
  28244. * Size animation type
  28245. */
  28246. private static _ANIMATIONTYPE_SIZE;
  28247. /**
  28248. * Relative Loop Mode
  28249. */
  28250. private static _ANIMATIONLOOPMODE_RELATIVE;
  28251. /**
  28252. * Cycle Loop Mode
  28253. */
  28254. private static _ANIMATIONLOOPMODE_CYCLE;
  28255. /**
  28256. * Constant Loop Mode
  28257. */
  28258. private static _ANIMATIONLOOPMODE_CONSTANT;
  28259. /**
  28260. * Get the float animation type
  28261. */
  28262. static readonly ANIMATIONTYPE_FLOAT: number;
  28263. /**
  28264. * Get the Vector3 animation type
  28265. */
  28266. static readonly ANIMATIONTYPE_VECTOR3: number;
  28267. /**
  28268. * Get the Vector2 animation type
  28269. */
  28270. static readonly ANIMATIONTYPE_VECTOR2: number;
  28271. /**
  28272. * Get the Size animation type
  28273. */
  28274. static readonly ANIMATIONTYPE_SIZE: number;
  28275. /**
  28276. * Get the Quaternion animation type
  28277. */
  28278. static readonly ANIMATIONTYPE_QUATERNION: number;
  28279. /**
  28280. * Get the Matrix animation type
  28281. */
  28282. static readonly ANIMATIONTYPE_MATRIX: number;
  28283. /**
  28284. * Get the Color3 animation type
  28285. */
  28286. static readonly ANIMATIONTYPE_COLOR3: number;
  28287. /**
  28288. * Get the Relative Loop Mode
  28289. */
  28290. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28291. /**
  28292. * Get the Cycle Loop Mode
  28293. */
  28294. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28295. /**
  28296. * Get the Constant Loop Mode
  28297. */
  28298. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28299. /** @hidden */
  28300. static _UniversalLerp(left: any, right: any, amount: number): any;
  28301. /**
  28302. * Parses an animation object and creates an animation
  28303. * @param parsedAnimation Parsed animation object
  28304. * @returns Animation object
  28305. */
  28306. static Parse(parsedAnimation: any): Animation;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. }
  28314. }
  28315. declare module "babylonjs/Animations/animatable.interface" {
  28316. import { Nullable } from "babylonjs/types";
  28317. import { Animation } from "babylonjs/Animations/animation";
  28318. /**
  28319. * Interface containing an array of animations
  28320. */
  28321. export interface IAnimatable {
  28322. /**
  28323. * Array of animations
  28324. */
  28325. animations: Nullable<Array<Animation>>;
  28326. }
  28327. }
  28328. declare module "babylonjs/Materials/fresnelParameters" {
  28329. import { Color3 } from "babylonjs/Maths/math.color";
  28330. /**
  28331. * This represents all the required information to add a fresnel effect on a material:
  28332. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28333. */
  28334. export class FresnelParameters {
  28335. private _isEnabled;
  28336. /**
  28337. * Define if the fresnel effect is enable or not.
  28338. */
  28339. isEnabled: boolean;
  28340. /**
  28341. * Define the color used on edges (grazing angle)
  28342. */
  28343. leftColor: Color3;
  28344. /**
  28345. * Define the color used on center
  28346. */
  28347. rightColor: Color3;
  28348. /**
  28349. * Define bias applied to computed fresnel term
  28350. */
  28351. bias: number;
  28352. /**
  28353. * Defined the power exponent applied to fresnel term
  28354. */
  28355. power: number;
  28356. /**
  28357. * Clones the current fresnel and its valuues
  28358. * @returns a clone fresnel configuration
  28359. */
  28360. clone(): FresnelParameters;
  28361. /**
  28362. * Serializes the current fresnel parameters to a JSON representation.
  28363. * @return the JSON serialization
  28364. */
  28365. serialize(): any;
  28366. /**
  28367. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28368. * @param parsedFresnelParameters Define the JSON representation
  28369. * @returns the parsed parameters
  28370. */
  28371. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28372. }
  28373. }
  28374. declare module "babylonjs/Misc/decorators" {
  28375. import { Nullable } from "babylonjs/types";
  28376. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28377. import { Scene } from "babylonjs/scene";
  28378. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28379. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28380. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28381. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28382. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28383. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28384. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28385. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28386. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28387. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28388. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28389. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28390. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28391. /**
  28392. * Decorator used to define property that can be serialized as reference to a camera
  28393. * @param sourceName defines the name of the property to decorate
  28394. */
  28395. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28396. /**
  28397. * Class used to help serialization objects
  28398. */
  28399. export class SerializationHelper {
  28400. /** @hidden */
  28401. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28402. /** @hidden */
  28403. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28404. /** @hidden */
  28405. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28406. /** @hidden */
  28407. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28408. /**
  28409. * Appends the serialized animations from the source animations
  28410. * @param source Source containing the animations
  28411. * @param destination Target to store the animations
  28412. */
  28413. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28414. /**
  28415. * Static function used to serialized a specific entity
  28416. * @param entity defines the entity to serialize
  28417. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28418. * @returns a JSON compatible object representing the serialization of the entity
  28419. */
  28420. static Serialize<T>(entity: T, serializationObject?: any): any;
  28421. /**
  28422. * Creates a new entity from a serialization data object
  28423. * @param creationFunction defines a function used to instanciated the new entity
  28424. * @param source defines the source serialization data
  28425. * @param scene defines the hosting scene
  28426. * @param rootUrl defines the root url for resources
  28427. * @returns a new entity
  28428. */
  28429. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28430. /**
  28431. * Clones an object
  28432. * @param creationFunction defines the function used to instanciate the new object
  28433. * @param source defines the source object
  28434. * @returns the cloned object
  28435. */
  28436. static Clone<T>(creationFunction: () => T, source: T): T;
  28437. /**
  28438. * Instanciates a new object based on a source one (some data will be shared between both object)
  28439. * @param creationFunction defines the function used to instanciate the new object
  28440. * @param source defines the source object
  28441. * @returns the new object
  28442. */
  28443. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28444. }
  28445. }
  28446. declare module "babylonjs/Misc/guid" {
  28447. /**
  28448. * Class used to manipulate GUIDs
  28449. */
  28450. export class GUID {
  28451. /**
  28452. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28453. * Be aware Math.random() could cause collisions, but:
  28454. * "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"
  28455. * @returns a pseudo random id
  28456. */
  28457. static RandomId(): string;
  28458. }
  28459. }
  28460. declare module "babylonjs/Materials/Textures/baseTexture" {
  28461. import { Observable } from "babylonjs/Misc/observable";
  28462. import { Nullable } from "babylonjs/types";
  28463. import { Scene } from "babylonjs/scene";
  28464. import { Matrix } from "babylonjs/Maths/math.vector";
  28465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28467. import { ISize } from "babylonjs/Maths/math.size";
  28468. /**
  28469. * Base class of all the textures in babylon.
  28470. * It groups all the common properties the materials, post process, lights... might need
  28471. * in order to make a correct use of the texture.
  28472. */
  28473. export class BaseTexture implements IAnimatable {
  28474. /**
  28475. * Default anisotropic filtering level for the application.
  28476. * It is set to 4 as a good tradeoff between perf and quality.
  28477. */
  28478. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28479. /**
  28480. * Gets or sets the unique id of the texture
  28481. */
  28482. uniqueId: number;
  28483. /**
  28484. * Define the name of the texture.
  28485. */
  28486. name: string;
  28487. /**
  28488. * Gets or sets an object used to store user defined information.
  28489. */
  28490. metadata: any;
  28491. /**
  28492. * For internal use only. Please do not use.
  28493. */
  28494. reservedDataStore: any;
  28495. private _hasAlpha;
  28496. /**
  28497. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28498. */
  28499. hasAlpha: boolean;
  28500. /**
  28501. * Defines if the alpha value should be determined via the rgb values.
  28502. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28503. */
  28504. getAlphaFromRGB: boolean;
  28505. /**
  28506. * Intensity or strength of the texture.
  28507. * It is commonly used by materials to fine tune the intensity of the texture
  28508. */
  28509. level: number;
  28510. /**
  28511. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28512. * This is part of the texture as textures usually maps to one uv set.
  28513. */
  28514. coordinatesIndex: number;
  28515. private _coordinatesMode;
  28516. /**
  28517. * How a texture is mapped.
  28518. *
  28519. * | Value | Type | Description |
  28520. * | ----- | ----------------------------------- | ----------- |
  28521. * | 0 | EXPLICIT_MODE | |
  28522. * | 1 | SPHERICAL_MODE | |
  28523. * | 2 | PLANAR_MODE | |
  28524. * | 3 | CUBIC_MODE | |
  28525. * | 4 | PROJECTION_MODE | |
  28526. * | 5 | SKYBOX_MODE | |
  28527. * | 6 | INVCUBIC_MODE | |
  28528. * | 7 | EQUIRECTANGULAR_MODE | |
  28529. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28530. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28531. */
  28532. coordinatesMode: number;
  28533. /**
  28534. * | Value | Type | Description |
  28535. * | ----- | ------------------ | ----------- |
  28536. * | 0 | CLAMP_ADDRESSMODE | |
  28537. * | 1 | WRAP_ADDRESSMODE | |
  28538. * | 2 | MIRROR_ADDRESSMODE | |
  28539. */
  28540. wrapU: number;
  28541. /**
  28542. * | Value | Type | Description |
  28543. * | ----- | ------------------ | ----------- |
  28544. * | 0 | CLAMP_ADDRESSMODE | |
  28545. * | 1 | WRAP_ADDRESSMODE | |
  28546. * | 2 | MIRROR_ADDRESSMODE | |
  28547. */
  28548. wrapV: number;
  28549. /**
  28550. * | Value | Type | Description |
  28551. * | ----- | ------------------ | ----------- |
  28552. * | 0 | CLAMP_ADDRESSMODE | |
  28553. * | 1 | WRAP_ADDRESSMODE | |
  28554. * | 2 | MIRROR_ADDRESSMODE | |
  28555. */
  28556. wrapR: number;
  28557. /**
  28558. * With compliant hardware and browser (supporting anisotropic filtering)
  28559. * this defines the level of anisotropic filtering in the texture.
  28560. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28561. */
  28562. anisotropicFilteringLevel: number;
  28563. /**
  28564. * Define if the texture is a cube texture or if false a 2d texture.
  28565. */
  28566. isCube: boolean;
  28567. /**
  28568. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28569. */
  28570. is3D: boolean;
  28571. /**
  28572. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28573. * HDR texture are usually stored in linear space.
  28574. * This only impacts the PBR and Background materials
  28575. */
  28576. gammaSpace: boolean;
  28577. /**
  28578. * Gets or sets whether or not the texture contains RGBD data.
  28579. */
  28580. isRGBD: boolean;
  28581. /**
  28582. * Is Z inverted in the texture (useful in a cube texture).
  28583. */
  28584. invertZ: boolean;
  28585. /**
  28586. * Are mip maps generated for this texture or not.
  28587. */
  28588. readonly noMipmap: boolean;
  28589. /**
  28590. * @hidden
  28591. */
  28592. lodLevelInAlpha: boolean;
  28593. /**
  28594. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28595. */
  28596. lodGenerationOffset: number;
  28597. /**
  28598. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28599. */
  28600. lodGenerationScale: number;
  28601. /**
  28602. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28603. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28604. * average roughness values.
  28605. */
  28606. linearSpecularLOD: boolean;
  28607. /**
  28608. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28609. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28610. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28611. */
  28612. irradianceTexture: Nullable<BaseTexture>;
  28613. /**
  28614. * Define if the texture is a render target.
  28615. */
  28616. isRenderTarget: boolean;
  28617. /**
  28618. * Define the unique id of the texture in the scene.
  28619. */
  28620. readonly uid: string;
  28621. /**
  28622. * Return a string representation of the texture.
  28623. * @returns the texture as a string
  28624. */
  28625. toString(): string;
  28626. /**
  28627. * Get the class name of the texture.
  28628. * @returns "BaseTexture"
  28629. */
  28630. getClassName(): string;
  28631. /**
  28632. * Define the list of animation attached to the texture.
  28633. */
  28634. animations: import("babylonjs/Animations/animation").Animation[];
  28635. /**
  28636. * An event triggered when the texture is disposed.
  28637. */
  28638. onDisposeObservable: Observable<BaseTexture>;
  28639. private _onDisposeObserver;
  28640. /**
  28641. * Callback triggered when the texture has been disposed.
  28642. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28643. */
  28644. onDispose: () => void;
  28645. /**
  28646. * Define the current state of the loading sequence when in delayed load mode.
  28647. */
  28648. delayLoadState: number;
  28649. private _scene;
  28650. /** @hidden */
  28651. _texture: Nullable<InternalTexture>;
  28652. private _uid;
  28653. /**
  28654. * Define if the texture is preventinga material to render or not.
  28655. * If not and the texture is not ready, the engine will use a default black texture instead.
  28656. */
  28657. readonly isBlocking: boolean;
  28658. /**
  28659. * Instantiates a new BaseTexture.
  28660. * Base class of all the textures in babylon.
  28661. * It groups all the common properties the materials, post process, lights... might need
  28662. * in order to make a correct use of the texture.
  28663. * @param scene Define the scene the texture blongs to
  28664. */
  28665. constructor(scene: Nullable<Scene>);
  28666. /**
  28667. * Get the scene the texture belongs to.
  28668. * @returns the scene or null if undefined
  28669. */
  28670. getScene(): Nullable<Scene>;
  28671. /**
  28672. * Get the texture transform matrix used to offset tile the texture for istance.
  28673. * @returns the transformation matrix
  28674. */
  28675. getTextureMatrix(): Matrix;
  28676. /**
  28677. * Get the texture reflection matrix used to rotate/transform the reflection.
  28678. * @returns the reflection matrix
  28679. */
  28680. getReflectionTextureMatrix(): Matrix;
  28681. /**
  28682. * Get the underlying lower level texture from Babylon.
  28683. * @returns the insternal texture
  28684. */
  28685. getInternalTexture(): Nullable<InternalTexture>;
  28686. /**
  28687. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28688. * @returns true if ready or not blocking
  28689. */
  28690. isReadyOrNotBlocking(): boolean;
  28691. /**
  28692. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28693. * @returns true if fully ready
  28694. */
  28695. isReady(): boolean;
  28696. private _cachedSize;
  28697. /**
  28698. * Get the size of the texture.
  28699. * @returns the texture size.
  28700. */
  28701. getSize(): ISize;
  28702. /**
  28703. * Get the base size of the texture.
  28704. * It can be different from the size if the texture has been resized for POT for instance
  28705. * @returns the base size
  28706. */
  28707. getBaseSize(): ISize;
  28708. /**
  28709. * Update the sampling mode of the texture.
  28710. * Default is Trilinear mode.
  28711. *
  28712. * | Value | Type | Description |
  28713. * | ----- | ------------------ | ----------- |
  28714. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28715. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28716. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28717. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28718. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28719. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28720. * | 7 | NEAREST_LINEAR | |
  28721. * | 8 | NEAREST_NEAREST | |
  28722. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28723. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28724. * | 11 | LINEAR_LINEAR | |
  28725. * | 12 | LINEAR_NEAREST | |
  28726. *
  28727. * > _mag_: magnification filter (close to the viewer)
  28728. * > _min_: minification filter (far from the viewer)
  28729. * > _mip_: filter used between mip map levels
  28730. *@param samplingMode Define the new sampling mode of the texture
  28731. */
  28732. updateSamplingMode(samplingMode: number): void;
  28733. /**
  28734. * Scales the texture if is `canRescale()`
  28735. * @param ratio the resize factor we want to use to rescale
  28736. */
  28737. scale(ratio: number): void;
  28738. /**
  28739. * Get if the texture can rescale.
  28740. */
  28741. readonly canRescale: boolean;
  28742. /** @hidden */
  28743. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28744. /** @hidden */
  28745. _rebuild(): void;
  28746. /**
  28747. * Triggers the load sequence in delayed load mode.
  28748. */
  28749. delayLoad(): void;
  28750. /**
  28751. * Clones the texture.
  28752. * @returns the cloned texture
  28753. */
  28754. clone(): Nullable<BaseTexture>;
  28755. /**
  28756. * Get the texture underlying type (INT, FLOAT...)
  28757. */
  28758. readonly textureType: number;
  28759. /**
  28760. * Get the texture underlying format (RGB, RGBA...)
  28761. */
  28762. readonly textureFormat: number;
  28763. /**
  28764. * Indicates that textures need to be re-calculated for all materials
  28765. */
  28766. protected _markAllSubMeshesAsTexturesDirty(): void;
  28767. /**
  28768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28769. * This will returns an RGBA array buffer containing either in values (0-255) or
  28770. * float values (0-1) depending of the underlying buffer type.
  28771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28773. * @param buffer defines a user defined buffer to fill with data (can be null)
  28774. * @returns The Array buffer containing the pixels data.
  28775. */
  28776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28777. /**
  28778. * Release and destroy the underlying lower level texture aka internalTexture.
  28779. */
  28780. releaseInternalTexture(): void;
  28781. /** @hidden */
  28782. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28783. /** @hidden */
  28784. readonly _lodTextureMid: Nullable<BaseTexture>;
  28785. /** @hidden */
  28786. readonly _lodTextureLow: Nullable<BaseTexture>;
  28787. /**
  28788. * Dispose the texture and release its associated resources.
  28789. */
  28790. dispose(): void;
  28791. /**
  28792. * Serialize the texture into a JSON representation that can be parsed later on.
  28793. * @returns the JSON representation of the texture
  28794. */
  28795. serialize(): any;
  28796. /**
  28797. * Helper function to be called back once a list of texture contains only ready textures.
  28798. * @param textures Define the list of textures to wait for
  28799. * @param callback Define the callback triggered once the entire list will be ready
  28800. */
  28801. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28802. }
  28803. }
  28804. declare module "babylonjs/Materials/effect" {
  28805. import { Observable } from "babylonjs/Misc/observable";
  28806. import { Nullable } from "babylonjs/types";
  28807. import { IDisposable } from "babylonjs/scene";
  28808. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28809. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28810. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28811. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28812. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28813. import { Engine } from "babylonjs/Engines/engine";
  28814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28818. /**
  28819. * Options to be used when creating an effect.
  28820. */
  28821. export interface IEffectCreationOptions {
  28822. /**
  28823. * Atrributes that will be used in the shader.
  28824. */
  28825. attributes: string[];
  28826. /**
  28827. * Uniform varible names that will be set in the shader.
  28828. */
  28829. uniformsNames: string[];
  28830. /**
  28831. * Uniform buffer varible names that will be set in the shader.
  28832. */
  28833. uniformBuffersNames: string[];
  28834. /**
  28835. * Sampler texture variable names that will be set in the shader.
  28836. */
  28837. samplers: string[];
  28838. /**
  28839. * Define statements that will be set in the shader.
  28840. */
  28841. defines: any;
  28842. /**
  28843. * Possible fallbacks for this effect to improve performance when needed.
  28844. */
  28845. fallbacks: Nullable<IEffectFallbacks>;
  28846. /**
  28847. * Callback that will be called when the shader is compiled.
  28848. */
  28849. onCompiled: Nullable<(effect: Effect) => void>;
  28850. /**
  28851. * Callback that will be called if an error occurs during shader compilation.
  28852. */
  28853. onError: Nullable<(effect: Effect, errors: string) => void>;
  28854. /**
  28855. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28856. */
  28857. indexParameters?: any;
  28858. /**
  28859. * Max number of lights that can be used in the shader.
  28860. */
  28861. maxSimultaneousLights?: number;
  28862. /**
  28863. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28864. */
  28865. transformFeedbackVaryings?: Nullable<string[]>;
  28866. }
  28867. /**
  28868. * Effect containing vertex and fragment shader that can be executed on an object.
  28869. */
  28870. export class Effect implements IDisposable {
  28871. /**
  28872. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28873. */
  28874. static ShadersRepository: string;
  28875. /**
  28876. * Name of the effect.
  28877. */
  28878. name: any;
  28879. /**
  28880. * String container all the define statements that should be set on the shader.
  28881. */
  28882. defines: string;
  28883. /**
  28884. * Callback that will be called when the shader is compiled.
  28885. */
  28886. onCompiled: Nullable<(effect: Effect) => void>;
  28887. /**
  28888. * Callback that will be called if an error occurs during shader compilation.
  28889. */
  28890. onError: Nullable<(effect: Effect, errors: string) => void>;
  28891. /**
  28892. * Callback that will be called when effect is bound.
  28893. */
  28894. onBind: Nullable<(effect: Effect) => void>;
  28895. /**
  28896. * Unique ID of the effect.
  28897. */
  28898. uniqueId: number;
  28899. /**
  28900. * Observable that will be called when the shader is compiled.
  28901. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28902. */
  28903. onCompileObservable: Observable<Effect>;
  28904. /**
  28905. * Observable that will be called if an error occurs during shader compilation.
  28906. */
  28907. onErrorObservable: Observable<Effect>;
  28908. /** @hidden */
  28909. _onBindObservable: Nullable<Observable<Effect>>;
  28910. /**
  28911. * Observable that will be called when effect is bound.
  28912. */
  28913. readonly onBindObservable: Observable<Effect>;
  28914. /** @hidden */
  28915. _bonesComputationForcedToCPU: boolean;
  28916. private static _uniqueIdSeed;
  28917. private _engine;
  28918. private _uniformBuffersNames;
  28919. private _uniformsNames;
  28920. private _samplerList;
  28921. private _samplers;
  28922. private _isReady;
  28923. private _compilationError;
  28924. private _allFallbacksProcessed;
  28925. private _attributesNames;
  28926. private _attributes;
  28927. private _uniforms;
  28928. /**
  28929. * Key for the effect.
  28930. * @hidden
  28931. */
  28932. _key: string;
  28933. private _indexParameters;
  28934. private _fallbacks;
  28935. private _vertexSourceCode;
  28936. private _fragmentSourceCode;
  28937. private _vertexSourceCodeOverride;
  28938. private _fragmentSourceCodeOverride;
  28939. private _transformFeedbackVaryings;
  28940. /**
  28941. * Compiled shader to webGL program.
  28942. * @hidden
  28943. */
  28944. _pipelineContext: Nullable<IPipelineContext>;
  28945. private _valueCache;
  28946. private static _baseCache;
  28947. /**
  28948. * Instantiates an effect.
  28949. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28950. * @param baseName Name of the effect.
  28951. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28952. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28953. * @param samplers List of sampler variables that will be passed to the shader.
  28954. * @param engine Engine to be used to render the effect
  28955. * @param defines Define statements to be added to the shader.
  28956. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28957. * @param onCompiled Callback that will be called when the shader is compiled.
  28958. * @param onError Callback that will be called if an error occurs during shader compilation.
  28959. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28960. */
  28961. 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);
  28962. private _useFinalCode;
  28963. /**
  28964. * Unique key for this effect
  28965. */
  28966. readonly key: string;
  28967. /**
  28968. * If the effect has been compiled and prepared.
  28969. * @returns if the effect is compiled and prepared.
  28970. */
  28971. isReady(): boolean;
  28972. private _isReadyInternal;
  28973. /**
  28974. * The engine the effect was initialized with.
  28975. * @returns the engine.
  28976. */
  28977. getEngine(): Engine;
  28978. /**
  28979. * The pipeline context for this effect
  28980. * @returns the associated pipeline context
  28981. */
  28982. getPipelineContext(): Nullable<IPipelineContext>;
  28983. /**
  28984. * The set of names of attribute variables for the shader.
  28985. * @returns An array of attribute names.
  28986. */
  28987. getAttributesNames(): string[];
  28988. /**
  28989. * Returns the attribute at the given index.
  28990. * @param index The index of the attribute.
  28991. * @returns The location of the attribute.
  28992. */
  28993. getAttributeLocation(index: number): number;
  28994. /**
  28995. * Returns the attribute based on the name of the variable.
  28996. * @param name of the attribute to look up.
  28997. * @returns the attribute location.
  28998. */
  28999. getAttributeLocationByName(name: string): number;
  29000. /**
  29001. * The number of attributes.
  29002. * @returns the numnber of attributes.
  29003. */
  29004. getAttributesCount(): number;
  29005. /**
  29006. * Gets the index of a uniform variable.
  29007. * @param uniformName of the uniform to look up.
  29008. * @returns the index.
  29009. */
  29010. getUniformIndex(uniformName: string): number;
  29011. /**
  29012. * Returns the attribute based on the name of the variable.
  29013. * @param uniformName of the uniform to look up.
  29014. * @returns the location of the uniform.
  29015. */
  29016. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29017. /**
  29018. * Returns an array of sampler variable names
  29019. * @returns The array of sampler variable neames.
  29020. */
  29021. getSamplers(): string[];
  29022. /**
  29023. * The error from the last compilation.
  29024. * @returns the error string.
  29025. */
  29026. getCompilationError(): string;
  29027. /**
  29028. * Gets a boolean indicating that all fallbacks were used during compilation
  29029. * @returns true if all fallbacks were used
  29030. */
  29031. allFallbacksProcessed(): boolean;
  29032. /**
  29033. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29034. * @param func The callback to be used.
  29035. */
  29036. executeWhenCompiled(func: (effect: Effect) => void): void;
  29037. private _checkIsReady;
  29038. private _loadShader;
  29039. /**
  29040. * Recompiles the webGL program
  29041. * @param vertexSourceCode The source code for the vertex shader.
  29042. * @param fragmentSourceCode The source code for the fragment shader.
  29043. * @param onCompiled Callback called when completed.
  29044. * @param onError Callback called on error.
  29045. * @hidden
  29046. */
  29047. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29048. /**
  29049. * Prepares the effect
  29050. * @hidden
  29051. */
  29052. _prepareEffect(): void;
  29053. private _processCompilationErrors;
  29054. /**
  29055. * Checks if the effect is supported. (Must be called after compilation)
  29056. */
  29057. readonly isSupported: boolean;
  29058. /**
  29059. * Binds a texture to the engine to be used as output of the shader.
  29060. * @param channel Name of the output variable.
  29061. * @param texture Texture to bind.
  29062. * @hidden
  29063. */
  29064. _bindTexture(channel: string, texture: InternalTexture): void;
  29065. /**
  29066. * Sets a texture on the engine to be used in the shader.
  29067. * @param channel Name of the sampler variable.
  29068. * @param texture Texture to set.
  29069. */
  29070. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29071. /**
  29072. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29073. * @param channel Name of the sampler variable.
  29074. * @param texture Texture to set.
  29075. */
  29076. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29077. /**
  29078. * Sets an array of textures on the engine to be used in the shader.
  29079. * @param channel Name of the variable.
  29080. * @param textures Textures to set.
  29081. */
  29082. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29083. /**
  29084. * 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)
  29085. * @param channel Name of the sampler variable.
  29086. * @param postProcess Post process to get the input texture from.
  29087. */
  29088. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29089. /**
  29090. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29091. * 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)
  29092. * @param channel Name of the sampler variable.
  29093. * @param postProcess Post process to get the output texture from.
  29094. */
  29095. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29096. /** @hidden */
  29097. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29098. /** @hidden */
  29099. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29100. /** @hidden */
  29101. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29102. /** @hidden */
  29103. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29104. /**
  29105. * Binds a buffer to a uniform.
  29106. * @param buffer Buffer to bind.
  29107. * @param name Name of the uniform variable to bind to.
  29108. */
  29109. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29110. /**
  29111. * Binds block to a uniform.
  29112. * @param blockName Name of the block to bind.
  29113. * @param index Index to bind.
  29114. */
  29115. bindUniformBlock(blockName: string, index: number): void;
  29116. /**
  29117. * Sets an interger value on a uniform variable.
  29118. * @param uniformName Name of the variable.
  29119. * @param value Value to be set.
  29120. * @returns this effect.
  29121. */
  29122. setInt(uniformName: string, value: number): Effect;
  29123. /**
  29124. * Sets an int array on a uniform variable.
  29125. * @param uniformName Name of the variable.
  29126. * @param array array to be set.
  29127. * @returns this effect.
  29128. */
  29129. setIntArray(uniformName: string, array: Int32Array): Effect;
  29130. /**
  29131. * 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)
  29132. * @param uniformName Name of the variable.
  29133. * @param array array to be set.
  29134. * @returns this effect.
  29135. */
  29136. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29137. /**
  29138. * 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)
  29139. * @param uniformName Name of the variable.
  29140. * @param array array to be set.
  29141. * @returns this effect.
  29142. */
  29143. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29144. /**
  29145. * 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)
  29146. * @param uniformName Name of the variable.
  29147. * @param array array to be set.
  29148. * @returns this effect.
  29149. */
  29150. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29151. /**
  29152. * Sets an float array on a uniform variable.
  29153. * @param uniformName Name of the variable.
  29154. * @param array array to be set.
  29155. * @returns this effect.
  29156. */
  29157. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29158. /**
  29159. * 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)
  29160. * @param uniformName Name of the variable.
  29161. * @param array array to be set.
  29162. * @returns this effect.
  29163. */
  29164. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29165. /**
  29166. * 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)
  29167. * @param uniformName Name of the variable.
  29168. * @param array array to be set.
  29169. * @returns this effect.
  29170. */
  29171. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29172. /**
  29173. * 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)
  29174. * @param uniformName Name of the variable.
  29175. * @param array array to be set.
  29176. * @returns this effect.
  29177. */
  29178. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29179. /**
  29180. * Sets an array on a uniform variable.
  29181. * @param uniformName Name of the variable.
  29182. * @param array array to be set.
  29183. * @returns this effect.
  29184. */
  29185. setArray(uniformName: string, array: number[]): Effect;
  29186. /**
  29187. * 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)
  29188. * @param uniformName Name of the variable.
  29189. * @param array array to be set.
  29190. * @returns this effect.
  29191. */
  29192. setArray2(uniformName: string, array: number[]): Effect;
  29193. /**
  29194. * 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)
  29195. * @param uniformName Name of the variable.
  29196. * @param array array to be set.
  29197. * @returns this effect.
  29198. */
  29199. setArray3(uniformName: string, array: number[]): Effect;
  29200. /**
  29201. * 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)
  29202. * @param uniformName Name of the variable.
  29203. * @param array array to be set.
  29204. * @returns this effect.
  29205. */
  29206. setArray4(uniformName: string, array: number[]): Effect;
  29207. /**
  29208. * Sets matrices on a uniform variable.
  29209. * @param uniformName Name of the variable.
  29210. * @param matrices matrices to be set.
  29211. * @returns this effect.
  29212. */
  29213. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29214. /**
  29215. * Sets matrix on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param matrix matrix to be set.
  29218. * @returns this effect.
  29219. */
  29220. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29221. /**
  29222. * 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)
  29223. * @param uniformName Name of the variable.
  29224. * @param matrix matrix to be set.
  29225. * @returns this effect.
  29226. */
  29227. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29228. /**
  29229. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29230. * @param uniformName Name of the variable.
  29231. * @param matrix matrix to be set.
  29232. * @returns this effect.
  29233. */
  29234. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29235. /**
  29236. * Sets a float on a uniform variable.
  29237. * @param uniformName Name of the variable.
  29238. * @param value value to be set.
  29239. * @returns this effect.
  29240. */
  29241. setFloat(uniformName: string, value: number): Effect;
  29242. /**
  29243. * Sets a boolean on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param bool value to be set.
  29246. * @returns this effect.
  29247. */
  29248. setBool(uniformName: string, bool: boolean): Effect;
  29249. /**
  29250. * Sets a Vector2 on a uniform variable.
  29251. * @param uniformName Name of the variable.
  29252. * @param vector2 vector2 to be set.
  29253. * @returns this effect.
  29254. */
  29255. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29256. /**
  29257. * Sets a float2 on a uniform variable.
  29258. * @param uniformName Name of the variable.
  29259. * @param x First float in float2.
  29260. * @param y Second float in float2.
  29261. * @returns this effect.
  29262. */
  29263. setFloat2(uniformName: string, x: number, y: number): Effect;
  29264. /**
  29265. * Sets a Vector3 on a uniform variable.
  29266. * @param uniformName Name of the variable.
  29267. * @param vector3 Value to be set.
  29268. * @returns this effect.
  29269. */
  29270. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29271. /**
  29272. * Sets a float3 on a uniform variable.
  29273. * @param uniformName Name of the variable.
  29274. * @param x First float in float3.
  29275. * @param y Second float in float3.
  29276. * @param z Third float in float3.
  29277. * @returns this effect.
  29278. */
  29279. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29280. /**
  29281. * Sets a Vector4 on a uniform variable.
  29282. * @param uniformName Name of the variable.
  29283. * @param vector4 Value to be set.
  29284. * @returns this effect.
  29285. */
  29286. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29287. /**
  29288. * Sets a float4 on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param x First float in float4.
  29291. * @param y Second float in float4.
  29292. * @param z Third float in float4.
  29293. * @param w Fourth float in float4.
  29294. * @returns this effect.
  29295. */
  29296. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29297. /**
  29298. * Sets a Color3 on a uniform variable.
  29299. * @param uniformName Name of the variable.
  29300. * @param color3 Value to be set.
  29301. * @returns this effect.
  29302. */
  29303. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29304. /**
  29305. * Sets a Color4 on a uniform variable.
  29306. * @param uniformName Name of the variable.
  29307. * @param color3 Value to be set.
  29308. * @param alpha Alpha value to be set.
  29309. * @returns this effect.
  29310. */
  29311. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29312. /**
  29313. * Sets a Color4 on a uniform variable
  29314. * @param uniformName defines the name of the variable
  29315. * @param color4 defines the value to be set
  29316. * @returns this effect.
  29317. */
  29318. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29319. /** Release all associated resources */
  29320. dispose(): void;
  29321. /**
  29322. * This function will add a new shader to the shader store
  29323. * @param name the name of the shader
  29324. * @param pixelShader optional pixel shader content
  29325. * @param vertexShader optional vertex shader content
  29326. */
  29327. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29328. /**
  29329. * Store of each shader (The can be looked up using effect.key)
  29330. */
  29331. static ShadersStore: {
  29332. [key: string]: string;
  29333. };
  29334. /**
  29335. * Store of each included file for a shader (The can be looked up using effect.key)
  29336. */
  29337. static IncludesShadersStore: {
  29338. [key: string]: string;
  29339. };
  29340. /**
  29341. * Resets the cache of effects.
  29342. */
  29343. static ResetCache(): void;
  29344. }
  29345. }
  29346. declare module "babylonjs/Engines/engineCapabilities" {
  29347. import { Nullable } from "babylonjs/types";
  29348. /**
  29349. * Class used to describe the capabilities of the engine relatively to the current browser
  29350. */
  29351. export class EngineCapabilities {
  29352. /** Maximum textures units per fragment shader */
  29353. maxTexturesImageUnits: number;
  29354. /** Maximum texture units per vertex shader */
  29355. maxVertexTextureImageUnits: number;
  29356. /** Maximum textures units in the entire pipeline */
  29357. maxCombinedTexturesImageUnits: number;
  29358. /** Maximum texture size */
  29359. maxTextureSize: number;
  29360. /** Maximum cube texture size */
  29361. maxCubemapTextureSize: number;
  29362. /** Maximum render texture size */
  29363. maxRenderTextureSize: number;
  29364. /** Maximum number of vertex attributes */
  29365. maxVertexAttribs: number;
  29366. /** Maximum number of varyings */
  29367. maxVaryingVectors: number;
  29368. /** Maximum number of uniforms per vertex shader */
  29369. maxVertexUniformVectors: number;
  29370. /** Maximum number of uniforms per fragment shader */
  29371. maxFragmentUniformVectors: number;
  29372. /** Defines if standard derivates (dx/dy) are supported */
  29373. standardDerivatives: boolean;
  29374. /** Defines if s3tc texture compression is supported */
  29375. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29376. /** Defines if pvrtc texture compression is supported */
  29377. pvrtc: any;
  29378. /** Defines if etc1 texture compression is supported */
  29379. etc1: any;
  29380. /** Defines if etc2 texture compression is supported */
  29381. etc2: any;
  29382. /** Defines if astc texture compression is supported */
  29383. astc: any;
  29384. /** Defines if float textures are supported */
  29385. textureFloat: boolean;
  29386. /** Defines if vertex array objects are supported */
  29387. vertexArrayObject: boolean;
  29388. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29389. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29390. /** Gets the maximum level of anisotropy supported */
  29391. maxAnisotropy: number;
  29392. /** Defines if instancing is supported */
  29393. instancedArrays: boolean;
  29394. /** Defines if 32 bits indices are supported */
  29395. uintIndices: boolean;
  29396. /** Defines if high precision shaders are supported */
  29397. highPrecisionShaderSupported: boolean;
  29398. /** Defines if depth reading in the fragment shader is supported */
  29399. fragmentDepthSupported: boolean;
  29400. /** Defines if float texture linear filtering is supported*/
  29401. textureFloatLinearFiltering: boolean;
  29402. /** Defines if rendering to float textures is supported */
  29403. textureFloatRender: boolean;
  29404. /** Defines if half float textures are supported*/
  29405. textureHalfFloat: boolean;
  29406. /** Defines if half float texture linear filtering is supported*/
  29407. textureHalfFloatLinearFiltering: boolean;
  29408. /** Defines if rendering to half float textures is supported */
  29409. textureHalfFloatRender: boolean;
  29410. /** Defines if textureLOD shader command is supported */
  29411. textureLOD: boolean;
  29412. /** Defines if draw buffers extension is supported */
  29413. drawBuffersExtension: boolean;
  29414. /** Defines if depth textures are supported */
  29415. depthTextureExtension: boolean;
  29416. /** Defines if float color buffer are supported */
  29417. colorBufferFloat: boolean;
  29418. /** Gets disjoint timer query extension (null if not supported) */
  29419. timerQuery: EXT_disjoint_timer_query;
  29420. /** Defines if timestamp can be used with timer query */
  29421. canUseTimestampForTimerQuery: boolean;
  29422. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29423. multiview: any;
  29424. /** Function used to let the system compiles shaders in background */
  29425. parallelShaderCompile: {
  29426. COMPLETION_STATUS_KHR: number;
  29427. };
  29428. /** Max number of texture samples for MSAA */
  29429. maxMSAASamples: number;
  29430. /** Defines if the blend min max extension is supported */
  29431. blendMinMax: boolean;
  29432. }
  29433. }
  29434. declare module "babylonjs/States/depthCullingState" {
  29435. import { Nullable } from "babylonjs/types";
  29436. /**
  29437. * @hidden
  29438. **/
  29439. export class DepthCullingState {
  29440. private _isDepthTestDirty;
  29441. private _isDepthMaskDirty;
  29442. private _isDepthFuncDirty;
  29443. private _isCullFaceDirty;
  29444. private _isCullDirty;
  29445. private _isZOffsetDirty;
  29446. private _isFrontFaceDirty;
  29447. private _depthTest;
  29448. private _depthMask;
  29449. private _depthFunc;
  29450. private _cull;
  29451. private _cullFace;
  29452. private _zOffset;
  29453. private _frontFace;
  29454. /**
  29455. * Initializes the state.
  29456. */
  29457. constructor();
  29458. readonly isDirty: boolean;
  29459. zOffset: number;
  29460. cullFace: Nullable<number>;
  29461. cull: Nullable<boolean>;
  29462. depthFunc: Nullable<number>;
  29463. depthMask: boolean;
  29464. depthTest: boolean;
  29465. frontFace: Nullable<number>;
  29466. reset(): void;
  29467. apply(gl: WebGLRenderingContext): void;
  29468. }
  29469. }
  29470. declare module "babylonjs/States/stencilState" {
  29471. /**
  29472. * @hidden
  29473. **/
  29474. export class StencilState {
  29475. /** 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 */
  29476. static readonly ALWAYS: number;
  29477. /** Passed to stencilOperation to specify that stencil value must be kept */
  29478. static readonly KEEP: number;
  29479. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29480. static readonly REPLACE: number;
  29481. private _isStencilTestDirty;
  29482. private _isStencilMaskDirty;
  29483. private _isStencilFuncDirty;
  29484. private _isStencilOpDirty;
  29485. private _stencilTest;
  29486. private _stencilMask;
  29487. private _stencilFunc;
  29488. private _stencilFuncRef;
  29489. private _stencilFuncMask;
  29490. private _stencilOpStencilFail;
  29491. private _stencilOpDepthFail;
  29492. private _stencilOpStencilDepthPass;
  29493. readonly isDirty: boolean;
  29494. stencilFunc: number;
  29495. stencilFuncRef: number;
  29496. stencilFuncMask: number;
  29497. stencilOpStencilFail: number;
  29498. stencilOpDepthFail: number;
  29499. stencilOpStencilDepthPass: number;
  29500. stencilMask: number;
  29501. stencilTest: boolean;
  29502. constructor();
  29503. reset(): void;
  29504. apply(gl: WebGLRenderingContext): void;
  29505. }
  29506. }
  29507. declare module "babylonjs/States/alphaCullingState" {
  29508. /**
  29509. * @hidden
  29510. **/
  29511. export class AlphaState {
  29512. private _isAlphaBlendDirty;
  29513. private _isBlendFunctionParametersDirty;
  29514. private _isBlendEquationParametersDirty;
  29515. private _isBlendConstantsDirty;
  29516. private _alphaBlend;
  29517. private _blendFunctionParameters;
  29518. private _blendEquationParameters;
  29519. private _blendConstants;
  29520. /**
  29521. * Initializes the state.
  29522. */
  29523. constructor();
  29524. readonly isDirty: boolean;
  29525. alphaBlend: boolean;
  29526. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29527. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29528. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29529. reset(): void;
  29530. apply(gl: WebGLRenderingContext): void;
  29531. }
  29532. }
  29533. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29534. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29535. /** @hidden */
  29536. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29537. attributeProcessor(attribute: string): string;
  29538. varyingProcessor(varying: string, isFragment: boolean): string;
  29539. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29540. }
  29541. }
  29542. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29543. /**
  29544. * Interface for attribute information associated with buffer instanciation
  29545. */
  29546. export class InstancingAttributeInfo {
  29547. /**
  29548. * Index/offset of the attribute in the vertex shader
  29549. */
  29550. index: number;
  29551. /**
  29552. * size of the attribute, 1, 2, 3 or 4
  29553. */
  29554. attributeSize: number;
  29555. /**
  29556. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29557. * default is FLOAT
  29558. */
  29559. attribyteType: number;
  29560. /**
  29561. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29562. */
  29563. normalized: boolean;
  29564. /**
  29565. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29566. */
  29567. offset: number;
  29568. /**
  29569. * Name of the GLSL attribute, for debugging purpose only
  29570. */
  29571. attributeName: string;
  29572. }
  29573. }
  29574. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29575. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29576. import { Nullable } from "babylonjs/types";
  29577. module "babylonjs/Engines/thinEngine" {
  29578. interface ThinEngine {
  29579. /**
  29580. * Update a video texture
  29581. * @param texture defines the texture to update
  29582. * @param video defines the video element to use
  29583. * @param invertY defines if data must be stored with Y axis inverted
  29584. */
  29585. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29586. }
  29587. }
  29588. }
  29589. declare module "babylonjs/Materials/Textures/videoTexture" {
  29590. import { Observable } from "babylonjs/Misc/observable";
  29591. import { Nullable } from "babylonjs/types";
  29592. import { Scene } from "babylonjs/scene";
  29593. import { Texture } from "babylonjs/Materials/Textures/texture";
  29594. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29595. /**
  29596. * Settings for finer control over video usage
  29597. */
  29598. export interface VideoTextureSettings {
  29599. /**
  29600. * Applies `autoplay` to video, if specified
  29601. */
  29602. autoPlay?: boolean;
  29603. /**
  29604. * Applies `loop` to video, if specified
  29605. */
  29606. loop?: boolean;
  29607. /**
  29608. * Automatically updates internal texture from video at every frame in the render loop
  29609. */
  29610. autoUpdateTexture: boolean;
  29611. /**
  29612. * Image src displayed during the video loading or until the user interacts with the video.
  29613. */
  29614. poster?: string;
  29615. }
  29616. /**
  29617. * If you want to display a video in your scene, this is the special texture for that.
  29618. * This special texture works similar to other textures, with the exception of a few parameters.
  29619. * @see https://doc.babylonjs.com/how_to/video_texture
  29620. */
  29621. export class VideoTexture extends Texture {
  29622. /**
  29623. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29624. */
  29625. readonly autoUpdateTexture: boolean;
  29626. /**
  29627. * The video instance used by the texture internally
  29628. */
  29629. readonly video: HTMLVideoElement;
  29630. private _onUserActionRequestedObservable;
  29631. /**
  29632. * Event triggerd when a dom action is required by the user to play the video.
  29633. * This happens due to recent changes in browser policies preventing video to auto start.
  29634. */
  29635. readonly onUserActionRequestedObservable: Observable<Texture>;
  29636. private _generateMipMaps;
  29637. private _engine;
  29638. private _stillImageCaptured;
  29639. private _displayingPosterTexture;
  29640. private _settings;
  29641. private _createInternalTextureOnEvent;
  29642. private _frameId;
  29643. /**
  29644. * Creates a video texture.
  29645. * If you want to display a video in your scene, this is the special texture for that.
  29646. * This special texture works similar to other textures, with the exception of a few parameters.
  29647. * @see https://doc.babylonjs.com/how_to/video_texture
  29648. * @param name optional name, will detect from video source, if not defined
  29649. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29650. * @param scene is obviously the current scene.
  29651. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29652. * @param invertY is false by default but can be used to invert video on Y axis
  29653. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29654. * @param settings allows finer control over video usage
  29655. */
  29656. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29657. private _getName;
  29658. private _getVideo;
  29659. private _createInternalTexture;
  29660. private reset;
  29661. /**
  29662. * @hidden Internal method to initiate `update`.
  29663. */
  29664. _rebuild(): void;
  29665. /**
  29666. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29667. */
  29668. update(): void;
  29669. /**
  29670. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29671. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29672. */
  29673. updateTexture(isVisible: boolean): void;
  29674. protected _updateInternalTexture: () => void;
  29675. /**
  29676. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29677. * @param url New url.
  29678. */
  29679. updateURL(url: string): void;
  29680. /**
  29681. * Dispose the texture and release its associated resources.
  29682. */
  29683. dispose(): void;
  29684. /**
  29685. * Creates a video texture straight from a stream.
  29686. * @param scene Define the scene the texture should be created in
  29687. * @param stream Define the stream the texture should be created from
  29688. * @returns The created video texture as a promise
  29689. */
  29690. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29691. /**
  29692. * Creates a video texture straight from your WebCam video feed.
  29693. * @param scene Define the scene the texture should be created in
  29694. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29695. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29696. * @returns The created video texture as a promise
  29697. */
  29698. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29699. minWidth: number;
  29700. maxWidth: number;
  29701. minHeight: number;
  29702. maxHeight: number;
  29703. deviceId: string;
  29704. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29705. /**
  29706. * Creates a video texture straight from your WebCam video feed.
  29707. * @param scene Define the scene the texture should be created in
  29708. * @param onReady Define a callback to triggered once the texture will be ready
  29709. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29710. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29711. */
  29712. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29713. minWidth: number;
  29714. maxWidth: number;
  29715. minHeight: number;
  29716. maxHeight: number;
  29717. deviceId: string;
  29718. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29719. }
  29720. }
  29721. declare module "babylonjs/Engines/thinEngine" {
  29722. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29723. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29724. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29725. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29726. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29727. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29728. import { Observable } from "babylonjs/Misc/observable";
  29729. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29730. import { StencilState } from "babylonjs/States/stencilState";
  29731. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29733. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29734. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29736. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29737. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29738. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29739. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29740. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29742. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29743. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29744. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29745. /**
  29746. * Defines the interface used by objects working like Scene
  29747. * @hidden
  29748. */
  29749. interface ISceneLike {
  29750. _addPendingData(data: any): void;
  29751. _removePendingData(data: any): void;
  29752. offlineProvider: IOfflineProvider;
  29753. }
  29754. /** Interface defining initialization parameters for Engine class */
  29755. export interface EngineOptions extends WebGLContextAttributes {
  29756. /**
  29757. * Defines if the engine should no exceed a specified device ratio
  29758. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29759. */
  29760. limitDeviceRatio?: number;
  29761. /**
  29762. * Defines if webvr should be enabled automatically
  29763. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29764. */
  29765. autoEnableWebVR?: boolean;
  29766. /**
  29767. * Defines if webgl2 should be turned off even if supported
  29768. * @see http://doc.babylonjs.com/features/webgl2
  29769. */
  29770. disableWebGL2Support?: boolean;
  29771. /**
  29772. * Defines if webaudio should be initialized as well
  29773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29774. */
  29775. audioEngine?: boolean;
  29776. /**
  29777. * Defines if animations should run using a deterministic lock step
  29778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29779. */
  29780. deterministicLockstep?: boolean;
  29781. /** Defines the maximum steps to use with deterministic lock step mode */
  29782. lockstepMaxSteps?: number;
  29783. /**
  29784. * Defines that engine should ignore context lost events
  29785. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29786. */
  29787. doNotHandleContextLost?: boolean;
  29788. /**
  29789. * Defines that engine should ignore modifying touch action attribute and style
  29790. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29791. */
  29792. doNotHandleTouchAction?: boolean;
  29793. /**
  29794. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29795. */
  29796. useHighPrecisionFloats?: boolean;
  29797. }
  29798. /**
  29799. * The base engine class (root of all engines)
  29800. */
  29801. export class ThinEngine {
  29802. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29803. static ExceptionList: ({
  29804. key: string;
  29805. capture: string;
  29806. captureConstraint: number;
  29807. targets: string[];
  29808. } | {
  29809. key: string;
  29810. capture: null;
  29811. captureConstraint: null;
  29812. targets: string[];
  29813. })[];
  29814. /** @hidden */
  29815. static _TextureLoaders: IInternalTextureLoader[];
  29816. /**
  29817. * Returns the current npm package of the sdk
  29818. */
  29819. static readonly NpmPackage: string;
  29820. /**
  29821. * Returns the current version of the framework
  29822. */
  29823. static readonly Version: string;
  29824. /**
  29825. * Returns a string describing the current engine
  29826. */
  29827. readonly description: string;
  29828. /**
  29829. * Gets or sets the epsilon value used by collision engine
  29830. */
  29831. static CollisionsEpsilon: number;
  29832. /**
  29833. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29834. */
  29835. static ShadersRepository: string;
  29836. /** @hidden */
  29837. _shaderProcessor: IShaderProcessor;
  29838. /**
  29839. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29840. */
  29841. forcePOTTextures: boolean;
  29842. /**
  29843. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29844. */
  29845. isFullscreen: boolean;
  29846. /**
  29847. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29848. */
  29849. cullBackFaces: boolean;
  29850. /**
  29851. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29852. */
  29853. renderEvenInBackground: boolean;
  29854. /**
  29855. * Gets or sets a boolean indicating that cache can be kept between frames
  29856. */
  29857. preventCacheWipeBetweenFrames: boolean;
  29858. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29859. validateShaderPrograms: boolean;
  29860. /**
  29861. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29862. */
  29863. disableUniformBuffers: boolean;
  29864. /** @hidden */
  29865. _uniformBuffers: UniformBuffer[];
  29866. /**
  29867. * Gets a boolean indicating that the engine supports uniform buffers
  29868. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29869. */
  29870. readonly supportsUniformBuffers: boolean;
  29871. /** @hidden */
  29872. _gl: WebGLRenderingContext;
  29873. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29874. protected _windowIsBackground: boolean;
  29875. protected _webGLVersion: number;
  29876. protected _highPrecisionShadersAllowed: boolean;
  29877. /** @hidden */
  29878. readonly _shouldUseHighPrecisionShader: boolean;
  29879. /**
  29880. * Gets a boolean indicating that only power of 2 textures are supported
  29881. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29882. */
  29883. readonly needPOTTextures: boolean;
  29884. /** @hidden */
  29885. _badOS: boolean;
  29886. /** @hidden */
  29887. _badDesktopOS: boolean;
  29888. private _hardwareScalingLevel;
  29889. /** @hidden */
  29890. _caps: EngineCapabilities;
  29891. private _isStencilEnable;
  29892. protected _colorWrite: boolean;
  29893. private _glVersion;
  29894. private _glRenderer;
  29895. private _glVendor;
  29896. /** @hidden */
  29897. _videoTextureSupported: boolean;
  29898. protected _renderingQueueLaunched: boolean;
  29899. protected _activeRenderLoops: (() => void)[];
  29900. /**
  29901. * Observable signaled when a context lost event is raised
  29902. */
  29903. onContextLostObservable: Observable<ThinEngine>;
  29904. /**
  29905. * Observable signaled when a context restored event is raised
  29906. */
  29907. onContextRestoredObservable: Observable<ThinEngine>;
  29908. private _onContextLost;
  29909. private _onContextRestored;
  29910. protected _contextWasLost: boolean;
  29911. /** @hidden */
  29912. _doNotHandleContextLost: boolean;
  29913. /**
  29914. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29916. */
  29917. doNotHandleContextLost: boolean;
  29918. /**
  29919. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29920. */
  29921. disableVertexArrayObjects: boolean;
  29922. /** @hidden */
  29923. protected _depthCullingState: DepthCullingState;
  29924. /** @hidden */
  29925. protected _stencilState: StencilState;
  29926. /** @hidden */
  29927. protected _alphaState: AlphaState;
  29928. /** @hidden */
  29929. _internalTexturesCache: InternalTexture[];
  29930. /** @hidden */
  29931. protected _activeChannel: number;
  29932. private _currentTextureChannel;
  29933. /** @hidden */
  29934. protected _boundTexturesCache: {
  29935. [key: string]: Nullable<InternalTexture>;
  29936. };
  29937. /** @hidden */
  29938. protected _currentEffect: Nullable<Effect>;
  29939. /** @hidden */
  29940. protected _currentProgram: Nullable<WebGLProgram>;
  29941. private _compiledEffects;
  29942. private _vertexAttribArraysEnabled;
  29943. /** @hidden */
  29944. protected _cachedViewport: Nullable<IViewportLike>;
  29945. private _cachedVertexArrayObject;
  29946. /** @hidden */
  29947. protected _cachedVertexBuffers: any;
  29948. /** @hidden */
  29949. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29950. /** @hidden */
  29951. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29952. /** @hidden */
  29953. _currentRenderTarget: Nullable<InternalTexture>;
  29954. private _uintIndicesCurrentlySet;
  29955. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29956. /** @hidden */
  29957. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29958. private _currentBufferPointers;
  29959. private _currentInstanceLocations;
  29960. private _currentInstanceBuffers;
  29961. private _textureUnits;
  29962. /** @hidden */
  29963. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29964. /** @hidden */
  29965. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29966. /** @hidden */
  29967. _bindedRenderFunction: any;
  29968. private _vaoRecordInProgress;
  29969. private _mustWipeVertexAttributes;
  29970. private _emptyTexture;
  29971. private _emptyCubeTexture;
  29972. private _emptyTexture3D;
  29973. /** @hidden */
  29974. _frameHandler: number;
  29975. private _nextFreeTextureSlots;
  29976. private _maxSimultaneousTextures;
  29977. private _activeRequests;
  29978. protected _texturesSupported: string[];
  29979. /** @hidden */
  29980. _textureFormatInUse: Nullable<string>;
  29981. protected readonly _supportsHardwareTextureRescaling: boolean;
  29982. /**
  29983. * Gets the list of texture formats supported
  29984. */
  29985. readonly texturesSupported: Array<string>;
  29986. /**
  29987. * Gets the list of texture formats in use
  29988. */
  29989. readonly textureFormatInUse: Nullable<string>;
  29990. /**
  29991. * Gets the current viewport
  29992. */
  29993. readonly currentViewport: Nullable<IViewportLike>;
  29994. /**
  29995. * Gets the default empty texture
  29996. */
  29997. readonly emptyTexture: InternalTexture;
  29998. /**
  29999. * Gets the default empty 3D texture
  30000. */
  30001. readonly emptyTexture3D: InternalTexture;
  30002. /**
  30003. * Gets the default empty cube texture
  30004. */
  30005. readonly emptyCubeTexture: InternalTexture;
  30006. /**
  30007. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30008. */
  30009. readonly premultipliedAlpha: boolean;
  30010. /**
  30011. * Observable event triggered before each texture is initialized
  30012. */
  30013. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30014. /**
  30015. * Creates a new engine
  30016. * @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
  30017. * @param antialias defines enable antialiasing (default: false)
  30018. * @param options defines further options to be sent to the getContext() function
  30019. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30020. */
  30021. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30022. private _rebuildInternalTextures;
  30023. private _rebuildEffects;
  30024. /**
  30025. * Gets a boolean indicating if all created effects are ready
  30026. * @returns true if all effects are ready
  30027. */
  30028. areAllEffectsReady(): boolean;
  30029. protected _rebuildBuffers(): void;
  30030. private _initGLContext;
  30031. /**
  30032. * Gets version of the current webGL context
  30033. */
  30034. readonly webGLVersion: number;
  30035. /**
  30036. * Gets a string idenfifying the name of the class
  30037. * @returns "Engine" string
  30038. */
  30039. getClassName(): string;
  30040. /**
  30041. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30042. */
  30043. readonly isStencilEnable: boolean;
  30044. /** @hidden */
  30045. _prepareWorkingCanvas(): void;
  30046. /**
  30047. * Reset the texture cache to empty state
  30048. */
  30049. resetTextureCache(): void;
  30050. /**
  30051. * Gets an object containing information about the current webGL context
  30052. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30053. */
  30054. getGlInfo(): {
  30055. vendor: string;
  30056. renderer: string;
  30057. version: string;
  30058. };
  30059. /**
  30060. * Defines the hardware scaling level.
  30061. * By default the hardware scaling level is computed from the window device ratio.
  30062. * 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.
  30063. * @param level defines the level to use
  30064. */
  30065. setHardwareScalingLevel(level: number): void;
  30066. /**
  30067. * Gets the current hardware scaling level.
  30068. * By default the hardware scaling level is computed from the window device ratio.
  30069. * 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.
  30070. * @returns a number indicating the current hardware scaling level
  30071. */
  30072. getHardwareScalingLevel(): number;
  30073. /**
  30074. * Gets the list of loaded textures
  30075. * @returns an array containing all loaded textures
  30076. */
  30077. getLoadedTexturesCache(): InternalTexture[];
  30078. /**
  30079. * Gets the object containing all engine capabilities
  30080. * @returns the EngineCapabilities object
  30081. */
  30082. getCaps(): EngineCapabilities;
  30083. /**
  30084. * stop executing a render loop function and remove it from the execution array
  30085. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30086. */
  30087. stopRenderLoop(renderFunction?: () => void): void;
  30088. /** @hidden */
  30089. _renderLoop(): void;
  30090. /**
  30091. * Gets the HTML canvas attached with the current webGL context
  30092. * @returns a HTML canvas
  30093. */
  30094. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30095. /**
  30096. * Gets host window
  30097. * @returns the host window object
  30098. */
  30099. getHostWindow(): Nullable<Window>;
  30100. /**
  30101. * Gets the current render width
  30102. * @param useScreen defines if screen size must be used (or the current render target if any)
  30103. * @returns a number defining the current render width
  30104. */
  30105. getRenderWidth(useScreen?: boolean): number;
  30106. /**
  30107. * Gets the current render height
  30108. * @param useScreen defines if screen size must be used (or the current render target if any)
  30109. * @returns a number defining the current render height
  30110. */
  30111. getRenderHeight(useScreen?: boolean): number;
  30112. /**
  30113. * Can be used to override the current requestAnimationFrame requester.
  30114. * @hidden
  30115. */
  30116. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30117. /**
  30118. * Register and execute a render loop. The engine can have more than one render function
  30119. * @param renderFunction defines the function to continuously execute
  30120. */
  30121. runRenderLoop(renderFunction: () => void): void;
  30122. /**
  30123. * Clear the current render buffer or the current render target (if any is set up)
  30124. * @param color defines the color to use
  30125. * @param backBuffer defines if the back buffer must be cleared
  30126. * @param depth defines if the depth buffer must be cleared
  30127. * @param stencil defines if the stencil buffer must be cleared
  30128. */
  30129. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30130. private _viewportCached;
  30131. /** @hidden */
  30132. _viewport(x: number, y: number, width: number, height: number): void;
  30133. /**
  30134. * Set the WebGL's viewport
  30135. * @param viewport defines the viewport element to be used
  30136. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30137. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30138. */
  30139. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30140. /**
  30141. * Begin a new frame
  30142. */
  30143. beginFrame(): void;
  30144. /**
  30145. * Enf the current frame
  30146. */
  30147. endFrame(): void;
  30148. /**
  30149. * Resize the view according to the canvas' size
  30150. */
  30151. resize(): void;
  30152. /**
  30153. * Force a specific size of the canvas
  30154. * @param width defines the new canvas' width
  30155. * @param height defines the new canvas' height
  30156. */
  30157. setSize(width: number, height: number): void;
  30158. /**
  30159. * Binds the frame buffer to the specified texture.
  30160. * @param texture The texture to render to or null for the default canvas
  30161. * @param faceIndex The face of the texture to render to in case of cube texture
  30162. * @param requiredWidth The width of the target to render to
  30163. * @param requiredHeight The height of the target to render to
  30164. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30165. * @param depthStencilTexture The depth stencil texture to use to render
  30166. * @param lodLevel defines le lod level to bind to the frame buffer
  30167. */
  30168. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30169. /** @hidden */
  30170. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30171. /**
  30172. * Unbind the current render target texture from the webGL context
  30173. * @param texture defines the render target texture to unbind
  30174. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30175. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30176. */
  30177. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30178. /**
  30179. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30180. */
  30181. flushFramebuffer(): void;
  30182. /**
  30183. * Unbind the current render target and bind the default framebuffer
  30184. */
  30185. restoreDefaultFramebuffer(): void;
  30186. private _resetVertexBufferBinding;
  30187. /**
  30188. * Creates a vertex buffer
  30189. * @param data the data for the vertex buffer
  30190. * @returns the new WebGL static buffer
  30191. */
  30192. createVertexBuffer(data: DataArray): DataBuffer;
  30193. private _createVertexBuffer;
  30194. /**
  30195. * Creates a dynamic vertex buffer
  30196. * @param data the data for the dynamic vertex buffer
  30197. * @returns the new WebGL dynamic buffer
  30198. */
  30199. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30200. /**
  30201. * Updates a dynamic vertex buffer.
  30202. * @param vertexBuffer the vertex buffer to update
  30203. * @param data the data used to update the vertex buffer
  30204. * @param byteOffset the byte offset of the data
  30205. * @param byteLength the byte length of the data
  30206. */
  30207. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30208. protected _resetIndexBufferBinding(): void;
  30209. /**
  30210. * Creates a new index buffer
  30211. * @param indices defines the content of the index buffer
  30212. * @param updatable defines if the index buffer must be updatable
  30213. * @returns a new webGL buffer
  30214. */
  30215. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30216. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30217. /**
  30218. * Bind a webGL buffer to the webGL context
  30219. * @param buffer defines the buffer to bind
  30220. */
  30221. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30222. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30223. private bindBuffer;
  30224. /**
  30225. * update the bound buffer with the given data
  30226. * @param data defines the data to update
  30227. */
  30228. updateArrayBuffer(data: Float32Array): void;
  30229. private _vertexAttribPointer;
  30230. private _bindIndexBufferWithCache;
  30231. private _bindVertexBuffersAttributes;
  30232. /**
  30233. * Records a vertex array object
  30234. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30235. * @param vertexBuffers defines the list of vertex buffers to store
  30236. * @param indexBuffer defines the index buffer to store
  30237. * @param effect defines the effect to store
  30238. * @returns the new vertex array object
  30239. */
  30240. recordVertexArrayObject(vertexBuffers: {
  30241. [key: string]: VertexBuffer;
  30242. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30243. /**
  30244. * Bind a specific vertex array object
  30245. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30246. * @param vertexArrayObject defines the vertex array object to bind
  30247. * @param indexBuffer defines the index buffer to bind
  30248. */
  30249. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30250. /**
  30251. * Bind webGl buffers directly to the webGL context
  30252. * @param vertexBuffer defines the vertex buffer to bind
  30253. * @param indexBuffer defines the index buffer to bind
  30254. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30255. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30256. * @param effect defines the effect associated with the vertex buffer
  30257. */
  30258. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30259. private _unbindVertexArrayObject;
  30260. /**
  30261. * Bind a list of vertex buffers to the webGL context
  30262. * @param vertexBuffers defines the list of vertex buffers to bind
  30263. * @param indexBuffer defines the index buffer to bind
  30264. * @param effect defines the effect associated with the vertex buffers
  30265. */
  30266. bindBuffers(vertexBuffers: {
  30267. [key: string]: Nullable<VertexBuffer>;
  30268. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30269. /**
  30270. * Unbind all instance attributes
  30271. */
  30272. unbindInstanceAttributes(): void;
  30273. /**
  30274. * Release and free the memory of a vertex array object
  30275. * @param vao defines the vertex array object to delete
  30276. */
  30277. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30278. /** @hidden */
  30279. _releaseBuffer(buffer: DataBuffer): boolean;
  30280. protected _deleteBuffer(buffer: DataBuffer): void;
  30281. /**
  30282. * Creates a webGL buffer to use with instanciation
  30283. * @param capacity defines the size of the buffer
  30284. * @returns the webGL buffer
  30285. */
  30286. createInstancesBuffer(capacity: number): DataBuffer;
  30287. /**
  30288. * Delete a webGL buffer used with instanciation
  30289. * @param buffer defines the webGL buffer to delete
  30290. */
  30291. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30292. /**
  30293. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30294. * @param instancesBuffer defines the webGL buffer to update and bind
  30295. * @param data defines the data to store in the buffer
  30296. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30297. */
  30298. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30299. /**
  30300. * Apply all cached states (depth, culling, stencil and alpha)
  30301. */
  30302. applyStates(): void;
  30303. /**
  30304. * Send a draw order
  30305. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30306. * @param indexStart defines the starting index
  30307. * @param indexCount defines the number of index to draw
  30308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30309. */
  30310. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30311. /**
  30312. * Draw a list of points
  30313. * @param verticesStart defines the index of first vertex to draw
  30314. * @param verticesCount defines the count of vertices to draw
  30315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30316. */
  30317. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30318. /**
  30319. * Draw a list of unindexed primitives
  30320. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30321. * @param verticesStart defines the index of first vertex to draw
  30322. * @param verticesCount defines the count of vertices to draw
  30323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30324. */
  30325. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30326. /**
  30327. * Draw a list of indexed primitives
  30328. * @param fillMode defines the primitive to use
  30329. * @param indexStart defines the starting index
  30330. * @param indexCount defines the number of index to draw
  30331. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30332. */
  30333. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30334. /**
  30335. * Draw a list of unindexed primitives
  30336. * @param fillMode defines the primitive to use
  30337. * @param verticesStart defines the index of first vertex to draw
  30338. * @param verticesCount defines the count of vertices to draw
  30339. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30340. */
  30341. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30342. private _drawMode;
  30343. /** @hidden */
  30344. protected _reportDrawCall(): void;
  30345. /** @hidden */
  30346. _releaseEffect(effect: Effect): void;
  30347. /** @hidden */
  30348. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30349. /**
  30350. * Create a new effect (used to store vertex/fragment shaders)
  30351. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30352. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30353. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30354. * @param samplers defines an array of string used to represent textures
  30355. * @param defines defines the string containing the defines to use to compile the shaders
  30356. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30357. * @param onCompiled defines a function to call when the effect creation is successful
  30358. * @param onError defines a function to call when the effect creation has failed
  30359. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30360. * @returns the new Effect
  30361. */
  30362. 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;
  30363. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30364. private _compileShader;
  30365. private _compileRawShader;
  30366. /**
  30367. * Directly creates a webGL program
  30368. * @param pipelineContext defines the pipeline context to attach to
  30369. * @param vertexCode defines the vertex shader code to use
  30370. * @param fragmentCode defines the fragment shader code to use
  30371. * @param context defines the webGL context to use (if not set, the current one will be used)
  30372. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30373. * @returns the new webGL program
  30374. */
  30375. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30376. /**
  30377. * Creates a webGL program
  30378. * @param pipelineContext defines the pipeline context to attach to
  30379. * @param vertexCode defines the vertex shader code to use
  30380. * @param fragmentCode defines the fragment shader code to use
  30381. * @param defines defines the string containing the defines to use to compile the shaders
  30382. * @param context defines the webGL context to use (if not set, the current one will be used)
  30383. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30384. * @returns the new webGL program
  30385. */
  30386. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30387. /**
  30388. * Creates a new pipeline context
  30389. * @returns the new pipeline
  30390. */
  30391. createPipelineContext(): IPipelineContext;
  30392. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30393. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30394. /** @hidden */
  30395. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30396. /** @hidden */
  30397. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30398. /** @hidden */
  30399. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30400. /**
  30401. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30402. * @param pipelineContext defines the pipeline context to use
  30403. * @param uniformsNames defines the list of uniform names
  30404. * @returns an array of webGL uniform locations
  30405. */
  30406. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30407. /**
  30408. * Gets the lsit of active attributes for a given webGL program
  30409. * @param pipelineContext defines the pipeline context to use
  30410. * @param attributesNames defines the list of attribute names to get
  30411. * @returns an array of indices indicating the offset of each attribute
  30412. */
  30413. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30414. /**
  30415. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30416. * @param effect defines the effect to activate
  30417. */
  30418. enableEffect(effect: Nullable<Effect>): void;
  30419. /**
  30420. * Set the value of an uniform to an array of int32
  30421. * @param uniform defines the webGL uniform location where to store the value
  30422. * @param array defines the array of int32 to store
  30423. */
  30424. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30425. /**
  30426. * Set the value of an uniform to an array of int32 (stored as vec2)
  30427. * @param uniform defines the webGL uniform location where to store the value
  30428. * @param array defines the array of int32 to store
  30429. */
  30430. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30431. /**
  30432. * Set the value of an uniform to an array of int32 (stored as vec3)
  30433. * @param uniform defines the webGL uniform location where to store the value
  30434. * @param array defines the array of int32 to store
  30435. */
  30436. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30437. /**
  30438. * Set the value of an uniform to an array of int32 (stored as vec4)
  30439. * @param uniform defines the webGL uniform location where to store the value
  30440. * @param array defines the array of int32 to store
  30441. */
  30442. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30443. /**
  30444. * Set the value of an uniform to an array of float32
  30445. * @param uniform defines the webGL uniform location where to store the value
  30446. * @param array defines the array of float32 to store
  30447. */
  30448. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30449. /**
  30450. * Set the value of an uniform to an array of float32 (stored as vec2)
  30451. * @param uniform defines the webGL uniform location where to store the value
  30452. * @param array defines the array of float32 to store
  30453. */
  30454. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30455. /**
  30456. * Set the value of an uniform to an array of float32 (stored as vec3)
  30457. * @param uniform defines the webGL uniform location where to store the value
  30458. * @param array defines the array of float32 to store
  30459. */
  30460. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30461. /**
  30462. * Set the value of an uniform to an array of float32 (stored as vec4)
  30463. * @param uniform defines the webGL uniform location where to store the value
  30464. * @param array defines the array of float32 to store
  30465. */
  30466. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30467. /**
  30468. * Set the value of an uniform to an array of number
  30469. * @param uniform defines the webGL uniform location where to store the value
  30470. * @param array defines the array of number to store
  30471. */
  30472. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30473. /**
  30474. * Set the value of an uniform to an array of number (stored as vec2)
  30475. * @param uniform defines the webGL uniform location where to store the value
  30476. * @param array defines the array of number to store
  30477. */
  30478. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30479. /**
  30480. * Set the value of an uniform to an array of number (stored as vec3)
  30481. * @param uniform defines the webGL uniform location where to store the value
  30482. * @param array defines the array of number to store
  30483. */
  30484. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30485. /**
  30486. * Set the value of an uniform to an array of number (stored as vec4)
  30487. * @param uniform defines the webGL uniform location where to store the value
  30488. * @param array defines the array of number to store
  30489. */
  30490. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30491. /**
  30492. * Set the value of an uniform to an array of float32 (stored as matrices)
  30493. * @param uniform defines the webGL uniform location where to store the value
  30494. * @param matrices defines the array of float32 to store
  30495. */
  30496. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30497. /**
  30498. * Set the value of an uniform to a matrix (3x3)
  30499. * @param uniform defines the webGL uniform location where to store the value
  30500. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30501. */
  30502. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30503. /**
  30504. * Set the value of an uniform to a matrix (2x2)
  30505. * @param uniform defines the webGL uniform location where to store the value
  30506. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30507. */
  30508. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30509. /**
  30510. * Set the value of an uniform to a number (int)
  30511. * @param uniform defines the webGL uniform location where to store the value
  30512. * @param value defines the int number to store
  30513. */
  30514. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30515. /**
  30516. * Set the value of an uniform to a number (float)
  30517. * @param uniform defines the webGL uniform location where to store the value
  30518. * @param value defines the float number to store
  30519. */
  30520. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30521. /**
  30522. * Set the value of an uniform to a vec2
  30523. * @param uniform defines the webGL uniform location where to store the value
  30524. * @param x defines the 1st component of the value
  30525. * @param y defines the 2nd component of the value
  30526. */
  30527. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30528. /**
  30529. * Set the value of an uniform to a vec3
  30530. * @param uniform defines the webGL uniform location where to store the value
  30531. * @param x defines the 1st component of the value
  30532. * @param y defines the 2nd component of the value
  30533. * @param z defines the 3rd component of the value
  30534. */
  30535. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30536. /**
  30537. * Set the value of an uniform to a boolean
  30538. * @param uniform defines the webGL uniform location where to store the value
  30539. * @param bool defines the boolean to store
  30540. */
  30541. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30542. /**
  30543. * Set the value of an uniform to a vec4
  30544. * @param uniform defines the webGL uniform location where to store the value
  30545. * @param x defines the 1st component of the value
  30546. * @param y defines the 2nd component of the value
  30547. * @param z defines the 3rd component of the value
  30548. * @param w defines the 4th component of the value
  30549. */
  30550. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30551. /**
  30552. * Sets a Color4 on a uniform variable
  30553. * @param uniform defines the uniform location
  30554. * @param color4 defines the value to be set
  30555. */
  30556. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30557. /**
  30558. * Gets the depth culling state manager
  30559. */
  30560. readonly depthCullingState: DepthCullingState;
  30561. /**
  30562. * Gets the alpha state manager
  30563. */
  30564. readonly alphaState: AlphaState;
  30565. /**
  30566. * Gets the stencil state manager
  30567. */
  30568. readonly stencilState: StencilState;
  30569. /**
  30570. * Clears the list of texture accessible through engine.
  30571. * This can help preventing texture load conflict due to name collision.
  30572. */
  30573. clearInternalTexturesCache(): void;
  30574. /**
  30575. * Force the entire cache to be cleared
  30576. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30577. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30578. */
  30579. wipeCaches(bruteForce?: boolean): void;
  30580. /** @hidden */
  30581. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30582. min: number;
  30583. mag: number;
  30584. };
  30585. /** @hidden */
  30586. _createTexture(): WebGLTexture;
  30587. /**
  30588. * Usually called from Texture.ts.
  30589. * Passed information to create a WebGLTexture
  30590. * @param urlArg defines a value which contains one of the following:
  30591. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30592. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30593. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30595. * @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)
  30596. * @param scene needed for loading to the correct scene
  30597. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30598. * @param onLoad optional callback to be called upon successful completion
  30599. * @param onError optional callback to be called upon failure
  30600. * @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
  30601. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30602. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30603. * @param forcedExtension defines the extension to use to pick the right loader
  30604. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30605. * @param mimeType defines an optional mime type
  30606. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30607. */
  30608. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30609. /**
  30610. * @hidden
  30611. */
  30612. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30613. /**
  30614. * Creates a raw texture
  30615. * @param data defines the data to store in the texture
  30616. * @param width defines the width of the texture
  30617. * @param height defines the height of the texture
  30618. * @param format defines the format of the data
  30619. * @param generateMipMaps defines if the engine should generate the mip levels
  30620. * @param invertY defines if data must be stored with Y axis inverted
  30621. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30622. * @param compression defines the compression used (null by default)
  30623. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30624. * @returns the raw texture inside an InternalTexture
  30625. */
  30626. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30627. /**
  30628. * Creates a new raw cube texture
  30629. * @param data defines the array of data to use to create each face
  30630. * @param size defines the size of the textures
  30631. * @param format defines the format of the data
  30632. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30633. * @param generateMipMaps defines if the engine should generate the mip levels
  30634. * @param invertY defines if data must be stored with Y axis inverted
  30635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30636. * @param compression defines the compression used (null by default)
  30637. * @returns the cube texture as an InternalTexture
  30638. */
  30639. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30640. /**
  30641. * Creates a new raw 3D texture
  30642. * @param data defines the data used to create the texture
  30643. * @param width defines the width of the texture
  30644. * @param height defines the height of the texture
  30645. * @param depth defines the depth of the texture
  30646. * @param format defines the format of the texture
  30647. * @param generateMipMaps defines if the engine must generate mip levels
  30648. * @param invertY defines if data must be stored with Y axis inverted
  30649. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30650. * @param compression defines the compressed used (can be null)
  30651. * @param textureType defines the compressed used (can be null)
  30652. * @returns a new raw 3D texture (stored in an InternalTexture)
  30653. */
  30654. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30655. private _unpackFlipYCached;
  30656. /**
  30657. * In case you are sharing the context with other applications, it might
  30658. * be interested to not cache the unpack flip y state to ensure a consistent
  30659. * value would be set.
  30660. */
  30661. enableUnpackFlipYCached: boolean;
  30662. /** @hidden */
  30663. _unpackFlipY(value: boolean): void;
  30664. /** @hidden */
  30665. _getUnpackAlignement(): number;
  30666. /**
  30667. * Update the sampling mode of a given texture
  30668. * @param samplingMode defines the required sampling mode
  30669. * @param texture defines the texture to update
  30670. */
  30671. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30672. /**
  30673. * Updates a depth texture Comparison Mode and Function.
  30674. * If the comparison Function is equal to 0, the mode will be set to none.
  30675. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30676. * @param texture The texture to set the comparison function for
  30677. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30678. */
  30679. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30680. /** @hidden */
  30681. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30682. width: number;
  30683. height: number;
  30684. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30685. /**
  30686. * Creates a depth stencil texture.
  30687. * This is only available in WebGL 2 or with the depth texture extension available.
  30688. * @param size The size of face edge in the texture.
  30689. * @param options The options defining the texture.
  30690. * @returns The texture
  30691. */
  30692. createDepthStencilTexture(size: number | {
  30693. width: number;
  30694. height: number;
  30695. }, options: DepthTextureCreationOptions): InternalTexture;
  30696. /**
  30697. * Creates a depth stencil texture.
  30698. * This is only available in WebGL 2 or with the depth texture extension available.
  30699. * @param size The size of face edge in the texture.
  30700. * @param options The options defining the texture.
  30701. * @returns The texture
  30702. */
  30703. private _createDepthStencilTexture;
  30704. /** @hidden */
  30705. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30706. /** @hidden */
  30707. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30708. /** @hidden */
  30709. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30710. /** @hidden */
  30711. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  30712. /**
  30713. * @hidden
  30714. */
  30715. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30716. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30717. private _prepareWebGLTexture;
  30718. /** @hidden */
  30719. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30720. /** @hidden */
  30721. _releaseFramebufferObjects(texture: InternalTexture): void;
  30722. /** @hidden */
  30723. _releaseTexture(texture: InternalTexture): void;
  30724. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30725. protected _setProgram(program: WebGLProgram): void;
  30726. protected _boundUniforms: {
  30727. [key: number]: WebGLUniformLocation;
  30728. };
  30729. /**
  30730. * Binds an effect to the webGL context
  30731. * @param effect defines the effect to bind
  30732. */
  30733. bindSamplers(effect: Effect): void;
  30734. private _activateCurrentTexture;
  30735. /** @hidden */
  30736. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30737. /** @hidden */
  30738. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30739. /**
  30740. * Unbind all textures from the webGL context
  30741. */
  30742. unbindAllTextures(): void;
  30743. /**
  30744. * Sets a texture to the according uniform.
  30745. * @param channel The texture channel
  30746. * @param uniform The uniform to set
  30747. * @param texture The texture to apply
  30748. */
  30749. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30750. private _bindSamplerUniformToChannel;
  30751. private _getTextureWrapMode;
  30752. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30753. /**
  30754. * Sets an array of texture to the webGL context
  30755. * @param channel defines the channel where the texture array must be set
  30756. * @param uniform defines the associated uniform location
  30757. * @param textures defines the array of textures to bind
  30758. */
  30759. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30760. /** @hidden */
  30761. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30762. private _setTextureParameterFloat;
  30763. private _setTextureParameterInteger;
  30764. /**
  30765. * Unbind all vertex attributes from the webGL context
  30766. */
  30767. unbindAllAttributes(): void;
  30768. /**
  30769. * 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
  30770. */
  30771. releaseEffects(): void;
  30772. /**
  30773. * Dispose and release all associated resources
  30774. */
  30775. dispose(): void;
  30776. /**
  30777. * Attach a new callback raised when context lost event is fired
  30778. * @param callback defines the callback to call
  30779. */
  30780. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30781. /**
  30782. * Attach a new callback raised when context restored event is fired
  30783. * @param callback defines the callback to call
  30784. */
  30785. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30786. /**
  30787. * Get the current error code of the webGL context
  30788. * @returns the error code
  30789. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30790. */
  30791. getError(): number;
  30792. private _canRenderToFloatFramebuffer;
  30793. private _canRenderToHalfFloatFramebuffer;
  30794. private _canRenderToFramebuffer;
  30795. /** @hidden */
  30796. _getWebGLTextureType(type: number): number;
  30797. /** @hidden */
  30798. _getInternalFormat(format: number): number;
  30799. /** @hidden */
  30800. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30801. /** @hidden */
  30802. _getRGBAMultiSampleBufferFormat(type: number): number;
  30803. /** @hidden */
  30804. _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;
  30805. /**
  30806. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30807. * @returns true if the engine can be created
  30808. * @ignorenaming
  30809. */
  30810. static isSupported(): boolean;
  30811. /**
  30812. * Find the next highest power of two.
  30813. * @param x Number to start search from.
  30814. * @return Next highest power of two.
  30815. */
  30816. static CeilingPOT(x: number): number;
  30817. /**
  30818. * Find the next lowest power of two.
  30819. * @param x Number to start search from.
  30820. * @return Next lowest power of two.
  30821. */
  30822. static FloorPOT(x: number): number;
  30823. /**
  30824. * Find the nearest power of two.
  30825. * @param x Number to start search from.
  30826. * @return Next nearest power of two.
  30827. */
  30828. static NearestPOT(x: number): number;
  30829. /**
  30830. * Get the closest exponent of two
  30831. * @param value defines the value to approximate
  30832. * @param max defines the maximum value to return
  30833. * @param mode defines how to define the closest value
  30834. * @returns closest exponent of two of the given value
  30835. */
  30836. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30837. /**
  30838. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30839. * @param func - the function to be called
  30840. * @param requester - the object that will request the next frame. Falls back to window.
  30841. * @returns frame number
  30842. */
  30843. static QueueNewFrame(func: () => void, requester?: any): number;
  30844. }
  30845. }
  30846. declare module "babylonjs/Maths/sphericalPolynomial" {
  30847. import { Vector3 } from "babylonjs/Maths/math.vector";
  30848. import { Color3 } from "babylonjs/Maths/math.color";
  30849. /**
  30850. * Class representing spherical harmonics coefficients to the 3rd degree
  30851. */
  30852. export class SphericalHarmonics {
  30853. /**
  30854. * Defines whether or not the harmonics have been prescaled for rendering.
  30855. */
  30856. preScaled: boolean;
  30857. /**
  30858. * The l0,0 coefficients of the spherical harmonics
  30859. */
  30860. l00: Vector3;
  30861. /**
  30862. * The l1,-1 coefficients of the spherical harmonics
  30863. */
  30864. l1_1: Vector3;
  30865. /**
  30866. * The l1,0 coefficients of the spherical harmonics
  30867. */
  30868. l10: Vector3;
  30869. /**
  30870. * The l1,1 coefficients of the spherical harmonics
  30871. */
  30872. l11: Vector3;
  30873. /**
  30874. * The l2,-2 coefficients of the spherical harmonics
  30875. */
  30876. l2_2: Vector3;
  30877. /**
  30878. * The l2,-1 coefficients of the spherical harmonics
  30879. */
  30880. l2_1: Vector3;
  30881. /**
  30882. * The l2,0 coefficients of the spherical harmonics
  30883. */
  30884. l20: Vector3;
  30885. /**
  30886. * The l2,1 coefficients of the spherical harmonics
  30887. */
  30888. l21: Vector3;
  30889. /**
  30890. * The l2,2 coefficients of the spherical harmonics
  30891. */
  30892. l22: Vector3;
  30893. /**
  30894. * Adds a light to the spherical harmonics
  30895. * @param direction the direction of the light
  30896. * @param color the color of the light
  30897. * @param deltaSolidAngle the delta solid angle of the light
  30898. */
  30899. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30900. /**
  30901. * Scales the spherical harmonics by the given amount
  30902. * @param scale the amount to scale
  30903. */
  30904. scaleInPlace(scale: number): void;
  30905. /**
  30906. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30907. *
  30908. * ```
  30909. * E_lm = A_l * L_lm
  30910. * ```
  30911. *
  30912. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30913. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30914. * the scaling factors are given in equation 9.
  30915. */
  30916. convertIncidentRadianceToIrradiance(): void;
  30917. /**
  30918. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30919. *
  30920. * ```
  30921. * L = (1/pi) * E * rho
  30922. * ```
  30923. *
  30924. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30925. */
  30926. convertIrradianceToLambertianRadiance(): void;
  30927. /**
  30928. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30929. * required operations at run time.
  30930. *
  30931. * This is simply done by scaling back the SH with Ylm constants parameter.
  30932. * The trigonometric part being applied by the shader at run time.
  30933. */
  30934. preScaleForRendering(): void;
  30935. /**
  30936. * Constructs a spherical harmonics from an array.
  30937. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30938. * @returns the spherical harmonics
  30939. */
  30940. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30941. /**
  30942. * Gets the spherical harmonics from polynomial
  30943. * @param polynomial the spherical polynomial
  30944. * @returns the spherical harmonics
  30945. */
  30946. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30947. }
  30948. /**
  30949. * Class representing spherical polynomial coefficients to the 3rd degree
  30950. */
  30951. export class SphericalPolynomial {
  30952. private _harmonics;
  30953. /**
  30954. * The spherical harmonics used to create the polynomials.
  30955. */
  30956. readonly preScaledHarmonics: SphericalHarmonics;
  30957. /**
  30958. * The x coefficients of the spherical polynomial
  30959. */
  30960. x: Vector3;
  30961. /**
  30962. * The y coefficients of the spherical polynomial
  30963. */
  30964. y: Vector3;
  30965. /**
  30966. * The z coefficients of the spherical polynomial
  30967. */
  30968. z: Vector3;
  30969. /**
  30970. * The xx coefficients of the spherical polynomial
  30971. */
  30972. xx: Vector3;
  30973. /**
  30974. * The yy coefficients of the spherical polynomial
  30975. */
  30976. yy: Vector3;
  30977. /**
  30978. * The zz coefficients of the spherical polynomial
  30979. */
  30980. zz: Vector3;
  30981. /**
  30982. * The xy coefficients of the spherical polynomial
  30983. */
  30984. xy: Vector3;
  30985. /**
  30986. * The yz coefficients of the spherical polynomial
  30987. */
  30988. yz: Vector3;
  30989. /**
  30990. * The zx coefficients of the spherical polynomial
  30991. */
  30992. zx: Vector3;
  30993. /**
  30994. * Adds an ambient color to the spherical polynomial
  30995. * @param color the color to add
  30996. */
  30997. addAmbient(color: Color3): void;
  30998. /**
  30999. * Scales the spherical polynomial by the given amount
  31000. * @param scale the amount to scale
  31001. */
  31002. scaleInPlace(scale: number): void;
  31003. /**
  31004. * Gets the spherical polynomial from harmonics
  31005. * @param harmonics the spherical harmonics
  31006. * @returns the spherical polynomial
  31007. */
  31008. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31009. /**
  31010. * Constructs a spherical polynomial from an array.
  31011. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31012. * @returns the spherical polynomial
  31013. */
  31014. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31015. }
  31016. }
  31017. declare module "babylonjs/Materials/Textures/internalTexture" {
  31018. import { Observable } from "babylonjs/Misc/observable";
  31019. import { Nullable, int } from "babylonjs/types";
  31020. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31022. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31023. /**
  31024. * Defines the source of the internal texture
  31025. */
  31026. export enum InternalTextureSource {
  31027. /**
  31028. * The source of the texture data is unknown
  31029. */
  31030. Unknown = 0,
  31031. /**
  31032. * Texture data comes from an URL
  31033. */
  31034. Url = 1,
  31035. /**
  31036. * Texture data is only used for temporary storage
  31037. */
  31038. Temp = 2,
  31039. /**
  31040. * Texture data comes from raw data (ArrayBuffer)
  31041. */
  31042. Raw = 3,
  31043. /**
  31044. * Texture content is dynamic (video or dynamic texture)
  31045. */
  31046. Dynamic = 4,
  31047. /**
  31048. * Texture content is generated by rendering to it
  31049. */
  31050. RenderTarget = 5,
  31051. /**
  31052. * Texture content is part of a multi render target process
  31053. */
  31054. MultiRenderTarget = 6,
  31055. /**
  31056. * Texture data comes from a cube data file
  31057. */
  31058. Cube = 7,
  31059. /**
  31060. * Texture data comes from a raw cube data
  31061. */
  31062. CubeRaw = 8,
  31063. /**
  31064. * Texture data come from a prefiltered cube data file
  31065. */
  31066. CubePrefiltered = 9,
  31067. /**
  31068. * Texture content is raw 3D data
  31069. */
  31070. Raw3D = 10,
  31071. /**
  31072. * Texture content is a depth texture
  31073. */
  31074. Depth = 11,
  31075. /**
  31076. * Texture data comes from a raw cube data encoded with RGBD
  31077. */
  31078. CubeRawRGBD = 12
  31079. }
  31080. /**
  31081. * Class used to store data associated with WebGL texture data for the engine
  31082. * This class should not be used directly
  31083. */
  31084. export class InternalTexture {
  31085. /** @hidden */
  31086. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31087. /**
  31088. * Defines if the texture is ready
  31089. */
  31090. isReady: boolean;
  31091. /**
  31092. * Defines if the texture is a cube texture
  31093. */
  31094. isCube: boolean;
  31095. /**
  31096. * Defines if the texture contains 3D data
  31097. */
  31098. is3D: boolean;
  31099. /**
  31100. * Defines if the texture contains multiview data
  31101. */
  31102. isMultiview: boolean;
  31103. /**
  31104. * Gets the URL used to load this texture
  31105. */
  31106. url: string;
  31107. /**
  31108. * Gets the sampling mode of the texture
  31109. */
  31110. samplingMode: number;
  31111. /**
  31112. * Gets a boolean indicating if the texture needs mipmaps generation
  31113. */
  31114. generateMipMaps: boolean;
  31115. /**
  31116. * Gets the number of samples used by the texture (WebGL2+ only)
  31117. */
  31118. samples: number;
  31119. /**
  31120. * Gets the type of the texture (int, float...)
  31121. */
  31122. type: number;
  31123. /**
  31124. * Gets the format of the texture (RGB, RGBA...)
  31125. */
  31126. format: number;
  31127. /**
  31128. * Observable called when the texture is loaded
  31129. */
  31130. onLoadedObservable: Observable<InternalTexture>;
  31131. /**
  31132. * Gets the width of the texture
  31133. */
  31134. width: number;
  31135. /**
  31136. * Gets the height of the texture
  31137. */
  31138. height: number;
  31139. /**
  31140. * Gets the depth of the texture
  31141. */
  31142. depth: number;
  31143. /**
  31144. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31145. */
  31146. baseWidth: number;
  31147. /**
  31148. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31149. */
  31150. baseHeight: number;
  31151. /**
  31152. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31153. */
  31154. baseDepth: number;
  31155. /**
  31156. * Gets a boolean indicating if the texture is inverted on Y axis
  31157. */
  31158. invertY: boolean;
  31159. /** @hidden */
  31160. _invertVScale: boolean;
  31161. /** @hidden */
  31162. _associatedChannel: number;
  31163. /** @hidden */
  31164. _source: InternalTextureSource;
  31165. /** @hidden */
  31166. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31167. /** @hidden */
  31168. _bufferView: Nullable<ArrayBufferView>;
  31169. /** @hidden */
  31170. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31171. /** @hidden */
  31172. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31173. /** @hidden */
  31174. _size: number;
  31175. /** @hidden */
  31176. _extension: string;
  31177. /** @hidden */
  31178. _files: Nullable<string[]>;
  31179. /** @hidden */
  31180. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31181. /** @hidden */
  31182. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31183. /** @hidden */
  31184. _framebuffer: Nullable<WebGLFramebuffer>;
  31185. /** @hidden */
  31186. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31187. /** @hidden */
  31188. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31189. /** @hidden */
  31190. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31191. /** @hidden */
  31192. _attachments: Nullable<number[]>;
  31193. /** @hidden */
  31194. _cachedCoordinatesMode: Nullable<number>;
  31195. /** @hidden */
  31196. _cachedWrapU: Nullable<number>;
  31197. /** @hidden */
  31198. _cachedWrapV: Nullable<number>;
  31199. /** @hidden */
  31200. _cachedWrapR: Nullable<number>;
  31201. /** @hidden */
  31202. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31203. /** @hidden */
  31204. _isDisabled: boolean;
  31205. /** @hidden */
  31206. _compression: Nullable<string>;
  31207. /** @hidden */
  31208. _generateStencilBuffer: boolean;
  31209. /** @hidden */
  31210. _generateDepthBuffer: boolean;
  31211. /** @hidden */
  31212. _comparisonFunction: number;
  31213. /** @hidden */
  31214. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31215. /** @hidden */
  31216. _lodGenerationScale: number;
  31217. /** @hidden */
  31218. _lodGenerationOffset: number;
  31219. /** @hidden */
  31220. _colorTextureArray: Nullable<WebGLTexture>;
  31221. /** @hidden */
  31222. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31223. /** @hidden */
  31224. _lodTextureHigh: Nullable<BaseTexture>;
  31225. /** @hidden */
  31226. _lodTextureMid: Nullable<BaseTexture>;
  31227. /** @hidden */
  31228. _lodTextureLow: Nullable<BaseTexture>;
  31229. /** @hidden */
  31230. _isRGBD: boolean;
  31231. /** @hidden */
  31232. _linearSpecularLOD: boolean;
  31233. /** @hidden */
  31234. _irradianceTexture: Nullable<BaseTexture>;
  31235. /** @hidden */
  31236. _webGLTexture: Nullable<WebGLTexture>;
  31237. /** @hidden */
  31238. _references: number;
  31239. private _engine;
  31240. /**
  31241. * Gets the Engine the texture belongs to.
  31242. * @returns The babylon engine
  31243. */
  31244. getEngine(): ThinEngine;
  31245. /**
  31246. * Gets the data source type of the texture
  31247. */
  31248. readonly source: InternalTextureSource;
  31249. /**
  31250. * Creates a new InternalTexture
  31251. * @param engine defines the engine to use
  31252. * @param source defines the type of data that will be used
  31253. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31254. */
  31255. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31256. /**
  31257. * Increments the number of references (ie. the number of Texture that point to it)
  31258. */
  31259. incrementReferences(): void;
  31260. /**
  31261. * Change the size of the texture (not the size of the content)
  31262. * @param width defines the new width
  31263. * @param height defines the new height
  31264. * @param depth defines the new depth (1 by default)
  31265. */
  31266. updateSize(width: int, height: int, depth?: int): void;
  31267. /** @hidden */
  31268. _rebuild(): void;
  31269. /** @hidden */
  31270. _swapAndDie(target: InternalTexture): void;
  31271. /**
  31272. * Dispose the current allocated resources
  31273. */
  31274. dispose(): void;
  31275. }
  31276. }
  31277. declare module "babylonjs/Audio/analyser" {
  31278. import { Scene } from "babylonjs/scene";
  31279. /**
  31280. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31282. */
  31283. export class Analyser {
  31284. /**
  31285. * Gets or sets the smoothing
  31286. * @ignorenaming
  31287. */
  31288. SMOOTHING: number;
  31289. /**
  31290. * Gets or sets the FFT table size
  31291. * @ignorenaming
  31292. */
  31293. FFT_SIZE: number;
  31294. /**
  31295. * Gets or sets the bar graph amplitude
  31296. * @ignorenaming
  31297. */
  31298. BARGRAPHAMPLITUDE: number;
  31299. /**
  31300. * Gets or sets the position of the debug canvas
  31301. * @ignorenaming
  31302. */
  31303. DEBUGCANVASPOS: {
  31304. x: number;
  31305. y: number;
  31306. };
  31307. /**
  31308. * Gets or sets the debug canvas size
  31309. * @ignorenaming
  31310. */
  31311. DEBUGCANVASSIZE: {
  31312. width: number;
  31313. height: number;
  31314. };
  31315. private _byteFreqs;
  31316. private _byteTime;
  31317. private _floatFreqs;
  31318. private _webAudioAnalyser;
  31319. private _debugCanvas;
  31320. private _debugCanvasContext;
  31321. private _scene;
  31322. private _registerFunc;
  31323. private _audioEngine;
  31324. /**
  31325. * Creates a new analyser
  31326. * @param scene defines hosting scene
  31327. */
  31328. constructor(scene: Scene);
  31329. /**
  31330. * Get the number of data values you will have to play with for the visualization
  31331. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31332. * @returns a number
  31333. */
  31334. getFrequencyBinCount(): number;
  31335. /**
  31336. * Gets the current frequency data as a byte array
  31337. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31338. * @returns a Uint8Array
  31339. */
  31340. getByteFrequencyData(): Uint8Array;
  31341. /**
  31342. * Gets the current waveform as a byte array
  31343. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31344. * @returns a Uint8Array
  31345. */
  31346. getByteTimeDomainData(): Uint8Array;
  31347. /**
  31348. * Gets the current frequency data as a float array
  31349. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31350. * @returns a Float32Array
  31351. */
  31352. getFloatFrequencyData(): Float32Array;
  31353. /**
  31354. * Renders the debug canvas
  31355. */
  31356. drawDebugCanvas(): void;
  31357. /**
  31358. * Stops rendering the debug canvas and removes it
  31359. */
  31360. stopDebugCanvas(): void;
  31361. /**
  31362. * Connects two audio nodes
  31363. * @param inputAudioNode defines first node to connect
  31364. * @param outputAudioNode defines second node to connect
  31365. */
  31366. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31367. /**
  31368. * Releases all associated resources
  31369. */
  31370. dispose(): void;
  31371. }
  31372. }
  31373. declare module "babylonjs/Audio/audioEngine" {
  31374. import { IDisposable } from "babylonjs/scene";
  31375. import { Analyser } from "babylonjs/Audio/analyser";
  31376. import { Nullable } from "babylonjs/types";
  31377. import { Observable } from "babylonjs/Misc/observable";
  31378. /**
  31379. * This represents an audio engine and it is responsible
  31380. * to play, synchronize and analyse sounds throughout the application.
  31381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31382. */
  31383. export interface IAudioEngine extends IDisposable {
  31384. /**
  31385. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31386. */
  31387. readonly canUseWebAudio: boolean;
  31388. /**
  31389. * Gets the current AudioContext if available.
  31390. */
  31391. readonly audioContext: Nullable<AudioContext>;
  31392. /**
  31393. * The master gain node defines the global audio volume of your audio engine.
  31394. */
  31395. readonly masterGain: GainNode;
  31396. /**
  31397. * Gets whether or not mp3 are supported by your browser.
  31398. */
  31399. readonly isMP3supported: boolean;
  31400. /**
  31401. * Gets whether or not ogg are supported by your browser.
  31402. */
  31403. readonly isOGGsupported: boolean;
  31404. /**
  31405. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31406. * @ignoreNaming
  31407. */
  31408. WarnedWebAudioUnsupported: boolean;
  31409. /**
  31410. * Defines if the audio engine relies on a custom unlocked button.
  31411. * In this case, the embedded button will not be displayed.
  31412. */
  31413. useCustomUnlockedButton: boolean;
  31414. /**
  31415. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31416. */
  31417. readonly unlocked: boolean;
  31418. /**
  31419. * Event raised when audio has been unlocked on the browser.
  31420. */
  31421. onAudioUnlockedObservable: Observable<AudioEngine>;
  31422. /**
  31423. * Event raised when audio has been locked on the browser.
  31424. */
  31425. onAudioLockedObservable: Observable<AudioEngine>;
  31426. /**
  31427. * Flags the audio engine in Locked state.
  31428. * This happens due to new browser policies preventing audio to autoplay.
  31429. */
  31430. lock(): void;
  31431. /**
  31432. * Unlocks the audio engine once a user action has been done on the dom.
  31433. * This is helpful to resume play once browser policies have been satisfied.
  31434. */
  31435. unlock(): void;
  31436. }
  31437. /**
  31438. * This represents the default audio engine used in babylon.
  31439. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31441. */
  31442. export class AudioEngine implements IAudioEngine {
  31443. private _audioContext;
  31444. private _audioContextInitialized;
  31445. private _muteButton;
  31446. private _hostElement;
  31447. /**
  31448. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31449. */
  31450. canUseWebAudio: boolean;
  31451. /**
  31452. * The master gain node defines the global audio volume of your audio engine.
  31453. */
  31454. masterGain: GainNode;
  31455. /**
  31456. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31457. * @ignoreNaming
  31458. */
  31459. WarnedWebAudioUnsupported: boolean;
  31460. /**
  31461. * Gets whether or not mp3 are supported by your browser.
  31462. */
  31463. isMP3supported: boolean;
  31464. /**
  31465. * Gets whether or not ogg are supported by your browser.
  31466. */
  31467. isOGGsupported: boolean;
  31468. /**
  31469. * Gets whether audio has been unlocked on the device.
  31470. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31471. * a user interaction has happened.
  31472. */
  31473. unlocked: boolean;
  31474. /**
  31475. * Defines if the audio engine relies on a custom unlocked button.
  31476. * In this case, the embedded button will not be displayed.
  31477. */
  31478. useCustomUnlockedButton: boolean;
  31479. /**
  31480. * Event raised when audio has been unlocked on the browser.
  31481. */
  31482. onAudioUnlockedObservable: Observable<AudioEngine>;
  31483. /**
  31484. * Event raised when audio has been locked on the browser.
  31485. */
  31486. onAudioLockedObservable: Observable<AudioEngine>;
  31487. /**
  31488. * Gets the current AudioContext if available.
  31489. */
  31490. readonly audioContext: Nullable<AudioContext>;
  31491. private _connectedAnalyser;
  31492. /**
  31493. * Instantiates a new audio engine.
  31494. *
  31495. * There should be only one per page as some browsers restrict the number
  31496. * of audio contexts you can create.
  31497. * @param hostElement defines the host element where to display the mute icon if necessary
  31498. */
  31499. constructor(hostElement?: Nullable<HTMLElement>);
  31500. /**
  31501. * Flags the audio engine in Locked state.
  31502. * This happens due to new browser policies preventing audio to autoplay.
  31503. */
  31504. lock(): void;
  31505. /**
  31506. * Unlocks the audio engine once a user action has been done on the dom.
  31507. * This is helpful to resume play once browser policies have been satisfied.
  31508. */
  31509. unlock(): void;
  31510. private _resumeAudioContext;
  31511. private _initializeAudioContext;
  31512. private _tryToRun;
  31513. private _triggerRunningState;
  31514. private _triggerSuspendedState;
  31515. private _displayMuteButton;
  31516. private _moveButtonToTopLeft;
  31517. private _onResize;
  31518. private _hideMuteButton;
  31519. /**
  31520. * Destroy and release the resources associated with the audio ccontext.
  31521. */
  31522. dispose(): void;
  31523. /**
  31524. * Gets the global volume sets on the master gain.
  31525. * @returns the global volume if set or -1 otherwise
  31526. */
  31527. getGlobalVolume(): number;
  31528. /**
  31529. * Sets the global volume of your experience (sets on the master gain).
  31530. * @param newVolume Defines the new global volume of the application
  31531. */
  31532. setGlobalVolume(newVolume: number): void;
  31533. /**
  31534. * Connect the audio engine to an audio analyser allowing some amazing
  31535. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31537. * @param analyser The analyser to connect to the engine
  31538. */
  31539. connectToAnalyser(analyser: Analyser): void;
  31540. }
  31541. }
  31542. declare module "babylonjs/Loading/loadingScreen" {
  31543. /**
  31544. * Interface used to present a loading screen while loading a scene
  31545. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31546. */
  31547. export interface ILoadingScreen {
  31548. /**
  31549. * Function called to display the loading screen
  31550. */
  31551. displayLoadingUI: () => void;
  31552. /**
  31553. * Function called to hide the loading screen
  31554. */
  31555. hideLoadingUI: () => void;
  31556. /**
  31557. * Gets or sets the color to use for the background
  31558. */
  31559. loadingUIBackgroundColor: string;
  31560. /**
  31561. * Gets or sets the text to display while loading
  31562. */
  31563. loadingUIText: string;
  31564. }
  31565. /**
  31566. * Class used for the default loading screen
  31567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31568. */
  31569. export class DefaultLoadingScreen implements ILoadingScreen {
  31570. private _renderingCanvas;
  31571. private _loadingText;
  31572. private _loadingDivBackgroundColor;
  31573. private _loadingDiv;
  31574. private _loadingTextDiv;
  31575. /** Gets or sets the logo url to use for the default loading screen */
  31576. static DefaultLogoUrl: string;
  31577. /** Gets or sets the spinner url to use for the default loading screen */
  31578. static DefaultSpinnerUrl: string;
  31579. /**
  31580. * Creates a new default loading screen
  31581. * @param _renderingCanvas defines the canvas used to render the scene
  31582. * @param _loadingText defines the default text to display
  31583. * @param _loadingDivBackgroundColor defines the default background color
  31584. */
  31585. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31586. /**
  31587. * Function called to display the loading screen
  31588. */
  31589. displayLoadingUI(): void;
  31590. /**
  31591. * Function called to hide the loading screen
  31592. */
  31593. hideLoadingUI(): void;
  31594. /**
  31595. * Gets or sets the text to display while loading
  31596. */
  31597. loadingUIText: string;
  31598. /**
  31599. * Gets or sets the color to use for the background
  31600. */
  31601. loadingUIBackgroundColor: string;
  31602. private _resizeLoadingUI;
  31603. }
  31604. }
  31605. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31606. /**
  31607. * Interface for any object that can request an animation frame
  31608. */
  31609. export interface ICustomAnimationFrameRequester {
  31610. /**
  31611. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31612. */
  31613. renderFunction?: Function;
  31614. /**
  31615. * Called to request the next frame to render to
  31616. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31617. */
  31618. requestAnimationFrame: Function;
  31619. /**
  31620. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31621. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31622. */
  31623. requestID?: number;
  31624. }
  31625. }
  31626. declare module "babylonjs/Misc/performanceMonitor" {
  31627. /**
  31628. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31629. */
  31630. export class PerformanceMonitor {
  31631. private _enabled;
  31632. private _rollingFrameTime;
  31633. private _lastFrameTimeMs;
  31634. /**
  31635. * constructor
  31636. * @param frameSampleSize The number of samples required to saturate the sliding window
  31637. */
  31638. constructor(frameSampleSize?: number);
  31639. /**
  31640. * Samples current frame
  31641. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31642. */
  31643. sampleFrame(timeMs?: number): void;
  31644. /**
  31645. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31646. */
  31647. readonly averageFrameTime: number;
  31648. /**
  31649. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31650. */
  31651. readonly averageFrameTimeVariance: number;
  31652. /**
  31653. * Returns the frame time of the most recent frame
  31654. */
  31655. readonly instantaneousFrameTime: number;
  31656. /**
  31657. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31658. */
  31659. readonly averageFPS: number;
  31660. /**
  31661. * Returns the average framerate in frames per second using the most recent frame time
  31662. */
  31663. readonly instantaneousFPS: number;
  31664. /**
  31665. * Returns true if enough samples have been taken to completely fill the sliding window
  31666. */
  31667. readonly isSaturated: boolean;
  31668. /**
  31669. * Enables contributions to the sliding window sample set
  31670. */
  31671. enable(): void;
  31672. /**
  31673. * Disables contributions to the sliding window sample set
  31674. * Samples will not be interpolated over the disabled period
  31675. */
  31676. disable(): void;
  31677. /**
  31678. * Returns true if sampling is enabled
  31679. */
  31680. readonly isEnabled: boolean;
  31681. /**
  31682. * Resets performance monitor
  31683. */
  31684. reset(): void;
  31685. }
  31686. /**
  31687. * RollingAverage
  31688. *
  31689. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31690. */
  31691. export class RollingAverage {
  31692. /**
  31693. * Current average
  31694. */
  31695. average: number;
  31696. /**
  31697. * Current variance
  31698. */
  31699. variance: number;
  31700. protected _samples: Array<number>;
  31701. protected _sampleCount: number;
  31702. protected _pos: number;
  31703. protected _m2: number;
  31704. /**
  31705. * constructor
  31706. * @param length The number of samples required to saturate the sliding window
  31707. */
  31708. constructor(length: number);
  31709. /**
  31710. * Adds a sample to the sample set
  31711. * @param v The sample value
  31712. */
  31713. add(v: number): void;
  31714. /**
  31715. * Returns previously added values or null if outside of history or outside the sliding window domain
  31716. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31717. * @return Value previously recorded with add() or null if outside of range
  31718. */
  31719. history(i: number): number;
  31720. /**
  31721. * Returns true if enough samples have been taken to completely fill the sliding window
  31722. * @return true if sample-set saturated
  31723. */
  31724. isSaturated(): boolean;
  31725. /**
  31726. * Resets the rolling average (equivalent to 0 samples taken so far)
  31727. */
  31728. reset(): void;
  31729. /**
  31730. * Wraps a value around the sample range boundaries
  31731. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31732. * @return Wrapped position in sample range
  31733. */
  31734. protected _wrapPosition(i: number): number;
  31735. }
  31736. }
  31737. declare module "babylonjs/Misc/perfCounter" {
  31738. /**
  31739. * This class is used to track a performance counter which is number based.
  31740. * The user has access to many properties which give statistics of different nature.
  31741. *
  31742. * The implementer can track two kinds of Performance Counter: time and count.
  31743. * 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.
  31744. * 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.
  31745. */
  31746. export class PerfCounter {
  31747. /**
  31748. * Gets or sets a global boolean to turn on and off all the counters
  31749. */
  31750. static Enabled: boolean;
  31751. /**
  31752. * Returns the smallest value ever
  31753. */
  31754. readonly min: number;
  31755. /**
  31756. * Returns the biggest value ever
  31757. */
  31758. readonly max: number;
  31759. /**
  31760. * Returns the average value since the performance counter is running
  31761. */
  31762. readonly average: number;
  31763. /**
  31764. * Returns the average value of the last second the counter was monitored
  31765. */
  31766. readonly lastSecAverage: number;
  31767. /**
  31768. * Returns the current value
  31769. */
  31770. readonly current: number;
  31771. /**
  31772. * Gets the accumulated total
  31773. */
  31774. readonly total: number;
  31775. /**
  31776. * Gets the total value count
  31777. */
  31778. readonly count: number;
  31779. /**
  31780. * Creates a new counter
  31781. */
  31782. constructor();
  31783. /**
  31784. * Call this method to start monitoring a new frame.
  31785. * 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.
  31786. */
  31787. fetchNewFrame(): void;
  31788. /**
  31789. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31790. * @param newCount the count value to add to the monitored count
  31791. * @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.
  31792. */
  31793. addCount(newCount: number, fetchResult: boolean): void;
  31794. /**
  31795. * Start monitoring this performance counter
  31796. */
  31797. beginMonitoring(): void;
  31798. /**
  31799. * Compute the time lapsed since the previous beginMonitoring() call.
  31800. * @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
  31801. */
  31802. endMonitoring(newFrame?: boolean): void;
  31803. private _fetchResult;
  31804. private _startMonitoringTime;
  31805. private _min;
  31806. private _max;
  31807. private _average;
  31808. private _current;
  31809. private _totalValueCount;
  31810. private _totalAccumulated;
  31811. private _lastSecAverage;
  31812. private _lastSecAccumulated;
  31813. private _lastSecTime;
  31814. private _lastSecValueCount;
  31815. }
  31816. }
  31817. declare module "babylonjs/Engines/engine" {
  31818. import { Observable } from "babylonjs/Misc/observable";
  31819. import { Nullable, IndicesArray } from "babylonjs/types";
  31820. import { Scene } from "babylonjs/scene";
  31821. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31822. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31823. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31824. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31825. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31826. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31827. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31828. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31829. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31831. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31832. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31833. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31834. import { Material } from "babylonjs/Materials/material";
  31835. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31836. /**
  31837. * Defines the interface used by display changed events
  31838. */
  31839. export interface IDisplayChangedEventArgs {
  31840. /** Gets the vrDisplay object (if any) */
  31841. vrDisplay: Nullable<any>;
  31842. /** Gets a boolean indicating if webVR is supported */
  31843. vrSupported: boolean;
  31844. }
  31845. /**
  31846. * Defines the interface used by objects containing a viewport (like a camera)
  31847. */
  31848. interface IViewportOwnerLike {
  31849. /**
  31850. * Gets or sets the viewport
  31851. */
  31852. viewport: IViewportLike;
  31853. }
  31854. /**
  31855. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31856. */
  31857. export class Engine extends ThinEngine {
  31858. /** Defines that alpha blending is disabled */
  31859. static readonly ALPHA_DISABLE: number;
  31860. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31861. static readonly ALPHA_ADD: number;
  31862. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31863. static readonly ALPHA_COMBINE: number;
  31864. /** Defines that alpha blending to DEST - SRC * DEST */
  31865. static readonly ALPHA_SUBTRACT: number;
  31866. /** Defines that alpha blending to SRC * DEST */
  31867. static readonly ALPHA_MULTIPLY: number;
  31868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31869. static readonly ALPHA_MAXIMIZED: number;
  31870. /** Defines that alpha blending to SRC + DEST */
  31871. static readonly ALPHA_ONEONE: number;
  31872. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31873. static readonly ALPHA_PREMULTIPLIED: number;
  31874. /**
  31875. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31876. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31877. */
  31878. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31879. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31880. static readonly ALPHA_INTERPOLATE: number;
  31881. /**
  31882. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31883. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31884. */
  31885. static readonly ALPHA_SCREENMODE: number;
  31886. /** Defines that the ressource is not delayed*/
  31887. static readonly DELAYLOADSTATE_NONE: number;
  31888. /** Defines that the ressource was successfully delay loaded */
  31889. static readonly DELAYLOADSTATE_LOADED: number;
  31890. /** Defines that the ressource is currently delay loading */
  31891. static readonly DELAYLOADSTATE_LOADING: number;
  31892. /** Defines that the ressource is delayed and has not started loading */
  31893. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31895. static readonly NEVER: number;
  31896. /** 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 */
  31897. static readonly ALWAYS: number;
  31898. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31899. static readonly LESS: number;
  31900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31901. static readonly EQUAL: number;
  31902. /** 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 */
  31903. static readonly LEQUAL: number;
  31904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31905. static readonly GREATER: number;
  31906. /** 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 */
  31907. static readonly GEQUAL: number;
  31908. /** 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 */
  31909. static readonly NOTEQUAL: number;
  31910. /** Passed to stencilOperation to specify that stencil value must be kept */
  31911. static readonly KEEP: number;
  31912. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31913. static readonly REPLACE: number;
  31914. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31915. static readonly INCR: number;
  31916. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31917. static readonly DECR: number;
  31918. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31919. static readonly INVERT: number;
  31920. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31921. static readonly INCR_WRAP: number;
  31922. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31923. static readonly DECR_WRAP: number;
  31924. /** Texture is not repeating outside of 0..1 UVs */
  31925. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31926. /** Texture is repeating outside of 0..1 UVs */
  31927. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31928. /** Texture is repeating and mirrored */
  31929. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31930. /** ALPHA */
  31931. static readonly TEXTUREFORMAT_ALPHA: number;
  31932. /** LUMINANCE */
  31933. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31934. /** LUMINANCE_ALPHA */
  31935. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31936. /** RGB */
  31937. static readonly TEXTUREFORMAT_RGB: number;
  31938. /** RGBA */
  31939. static readonly TEXTUREFORMAT_RGBA: number;
  31940. /** RED */
  31941. static readonly TEXTUREFORMAT_RED: number;
  31942. /** RED (2nd reference) */
  31943. static readonly TEXTUREFORMAT_R: number;
  31944. /** RG */
  31945. static readonly TEXTUREFORMAT_RG: number;
  31946. /** RED_INTEGER */
  31947. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31948. /** RED_INTEGER (2nd reference) */
  31949. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31950. /** RG_INTEGER */
  31951. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31952. /** RGB_INTEGER */
  31953. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31954. /** RGBA_INTEGER */
  31955. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31956. /** UNSIGNED_BYTE */
  31957. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31958. /** UNSIGNED_BYTE (2nd reference) */
  31959. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31960. /** FLOAT */
  31961. static readonly TEXTURETYPE_FLOAT: number;
  31962. /** HALF_FLOAT */
  31963. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31964. /** BYTE */
  31965. static readonly TEXTURETYPE_BYTE: number;
  31966. /** SHORT */
  31967. static readonly TEXTURETYPE_SHORT: number;
  31968. /** UNSIGNED_SHORT */
  31969. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31970. /** INT */
  31971. static readonly TEXTURETYPE_INT: number;
  31972. /** UNSIGNED_INT */
  31973. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31974. /** UNSIGNED_SHORT_4_4_4_4 */
  31975. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31976. /** UNSIGNED_SHORT_5_5_5_1 */
  31977. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31978. /** UNSIGNED_SHORT_5_6_5 */
  31979. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31980. /** UNSIGNED_INT_2_10_10_10_REV */
  31981. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31982. /** UNSIGNED_INT_24_8 */
  31983. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31984. /** UNSIGNED_INT_10F_11F_11F_REV */
  31985. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31986. /** UNSIGNED_INT_5_9_9_9_REV */
  31987. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31988. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31989. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31990. /** nearest is mag = nearest and min = nearest and mip = linear */
  31991. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31993. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31994. /** Trilinear is mag = linear and min = linear and mip = linear */
  31995. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31996. /** nearest is mag = nearest and min = nearest and mip = linear */
  31997. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31998. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31999. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32000. /** Trilinear is mag = linear and min = linear and mip = linear */
  32001. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32002. /** mag = nearest and min = nearest and mip = nearest */
  32003. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32004. /** mag = nearest and min = linear and mip = nearest */
  32005. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32006. /** mag = nearest and min = linear and mip = linear */
  32007. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32008. /** mag = nearest and min = linear and mip = none */
  32009. static readonly TEXTURE_NEAREST_LINEAR: number;
  32010. /** mag = nearest and min = nearest and mip = none */
  32011. static readonly TEXTURE_NEAREST_NEAREST: number;
  32012. /** mag = linear and min = nearest and mip = nearest */
  32013. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32014. /** mag = linear and min = nearest and mip = linear */
  32015. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32016. /** mag = linear and min = linear and mip = none */
  32017. static readonly TEXTURE_LINEAR_LINEAR: number;
  32018. /** mag = linear and min = nearest and mip = none */
  32019. static readonly TEXTURE_LINEAR_NEAREST: number;
  32020. /** Explicit coordinates mode */
  32021. static readonly TEXTURE_EXPLICIT_MODE: number;
  32022. /** Spherical coordinates mode */
  32023. static readonly TEXTURE_SPHERICAL_MODE: number;
  32024. /** Planar coordinates mode */
  32025. static readonly TEXTURE_PLANAR_MODE: number;
  32026. /** Cubic coordinates mode */
  32027. static readonly TEXTURE_CUBIC_MODE: number;
  32028. /** Projection coordinates mode */
  32029. static readonly TEXTURE_PROJECTION_MODE: number;
  32030. /** Skybox coordinates mode */
  32031. static readonly TEXTURE_SKYBOX_MODE: number;
  32032. /** Inverse Cubic coordinates mode */
  32033. static readonly TEXTURE_INVCUBIC_MODE: number;
  32034. /** Equirectangular coordinates mode */
  32035. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32036. /** Equirectangular Fixed coordinates mode */
  32037. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32038. /** Equirectangular Fixed Mirrored coordinates mode */
  32039. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32040. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32041. static readonly SCALEMODE_FLOOR: number;
  32042. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32043. static readonly SCALEMODE_NEAREST: number;
  32044. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32045. static readonly SCALEMODE_CEILING: number;
  32046. /**
  32047. * Returns the current npm package of the sdk
  32048. */
  32049. static readonly NpmPackage: string;
  32050. /**
  32051. * Returns the current version of the framework
  32052. */
  32053. static readonly Version: string;
  32054. /** Gets the list of created engines */
  32055. static readonly Instances: Engine[];
  32056. /**
  32057. * Gets the latest created engine
  32058. */
  32059. static readonly LastCreatedEngine: Nullable<Engine>;
  32060. /**
  32061. * Gets the latest created scene
  32062. */
  32063. static readonly LastCreatedScene: Nullable<Scene>;
  32064. /**
  32065. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32066. * @param flag defines which part of the materials must be marked as dirty
  32067. * @param predicate defines a predicate used to filter which materials should be affected
  32068. */
  32069. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32070. /**
  32071. * Method called to create the default loading screen.
  32072. * This can be overriden in your own app.
  32073. * @param canvas The rendering canvas element
  32074. * @returns The loading screen
  32075. */
  32076. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32077. /**
  32078. * Method called to create the default rescale post process on each engine.
  32079. */
  32080. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32081. /**
  32082. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32083. **/
  32084. enableOfflineSupport: boolean;
  32085. /**
  32086. * 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)
  32087. **/
  32088. disableManifestCheck: boolean;
  32089. /**
  32090. * Gets the list of created scenes
  32091. */
  32092. scenes: Scene[];
  32093. /**
  32094. * Event raised when a new scene is created
  32095. */
  32096. onNewSceneAddedObservable: Observable<Scene>;
  32097. /**
  32098. * Gets the list of created postprocesses
  32099. */
  32100. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32101. /**
  32102. * Gets a boolean indicating if the pointer is currently locked
  32103. */
  32104. isPointerLock: boolean;
  32105. /**
  32106. * Observable event triggered each time the rendering canvas is resized
  32107. */
  32108. onResizeObservable: Observable<Engine>;
  32109. /**
  32110. * Observable event triggered each time the canvas loses focus
  32111. */
  32112. onCanvasBlurObservable: Observable<Engine>;
  32113. /**
  32114. * Observable event triggered each time the canvas gains focus
  32115. */
  32116. onCanvasFocusObservable: Observable<Engine>;
  32117. /**
  32118. * Observable event triggered each time the canvas receives pointerout event
  32119. */
  32120. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32121. /**
  32122. * Observable raised when the engine begins a new frame
  32123. */
  32124. onBeginFrameObservable: Observable<Engine>;
  32125. /**
  32126. * If set, will be used to request the next animation frame for the render loop
  32127. */
  32128. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32129. /**
  32130. * Observable raised when the engine ends the current frame
  32131. */
  32132. onEndFrameObservable: Observable<Engine>;
  32133. /**
  32134. * Observable raised when the engine is about to compile a shader
  32135. */
  32136. onBeforeShaderCompilationObservable: Observable<Engine>;
  32137. /**
  32138. * Observable raised when the engine has jsut compiled a shader
  32139. */
  32140. onAfterShaderCompilationObservable: Observable<Engine>;
  32141. /**
  32142. * Gets the audio engine
  32143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32144. * @ignorenaming
  32145. */
  32146. static audioEngine: IAudioEngine;
  32147. /**
  32148. * Default AudioEngine factory responsible of creating the Audio Engine.
  32149. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32150. */
  32151. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32152. /**
  32153. * Default offline support factory responsible of creating a tool used to store data locally.
  32154. * By default, this will create a Database object if the workload has been embedded.
  32155. */
  32156. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32157. private _loadingScreen;
  32158. private _pointerLockRequested;
  32159. private _dummyFramebuffer;
  32160. private _rescalePostProcess;
  32161. /** @hidden */
  32162. protected _alphaMode: number;
  32163. /** @hidden */
  32164. protected _alphaEquation: number;
  32165. private _deterministicLockstep;
  32166. private _lockstepMaxSteps;
  32167. protected readonly _supportsHardwareTextureRescaling: boolean;
  32168. private _fps;
  32169. private _deltaTime;
  32170. /** @hidden */
  32171. _drawCalls: PerfCounter;
  32172. /**
  32173. * Turn this value on if you want to pause FPS computation when in background
  32174. */
  32175. disablePerformanceMonitorInBackground: boolean;
  32176. private _performanceMonitor;
  32177. /**
  32178. * Gets the performance monitor attached to this engine
  32179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32180. */
  32181. readonly performanceMonitor: PerformanceMonitor;
  32182. private _onFocus;
  32183. private _onBlur;
  32184. private _onCanvasPointerOut;
  32185. private _onCanvasBlur;
  32186. private _onCanvasFocus;
  32187. private _onFullscreenChange;
  32188. private _onPointerLockChange;
  32189. /**
  32190. * Creates a new engine
  32191. * @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
  32192. * @param antialias defines enable antialiasing (default: false)
  32193. * @param options defines further options to be sent to the getContext() function
  32194. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32195. */
  32196. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32197. /**
  32198. * Gets current aspect ratio
  32199. * @param viewportOwner defines the camera to use to get the aspect ratio
  32200. * @param useScreen defines if screen size must be used (or the current render target if any)
  32201. * @returns a number defining the aspect ratio
  32202. */
  32203. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32204. /**
  32205. * Gets current screen aspect ratio
  32206. * @returns a number defining the aspect ratio
  32207. */
  32208. getScreenAspectRatio(): number;
  32209. /**
  32210. * Gets host document
  32211. * @returns the host document object
  32212. */
  32213. getHostDocument(): Document;
  32214. /**
  32215. * Gets the client rect of the HTML canvas attached with the current webGL context
  32216. * @returns a client rectanglee
  32217. */
  32218. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32219. /**
  32220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32222. * @returns true if engine is in deterministic lock step mode
  32223. */
  32224. isDeterministicLockStep(): boolean;
  32225. /**
  32226. * Gets the max steps when engine is running in deterministic lock step
  32227. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32228. * @returns the max steps
  32229. */
  32230. getLockstepMaxSteps(): number;
  32231. /**
  32232. * Force the mipmap generation for the given render target texture
  32233. * @param texture defines the render target texture to use
  32234. */
  32235. generateMipMapsForCubemap(texture: InternalTexture): void;
  32236. /** States */
  32237. /**
  32238. * Set various states to the webGL context
  32239. * @param culling defines backface culling state
  32240. * @param zOffset defines the value to apply to zOffset (0 by default)
  32241. * @param force defines if states must be applied even if cache is up to date
  32242. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32243. */
  32244. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32245. /**
  32246. * Set the z offset to apply to current rendering
  32247. * @param value defines the offset to apply
  32248. */
  32249. setZOffset(value: number): void;
  32250. /**
  32251. * Gets the current value of the zOffset
  32252. * @returns the current zOffset state
  32253. */
  32254. getZOffset(): number;
  32255. /**
  32256. * Enable or disable depth buffering
  32257. * @param enable defines the state to set
  32258. */
  32259. setDepthBuffer(enable: boolean): void;
  32260. /**
  32261. * Gets a boolean indicating if depth writing is enabled
  32262. * @returns the current depth writing state
  32263. */
  32264. getDepthWrite(): boolean;
  32265. /**
  32266. * Enable or disable depth writing
  32267. * @param enable defines the state to set
  32268. */
  32269. setDepthWrite(enable: boolean): void;
  32270. /**
  32271. * Enable or disable color writing
  32272. * @param enable defines the state to set
  32273. */
  32274. setColorWrite(enable: boolean): void;
  32275. /**
  32276. * Gets a boolean indicating if color writing is enabled
  32277. * @returns the current color writing state
  32278. */
  32279. getColorWrite(): boolean;
  32280. /**
  32281. * Sets alpha constants used by some alpha blending modes
  32282. * @param r defines the red component
  32283. * @param g defines the green component
  32284. * @param b defines the blue component
  32285. * @param a defines the alpha component
  32286. */
  32287. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32288. /**
  32289. * Sets the current alpha mode
  32290. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32291. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32293. */
  32294. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32295. /**
  32296. * Gets the current alpha mode
  32297. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32298. * @returns the current alpha mode
  32299. */
  32300. getAlphaMode(): number;
  32301. /**
  32302. * Sets the current alpha equation
  32303. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32304. */
  32305. setAlphaEquation(equation: number): void;
  32306. /**
  32307. * Gets the current alpha equation.
  32308. * @returns the current alpha equation
  32309. */
  32310. getAlphaEquation(): number;
  32311. /**
  32312. * Gets a boolean indicating if stencil buffer is enabled
  32313. * @returns the current stencil buffer state
  32314. */
  32315. getStencilBuffer(): boolean;
  32316. /**
  32317. * Enable or disable the stencil buffer
  32318. * @param enable defines if the stencil buffer must be enabled or disabled
  32319. */
  32320. setStencilBuffer(enable: boolean): void;
  32321. /**
  32322. * Gets the current stencil mask
  32323. * @returns a number defining the new stencil mask to use
  32324. */
  32325. getStencilMask(): number;
  32326. /**
  32327. * Sets the current stencil mask
  32328. * @param mask defines the new stencil mask to use
  32329. */
  32330. setStencilMask(mask: number): void;
  32331. /**
  32332. * Gets the current stencil function
  32333. * @returns a number defining the stencil function to use
  32334. */
  32335. getStencilFunction(): number;
  32336. /**
  32337. * Gets the current stencil reference value
  32338. * @returns a number defining the stencil reference value to use
  32339. */
  32340. getStencilFunctionReference(): number;
  32341. /**
  32342. * Gets the current stencil mask
  32343. * @returns a number defining the stencil mask to use
  32344. */
  32345. getStencilFunctionMask(): number;
  32346. /**
  32347. * Sets the current stencil function
  32348. * @param stencilFunc defines the new stencil function to use
  32349. */
  32350. setStencilFunction(stencilFunc: number): void;
  32351. /**
  32352. * Sets the current stencil reference
  32353. * @param reference defines the new stencil reference to use
  32354. */
  32355. setStencilFunctionReference(reference: number): void;
  32356. /**
  32357. * Sets the current stencil mask
  32358. * @param mask defines the new stencil mask to use
  32359. */
  32360. setStencilFunctionMask(mask: number): void;
  32361. /**
  32362. * Gets the current stencil operation when stencil fails
  32363. * @returns a number defining stencil operation to use when stencil fails
  32364. */
  32365. getStencilOperationFail(): number;
  32366. /**
  32367. * Gets the current stencil operation when depth fails
  32368. * @returns a number defining stencil operation to use when depth fails
  32369. */
  32370. getStencilOperationDepthFail(): number;
  32371. /**
  32372. * Gets the current stencil operation when stencil passes
  32373. * @returns a number defining stencil operation to use when stencil passes
  32374. */
  32375. getStencilOperationPass(): number;
  32376. /**
  32377. * Sets the stencil operation to use when stencil fails
  32378. * @param operation defines the stencil operation to use when stencil fails
  32379. */
  32380. setStencilOperationFail(operation: number): void;
  32381. /**
  32382. * Sets the stencil operation to use when depth fails
  32383. * @param operation defines the stencil operation to use when depth fails
  32384. */
  32385. setStencilOperationDepthFail(operation: number): void;
  32386. /**
  32387. * Sets the stencil operation to use when stencil passes
  32388. * @param operation defines the stencil operation to use when stencil passes
  32389. */
  32390. setStencilOperationPass(operation: number): void;
  32391. /**
  32392. * Sets a boolean indicating if the dithering state is enabled or disabled
  32393. * @param value defines the dithering state
  32394. */
  32395. setDitheringState(value: boolean): void;
  32396. /**
  32397. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32398. * @param value defines the rasterizer state
  32399. */
  32400. setRasterizerState(value: boolean): void;
  32401. /**
  32402. * Gets the current depth function
  32403. * @returns a number defining the depth function
  32404. */
  32405. getDepthFunction(): Nullable<number>;
  32406. /**
  32407. * Sets the current depth function
  32408. * @param depthFunc defines the function to use
  32409. */
  32410. setDepthFunction(depthFunc: number): void;
  32411. /**
  32412. * Sets the current depth function to GREATER
  32413. */
  32414. setDepthFunctionToGreater(): void;
  32415. /**
  32416. * Sets the current depth function to GEQUAL
  32417. */
  32418. setDepthFunctionToGreaterOrEqual(): void;
  32419. /**
  32420. * Sets the current depth function to LESS
  32421. */
  32422. setDepthFunctionToLess(): void;
  32423. /**
  32424. * Sets the current depth function to LEQUAL
  32425. */
  32426. setDepthFunctionToLessOrEqual(): void;
  32427. private _cachedStencilBuffer;
  32428. private _cachedStencilFunction;
  32429. private _cachedStencilMask;
  32430. private _cachedStencilOperationPass;
  32431. private _cachedStencilOperationFail;
  32432. private _cachedStencilOperationDepthFail;
  32433. private _cachedStencilReference;
  32434. /**
  32435. * Caches the the state of the stencil buffer
  32436. */
  32437. cacheStencilState(): void;
  32438. /**
  32439. * Restores the state of the stencil buffer
  32440. */
  32441. restoreStencilState(): void;
  32442. /**
  32443. * Directly set the WebGL Viewport
  32444. * @param x defines the x coordinate of the viewport (in screen space)
  32445. * @param y defines the y coordinate of the viewport (in screen space)
  32446. * @param width defines the width of the viewport (in screen space)
  32447. * @param height defines the height of the viewport (in screen space)
  32448. * @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
  32449. */
  32450. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32451. /**
  32452. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32453. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32454. * @param y defines the y-coordinate of the corner of the clear rectangle
  32455. * @param width defines the width of the clear rectangle
  32456. * @param height defines the height of the clear rectangle
  32457. * @param clearColor defines the clear color
  32458. */
  32459. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32460. /**
  32461. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32462. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32463. * @param y defines the y-coordinate of the corner of the clear rectangle
  32464. * @param width defines the width of the clear rectangle
  32465. * @param height defines the height of the clear rectangle
  32466. */
  32467. enableScissor(x: number, y: number, width: number, height: number): void;
  32468. /**
  32469. * Disable previously set scissor test rectangle
  32470. */
  32471. disableScissor(): void;
  32472. protected _reportDrawCall(): void;
  32473. /**
  32474. * Initializes a webVR display and starts listening to display change events
  32475. * The onVRDisplayChangedObservable will be notified upon these changes
  32476. * @returns The onVRDisplayChangedObservable
  32477. */
  32478. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32479. /** @hidden */
  32480. _prepareVRComponent(): void;
  32481. /** @hidden */
  32482. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32483. /** @hidden */
  32484. _submitVRFrame(): void;
  32485. /**
  32486. * Call this function to leave webVR mode
  32487. * Will do nothing if webVR is not supported or if there is no webVR device
  32488. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32489. */
  32490. disableVR(): void;
  32491. /**
  32492. * Gets a boolean indicating that the system is in VR mode and is presenting
  32493. * @returns true if VR mode is engaged
  32494. */
  32495. isVRPresenting(): boolean;
  32496. /** @hidden */
  32497. _requestVRFrame(): void;
  32498. /** @hidden */
  32499. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32500. /**
  32501. * Gets the source code of the vertex shader associated with a specific webGL program
  32502. * @param program defines the program to use
  32503. * @returns a string containing the source code of the vertex shader associated with the program
  32504. */
  32505. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32506. /**
  32507. * Gets the source code of the fragment shader associated with a specific webGL program
  32508. * @param program defines the program to use
  32509. * @returns a string containing the source code of the fragment shader associated with the program
  32510. */
  32511. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32512. /**
  32513. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32514. * @param x defines the x coordinate of the rectangle where pixels must be read
  32515. * @param y defines the y coordinate of the rectangle where pixels must be read
  32516. * @param width defines the width of the rectangle where pixels must be read
  32517. * @param height defines the height of the rectangle where pixels must be read
  32518. * @returns a Uint8Array containing RGBA colors
  32519. */
  32520. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32521. /**
  32522. * Sets a depth stencil texture from a render target to the according uniform.
  32523. * @param channel The texture channel
  32524. * @param uniform The uniform to set
  32525. * @param texture The render target texture containing the depth stencil texture to apply
  32526. */
  32527. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32528. /**
  32529. * Sets a texture to the webGL context from a postprocess
  32530. * @param channel defines the channel to use
  32531. * @param postProcess defines the source postprocess
  32532. */
  32533. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32534. /**
  32535. * Binds the output of the passed in post process to the texture channel specified
  32536. * @param channel The channel the texture should be bound to
  32537. * @param postProcess The post process which's output should be bound
  32538. */
  32539. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32540. /** @hidden */
  32541. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32542. protected _rebuildBuffers(): void;
  32543. _renderLoop(): void;
  32544. /**
  32545. * Toggle full screen mode
  32546. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32547. */
  32548. switchFullscreen(requestPointerLock: boolean): void;
  32549. /**
  32550. * Enters full screen mode
  32551. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32552. */
  32553. enterFullscreen(requestPointerLock: boolean): void;
  32554. /**
  32555. * Exits full screen mode
  32556. */
  32557. exitFullscreen(): void;
  32558. /**
  32559. * Enters Pointerlock mode
  32560. */
  32561. enterPointerlock(): void;
  32562. /**
  32563. * Exits Pointerlock mode
  32564. */
  32565. exitPointerlock(): void;
  32566. /**
  32567. * Begin a new frame
  32568. */
  32569. beginFrame(): void;
  32570. /**
  32571. * Enf the current frame
  32572. */
  32573. endFrame(): void;
  32574. resize(): void;
  32575. /**
  32576. * Set the compressed texture format to use, based on the formats you have, and the formats
  32577. * supported by the hardware / browser.
  32578. *
  32579. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32580. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32581. * to API arguments needed to compressed textures. This puts the burden on the container
  32582. * generator to house the arcane code for determining these for current & future formats.
  32583. *
  32584. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32585. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32586. *
  32587. * Note: The result of this call is not taken into account when a texture is base64.
  32588. *
  32589. * @param formatsAvailable defines the list of those format families you have created
  32590. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32591. *
  32592. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32593. * @returns The extension selected.
  32594. */
  32595. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32596. /**
  32597. * Force a specific size of the canvas
  32598. * @param width defines the new canvas' width
  32599. * @param height defines the new canvas' height
  32600. */
  32601. setSize(width: number, height: number): void;
  32602. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32603. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32604. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32605. _releaseTexture(texture: InternalTexture): void;
  32606. /**
  32607. * @hidden
  32608. * Rescales a texture
  32609. * @param source input texutre
  32610. * @param destination destination texture
  32611. * @param scene scene to use to render the resize
  32612. * @param internalFormat format to use when resizing
  32613. * @param onComplete callback to be called when resize has completed
  32614. */
  32615. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32616. /**
  32617. * Gets the current framerate
  32618. * @returns a number representing the framerate
  32619. */
  32620. getFps(): number;
  32621. /**
  32622. * Gets the time spent between current and previous frame
  32623. * @returns a number representing the delta time in ms
  32624. */
  32625. getDeltaTime(): number;
  32626. private _measureFps;
  32627. /**
  32628. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32629. * @param renderTarget The render target to set the frame buffer for
  32630. */
  32631. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32632. /**
  32633. * Update a dynamic index buffer
  32634. * @param indexBuffer defines the target index buffer
  32635. * @param indices defines the data to update
  32636. * @param offset defines the offset in the target index buffer where update should start
  32637. */
  32638. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32639. /**
  32640. * Updates the sample count of a render target texture
  32641. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32642. * @param texture defines the texture to update
  32643. * @param samples defines the sample count to set
  32644. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32645. */
  32646. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32647. /** @hidden */
  32648. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32649. dispose(): void;
  32650. private _disableTouchAction;
  32651. /**
  32652. * Display the loading screen
  32653. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32654. */
  32655. displayLoadingUI(): void;
  32656. /**
  32657. * Hide the loading screen
  32658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32659. */
  32660. hideLoadingUI(): void;
  32661. /**
  32662. * Gets the current loading screen object
  32663. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32664. */
  32665. /**
  32666. * Sets the current loading screen object
  32667. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32668. */
  32669. loadingScreen: ILoadingScreen;
  32670. /**
  32671. * Sets the current loading screen text
  32672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32673. */
  32674. loadingUIText: string;
  32675. /**
  32676. * Sets the current loading screen background color
  32677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32678. */
  32679. loadingUIBackgroundColor: string;
  32680. /** Pointerlock and fullscreen */
  32681. /**
  32682. * Ask the browser to promote the current element to pointerlock mode
  32683. * @param element defines the DOM element to promote
  32684. */
  32685. static _RequestPointerlock(element: HTMLElement): void;
  32686. /**
  32687. * Asks the browser to exit pointerlock mode
  32688. */
  32689. static _ExitPointerlock(): void;
  32690. /**
  32691. * Ask the browser to promote the current element to fullscreen rendering mode
  32692. * @param element defines the DOM element to promote
  32693. */
  32694. static _RequestFullscreen(element: HTMLElement): void;
  32695. /**
  32696. * Asks the browser to exit fullscreen mode
  32697. */
  32698. static _ExitFullscreen(): void;
  32699. }
  32700. }
  32701. declare module "babylonjs/Engines/engineStore" {
  32702. import { Nullable } from "babylonjs/types";
  32703. import { Engine } from "babylonjs/Engines/engine";
  32704. import { Scene } from "babylonjs/scene";
  32705. /**
  32706. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32707. * during the life time of the application.
  32708. */
  32709. export class EngineStore {
  32710. /** Gets the list of created engines */
  32711. static Instances: import("babylonjs/Engines/engine").Engine[];
  32712. /** @hidden */
  32713. static _LastCreatedScene: Nullable<Scene>;
  32714. /**
  32715. * Gets the latest created engine
  32716. */
  32717. static readonly LastCreatedEngine: Nullable<Engine>;
  32718. /**
  32719. * Gets the latest created scene
  32720. */
  32721. static readonly LastCreatedScene: Nullable<Scene>;
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Texture content used if a texture cannot loaded
  32729. * @ignorenaming
  32730. */
  32731. static FallbackTexture: string;
  32732. }
  32733. }
  32734. declare module "babylonjs/Misc/promise" {
  32735. /**
  32736. * Helper class that provides a small promise polyfill
  32737. */
  32738. export class PromisePolyfill {
  32739. /**
  32740. * Static function used to check if the polyfill is required
  32741. * If this is the case then the function will inject the polyfill to window.Promise
  32742. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32743. */
  32744. static Apply(force?: boolean): void;
  32745. }
  32746. }
  32747. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32748. /**
  32749. * Interface for screenshot methods with describe argument called `size` as object with options
  32750. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32751. */
  32752. export interface IScreenshotSize {
  32753. /**
  32754. * number in pixels for canvas height
  32755. */
  32756. height?: number;
  32757. /**
  32758. * multiplier allowing render at a higher or lower resolution
  32759. * If value is defined then height and width will be ignored and taken from camera
  32760. */
  32761. precision?: number;
  32762. /**
  32763. * number in pixels for canvas width
  32764. */
  32765. width?: number;
  32766. }
  32767. }
  32768. declare module "babylonjs/Misc/tools" {
  32769. import { Nullable, float } from "babylonjs/types";
  32770. import { DomManagement } from "babylonjs/Misc/domManagement";
  32771. import { WebRequest } from "babylonjs/Misc/webRequest";
  32772. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32773. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32774. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32775. import { Camera } from "babylonjs/Cameras/camera";
  32776. import { Engine } from "babylonjs/Engines/engine";
  32777. interface IColor4Like {
  32778. r: float;
  32779. g: float;
  32780. b: float;
  32781. a: float;
  32782. }
  32783. /**
  32784. * Class containing a set of static utilities functions
  32785. */
  32786. export class Tools {
  32787. /**
  32788. * Gets or sets the base URL to use to load assets
  32789. */
  32790. static BaseUrl: string;
  32791. /**
  32792. * Enable/Disable Custom HTTP Request Headers globally.
  32793. * default = false
  32794. * @see CustomRequestHeaders
  32795. */
  32796. static UseCustomRequestHeaders: boolean;
  32797. /**
  32798. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32799. * i.e. when loading files, where the server/service expects an Authorization header
  32800. */
  32801. static CustomRequestHeaders: {
  32802. [key: string]: string;
  32803. };
  32804. /**
  32805. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32806. */
  32807. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32808. /**
  32809. * Default behaviour for cors in the application.
  32810. * It can be a string if the expected behavior is identical in the entire app.
  32811. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32812. */
  32813. static CorsBehavior: string | ((url: string | string[]) => string);
  32814. /**
  32815. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32816. * @ignorenaming
  32817. */
  32818. static UseFallbackTexture: boolean;
  32819. /**
  32820. * Use this object to register external classes like custom textures or material
  32821. * to allow the laoders to instantiate them
  32822. */
  32823. static RegisteredExternalClasses: {
  32824. [key: string]: Object;
  32825. };
  32826. /**
  32827. * Texture content used if a texture cannot loaded
  32828. * @ignorenaming
  32829. */
  32830. static fallbackTexture: string;
  32831. /**
  32832. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32833. * @param u defines the coordinate on X axis
  32834. * @param v defines the coordinate on Y axis
  32835. * @param width defines the width of the source data
  32836. * @param height defines the height of the source data
  32837. * @param pixels defines the source byte array
  32838. * @param color defines the output color
  32839. */
  32840. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32841. /**
  32842. * Interpolates between a and b via alpha
  32843. * @param a The lower value (returned when alpha = 0)
  32844. * @param b The upper value (returned when alpha = 1)
  32845. * @param alpha The interpolation-factor
  32846. * @return The mixed value
  32847. */
  32848. static Mix(a: number, b: number, alpha: number): number;
  32849. /**
  32850. * Tries to instantiate a new object from a given class name
  32851. * @param className defines the class name to instantiate
  32852. * @returns the new object or null if the system was not able to do the instantiation
  32853. */
  32854. static Instantiate(className: string): any;
  32855. /**
  32856. * Provides a slice function that will work even on IE
  32857. * @param data defines the array to slice
  32858. * @param start defines the start of the data (optional)
  32859. * @param end defines the end of the data (optional)
  32860. * @returns the new sliced array
  32861. */
  32862. static Slice<T>(data: T, start?: number, end?: number): T;
  32863. /**
  32864. * Polyfill for setImmediate
  32865. * @param action defines the action to execute after the current execution block
  32866. */
  32867. static SetImmediate(action: () => void): void;
  32868. /**
  32869. * Function indicating if a number is an exponent of 2
  32870. * @param value defines the value to test
  32871. * @returns true if the value is an exponent of 2
  32872. */
  32873. static IsExponentOfTwo(value: number): boolean;
  32874. private static _tmpFloatArray;
  32875. /**
  32876. * Returns the nearest 32-bit single precision float representation of a Number
  32877. * @param value A Number. If the parameter is of a different type, it will get converted
  32878. * to a number or to NaN if it cannot be converted
  32879. * @returns number
  32880. */
  32881. static FloatRound(value: number): number;
  32882. /**
  32883. * Extracts the filename from a path
  32884. * @param path defines the path to use
  32885. * @returns the filename
  32886. */
  32887. static GetFilename(path: string): string;
  32888. /**
  32889. * Extracts the "folder" part of a path (everything before the filename).
  32890. * @param uri The URI to extract the info from
  32891. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32892. * @returns The "folder" part of the path
  32893. */
  32894. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32895. /**
  32896. * Extracts text content from a DOM element hierarchy
  32897. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32898. */
  32899. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32900. /**
  32901. * Convert an angle in radians to degrees
  32902. * @param angle defines the angle to convert
  32903. * @returns the angle in degrees
  32904. */
  32905. static ToDegrees(angle: number): number;
  32906. /**
  32907. * Convert an angle in degrees to radians
  32908. * @param angle defines the angle to convert
  32909. * @returns the angle in radians
  32910. */
  32911. static ToRadians(angle: number): number;
  32912. /**
  32913. * Encode a buffer to a base64 string
  32914. * @param buffer defines the buffer to encode
  32915. * @returns the encoded string
  32916. */
  32917. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32918. /**
  32919. * Returns an array if obj is not an array
  32920. * @param obj defines the object to evaluate as an array
  32921. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32922. * @returns either obj directly if obj is an array or a new array containing obj
  32923. */
  32924. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32925. /**
  32926. * Gets the pointer prefix to use
  32927. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32928. */
  32929. static GetPointerPrefix(): string;
  32930. /**
  32931. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32932. * @param url define the url we are trying
  32933. * @param element define the dom element where to configure the cors policy
  32934. */
  32935. static SetCorsBehavior(url: string | string[], element: {
  32936. crossOrigin: string | null;
  32937. }): void;
  32938. /**
  32939. * Removes unwanted characters from an url
  32940. * @param url defines the url to clean
  32941. * @returns the cleaned url
  32942. */
  32943. static CleanUrl(url: string): string;
  32944. /**
  32945. * Gets or sets a function used to pre-process url before using them to load assets
  32946. */
  32947. static PreprocessUrl: (url: string) => string;
  32948. /**
  32949. * Loads an image as an HTMLImageElement.
  32950. * @param input url string, ArrayBuffer, or Blob to load
  32951. * @param onLoad callback called when the image successfully loads
  32952. * @param onError callback called when the image fails to load
  32953. * @param offlineProvider offline provider for caching
  32954. * @param mimeType optional mime type
  32955. * @returns the HTMLImageElement of the loaded image
  32956. */
  32957. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32958. /**
  32959. * Loads a file
  32960. * @param url url string, ArrayBuffer, or Blob to load
  32961. * @param onSuccess callback called when the file successfully loads
  32962. * @param onProgress callback called while file is loading (if the server supports this mode)
  32963. * @param offlineProvider defines the offline provider for caching
  32964. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32965. * @param onError callback called when the file fails to load
  32966. * @returns a file request object
  32967. */
  32968. 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;
  32969. /**
  32970. * Loads a file from a url
  32971. * @param url the file url to load
  32972. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32973. */
  32974. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32975. /**
  32976. * Load a script (identified by an url). When the url returns, the
  32977. * content of this file is added into a new script element, attached to the DOM (body element)
  32978. * @param scriptUrl defines the url of the script to laod
  32979. * @param onSuccess defines the callback called when the script is loaded
  32980. * @param onError defines the callback to call if an error occurs
  32981. * @param scriptId defines the id of the script element
  32982. */
  32983. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32984. /**
  32985. * Load an asynchronous script (identified by an url). When the url returns, the
  32986. * content of this file is added into a new script element, attached to the DOM (body element)
  32987. * @param scriptUrl defines the url of the script to laod
  32988. * @param scriptId defines the id of the script element
  32989. * @returns a promise request object
  32990. */
  32991. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32992. /**
  32993. * Loads a file from a blob
  32994. * @param fileToLoad defines the blob to use
  32995. * @param callback defines the callback to call when data is loaded
  32996. * @param progressCallback defines the callback to call during loading process
  32997. * @returns a file request object
  32998. */
  32999. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33000. /**
  33001. * Loads a file
  33002. * @param fileToLoad defines the file to load
  33003. * @param callback defines the callback to call when data is loaded
  33004. * @param progressCallBack defines the callback to call during loading process
  33005. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33006. * @returns a file request object
  33007. */
  33008. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33009. /**
  33010. * Creates a data url from a given string content
  33011. * @param content defines the content to convert
  33012. * @returns the new data url link
  33013. */
  33014. static FileAsURL(content: string): string;
  33015. /**
  33016. * Format the given number to a specific decimal format
  33017. * @param value defines the number to format
  33018. * @param decimals defines the number of decimals to use
  33019. * @returns the formatted string
  33020. */
  33021. static Format(value: number, decimals?: number): string;
  33022. /**
  33023. * Tries to copy an object by duplicating every property
  33024. * @param source defines the source object
  33025. * @param destination defines the target object
  33026. * @param doNotCopyList defines a list of properties to avoid
  33027. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33028. */
  33029. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33030. /**
  33031. * Gets a boolean indicating if the given object has no own property
  33032. * @param obj defines the object to test
  33033. * @returns true if object has no own property
  33034. */
  33035. static IsEmpty(obj: any): boolean;
  33036. /**
  33037. * Function used to register events at window level
  33038. * @param windowElement defines the Window object to use
  33039. * @param events defines the events to register
  33040. */
  33041. static RegisterTopRootEvents(windowElement: Window, events: {
  33042. name: string;
  33043. handler: Nullable<(e: FocusEvent) => any>;
  33044. }[]): void;
  33045. /**
  33046. * Function used to unregister events from window level
  33047. * @param windowElement defines the Window object to use
  33048. * @param events defines the events to unregister
  33049. */
  33050. static UnregisterTopRootEvents(windowElement: Window, events: {
  33051. name: string;
  33052. handler: Nullable<(e: FocusEvent) => any>;
  33053. }[]): void;
  33054. /**
  33055. * @ignore
  33056. */
  33057. static _ScreenshotCanvas: HTMLCanvasElement;
  33058. /**
  33059. * Dumps the current bound framebuffer
  33060. * @param width defines the rendering width
  33061. * @param height defines the rendering height
  33062. * @param engine defines the hosting engine
  33063. * @param successCallback defines the callback triggered once the data are available
  33064. * @param mimeType defines the mime type of the result
  33065. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33066. */
  33067. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33068. /**
  33069. * Converts the canvas data to blob.
  33070. * This acts as a polyfill for browsers not supporting the to blob function.
  33071. * @param canvas Defines the canvas to extract the data from
  33072. * @param successCallback Defines the callback triggered once the data are available
  33073. * @param mimeType Defines the mime type of the result
  33074. */
  33075. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33076. /**
  33077. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33078. * @param successCallback defines the callback triggered once the data are available
  33079. * @param mimeType defines the mime type of the result
  33080. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33081. */
  33082. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33083. /**
  33084. * Downloads a blob in the browser
  33085. * @param blob defines the blob to download
  33086. * @param fileName defines the name of the downloaded file
  33087. */
  33088. static Download(blob: Blob, fileName: string): void;
  33089. /**
  33090. * Captures a screenshot of the current rendering
  33091. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33092. * @param engine defines the rendering engine
  33093. * @param camera defines the source camera
  33094. * @param size This parameter can be set to a single number or to an object with the
  33095. * following (optional) properties: precision, width, height. If a single number is passed,
  33096. * it will be used for both width and height. If an object is passed, the screenshot size
  33097. * will be derived from the parameters. The precision property is a multiplier allowing
  33098. * rendering at a higher or lower resolution
  33099. * @param successCallback defines the callback receives a single parameter which contains the
  33100. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33101. * src parameter of an <img> to display it
  33102. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33103. * Check your browser for supported MIME types
  33104. */
  33105. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33106. /**
  33107. * Captures a screenshot of the current rendering
  33108. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33109. * @param engine defines the rendering engine
  33110. * @param camera defines the source camera
  33111. * @param size This parameter can be set to a single number or to an object with the
  33112. * following (optional) properties: precision, width, height. If a single number is passed,
  33113. * it will be used for both width and height. If an object is passed, the screenshot size
  33114. * will be derived from the parameters. The precision property is a multiplier allowing
  33115. * rendering at a higher or lower resolution
  33116. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33117. * Check your browser for supported MIME types
  33118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33119. * to the src parameter of an <img> to display it
  33120. */
  33121. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33122. /**
  33123. * Generates an image screenshot from the specified camera.
  33124. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33125. * @param engine The engine to use for rendering
  33126. * @param camera The camera to use for rendering
  33127. * @param size This parameter can be set to a single number or to an object with the
  33128. * following (optional) properties: precision, width, height. If a single number is passed,
  33129. * it will be used for both width and height. If an object is passed, the screenshot size
  33130. * will be derived from the parameters. The precision property is a multiplier allowing
  33131. * rendering at a higher or lower resolution
  33132. * @param successCallback The callback receives a single parameter which contains the
  33133. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33134. * src parameter of an <img> to display it
  33135. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33136. * Check your browser for supported MIME types
  33137. * @param samples Texture samples (default: 1)
  33138. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33139. * @param fileName A name for for the downloaded file.
  33140. */
  33141. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33142. /**
  33143. * Generates an image screenshot from the specified camera.
  33144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33145. * @param engine The engine to use for rendering
  33146. * @param camera The camera to use for rendering
  33147. * @param size This parameter can be set to a single number or to an object with the
  33148. * following (optional) properties: precision, width, height. If a single number is passed,
  33149. * it will be used for both width and height. If an object is passed, the screenshot size
  33150. * will be derived from the parameters. The precision property is a multiplier allowing
  33151. * rendering at a higher or lower resolution
  33152. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33153. * Check your browser for supported MIME types
  33154. * @param samples Texture samples (default: 1)
  33155. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33156. * @param fileName A name for for the downloaded file.
  33157. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33158. * to the src parameter of an <img> to display it
  33159. */
  33160. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33161. /**
  33162. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33163. * Be aware Math.random() could cause collisions, but:
  33164. * "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"
  33165. * @returns a pseudo random id
  33166. */
  33167. static RandomId(): string;
  33168. /**
  33169. * Test if the given uri is a base64 string
  33170. * @param uri The uri to test
  33171. * @return True if the uri is a base64 string or false otherwise
  33172. */
  33173. static IsBase64(uri: string): boolean;
  33174. /**
  33175. * Decode the given base64 uri.
  33176. * @param uri The uri to decode
  33177. * @return The decoded base64 data.
  33178. */
  33179. static DecodeBase64(uri: string): ArrayBuffer;
  33180. /**
  33181. * Gets the absolute url.
  33182. * @param url the input url
  33183. * @return the absolute url
  33184. */
  33185. static GetAbsoluteUrl(url: string): string;
  33186. /**
  33187. * No log
  33188. */
  33189. static readonly NoneLogLevel: number;
  33190. /**
  33191. * Only message logs
  33192. */
  33193. static readonly MessageLogLevel: number;
  33194. /**
  33195. * Only warning logs
  33196. */
  33197. static readonly WarningLogLevel: number;
  33198. /**
  33199. * Only error logs
  33200. */
  33201. static readonly ErrorLogLevel: number;
  33202. /**
  33203. * All logs
  33204. */
  33205. static readonly AllLogLevel: number;
  33206. /**
  33207. * Gets a value indicating the number of loading errors
  33208. * @ignorenaming
  33209. */
  33210. static readonly errorsCount: number;
  33211. /**
  33212. * Callback called when a new log is added
  33213. */
  33214. static OnNewCacheEntry: (entry: string) => void;
  33215. /**
  33216. * Log a message to the console
  33217. * @param message defines the message to log
  33218. */
  33219. static Log(message: string): void;
  33220. /**
  33221. * Write a warning message to the console
  33222. * @param message defines the message to log
  33223. */
  33224. static Warn(message: string): void;
  33225. /**
  33226. * Write an error message to the console
  33227. * @param message defines the message to log
  33228. */
  33229. static Error(message: string): void;
  33230. /**
  33231. * Gets current log cache (list of logs)
  33232. */
  33233. static readonly LogCache: string;
  33234. /**
  33235. * Clears the log cache
  33236. */
  33237. static ClearLogCache(): void;
  33238. /**
  33239. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33240. */
  33241. static LogLevels: number;
  33242. /**
  33243. * Checks if the window object exists
  33244. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33245. */
  33246. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33247. /**
  33248. * No performance log
  33249. */
  33250. static readonly PerformanceNoneLogLevel: number;
  33251. /**
  33252. * Use user marks to log performance
  33253. */
  33254. static readonly PerformanceUserMarkLogLevel: number;
  33255. /**
  33256. * Log performance to the console
  33257. */
  33258. static readonly PerformanceConsoleLogLevel: number;
  33259. private static _performance;
  33260. /**
  33261. * Sets the current performance log level
  33262. */
  33263. static PerformanceLogLevel: number;
  33264. private static _StartPerformanceCounterDisabled;
  33265. private static _EndPerformanceCounterDisabled;
  33266. private static _StartUserMark;
  33267. private static _EndUserMark;
  33268. private static _StartPerformanceConsole;
  33269. private static _EndPerformanceConsole;
  33270. /**
  33271. * Starts a performance counter
  33272. */
  33273. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33274. /**
  33275. * Ends a specific performance coutner
  33276. */
  33277. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33278. /**
  33279. * Gets either window.performance.now() if supported or Date.now() else
  33280. */
  33281. static readonly Now: number;
  33282. /**
  33283. * This method will return the name of the class used to create the instance of the given object.
  33284. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33285. * @param object the object to get the class name from
  33286. * @param isType defines if the object is actually a type
  33287. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33288. */
  33289. static GetClassName(object: any, isType?: boolean): string;
  33290. /**
  33291. * Gets the first element of an array satisfying a given predicate
  33292. * @param array defines the array to browse
  33293. * @param predicate defines the predicate to use
  33294. * @returns null if not found or the element
  33295. */
  33296. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33297. /**
  33298. * This method will return the name of the full name of the class, including its owning module (if any).
  33299. * 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).
  33300. * @param object the object to get the class name from
  33301. * @param isType defines if the object is actually a type
  33302. * @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.
  33303. * @ignorenaming
  33304. */
  33305. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33306. /**
  33307. * Returns a promise that resolves after the given amount of time.
  33308. * @param delay Number of milliseconds to delay
  33309. * @returns Promise that resolves after the given amount of time
  33310. */
  33311. static DelayAsync(delay: number): Promise<void>;
  33312. }
  33313. /**
  33314. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33315. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33316. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33317. * @param name The name of the class, case should be preserved
  33318. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33319. */
  33320. export function className(name: string, module?: string): (target: Object) => void;
  33321. /**
  33322. * An implementation of a loop for asynchronous functions.
  33323. */
  33324. export class AsyncLoop {
  33325. /**
  33326. * Defines the number of iterations for the loop
  33327. */
  33328. iterations: number;
  33329. /**
  33330. * Defines the current index of the loop.
  33331. */
  33332. index: number;
  33333. private _done;
  33334. private _fn;
  33335. private _successCallback;
  33336. /**
  33337. * Constructor.
  33338. * @param iterations the number of iterations.
  33339. * @param func the function to run each iteration
  33340. * @param successCallback the callback that will be called upon succesful execution
  33341. * @param offset starting offset.
  33342. */
  33343. constructor(
  33344. /**
  33345. * Defines the number of iterations for the loop
  33346. */
  33347. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33348. /**
  33349. * Execute the next iteration. Must be called after the last iteration was finished.
  33350. */
  33351. executeNext(): void;
  33352. /**
  33353. * Break the loop and run the success callback.
  33354. */
  33355. breakLoop(): void;
  33356. /**
  33357. * Create and run an async loop.
  33358. * @param iterations the number of iterations.
  33359. * @param fn the function to run each iteration
  33360. * @param successCallback the callback that will be called upon succesful execution
  33361. * @param offset starting offset.
  33362. * @returns the created async loop object
  33363. */
  33364. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33365. /**
  33366. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33367. * @param iterations total number of iterations
  33368. * @param syncedIterations number of synchronous iterations in each async iteration.
  33369. * @param fn the function to call each iteration.
  33370. * @param callback a success call back that will be called when iterating stops.
  33371. * @param breakFunction a break condition (optional)
  33372. * @param timeout timeout settings for the setTimeout function. default - 0.
  33373. * @returns the created async loop object
  33374. */
  33375. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33376. }
  33377. }
  33378. declare module "babylonjs/Misc/stringDictionary" {
  33379. import { Nullable } from "babylonjs/types";
  33380. /**
  33381. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33382. * The underlying implementation relies on an associative array to ensure the best performances.
  33383. * The value can be anything including 'null' but except 'undefined'
  33384. */
  33385. export class StringDictionary<T> {
  33386. /**
  33387. * This will clear this dictionary and copy the content from the 'source' one.
  33388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33389. * @param source the dictionary to take the content from and copy to this dictionary
  33390. */
  33391. copyFrom(source: StringDictionary<T>): void;
  33392. /**
  33393. * Get a value based from its key
  33394. * @param key the given key to get the matching value from
  33395. * @return the value if found, otherwise undefined is returned
  33396. */
  33397. get(key: string): T | undefined;
  33398. /**
  33399. * Get a value from its key or add it if it doesn't exist.
  33400. * This method will ensure you that a given key/data will be present in the dictionary.
  33401. * @param key the given key to get the matching value from
  33402. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33403. * The factory will only be invoked if there's no data for the given key.
  33404. * @return the value corresponding to the key.
  33405. */
  33406. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33407. /**
  33408. * Get a value from its key if present in the dictionary otherwise add it
  33409. * @param key the key to get the value from
  33410. * @param val if there's no such key/value pair in the dictionary add it with this value
  33411. * @return the value corresponding to the key
  33412. */
  33413. getOrAdd(key: string, val: T): T;
  33414. /**
  33415. * Check if there's a given key in the dictionary
  33416. * @param key the key to check for
  33417. * @return true if the key is present, false otherwise
  33418. */
  33419. contains(key: string): boolean;
  33420. /**
  33421. * Add a new key and its corresponding value
  33422. * @param key the key to add
  33423. * @param value the value corresponding to the key
  33424. * @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
  33425. */
  33426. add(key: string, value: T): boolean;
  33427. /**
  33428. * Update a specific value associated to a key
  33429. * @param key defines the key to use
  33430. * @param value defines the value to store
  33431. * @returns true if the value was updated (or false if the key was not found)
  33432. */
  33433. set(key: string, value: T): boolean;
  33434. /**
  33435. * Get the element of the given key and remove it from the dictionary
  33436. * @param key defines the key to search
  33437. * @returns the value associated with the key or null if not found
  33438. */
  33439. getAndRemove(key: string): Nullable<T>;
  33440. /**
  33441. * Remove a key/value from the dictionary.
  33442. * @param key the key to remove
  33443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33444. */
  33445. remove(key: string): boolean;
  33446. /**
  33447. * Clear the whole content of the dictionary
  33448. */
  33449. clear(): void;
  33450. /**
  33451. * Gets the current count
  33452. */
  33453. readonly count: number;
  33454. /**
  33455. * Execute a callback on each key/val of the dictionary.
  33456. * Note that you can remove any element in this dictionary in the callback implementation
  33457. * @param callback the callback to execute on a given key/value pair
  33458. */
  33459. forEach(callback: (key: string, val: T) => void): void;
  33460. /**
  33461. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33462. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33463. * Note that you can remove any element in this dictionary in the callback implementation
  33464. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33465. * @returns the first item
  33466. */
  33467. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33468. private _count;
  33469. private _data;
  33470. }
  33471. }
  33472. declare module "babylonjs/Collisions/collisionCoordinator" {
  33473. import { Nullable } from "babylonjs/types";
  33474. import { Scene } from "babylonjs/scene";
  33475. import { Vector3 } from "babylonjs/Maths/math.vector";
  33476. import { Collider } from "babylonjs/Collisions/collider";
  33477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33478. /** @hidden */
  33479. export interface ICollisionCoordinator {
  33480. createCollider(): Collider;
  33481. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33482. init(scene: Scene): void;
  33483. }
  33484. /** @hidden */
  33485. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33486. private _scene;
  33487. private _scaledPosition;
  33488. private _scaledVelocity;
  33489. private _finalPosition;
  33490. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33491. createCollider(): Collider;
  33492. init(scene: Scene): void;
  33493. private _collideWithWorld;
  33494. }
  33495. }
  33496. declare module "babylonjs/Inputs/scene.inputManager" {
  33497. import { Nullable } from "babylonjs/types";
  33498. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33499. import { Vector2 } from "babylonjs/Maths/math.vector";
  33500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33501. import { Scene } from "babylonjs/scene";
  33502. /**
  33503. * Class used to manage all inputs for the scene.
  33504. */
  33505. export class InputManager {
  33506. /** The distance in pixel that you have to move to prevent some events */
  33507. static DragMovementThreshold: number;
  33508. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33509. static LongPressDelay: number;
  33510. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33511. static DoubleClickDelay: number;
  33512. /** If you need to check double click without raising a single click at first click, enable this flag */
  33513. static ExclusiveDoubleClickMode: boolean;
  33514. private _wheelEventName;
  33515. private _onPointerMove;
  33516. private _onPointerDown;
  33517. private _onPointerUp;
  33518. private _initClickEvent;
  33519. private _initActionManager;
  33520. private _delayedSimpleClick;
  33521. private _delayedSimpleClickTimeout;
  33522. private _previousDelayedSimpleClickTimeout;
  33523. private _meshPickProceed;
  33524. private _previousButtonPressed;
  33525. private _currentPickResult;
  33526. private _previousPickResult;
  33527. private _totalPointersPressed;
  33528. private _doubleClickOccured;
  33529. private _pointerOverMesh;
  33530. private _pickedDownMesh;
  33531. private _pickedUpMesh;
  33532. private _pointerX;
  33533. private _pointerY;
  33534. private _unTranslatedPointerX;
  33535. private _unTranslatedPointerY;
  33536. private _startingPointerPosition;
  33537. private _previousStartingPointerPosition;
  33538. private _startingPointerTime;
  33539. private _previousStartingPointerTime;
  33540. private _pointerCaptures;
  33541. private _onKeyDown;
  33542. private _onKeyUp;
  33543. private _onCanvasFocusObserver;
  33544. private _onCanvasBlurObserver;
  33545. private _scene;
  33546. /**
  33547. * Creates a new InputManager
  33548. * @param scene defines the hosting scene
  33549. */
  33550. constructor(scene: Scene);
  33551. /**
  33552. * Gets the mesh that is currently under the pointer
  33553. */
  33554. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33555. /**
  33556. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33557. */
  33558. readonly unTranslatedPointer: Vector2;
  33559. /**
  33560. * Gets or sets the current on-screen X position of the pointer
  33561. */
  33562. pointerX: number;
  33563. /**
  33564. * Gets or sets the current on-screen Y position of the pointer
  33565. */
  33566. pointerY: number;
  33567. private _updatePointerPosition;
  33568. private _processPointerMove;
  33569. private _setRayOnPointerInfo;
  33570. private _checkPrePointerObservable;
  33571. /**
  33572. * Use this method to simulate a pointer move on a mesh
  33573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33576. */
  33577. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33578. /**
  33579. * Use this method to simulate a pointer down on a mesh
  33580. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33581. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33582. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33583. */
  33584. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33585. private _processPointerDown;
  33586. /** @hidden */
  33587. _isPointerSwiping(): boolean;
  33588. /**
  33589. * Use this method to simulate a pointer up on a mesh
  33590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33593. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33594. */
  33595. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33596. private _processPointerUp;
  33597. /**
  33598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33600. * @returns true if the pointer was captured
  33601. */
  33602. isPointerCaptured(pointerId?: number): boolean;
  33603. /**
  33604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33605. * @param attachUp defines if you want to attach events to pointerup
  33606. * @param attachDown defines if you want to attach events to pointerdown
  33607. * @param attachMove defines if you want to attach events to pointermove
  33608. */
  33609. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33610. /**
  33611. * Detaches all event handlers
  33612. */
  33613. detachControl(): void;
  33614. /**
  33615. * Force the value of meshUnderPointer
  33616. * @param mesh defines the mesh to use
  33617. */
  33618. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33619. /**
  33620. * Gets the mesh under the pointer
  33621. * @returns a Mesh or null if no mesh is under the pointer
  33622. */
  33623. getPointerOverMesh(): Nullable<AbstractMesh>;
  33624. }
  33625. }
  33626. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33627. /**
  33628. * Helper class used to generate session unique ID
  33629. */
  33630. export class UniqueIdGenerator {
  33631. private static _UniqueIdCounter;
  33632. /**
  33633. * Gets an unique (relatively to the current scene) Id
  33634. */
  33635. static readonly UniqueId: number;
  33636. }
  33637. }
  33638. declare module "babylonjs/Animations/animationGroup" {
  33639. import { Animatable } from "babylonjs/Animations/animatable";
  33640. import { Animation } from "babylonjs/Animations/animation";
  33641. import { Scene, IDisposable } from "babylonjs/scene";
  33642. import { Observable } from "babylonjs/Misc/observable";
  33643. import { Nullable } from "babylonjs/types";
  33644. import "babylonjs/Animations/animatable";
  33645. /**
  33646. * This class defines the direct association between an animation and a target
  33647. */
  33648. export class TargetedAnimation {
  33649. /**
  33650. * Animation to perform
  33651. */
  33652. animation: Animation;
  33653. /**
  33654. * Target to animate
  33655. */
  33656. target: any;
  33657. /**
  33658. * Serialize the object
  33659. * @returns the JSON object representing the current entity
  33660. */
  33661. serialize(): any;
  33662. }
  33663. /**
  33664. * Use this class to create coordinated animations on multiple targets
  33665. */
  33666. export class AnimationGroup implements IDisposable {
  33667. /** The name of the animation group */
  33668. name: string;
  33669. private _scene;
  33670. private _targetedAnimations;
  33671. private _animatables;
  33672. private _from;
  33673. private _to;
  33674. private _isStarted;
  33675. private _isPaused;
  33676. private _speedRatio;
  33677. private _loopAnimation;
  33678. /**
  33679. * Gets or sets the unique id of the node
  33680. */
  33681. uniqueId: number;
  33682. /**
  33683. * This observable will notify when one animation have ended
  33684. */
  33685. onAnimationEndObservable: Observable<TargetedAnimation>;
  33686. /**
  33687. * Observer raised when one animation loops
  33688. */
  33689. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33690. /**
  33691. * This observable will notify when all animations have ended.
  33692. */
  33693. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33694. /**
  33695. * This observable will notify when all animations have paused.
  33696. */
  33697. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33698. /**
  33699. * This observable will notify when all animations are playing.
  33700. */
  33701. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33702. /**
  33703. * Gets the first frame
  33704. */
  33705. readonly from: number;
  33706. /**
  33707. * Gets the last frame
  33708. */
  33709. readonly to: number;
  33710. /**
  33711. * Define if the animations are started
  33712. */
  33713. readonly isStarted: boolean;
  33714. /**
  33715. * Gets a value indicating that the current group is playing
  33716. */
  33717. readonly isPlaying: boolean;
  33718. /**
  33719. * Gets or sets the speed ratio to use for all animations
  33720. */
  33721. /**
  33722. * Gets or sets the speed ratio to use for all animations
  33723. */
  33724. speedRatio: number;
  33725. /**
  33726. * Gets or sets if all animations should loop or not
  33727. */
  33728. loopAnimation: boolean;
  33729. /**
  33730. * Gets the targeted animations for this animation group
  33731. */
  33732. readonly targetedAnimations: Array<TargetedAnimation>;
  33733. /**
  33734. * returning the list of animatables controlled by this animation group.
  33735. */
  33736. readonly animatables: Array<Animatable>;
  33737. /**
  33738. * Instantiates a new Animation Group.
  33739. * This helps managing several animations at once.
  33740. * @see http://doc.babylonjs.com/how_to/group
  33741. * @param name Defines the name of the group
  33742. * @param scene Defines the scene the group belongs to
  33743. */
  33744. constructor(
  33745. /** The name of the animation group */
  33746. name: string, scene?: Nullable<Scene>);
  33747. /**
  33748. * Add an animation (with its target) in the group
  33749. * @param animation defines the animation we want to add
  33750. * @param target defines the target of the animation
  33751. * @returns the TargetedAnimation object
  33752. */
  33753. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33754. /**
  33755. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33756. * It can add constant keys at begin or end
  33757. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33758. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33759. * @returns the animation group
  33760. */
  33761. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33762. /**
  33763. * Start all animations on given targets
  33764. * @param loop defines if animations must loop
  33765. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33766. * @param from defines the from key (optional)
  33767. * @param to defines the to key (optional)
  33768. * @returns the current animation group
  33769. */
  33770. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33771. /**
  33772. * Pause all animations
  33773. * @returns the animation group
  33774. */
  33775. pause(): AnimationGroup;
  33776. /**
  33777. * Play all animations to initial state
  33778. * This function will start() the animations if they were not started or will restart() them if they were paused
  33779. * @param loop defines if animations must loop
  33780. * @returns the animation group
  33781. */
  33782. play(loop?: boolean): AnimationGroup;
  33783. /**
  33784. * Reset all animations to initial state
  33785. * @returns the animation group
  33786. */
  33787. reset(): AnimationGroup;
  33788. /**
  33789. * Restart animations from key 0
  33790. * @returns the animation group
  33791. */
  33792. restart(): AnimationGroup;
  33793. /**
  33794. * Stop all animations
  33795. * @returns the animation group
  33796. */
  33797. stop(): AnimationGroup;
  33798. /**
  33799. * Set animation weight for all animatables
  33800. * @param weight defines the weight to use
  33801. * @return the animationGroup
  33802. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33803. */
  33804. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33805. /**
  33806. * Synchronize and normalize all animatables with a source animatable
  33807. * @param root defines the root animatable to synchronize with
  33808. * @return the animationGroup
  33809. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33810. */
  33811. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33812. /**
  33813. * Goes to a specific frame in this animation group
  33814. * @param frame the frame number to go to
  33815. * @return the animationGroup
  33816. */
  33817. goToFrame(frame: number): AnimationGroup;
  33818. /**
  33819. * Dispose all associated resources
  33820. */
  33821. dispose(): void;
  33822. private _checkAnimationGroupEnded;
  33823. /**
  33824. * Clone the current animation group and returns a copy
  33825. * @param newName defines the name of the new group
  33826. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33827. * @returns the new aniamtion group
  33828. */
  33829. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33830. /**
  33831. * Serializes the animationGroup to an object
  33832. * @returns Serialized object
  33833. */
  33834. serialize(): any;
  33835. /**
  33836. * Returns a new AnimationGroup object parsed from the source provided.
  33837. * @param parsedAnimationGroup defines the source
  33838. * @param scene defines the scene that will receive the animationGroup
  33839. * @returns a new AnimationGroup
  33840. */
  33841. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33842. /**
  33843. * Returns the string "AnimationGroup"
  33844. * @returns "AnimationGroup"
  33845. */
  33846. getClassName(): string;
  33847. /**
  33848. * Creates a detailled string about the object
  33849. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33850. * @returns a string representing the object
  33851. */
  33852. toString(fullDetails?: boolean): string;
  33853. }
  33854. }
  33855. declare module "babylonjs/scene" {
  33856. import { Nullable } from "babylonjs/types";
  33857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33858. import { Observable } from "babylonjs/Misc/observable";
  33859. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33860. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33861. import { Geometry } from "babylonjs/Meshes/geometry";
  33862. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33865. import { Mesh } from "babylonjs/Meshes/mesh";
  33866. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33867. import { Bone } from "babylonjs/Bones/bone";
  33868. import { Skeleton } from "babylonjs/Bones/skeleton";
  33869. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33870. import { Camera } from "babylonjs/Cameras/camera";
  33871. import { AbstractScene } from "babylonjs/abstractScene";
  33872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33874. import { Material } from "babylonjs/Materials/material";
  33875. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33876. import { Effect } from "babylonjs/Materials/effect";
  33877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33878. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33879. import { Light } from "babylonjs/Lights/light";
  33880. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33881. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33882. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33883. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33885. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33886. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33887. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33888. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33889. import { Engine } from "babylonjs/Engines/engine";
  33890. import { Node } from "babylonjs/node";
  33891. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33893. import { WebRequest } from "babylonjs/Misc/webRequest";
  33894. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33895. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33896. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33897. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33898. import { Plane } from "babylonjs/Maths/math.plane";
  33899. import { Ray } from "babylonjs/Culling/ray";
  33900. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33901. import { Animation } from "babylonjs/Animations/animation";
  33902. import { Animatable } from "babylonjs/Animations/animatable";
  33903. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33904. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33905. import { Collider } from "babylonjs/Collisions/collider";
  33906. /**
  33907. * Define an interface for all classes that will hold resources
  33908. */
  33909. export interface IDisposable {
  33910. /**
  33911. * Releases all held resources
  33912. */
  33913. dispose(): void;
  33914. }
  33915. /** Interface defining initialization parameters for Scene class */
  33916. export interface SceneOptions {
  33917. /**
  33918. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33919. * It will improve performance when the number of geometries becomes important.
  33920. */
  33921. useGeometryUniqueIdsMap?: boolean;
  33922. /**
  33923. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33924. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33925. */
  33926. useMaterialMeshMap?: boolean;
  33927. /**
  33928. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33929. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33930. */
  33931. useClonedMeshhMap?: boolean;
  33932. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33933. virtual?: boolean;
  33934. }
  33935. /**
  33936. * Represents a scene to be rendered by the engine.
  33937. * @see http://doc.babylonjs.com/features/scene
  33938. */
  33939. export class Scene extends AbstractScene implements IAnimatable {
  33940. /** The fog is deactivated */
  33941. static readonly FOGMODE_NONE: number;
  33942. /** The fog density is following an exponential function */
  33943. static readonly FOGMODE_EXP: number;
  33944. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33945. static readonly FOGMODE_EXP2: number;
  33946. /** The fog density is following a linear function. */
  33947. static readonly FOGMODE_LINEAR: number;
  33948. /**
  33949. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33950. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33951. */
  33952. static MinDeltaTime: number;
  33953. /**
  33954. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33955. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33956. */
  33957. static MaxDeltaTime: number;
  33958. /**
  33959. * Factory used to create the default material.
  33960. * @param name The name of the material to create
  33961. * @param scene The scene to create the material for
  33962. * @returns The default material
  33963. */
  33964. static DefaultMaterialFactory(scene: Scene): Material;
  33965. /**
  33966. * Factory used to create the a collision coordinator.
  33967. * @returns The collision coordinator
  33968. */
  33969. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33970. /** @hidden */
  33971. _inputManager: InputManager;
  33972. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33973. cameraToUseForPointers: Nullable<Camera>;
  33974. /** @hidden */
  33975. readonly _isScene: boolean;
  33976. /**
  33977. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33978. */
  33979. autoClear: boolean;
  33980. /**
  33981. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33982. */
  33983. autoClearDepthAndStencil: boolean;
  33984. /**
  33985. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33986. */
  33987. clearColor: Color4;
  33988. /**
  33989. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33990. */
  33991. ambientColor: Color3;
  33992. /**
  33993. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33994. * It should only be one of the following (if not the default embedded one):
  33995. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33996. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33997. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33998. * The material properties need to be setup according to the type of texture in use.
  33999. */
  34000. environmentBRDFTexture: BaseTexture;
  34001. /** @hidden */
  34002. protected _environmentTexture: Nullable<BaseTexture>;
  34003. /**
  34004. * Texture used in all pbr material as the reflection texture.
  34005. * As in the majority of the scene they are the same (exception for multi room and so on),
  34006. * this is easier to reference from here than from all the materials.
  34007. */
  34008. /**
  34009. * Texture used in all pbr material as the reflection texture.
  34010. * As in the majority of the scene they are the same (exception for multi room and so on),
  34011. * this is easier to set here than in all the materials.
  34012. */
  34013. environmentTexture: Nullable<BaseTexture>;
  34014. /** @hidden */
  34015. protected _environmentIntensity: number;
  34016. /**
  34017. * Intensity of the environment in all pbr material.
  34018. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34019. * As in the majority of the scene they are the same (exception for multi room and so on),
  34020. * this is easier to reference from here than from all the materials.
  34021. */
  34022. /**
  34023. * Intensity of the environment in all pbr material.
  34024. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34025. * As in the majority of the scene they are the same (exception for multi room and so on),
  34026. * this is easier to set here than in all the materials.
  34027. */
  34028. environmentIntensity: number;
  34029. /** @hidden */
  34030. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34031. /**
  34032. * Default image processing configuration used either in the rendering
  34033. * Forward main pass or through the imageProcessingPostProcess if present.
  34034. * As in the majority of the scene they are the same (exception for multi camera),
  34035. * this is easier to reference from here than from all the materials and post process.
  34036. *
  34037. * No setter as we it is a shared configuration, you can set the values instead.
  34038. */
  34039. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34040. private _forceWireframe;
  34041. /**
  34042. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34043. */
  34044. forceWireframe: boolean;
  34045. private _forcePointsCloud;
  34046. /**
  34047. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34048. */
  34049. forcePointsCloud: boolean;
  34050. /**
  34051. * Gets or sets the active clipplane 1
  34052. */
  34053. clipPlane: Nullable<Plane>;
  34054. /**
  34055. * Gets or sets the active clipplane 2
  34056. */
  34057. clipPlane2: Nullable<Plane>;
  34058. /**
  34059. * Gets or sets the active clipplane 3
  34060. */
  34061. clipPlane3: Nullable<Plane>;
  34062. /**
  34063. * Gets or sets the active clipplane 4
  34064. */
  34065. clipPlane4: Nullable<Plane>;
  34066. /**
  34067. * Gets or sets a boolean indicating if animations are enabled
  34068. */
  34069. animationsEnabled: boolean;
  34070. private _animationPropertiesOverride;
  34071. /**
  34072. * Gets or sets the animation properties override
  34073. */
  34074. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34075. /**
  34076. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34077. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34078. */
  34079. useConstantAnimationDeltaTime: boolean;
  34080. /**
  34081. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34082. * Please note that it requires to run a ray cast through the scene on every frame
  34083. */
  34084. constantlyUpdateMeshUnderPointer: boolean;
  34085. /**
  34086. * Defines the HTML cursor to use when hovering over interactive elements
  34087. */
  34088. hoverCursor: string;
  34089. /**
  34090. * Defines the HTML default cursor to use (empty by default)
  34091. */
  34092. defaultCursor: string;
  34093. /**
  34094. * Defines wether cursors are handled by the scene.
  34095. */
  34096. doNotHandleCursors: boolean;
  34097. /**
  34098. * This is used to call preventDefault() on pointer down
  34099. * in order to block unwanted artifacts like system double clicks
  34100. */
  34101. preventDefaultOnPointerDown: boolean;
  34102. /**
  34103. * This is used to call preventDefault() on pointer up
  34104. * in order to block unwanted artifacts like system double clicks
  34105. */
  34106. preventDefaultOnPointerUp: boolean;
  34107. /**
  34108. * Gets or sets user defined metadata
  34109. */
  34110. metadata: any;
  34111. /**
  34112. * For internal use only. Please do not use.
  34113. */
  34114. reservedDataStore: any;
  34115. /**
  34116. * Gets the name of the plugin used to load this scene (null by default)
  34117. */
  34118. loadingPluginName: string;
  34119. /**
  34120. * Use this array to add regular expressions used to disable offline support for specific urls
  34121. */
  34122. disableOfflineSupportExceptionRules: RegExp[];
  34123. /**
  34124. * An event triggered when the scene is disposed.
  34125. */
  34126. onDisposeObservable: Observable<Scene>;
  34127. private _onDisposeObserver;
  34128. /** Sets a function to be executed when this scene is disposed. */
  34129. onDispose: () => void;
  34130. /**
  34131. * An event triggered before rendering the scene (right after animations and physics)
  34132. */
  34133. onBeforeRenderObservable: Observable<Scene>;
  34134. private _onBeforeRenderObserver;
  34135. /** Sets a function to be executed before rendering this scene */
  34136. beforeRender: Nullable<() => void>;
  34137. /**
  34138. * An event triggered after rendering the scene
  34139. */
  34140. onAfterRenderObservable: Observable<Scene>;
  34141. /**
  34142. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34143. */
  34144. onAfterRenderCameraObservable: Observable<Camera>;
  34145. private _onAfterRenderObserver;
  34146. /** Sets a function to be executed after rendering this scene */
  34147. afterRender: Nullable<() => void>;
  34148. /**
  34149. * An event triggered before animating the scene
  34150. */
  34151. onBeforeAnimationsObservable: Observable<Scene>;
  34152. /**
  34153. * An event triggered after animations processing
  34154. */
  34155. onAfterAnimationsObservable: Observable<Scene>;
  34156. /**
  34157. * An event triggered before draw calls are ready to be sent
  34158. */
  34159. onBeforeDrawPhaseObservable: Observable<Scene>;
  34160. /**
  34161. * An event triggered after draw calls have been sent
  34162. */
  34163. onAfterDrawPhaseObservable: Observable<Scene>;
  34164. /**
  34165. * An event triggered when the scene is ready
  34166. */
  34167. onReadyObservable: Observable<Scene>;
  34168. /**
  34169. * An event triggered before rendering a camera
  34170. */
  34171. onBeforeCameraRenderObservable: Observable<Camera>;
  34172. private _onBeforeCameraRenderObserver;
  34173. /** Sets a function to be executed before rendering a camera*/
  34174. beforeCameraRender: () => void;
  34175. /**
  34176. * An event triggered after rendering a camera
  34177. */
  34178. onAfterCameraRenderObservable: Observable<Camera>;
  34179. private _onAfterCameraRenderObserver;
  34180. /** Sets a function to be executed after rendering a camera*/
  34181. afterCameraRender: () => void;
  34182. /**
  34183. * An event triggered when active meshes evaluation is about to start
  34184. */
  34185. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34186. /**
  34187. * An event triggered when active meshes evaluation is done
  34188. */
  34189. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34190. /**
  34191. * An event triggered when particles rendering is about to start
  34192. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34193. */
  34194. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34195. /**
  34196. * An event triggered when particles rendering is done
  34197. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34198. */
  34199. onAfterParticlesRenderingObservable: Observable<Scene>;
  34200. /**
  34201. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34202. */
  34203. onDataLoadedObservable: Observable<Scene>;
  34204. /**
  34205. * An event triggered when a camera is created
  34206. */
  34207. onNewCameraAddedObservable: Observable<Camera>;
  34208. /**
  34209. * An event triggered when a camera is removed
  34210. */
  34211. onCameraRemovedObservable: Observable<Camera>;
  34212. /**
  34213. * An event triggered when a light is created
  34214. */
  34215. onNewLightAddedObservable: Observable<Light>;
  34216. /**
  34217. * An event triggered when a light is removed
  34218. */
  34219. onLightRemovedObservable: Observable<Light>;
  34220. /**
  34221. * An event triggered when a geometry is created
  34222. */
  34223. onNewGeometryAddedObservable: Observable<Geometry>;
  34224. /**
  34225. * An event triggered when a geometry is removed
  34226. */
  34227. onGeometryRemovedObservable: Observable<Geometry>;
  34228. /**
  34229. * An event triggered when a transform node is created
  34230. */
  34231. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34232. /**
  34233. * An event triggered when a transform node is removed
  34234. */
  34235. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34236. /**
  34237. * An event triggered when a mesh is created
  34238. */
  34239. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34240. /**
  34241. * An event triggered when a mesh is removed
  34242. */
  34243. onMeshRemovedObservable: Observable<AbstractMesh>;
  34244. /**
  34245. * An event triggered when a skeleton is created
  34246. */
  34247. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34248. /**
  34249. * An event triggered when a skeleton is removed
  34250. */
  34251. onSkeletonRemovedObservable: Observable<Skeleton>;
  34252. /**
  34253. * An event triggered when a material is created
  34254. */
  34255. onNewMaterialAddedObservable: Observable<Material>;
  34256. /**
  34257. * An event triggered when a material is removed
  34258. */
  34259. onMaterialRemovedObservable: Observable<Material>;
  34260. /**
  34261. * An event triggered when a texture is created
  34262. */
  34263. onNewTextureAddedObservable: Observable<BaseTexture>;
  34264. /**
  34265. * An event triggered when a texture is removed
  34266. */
  34267. onTextureRemovedObservable: Observable<BaseTexture>;
  34268. /**
  34269. * An event triggered when render targets are about to be rendered
  34270. * Can happen multiple times per frame.
  34271. */
  34272. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34273. /**
  34274. * An event triggered when render targets were rendered.
  34275. * Can happen multiple times per frame.
  34276. */
  34277. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34278. /**
  34279. * An event triggered before calculating deterministic simulation step
  34280. */
  34281. onBeforeStepObservable: Observable<Scene>;
  34282. /**
  34283. * An event triggered after calculating deterministic simulation step
  34284. */
  34285. onAfterStepObservable: Observable<Scene>;
  34286. /**
  34287. * An event triggered when the activeCamera property is updated
  34288. */
  34289. onActiveCameraChanged: Observable<Scene>;
  34290. /**
  34291. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34292. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34293. * 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)
  34294. */
  34295. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34296. /**
  34297. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34298. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34299. * 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)
  34300. */
  34301. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34302. /**
  34303. * This Observable will when a mesh has been imported into the scene.
  34304. */
  34305. onMeshImportedObservable: Observable<AbstractMesh>;
  34306. /**
  34307. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34308. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34309. */
  34310. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34311. /** @hidden */
  34312. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34313. /**
  34314. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34315. */
  34316. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34317. /**
  34318. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34319. */
  34320. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34321. /**
  34322. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34323. */
  34324. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34325. /** Callback called when a pointer move is detected */
  34326. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34327. /** Callback called when a pointer down is detected */
  34328. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34329. /** Callback called when a pointer up is detected */
  34330. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34331. /** Callback called when a pointer pick is detected */
  34332. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34333. /**
  34334. * 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).
  34335. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34336. */
  34337. onPrePointerObservable: Observable<PointerInfoPre>;
  34338. /**
  34339. * Observable event triggered each time an input event is received from the rendering canvas
  34340. */
  34341. onPointerObservable: Observable<PointerInfo>;
  34342. /**
  34343. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34344. */
  34345. readonly unTranslatedPointer: Vector2;
  34346. /**
  34347. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34348. */
  34349. static DragMovementThreshold: number;
  34350. /**
  34351. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34352. */
  34353. static LongPressDelay: number;
  34354. /**
  34355. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34356. */
  34357. static DoubleClickDelay: number;
  34358. /** If you need to check double click without raising a single click at first click, enable this flag */
  34359. static ExclusiveDoubleClickMode: boolean;
  34360. /** @hidden */
  34361. _mirroredCameraPosition: Nullable<Vector3>;
  34362. /**
  34363. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34364. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34365. */
  34366. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34367. /**
  34368. * Observable event triggered each time an keyboard event is received from the hosting window
  34369. */
  34370. onKeyboardObservable: Observable<KeyboardInfo>;
  34371. private _useRightHandedSystem;
  34372. /**
  34373. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34374. */
  34375. useRightHandedSystem: boolean;
  34376. private _timeAccumulator;
  34377. private _currentStepId;
  34378. private _currentInternalStep;
  34379. /**
  34380. * Sets the step Id used by deterministic lock step
  34381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34382. * @param newStepId defines the step Id
  34383. */
  34384. setStepId(newStepId: number): void;
  34385. /**
  34386. * Gets the step Id used by deterministic lock step
  34387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34388. * @returns the step Id
  34389. */
  34390. getStepId(): number;
  34391. /**
  34392. * Gets the internal step used by deterministic lock step
  34393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34394. * @returns the internal step
  34395. */
  34396. getInternalStep(): number;
  34397. private _fogEnabled;
  34398. /**
  34399. * Gets or sets a boolean indicating if fog is enabled on this scene
  34400. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34401. * (Default is true)
  34402. */
  34403. fogEnabled: boolean;
  34404. private _fogMode;
  34405. /**
  34406. * Gets or sets the fog mode to use
  34407. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34408. * | mode | value |
  34409. * | --- | --- |
  34410. * | FOGMODE_NONE | 0 |
  34411. * | FOGMODE_EXP | 1 |
  34412. * | FOGMODE_EXP2 | 2 |
  34413. * | FOGMODE_LINEAR | 3 |
  34414. */
  34415. fogMode: number;
  34416. /**
  34417. * Gets or sets the fog color to use
  34418. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34419. * (Default is Color3(0.2, 0.2, 0.3))
  34420. */
  34421. fogColor: Color3;
  34422. /**
  34423. * Gets or sets the fog density to use
  34424. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34425. * (Default is 0.1)
  34426. */
  34427. fogDensity: number;
  34428. /**
  34429. * Gets or sets the fog start distance to use
  34430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34431. * (Default is 0)
  34432. */
  34433. fogStart: number;
  34434. /**
  34435. * Gets or sets the fog end distance to use
  34436. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34437. * (Default is 1000)
  34438. */
  34439. fogEnd: number;
  34440. private _shadowsEnabled;
  34441. /**
  34442. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34443. */
  34444. shadowsEnabled: boolean;
  34445. private _lightsEnabled;
  34446. /**
  34447. * Gets or sets a boolean indicating if lights are enabled on this scene
  34448. */
  34449. lightsEnabled: boolean;
  34450. /** All of the active cameras added to this scene. */
  34451. activeCameras: Camera[];
  34452. /** @hidden */
  34453. _activeCamera: Nullable<Camera>;
  34454. /** Gets or sets the current active camera */
  34455. activeCamera: Nullable<Camera>;
  34456. private _defaultMaterial;
  34457. /** The default material used on meshes when no material is affected */
  34458. /** The default material used on meshes when no material is affected */
  34459. defaultMaterial: Material;
  34460. private _texturesEnabled;
  34461. /**
  34462. * Gets or sets a boolean indicating if textures are enabled on this scene
  34463. */
  34464. texturesEnabled: boolean;
  34465. /**
  34466. * Gets or sets a boolean indicating if particles are enabled on this scene
  34467. */
  34468. particlesEnabled: boolean;
  34469. /**
  34470. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34471. */
  34472. spritesEnabled: boolean;
  34473. private _skeletonsEnabled;
  34474. /**
  34475. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34476. */
  34477. skeletonsEnabled: boolean;
  34478. /**
  34479. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34480. */
  34481. lensFlaresEnabled: boolean;
  34482. /**
  34483. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34484. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34485. */
  34486. collisionsEnabled: boolean;
  34487. private _collisionCoordinator;
  34488. /** @hidden */
  34489. readonly collisionCoordinator: ICollisionCoordinator;
  34490. /**
  34491. * Defines the gravity applied to this scene (used only for collisions)
  34492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34493. */
  34494. gravity: Vector3;
  34495. /**
  34496. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34497. */
  34498. postProcessesEnabled: boolean;
  34499. /**
  34500. * The list of postprocesses added to the scene
  34501. */
  34502. postProcesses: PostProcess[];
  34503. /**
  34504. * Gets the current postprocess manager
  34505. */
  34506. postProcessManager: PostProcessManager;
  34507. /**
  34508. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34509. */
  34510. renderTargetsEnabled: boolean;
  34511. /**
  34512. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34513. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34514. */
  34515. dumpNextRenderTargets: boolean;
  34516. /**
  34517. * The list of user defined render targets added to the scene
  34518. */
  34519. customRenderTargets: RenderTargetTexture[];
  34520. /**
  34521. * Defines if texture loading must be delayed
  34522. * If true, textures will only be loaded when they need to be rendered
  34523. */
  34524. useDelayedTextureLoading: boolean;
  34525. /**
  34526. * Gets the list of meshes imported to the scene through SceneLoader
  34527. */
  34528. importedMeshesFiles: String[];
  34529. /**
  34530. * Gets or sets a boolean indicating if probes are enabled on this scene
  34531. */
  34532. probesEnabled: boolean;
  34533. /**
  34534. * Gets or sets the current offline provider to use to store scene data
  34535. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34536. */
  34537. offlineProvider: IOfflineProvider;
  34538. /**
  34539. * Gets or sets the action manager associated with the scene
  34540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34541. */
  34542. actionManager: AbstractActionManager;
  34543. private _meshesForIntersections;
  34544. /**
  34545. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34546. */
  34547. proceduralTexturesEnabled: boolean;
  34548. private _engine;
  34549. private _totalVertices;
  34550. /** @hidden */
  34551. _activeIndices: PerfCounter;
  34552. /** @hidden */
  34553. _activeParticles: PerfCounter;
  34554. /** @hidden */
  34555. _activeBones: PerfCounter;
  34556. private _animationRatio;
  34557. /** @hidden */
  34558. _animationTimeLast: number;
  34559. /** @hidden */
  34560. _animationTime: number;
  34561. /**
  34562. * Gets or sets a general scale for animation speed
  34563. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34564. */
  34565. animationTimeScale: number;
  34566. /** @hidden */
  34567. _cachedMaterial: Nullable<Material>;
  34568. /** @hidden */
  34569. _cachedEffect: Nullable<Effect>;
  34570. /** @hidden */
  34571. _cachedVisibility: Nullable<number>;
  34572. private _renderId;
  34573. private _frameId;
  34574. private _executeWhenReadyTimeoutId;
  34575. private _intermediateRendering;
  34576. private _viewUpdateFlag;
  34577. private _projectionUpdateFlag;
  34578. /** @hidden */
  34579. _toBeDisposed: Nullable<IDisposable>[];
  34580. private _activeRequests;
  34581. /** @hidden */
  34582. _pendingData: any[];
  34583. private _isDisposed;
  34584. /**
  34585. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34586. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34587. */
  34588. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34589. private _activeMeshes;
  34590. private _processedMaterials;
  34591. private _renderTargets;
  34592. /** @hidden */
  34593. _activeParticleSystems: SmartArray<IParticleSystem>;
  34594. private _activeSkeletons;
  34595. private _softwareSkinnedMeshes;
  34596. private _renderingManager;
  34597. /** @hidden */
  34598. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34599. private _transformMatrix;
  34600. private _sceneUbo;
  34601. /** @hidden */
  34602. _viewMatrix: Matrix;
  34603. private _projectionMatrix;
  34604. /** @hidden */
  34605. _forcedViewPosition: Nullable<Vector3>;
  34606. /** @hidden */
  34607. _frustumPlanes: Plane[];
  34608. /**
  34609. * Gets the list of frustum planes (built from the active camera)
  34610. */
  34611. readonly frustumPlanes: Plane[];
  34612. /**
  34613. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34614. * This is useful if there are more lights that the maximum simulteanous authorized
  34615. */
  34616. requireLightSorting: boolean;
  34617. /** @hidden */
  34618. readonly useMaterialMeshMap: boolean;
  34619. /** @hidden */
  34620. readonly useClonedMeshhMap: boolean;
  34621. private _externalData;
  34622. private _uid;
  34623. /**
  34624. * @hidden
  34625. * Backing store of defined scene components.
  34626. */
  34627. _components: ISceneComponent[];
  34628. /**
  34629. * @hidden
  34630. * Backing store of defined scene components.
  34631. */
  34632. _serializableComponents: ISceneSerializableComponent[];
  34633. /**
  34634. * List of components to register on the next registration step.
  34635. */
  34636. private _transientComponents;
  34637. /**
  34638. * Registers the transient components if needed.
  34639. */
  34640. private _registerTransientComponents;
  34641. /**
  34642. * @hidden
  34643. * Add a component to the scene.
  34644. * Note that the ccomponent could be registered on th next frame if this is called after
  34645. * the register component stage.
  34646. * @param component Defines the component to add to the scene
  34647. */
  34648. _addComponent(component: ISceneComponent): void;
  34649. /**
  34650. * @hidden
  34651. * Gets a component from the scene.
  34652. * @param name defines the name of the component to retrieve
  34653. * @returns the component or null if not present
  34654. */
  34655. _getComponent(name: string): Nullable<ISceneComponent>;
  34656. /**
  34657. * @hidden
  34658. * Defines the actions happening before camera updates.
  34659. */
  34660. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34661. /**
  34662. * @hidden
  34663. * Defines the actions happening before clear the canvas.
  34664. */
  34665. _beforeClearStage: Stage<SimpleStageAction>;
  34666. /**
  34667. * @hidden
  34668. * Defines the actions when collecting render targets for the frame.
  34669. */
  34670. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34671. /**
  34672. * @hidden
  34673. * Defines the actions happening for one camera in the frame.
  34674. */
  34675. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34676. /**
  34677. * @hidden
  34678. * Defines the actions happening during the per mesh ready checks.
  34679. */
  34680. _isReadyForMeshStage: Stage<MeshStageAction>;
  34681. /**
  34682. * @hidden
  34683. * Defines the actions happening before evaluate active mesh checks.
  34684. */
  34685. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34686. /**
  34687. * @hidden
  34688. * Defines the actions happening during the evaluate sub mesh checks.
  34689. */
  34690. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34691. /**
  34692. * @hidden
  34693. * Defines the actions happening during the active mesh stage.
  34694. */
  34695. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34696. /**
  34697. * @hidden
  34698. * Defines the actions happening during the per camera render target step.
  34699. */
  34700. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34701. /**
  34702. * @hidden
  34703. * Defines the actions happening just before the active camera is drawing.
  34704. */
  34705. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34706. /**
  34707. * @hidden
  34708. * Defines the actions happening just before a render target is drawing.
  34709. */
  34710. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34711. /**
  34712. * @hidden
  34713. * Defines the actions happening just before a rendering group is drawing.
  34714. */
  34715. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34716. /**
  34717. * @hidden
  34718. * Defines the actions happening just before a mesh is drawing.
  34719. */
  34720. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34721. /**
  34722. * @hidden
  34723. * Defines the actions happening just after a mesh has been drawn.
  34724. */
  34725. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34726. /**
  34727. * @hidden
  34728. * Defines the actions happening just after a rendering group has been drawn.
  34729. */
  34730. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34731. /**
  34732. * @hidden
  34733. * Defines the actions happening just after the active camera has been drawn.
  34734. */
  34735. _afterCameraDrawStage: Stage<CameraStageAction>;
  34736. /**
  34737. * @hidden
  34738. * Defines the actions happening just after a render target has been drawn.
  34739. */
  34740. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34741. /**
  34742. * @hidden
  34743. * Defines the actions happening just after rendering all cameras and computing intersections.
  34744. */
  34745. _afterRenderStage: Stage<SimpleStageAction>;
  34746. /**
  34747. * @hidden
  34748. * Defines the actions happening when a pointer move event happens.
  34749. */
  34750. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34751. /**
  34752. * @hidden
  34753. * Defines the actions happening when a pointer down event happens.
  34754. */
  34755. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34756. /**
  34757. * @hidden
  34758. * Defines the actions happening when a pointer up event happens.
  34759. */
  34760. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34761. /**
  34762. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34763. */
  34764. private geometriesByUniqueId;
  34765. /**
  34766. * Creates a new Scene
  34767. * @param engine defines the engine to use to render this scene
  34768. * @param options defines the scene options
  34769. */
  34770. constructor(engine: Engine, options?: SceneOptions);
  34771. /**
  34772. * Gets a string idenfifying the name of the class
  34773. * @returns "Scene" string
  34774. */
  34775. getClassName(): string;
  34776. private _defaultMeshCandidates;
  34777. /**
  34778. * @hidden
  34779. */
  34780. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34781. private _defaultSubMeshCandidates;
  34782. /**
  34783. * @hidden
  34784. */
  34785. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34786. /**
  34787. * Sets the default candidate providers for the scene.
  34788. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34789. * and getCollidingSubMeshCandidates to their default function
  34790. */
  34791. setDefaultCandidateProviders(): void;
  34792. /**
  34793. * Gets the mesh that is currently under the pointer
  34794. */
  34795. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34796. /**
  34797. * Gets or sets the current on-screen X position of the pointer
  34798. */
  34799. pointerX: number;
  34800. /**
  34801. * Gets or sets the current on-screen Y position of the pointer
  34802. */
  34803. pointerY: number;
  34804. /**
  34805. * Gets the cached material (ie. the latest rendered one)
  34806. * @returns the cached material
  34807. */
  34808. getCachedMaterial(): Nullable<Material>;
  34809. /**
  34810. * Gets the cached effect (ie. the latest rendered one)
  34811. * @returns the cached effect
  34812. */
  34813. getCachedEffect(): Nullable<Effect>;
  34814. /**
  34815. * Gets the cached visibility state (ie. the latest rendered one)
  34816. * @returns the cached visibility state
  34817. */
  34818. getCachedVisibility(): Nullable<number>;
  34819. /**
  34820. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34821. * @param material defines the current material
  34822. * @param effect defines the current effect
  34823. * @param visibility defines the current visibility state
  34824. * @returns true if one parameter is not cached
  34825. */
  34826. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34827. /**
  34828. * Gets the engine associated with the scene
  34829. * @returns an Engine
  34830. */
  34831. getEngine(): Engine;
  34832. /**
  34833. * Gets the total number of vertices rendered per frame
  34834. * @returns the total number of vertices rendered per frame
  34835. */
  34836. getTotalVertices(): number;
  34837. /**
  34838. * Gets the performance counter for total vertices
  34839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34840. */
  34841. readonly totalVerticesPerfCounter: PerfCounter;
  34842. /**
  34843. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34844. * @returns the total number of active indices rendered per frame
  34845. */
  34846. getActiveIndices(): number;
  34847. /**
  34848. * Gets the performance counter for active indices
  34849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34850. */
  34851. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34852. /**
  34853. * Gets the total number of active particles rendered per frame
  34854. * @returns the total number of active particles rendered per frame
  34855. */
  34856. getActiveParticles(): number;
  34857. /**
  34858. * Gets the performance counter for active particles
  34859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34860. */
  34861. readonly activeParticlesPerfCounter: PerfCounter;
  34862. /**
  34863. * Gets the total number of active bones rendered per frame
  34864. * @returns the total number of active bones rendered per frame
  34865. */
  34866. getActiveBones(): number;
  34867. /**
  34868. * Gets the performance counter for active bones
  34869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34870. */
  34871. readonly activeBonesPerfCounter: PerfCounter;
  34872. /**
  34873. * Gets the array of active meshes
  34874. * @returns an array of AbstractMesh
  34875. */
  34876. getActiveMeshes(): SmartArray<AbstractMesh>;
  34877. /**
  34878. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34879. * @returns a number
  34880. */
  34881. getAnimationRatio(): number;
  34882. /**
  34883. * Gets an unique Id for the current render phase
  34884. * @returns a number
  34885. */
  34886. getRenderId(): number;
  34887. /**
  34888. * Gets an unique Id for the current frame
  34889. * @returns a number
  34890. */
  34891. getFrameId(): number;
  34892. /** Call this function if you want to manually increment the render Id*/
  34893. incrementRenderId(): void;
  34894. private _createUbo;
  34895. /**
  34896. * Use this method to simulate a pointer move on a mesh
  34897. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34898. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34899. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34900. * @returns the current scene
  34901. */
  34902. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34903. /**
  34904. * Use this method to simulate a pointer down on a mesh
  34905. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34906. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34907. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34908. * @returns the current scene
  34909. */
  34910. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34911. /**
  34912. * Use this method to simulate a pointer up on a mesh
  34913. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34914. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34915. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34916. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34917. * @returns the current scene
  34918. */
  34919. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34920. /**
  34921. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34922. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34923. * @returns true if the pointer was captured
  34924. */
  34925. isPointerCaptured(pointerId?: number): boolean;
  34926. /**
  34927. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34928. * @param attachUp defines if you want to attach events to pointerup
  34929. * @param attachDown defines if you want to attach events to pointerdown
  34930. * @param attachMove defines if you want to attach events to pointermove
  34931. */
  34932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34933. /** Detaches all event handlers*/
  34934. detachControl(): void;
  34935. /**
  34936. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34937. * Delay loaded resources are not taking in account
  34938. * @return true if all required resources are ready
  34939. */
  34940. isReady(): boolean;
  34941. /** Resets all cached information relative to material (including effect and visibility) */
  34942. resetCachedMaterial(): void;
  34943. /**
  34944. * Registers a function to be called before every frame render
  34945. * @param func defines the function to register
  34946. */
  34947. registerBeforeRender(func: () => void): void;
  34948. /**
  34949. * Unregisters a function called before every frame render
  34950. * @param func defines the function to unregister
  34951. */
  34952. unregisterBeforeRender(func: () => void): void;
  34953. /**
  34954. * Registers a function to be called after every frame render
  34955. * @param func defines the function to register
  34956. */
  34957. registerAfterRender(func: () => void): void;
  34958. /**
  34959. * Unregisters a function called after every frame render
  34960. * @param func defines the function to unregister
  34961. */
  34962. unregisterAfterRender(func: () => void): void;
  34963. private _executeOnceBeforeRender;
  34964. /**
  34965. * The provided function will run before render once and will be disposed afterwards.
  34966. * A timeout delay can be provided so that the function will be executed in N ms.
  34967. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34968. * @param func The function to be executed.
  34969. * @param timeout optional delay in ms
  34970. */
  34971. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34972. /** @hidden */
  34973. _addPendingData(data: any): void;
  34974. /** @hidden */
  34975. _removePendingData(data: any): void;
  34976. /**
  34977. * Returns the number of items waiting to be loaded
  34978. * @returns the number of items waiting to be loaded
  34979. */
  34980. getWaitingItemsCount(): number;
  34981. /**
  34982. * Returns a boolean indicating if the scene is still loading data
  34983. */
  34984. readonly isLoading: boolean;
  34985. /**
  34986. * Registers a function to be executed when the scene is ready
  34987. * @param {Function} func - the function to be executed
  34988. */
  34989. executeWhenReady(func: () => void): void;
  34990. /**
  34991. * Returns a promise that resolves when the scene is ready
  34992. * @returns A promise that resolves when the scene is ready
  34993. */
  34994. whenReadyAsync(): Promise<void>;
  34995. /** @hidden */
  34996. _checkIsReady(): void;
  34997. /**
  34998. * Gets all animatable attached to the scene
  34999. */
  35000. readonly animatables: Animatable[];
  35001. /**
  35002. * Resets the last animation time frame.
  35003. * Useful to override when animations start running when loading a scene for the first time.
  35004. */
  35005. resetLastAnimationTimeFrame(): void;
  35006. /**
  35007. * Gets the current view matrix
  35008. * @returns a Matrix
  35009. */
  35010. getViewMatrix(): Matrix;
  35011. /**
  35012. * Gets the current projection matrix
  35013. * @returns a Matrix
  35014. */
  35015. getProjectionMatrix(): Matrix;
  35016. /**
  35017. * Gets the current transform matrix
  35018. * @returns a Matrix made of View * Projection
  35019. */
  35020. getTransformMatrix(): Matrix;
  35021. /**
  35022. * Sets the current transform matrix
  35023. * @param viewL defines the View matrix to use
  35024. * @param projectionL defines the Projection matrix to use
  35025. * @param viewR defines the right View matrix to use (if provided)
  35026. * @param projectionR defines the right Projection matrix to use (if provided)
  35027. */
  35028. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35029. /**
  35030. * Gets the uniform buffer used to store scene data
  35031. * @returns a UniformBuffer
  35032. */
  35033. getSceneUniformBuffer(): UniformBuffer;
  35034. /**
  35035. * Gets an unique (relatively to the current scene) Id
  35036. * @returns an unique number for the scene
  35037. */
  35038. getUniqueId(): number;
  35039. /**
  35040. * Add a mesh to the list of scene's meshes
  35041. * @param newMesh defines the mesh to add
  35042. * @param recursive if all child meshes should also be added to the scene
  35043. */
  35044. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35045. /**
  35046. * Remove a mesh for the list of scene's meshes
  35047. * @param toRemove defines the mesh to remove
  35048. * @param recursive if all child meshes should also be removed from the scene
  35049. * @returns the index where the mesh was in the mesh list
  35050. */
  35051. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35052. /**
  35053. * Add a transform node to the list of scene's transform nodes
  35054. * @param newTransformNode defines the transform node to add
  35055. */
  35056. addTransformNode(newTransformNode: TransformNode): void;
  35057. /**
  35058. * Remove a transform node for the list of scene's transform nodes
  35059. * @param toRemove defines the transform node to remove
  35060. * @returns the index where the transform node was in the transform node list
  35061. */
  35062. removeTransformNode(toRemove: TransformNode): number;
  35063. /**
  35064. * Remove a skeleton for the list of scene's skeletons
  35065. * @param toRemove defines the skeleton to remove
  35066. * @returns the index where the skeleton was in the skeleton list
  35067. */
  35068. removeSkeleton(toRemove: Skeleton): number;
  35069. /**
  35070. * Remove a morph target for the list of scene's morph targets
  35071. * @param toRemove defines the morph target to remove
  35072. * @returns the index where the morph target was in the morph target list
  35073. */
  35074. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35075. /**
  35076. * Remove a light for the list of scene's lights
  35077. * @param toRemove defines the light to remove
  35078. * @returns the index where the light was in the light list
  35079. */
  35080. removeLight(toRemove: Light): number;
  35081. /**
  35082. * Remove a camera for the list of scene's cameras
  35083. * @param toRemove defines the camera to remove
  35084. * @returns the index where the camera was in the camera list
  35085. */
  35086. removeCamera(toRemove: Camera): number;
  35087. /**
  35088. * Remove a particle system for the list of scene's particle systems
  35089. * @param toRemove defines the particle system to remove
  35090. * @returns the index where the particle system was in the particle system list
  35091. */
  35092. removeParticleSystem(toRemove: IParticleSystem): number;
  35093. /**
  35094. * Remove a animation for the list of scene's animations
  35095. * @param toRemove defines the animation to remove
  35096. * @returns the index where the animation was in the animation list
  35097. */
  35098. removeAnimation(toRemove: Animation): number;
  35099. /**
  35100. * Will stop the animation of the given target
  35101. * @param target - the target
  35102. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35103. * @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)
  35104. */
  35105. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35106. /**
  35107. * Removes the given animation group from this scene.
  35108. * @param toRemove The animation group to remove
  35109. * @returns The index of the removed animation group
  35110. */
  35111. removeAnimationGroup(toRemove: AnimationGroup): number;
  35112. /**
  35113. * Removes the given multi-material from this scene.
  35114. * @param toRemove The multi-material to remove
  35115. * @returns The index of the removed multi-material
  35116. */
  35117. removeMultiMaterial(toRemove: MultiMaterial): number;
  35118. /**
  35119. * Removes the given material from this scene.
  35120. * @param toRemove The material to remove
  35121. * @returns The index of the removed material
  35122. */
  35123. removeMaterial(toRemove: Material): number;
  35124. /**
  35125. * Removes the given action manager from this scene.
  35126. * @param toRemove The action manager to remove
  35127. * @returns The index of the removed action manager
  35128. */
  35129. removeActionManager(toRemove: AbstractActionManager): number;
  35130. /**
  35131. * Removes the given texture from this scene.
  35132. * @param toRemove The texture to remove
  35133. * @returns The index of the removed texture
  35134. */
  35135. removeTexture(toRemove: BaseTexture): number;
  35136. /**
  35137. * Adds the given light to this scene
  35138. * @param newLight The light to add
  35139. */
  35140. addLight(newLight: Light): void;
  35141. /**
  35142. * Sorts the list list based on light priorities
  35143. */
  35144. sortLightsByPriority(): void;
  35145. /**
  35146. * Adds the given camera to this scene
  35147. * @param newCamera The camera to add
  35148. */
  35149. addCamera(newCamera: Camera): void;
  35150. /**
  35151. * Adds the given skeleton to this scene
  35152. * @param newSkeleton The skeleton to add
  35153. */
  35154. addSkeleton(newSkeleton: Skeleton): void;
  35155. /**
  35156. * Adds the given particle system to this scene
  35157. * @param newParticleSystem The particle system to add
  35158. */
  35159. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35160. /**
  35161. * Adds the given animation to this scene
  35162. * @param newAnimation The animation to add
  35163. */
  35164. addAnimation(newAnimation: Animation): void;
  35165. /**
  35166. * Adds the given animation group to this scene.
  35167. * @param newAnimationGroup The animation group to add
  35168. */
  35169. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35170. /**
  35171. * Adds the given multi-material to this scene
  35172. * @param newMultiMaterial The multi-material to add
  35173. */
  35174. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35175. /**
  35176. * Adds the given material to this scene
  35177. * @param newMaterial The material to add
  35178. */
  35179. addMaterial(newMaterial: Material): void;
  35180. /**
  35181. * Adds the given morph target to this scene
  35182. * @param newMorphTargetManager The morph target to add
  35183. */
  35184. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35185. /**
  35186. * Adds the given geometry to this scene
  35187. * @param newGeometry The geometry to add
  35188. */
  35189. addGeometry(newGeometry: Geometry): void;
  35190. /**
  35191. * Adds the given action manager to this scene
  35192. * @param newActionManager The action manager to add
  35193. */
  35194. addActionManager(newActionManager: AbstractActionManager): void;
  35195. /**
  35196. * Adds the given texture to this scene.
  35197. * @param newTexture The texture to add
  35198. */
  35199. addTexture(newTexture: BaseTexture): void;
  35200. /**
  35201. * Switch active camera
  35202. * @param newCamera defines the new active camera
  35203. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35204. */
  35205. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35206. /**
  35207. * sets the active camera of the scene using its ID
  35208. * @param id defines the camera's ID
  35209. * @return the new active camera or null if none found.
  35210. */
  35211. setActiveCameraByID(id: string): Nullable<Camera>;
  35212. /**
  35213. * sets the active camera of the scene using its name
  35214. * @param name defines the camera's name
  35215. * @returns the new active camera or null if none found.
  35216. */
  35217. setActiveCameraByName(name: string): Nullable<Camera>;
  35218. /**
  35219. * get an animation group using its name
  35220. * @param name defines the material's name
  35221. * @return the animation group or null if none found.
  35222. */
  35223. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35224. /**
  35225. * Get a material using its unique id
  35226. * @param uniqueId defines the material's unique id
  35227. * @return the material or null if none found.
  35228. */
  35229. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35230. /**
  35231. * get a material using its id
  35232. * @param id defines the material's ID
  35233. * @return the material or null if none found.
  35234. */
  35235. getMaterialByID(id: string): Nullable<Material>;
  35236. /**
  35237. * Gets a the last added material using a given id
  35238. * @param id defines the material's ID
  35239. * @return the last material with the given id or null if none found.
  35240. */
  35241. getLastMaterialByID(id: string): Nullable<Material>;
  35242. /**
  35243. * Gets a material using its name
  35244. * @param name defines the material's name
  35245. * @return the material or null if none found.
  35246. */
  35247. getMaterialByName(name: string): Nullable<Material>;
  35248. /**
  35249. * Get a texture using its unique id
  35250. * @param uniqueId defines the texture's unique id
  35251. * @return the texture or null if none found.
  35252. */
  35253. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35254. /**
  35255. * Gets a camera using its id
  35256. * @param id defines the id to look for
  35257. * @returns the camera or null if not found
  35258. */
  35259. getCameraByID(id: string): Nullable<Camera>;
  35260. /**
  35261. * Gets a camera using its unique id
  35262. * @param uniqueId defines the unique id to look for
  35263. * @returns the camera or null if not found
  35264. */
  35265. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35266. /**
  35267. * Gets a camera using its name
  35268. * @param name defines the camera's name
  35269. * @return the camera or null if none found.
  35270. */
  35271. getCameraByName(name: string): Nullable<Camera>;
  35272. /**
  35273. * Gets a bone using its id
  35274. * @param id defines the bone's id
  35275. * @return the bone or null if not found
  35276. */
  35277. getBoneByID(id: string): Nullable<Bone>;
  35278. /**
  35279. * Gets a bone using its id
  35280. * @param name defines the bone's name
  35281. * @return the bone or null if not found
  35282. */
  35283. getBoneByName(name: string): Nullable<Bone>;
  35284. /**
  35285. * Gets a light node using its name
  35286. * @param name defines the the light's name
  35287. * @return the light or null if none found.
  35288. */
  35289. getLightByName(name: string): Nullable<Light>;
  35290. /**
  35291. * Gets a light node using its id
  35292. * @param id defines the light's id
  35293. * @return the light or null if none found.
  35294. */
  35295. getLightByID(id: string): Nullable<Light>;
  35296. /**
  35297. * Gets a light node using its scene-generated unique ID
  35298. * @param uniqueId defines the light's unique id
  35299. * @return the light or null if none found.
  35300. */
  35301. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35302. /**
  35303. * Gets a particle system by id
  35304. * @param id defines the particle system id
  35305. * @return the corresponding system or null if none found
  35306. */
  35307. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35308. /**
  35309. * Gets a geometry using its ID
  35310. * @param id defines the geometry's id
  35311. * @return the geometry or null if none found.
  35312. */
  35313. getGeometryByID(id: string): Nullable<Geometry>;
  35314. private _getGeometryByUniqueID;
  35315. /**
  35316. * Add a new geometry to this scene
  35317. * @param geometry defines the geometry to be added to the scene.
  35318. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35319. * @return a boolean defining if the geometry was added or not
  35320. */
  35321. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35322. /**
  35323. * Removes an existing geometry
  35324. * @param geometry defines the geometry to be removed from the scene
  35325. * @return a boolean defining if the geometry was removed or not
  35326. */
  35327. removeGeometry(geometry: Geometry): boolean;
  35328. /**
  35329. * Gets the list of geometries attached to the scene
  35330. * @returns an array of Geometry
  35331. */
  35332. getGeometries(): Geometry[];
  35333. /**
  35334. * Gets the first added mesh found of a given ID
  35335. * @param id defines the id to search for
  35336. * @return the mesh found or null if not found at all
  35337. */
  35338. getMeshByID(id: string): Nullable<AbstractMesh>;
  35339. /**
  35340. * Gets a list of meshes using their id
  35341. * @param id defines the id to search for
  35342. * @returns a list of meshes
  35343. */
  35344. getMeshesByID(id: string): Array<AbstractMesh>;
  35345. /**
  35346. * Gets the first added transform node found of a given ID
  35347. * @param id defines the id to search for
  35348. * @return the found transform node or null if not found at all.
  35349. */
  35350. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35351. /**
  35352. * Gets a transform node with its auto-generated unique id
  35353. * @param uniqueId efines the unique id to search for
  35354. * @return the found transform node or null if not found at all.
  35355. */
  35356. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35357. /**
  35358. * Gets a list of transform nodes using their id
  35359. * @param id defines the id to search for
  35360. * @returns a list of transform nodes
  35361. */
  35362. getTransformNodesByID(id: string): Array<TransformNode>;
  35363. /**
  35364. * Gets a mesh with its auto-generated unique id
  35365. * @param uniqueId defines the unique id to search for
  35366. * @return the found mesh or null if not found at all.
  35367. */
  35368. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35369. /**
  35370. * Gets a the last added mesh using a given id
  35371. * @param id defines the id to search for
  35372. * @return the found mesh or null if not found at all.
  35373. */
  35374. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35375. /**
  35376. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35377. * @param id defines the id to search for
  35378. * @return the found node or null if not found at all
  35379. */
  35380. getLastEntryByID(id: string): Nullable<Node>;
  35381. /**
  35382. * Gets a node (Mesh, Camera, Light) using a given id
  35383. * @param id defines the id to search for
  35384. * @return the found node or null if not found at all
  35385. */
  35386. getNodeByID(id: string): Nullable<Node>;
  35387. /**
  35388. * Gets a node (Mesh, Camera, Light) using a given name
  35389. * @param name defines the name to search for
  35390. * @return the found node or null if not found at all.
  35391. */
  35392. getNodeByName(name: string): Nullable<Node>;
  35393. /**
  35394. * Gets a mesh using a given name
  35395. * @param name defines the name to search for
  35396. * @return the found mesh or null if not found at all.
  35397. */
  35398. getMeshByName(name: string): Nullable<AbstractMesh>;
  35399. /**
  35400. * Gets a transform node using a given name
  35401. * @param name defines the name to search for
  35402. * @return the found transform node or null if not found at all.
  35403. */
  35404. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35405. /**
  35406. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35407. * @param id defines the id to search for
  35408. * @return the found skeleton or null if not found at all.
  35409. */
  35410. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35411. /**
  35412. * Gets a skeleton using a given auto generated unique id
  35413. * @param uniqueId defines the unique id to search for
  35414. * @return the found skeleton or null if not found at all.
  35415. */
  35416. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35417. /**
  35418. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35419. * @param id defines the id to search for
  35420. * @return the found skeleton or null if not found at all.
  35421. */
  35422. getSkeletonById(id: string): Nullable<Skeleton>;
  35423. /**
  35424. * Gets a skeleton using a given name
  35425. * @param name defines the name to search for
  35426. * @return the found skeleton or null if not found at all.
  35427. */
  35428. getSkeletonByName(name: string): Nullable<Skeleton>;
  35429. /**
  35430. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35431. * @param id defines the id to search for
  35432. * @return the found morph target manager or null if not found at all.
  35433. */
  35434. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35435. /**
  35436. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35437. * @param id defines the id to search for
  35438. * @return the found morph target or null if not found at all.
  35439. */
  35440. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35441. /**
  35442. * Gets a boolean indicating if the given mesh is active
  35443. * @param mesh defines the mesh to look for
  35444. * @returns true if the mesh is in the active list
  35445. */
  35446. isActiveMesh(mesh: AbstractMesh): boolean;
  35447. /**
  35448. * Return a unique id as a string which can serve as an identifier for the scene
  35449. */
  35450. readonly uid: string;
  35451. /**
  35452. * Add an externaly attached data from its key.
  35453. * This method call will fail and return false, if such key already exists.
  35454. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35455. * @param key the unique key that identifies the data
  35456. * @param data the data object to associate to the key for this Engine instance
  35457. * @return true if no such key were already present and the data was added successfully, false otherwise
  35458. */
  35459. addExternalData<T>(key: string, data: T): boolean;
  35460. /**
  35461. * Get an externaly attached data from its key
  35462. * @param key the unique key that identifies the data
  35463. * @return the associated data, if present (can be null), or undefined if not present
  35464. */
  35465. getExternalData<T>(key: string): Nullable<T>;
  35466. /**
  35467. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35468. * @param key the unique key that identifies the data
  35469. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35470. * @return the associated data, can be null if the factory returned null.
  35471. */
  35472. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35473. /**
  35474. * Remove an externaly attached data from the Engine instance
  35475. * @param key the unique key that identifies the data
  35476. * @return true if the data was successfully removed, false if it doesn't exist
  35477. */
  35478. removeExternalData(key: string): boolean;
  35479. private _evaluateSubMesh;
  35480. /**
  35481. * Clear the processed materials smart array preventing retention point in material dispose.
  35482. */
  35483. freeProcessedMaterials(): void;
  35484. private _preventFreeActiveMeshesAndRenderingGroups;
  35485. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35486. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35487. * when disposing several meshes in a row or a hierarchy of meshes.
  35488. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35489. */
  35490. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35491. /**
  35492. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35493. */
  35494. freeActiveMeshes(): void;
  35495. /**
  35496. * Clear the info related to rendering groups preventing retention points during dispose.
  35497. */
  35498. freeRenderingGroups(): void;
  35499. /** @hidden */
  35500. _isInIntermediateRendering(): boolean;
  35501. /**
  35502. * Lambda returning the list of potentially active meshes.
  35503. */
  35504. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35505. /**
  35506. * Lambda returning the list of potentially active sub meshes.
  35507. */
  35508. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35509. /**
  35510. * Lambda returning the list of potentially intersecting sub meshes.
  35511. */
  35512. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35513. /**
  35514. * Lambda returning the list of potentially colliding sub meshes.
  35515. */
  35516. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35517. private _activeMeshesFrozen;
  35518. /**
  35519. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35520. * @returns the current scene
  35521. */
  35522. freezeActiveMeshes(): Scene;
  35523. /**
  35524. * Use this function to restart evaluating active meshes on every frame
  35525. * @returns the current scene
  35526. */
  35527. unfreezeActiveMeshes(): Scene;
  35528. private _evaluateActiveMeshes;
  35529. private _activeMesh;
  35530. /**
  35531. * Update the transform matrix to update from the current active camera
  35532. * @param force defines a boolean used to force the update even if cache is up to date
  35533. */
  35534. updateTransformMatrix(force?: boolean): void;
  35535. private _bindFrameBuffer;
  35536. /** @hidden */
  35537. _allowPostProcessClearColor: boolean;
  35538. /** @hidden */
  35539. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35540. private _processSubCameras;
  35541. private _checkIntersections;
  35542. /** @hidden */
  35543. _advancePhysicsEngineStep(step: number): void;
  35544. /**
  35545. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35546. */
  35547. getDeterministicFrameTime: () => number;
  35548. /** @hidden */
  35549. _animate(): void;
  35550. /** Execute all animations (for a frame) */
  35551. animate(): void;
  35552. /**
  35553. * Render the scene
  35554. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35555. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35556. */
  35557. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35558. /**
  35559. * Freeze all materials
  35560. * A frozen material will not be updatable but should be faster to render
  35561. */
  35562. freezeMaterials(): void;
  35563. /**
  35564. * Unfreeze all materials
  35565. * A frozen material will not be updatable but should be faster to render
  35566. */
  35567. unfreezeMaterials(): void;
  35568. /**
  35569. * Releases all held ressources
  35570. */
  35571. dispose(): void;
  35572. /**
  35573. * Gets if the scene is already disposed
  35574. */
  35575. readonly isDisposed: boolean;
  35576. /**
  35577. * Call this function to reduce memory footprint of the scene.
  35578. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35579. */
  35580. clearCachedVertexData(): void;
  35581. /**
  35582. * This function will remove the local cached buffer data from texture.
  35583. * It will save memory but will prevent the texture from being rebuilt
  35584. */
  35585. cleanCachedTextureBuffer(): void;
  35586. /**
  35587. * Get the world extend vectors with an optional filter
  35588. *
  35589. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35590. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35591. */
  35592. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35593. min: Vector3;
  35594. max: Vector3;
  35595. };
  35596. /**
  35597. * Creates a ray that can be used to pick in the scene
  35598. * @param x defines the x coordinate of the origin (on-screen)
  35599. * @param y defines the y coordinate of the origin (on-screen)
  35600. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35601. * @param camera defines the camera to use for the picking
  35602. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35603. * @returns a Ray
  35604. */
  35605. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35606. /**
  35607. * Creates a ray that can be used to pick in the scene
  35608. * @param x defines the x coordinate of the origin (on-screen)
  35609. * @param y defines the y coordinate of the origin (on-screen)
  35610. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35611. * @param result defines the ray where to store the picking ray
  35612. * @param camera defines the camera to use for the picking
  35613. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35614. * @returns the current scene
  35615. */
  35616. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35617. /**
  35618. * Creates a ray that can be used to pick in the scene
  35619. * @param x defines the x coordinate of the origin (on-screen)
  35620. * @param y defines the y coordinate of the origin (on-screen)
  35621. * @param camera defines the camera to use for the picking
  35622. * @returns a Ray
  35623. */
  35624. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35625. /**
  35626. * Creates a ray that can be used to pick in the scene
  35627. * @param x defines the x coordinate of the origin (on-screen)
  35628. * @param y defines the y coordinate of the origin (on-screen)
  35629. * @param result defines the ray where to store the picking ray
  35630. * @param camera defines the camera to use for the picking
  35631. * @returns the current scene
  35632. */
  35633. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35634. /** Launch a ray to try to pick a mesh in the scene
  35635. * @param x position on screen
  35636. * @param y position on screen
  35637. * @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
  35638. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35639. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35640. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35641. * @returns a PickingInfo
  35642. */
  35643. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35644. /** Use the given ray to pick a mesh in the scene
  35645. * @param ray The ray to use to pick meshes
  35646. * @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
  35647. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35648. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35649. * @returns a PickingInfo
  35650. */
  35651. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35652. /**
  35653. * Launch a ray to try to pick a mesh in the scene
  35654. * @param x X position on screen
  35655. * @param y Y position on screen
  35656. * @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
  35657. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35659. * @returns an array of PickingInfo
  35660. */
  35661. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35662. /**
  35663. * Launch a ray to try to pick a mesh in the scene
  35664. * @param ray Ray to use
  35665. * @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
  35666. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35667. * @returns an array of PickingInfo
  35668. */
  35669. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35670. /**
  35671. * Force the value of meshUnderPointer
  35672. * @param mesh defines the mesh to use
  35673. */
  35674. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35675. /**
  35676. * Gets the mesh under the pointer
  35677. * @returns a Mesh or null if no mesh is under the pointer
  35678. */
  35679. getPointerOverMesh(): Nullable<AbstractMesh>;
  35680. /** @hidden */
  35681. _rebuildGeometries(): void;
  35682. /** @hidden */
  35683. _rebuildTextures(): void;
  35684. private _getByTags;
  35685. /**
  35686. * Get a list of meshes by tags
  35687. * @param tagsQuery defines the tags query to use
  35688. * @param forEach defines a predicate used to filter results
  35689. * @returns an array of Mesh
  35690. */
  35691. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35692. /**
  35693. * Get a list of cameras by tags
  35694. * @param tagsQuery defines the tags query to use
  35695. * @param forEach defines a predicate used to filter results
  35696. * @returns an array of Camera
  35697. */
  35698. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35699. /**
  35700. * Get a list of lights by tags
  35701. * @param tagsQuery defines the tags query to use
  35702. * @param forEach defines a predicate used to filter results
  35703. * @returns an array of Light
  35704. */
  35705. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35706. /**
  35707. * Get a list of materials by tags
  35708. * @param tagsQuery defines the tags query to use
  35709. * @param forEach defines a predicate used to filter results
  35710. * @returns an array of Material
  35711. */
  35712. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35713. /**
  35714. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35715. * This allowed control for front to back rendering or reversly depending of the special needs.
  35716. *
  35717. * @param renderingGroupId The rendering group id corresponding to its index
  35718. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35719. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35720. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35721. */
  35722. 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;
  35723. /**
  35724. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35725. *
  35726. * @param renderingGroupId The rendering group id corresponding to its index
  35727. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35728. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35729. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35730. */
  35731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35732. /**
  35733. * Gets the current auto clear configuration for one rendering group of the rendering
  35734. * manager.
  35735. * @param index the rendering group index to get the information for
  35736. * @returns The auto clear setup for the requested rendering group
  35737. */
  35738. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35739. private _blockMaterialDirtyMechanism;
  35740. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35741. blockMaterialDirtyMechanism: boolean;
  35742. /**
  35743. * Will flag all materials as dirty to trigger new shader compilation
  35744. * @param flag defines the flag used to specify which material part must be marked as dirty
  35745. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35746. */
  35747. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35748. /** @hidden */
  35749. _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;
  35750. /** @hidden */
  35751. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35752. }
  35753. }
  35754. declare module "babylonjs/assetContainer" {
  35755. import { AbstractScene } from "babylonjs/abstractScene";
  35756. import { Scene } from "babylonjs/scene";
  35757. import { Mesh } from "babylonjs/Meshes/mesh";
  35758. /**
  35759. * Set of assets to keep when moving a scene into an asset container.
  35760. */
  35761. export class KeepAssets extends AbstractScene {
  35762. }
  35763. /**
  35764. * Container with a set of assets that can be added or removed from a scene.
  35765. */
  35766. export class AssetContainer extends AbstractScene {
  35767. /**
  35768. * The scene the AssetContainer belongs to.
  35769. */
  35770. scene: Scene;
  35771. /**
  35772. * Instantiates an AssetContainer.
  35773. * @param scene The scene the AssetContainer belongs to.
  35774. */
  35775. constructor(scene: Scene);
  35776. /**
  35777. * Adds all the assets from the container to the scene.
  35778. */
  35779. addAllToScene(): void;
  35780. /**
  35781. * Removes all the assets in the container from the scene
  35782. */
  35783. removeAllFromScene(): void;
  35784. /**
  35785. * Disposes all the assets in the container
  35786. */
  35787. dispose(): void;
  35788. private _moveAssets;
  35789. /**
  35790. * Removes all the assets contained in the scene and adds them to the container.
  35791. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35792. */
  35793. moveAllFromScene(keepAssets?: KeepAssets): void;
  35794. /**
  35795. * 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.
  35796. * @returns the root mesh
  35797. */
  35798. createRootMesh(): Mesh;
  35799. }
  35800. }
  35801. declare module "babylonjs/abstractScene" {
  35802. import { Scene } from "babylonjs/scene";
  35803. import { Nullable } from "babylonjs/types";
  35804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35806. import { Geometry } from "babylonjs/Meshes/geometry";
  35807. import { Skeleton } from "babylonjs/Bones/skeleton";
  35808. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35809. import { AssetContainer } from "babylonjs/assetContainer";
  35810. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35811. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35813. import { Material } from "babylonjs/Materials/material";
  35814. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35815. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35816. import { Camera } from "babylonjs/Cameras/camera";
  35817. import { Light } from "babylonjs/Lights/light";
  35818. import { Node } from "babylonjs/node";
  35819. import { Animation } from "babylonjs/Animations/animation";
  35820. /**
  35821. * Defines how the parser contract is defined.
  35822. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35823. */
  35824. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35825. /**
  35826. * Defines how the individual parser contract is defined.
  35827. * These parser can parse an individual asset
  35828. */
  35829. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35830. /**
  35831. * Base class of the scene acting as a container for the different elements composing a scene.
  35832. * This class is dynamically extended by the different components of the scene increasing
  35833. * flexibility and reducing coupling
  35834. */
  35835. export abstract class AbstractScene {
  35836. /**
  35837. * Stores the list of available parsers in the application.
  35838. */
  35839. private static _BabylonFileParsers;
  35840. /**
  35841. * Stores the list of available individual parsers in the application.
  35842. */
  35843. private static _IndividualBabylonFileParsers;
  35844. /**
  35845. * Adds a parser in the list of available ones
  35846. * @param name Defines the name of the parser
  35847. * @param parser Defines the parser to add
  35848. */
  35849. static AddParser(name: string, parser: BabylonFileParser): void;
  35850. /**
  35851. * Gets a general parser from the list of avaialble ones
  35852. * @param name Defines the name of the parser
  35853. * @returns the requested parser or null
  35854. */
  35855. static GetParser(name: string): Nullable<BabylonFileParser>;
  35856. /**
  35857. * Adds n individual parser in the list of available ones
  35858. * @param name Defines the name of the parser
  35859. * @param parser Defines the parser to add
  35860. */
  35861. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35862. /**
  35863. * Gets an individual parser from the list of avaialble ones
  35864. * @param name Defines the name of the parser
  35865. * @returns the requested parser or null
  35866. */
  35867. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35868. /**
  35869. * Parser json data and populate both a scene and its associated container object
  35870. * @param jsonData Defines the data to parse
  35871. * @param scene Defines the scene to parse the data for
  35872. * @param container Defines the container attached to the parsing sequence
  35873. * @param rootUrl Defines the root url of the data
  35874. */
  35875. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35876. /**
  35877. * Gets the list of root nodes (ie. nodes with no parent)
  35878. */
  35879. rootNodes: Node[];
  35880. /** All of the cameras added to this scene
  35881. * @see http://doc.babylonjs.com/babylon101/cameras
  35882. */
  35883. cameras: Camera[];
  35884. /**
  35885. * All of the lights added to this scene
  35886. * @see http://doc.babylonjs.com/babylon101/lights
  35887. */
  35888. lights: Light[];
  35889. /**
  35890. * All of the (abstract) meshes added to this scene
  35891. */
  35892. meshes: AbstractMesh[];
  35893. /**
  35894. * The list of skeletons added to the scene
  35895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35896. */
  35897. skeletons: Skeleton[];
  35898. /**
  35899. * All of the particle systems added to this scene
  35900. * @see http://doc.babylonjs.com/babylon101/particles
  35901. */
  35902. particleSystems: IParticleSystem[];
  35903. /**
  35904. * Gets a list of Animations associated with the scene
  35905. */
  35906. animations: Animation[];
  35907. /**
  35908. * All of the animation groups added to this scene
  35909. * @see http://doc.babylonjs.com/how_to/group
  35910. */
  35911. animationGroups: AnimationGroup[];
  35912. /**
  35913. * All of the multi-materials added to this scene
  35914. * @see http://doc.babylonjs.com/how_to/multi_materials
  35915. */
  35916. multiMaterials: MultiMaterial[];
  35917. /**
  35918. * All of the materials added to this scene
  35919. * In the context of a Scene, it is not supposed to be modified manually.
  35920. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35921. * Note also that the order of the Material wihin the array is not significant and might change.
  35922. * @see http://doc.babylonjs.com/babylon101/materials
  35923. */
  35924. materials: Material[];
  35925. /**
  35926. * The list of morph target managers added to the scene
  35927. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35928. */
  35929. morphTargetManagers: MorphTargetManager[];
  35930. /**
  35931. * The list of geometries used in the scene.
  35932. */
  35933. geometries: Geometry[];
  35934. /**
  35935. * All of the tranform nodes added to this scene
  35936. * In the context of a Scene, it is not supposed to be modified manually.
  35937. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35938. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35939. * @see http://doc.babylonjs.com/how_to/transformnode
  35940. */
  35941. transformNodes: TransformNode[];
  35942. /**
  35943. * ActionManagers available on the scene.
  35944. */
  35945. actionManagers: AbstractActionManager[];
  35946. /**
  35947. * Textures to keep.
  35948. */
  35949. textures: BaseTexture[];
  35950. /**
  35951. * Environment texture for the scene
  35952. */
  35953. environmentTexture: Nullable<BaseTexture>;
  35954. }
  35955. }
  35956. declare module "babylonjs/Audio/sound" {
  35957. import { Observable } from "babylonjs/Misc/observable";
  35958. import { Vector3 } from "babylonjs/Maths/math.vector";
  35959. import { Nullable } from "babylonjs/types";
  35960. import { Scene } from "babylonjs/scene";
  35961. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35962. /**
  35963. * Interface used to define options for Sound class
  35964. */
  35965. export interface ISoundOptions {
  35966. /**
  35967. * Does the sound autoplay once loaded.
  35968. */
  35969. autoplay?: boolean;
  35970. /**
  35971. * Does the sound loop after it finishes playing once.
  35972. */
  35973. loop?: boolean;
  35974. /**
  35975. * Sound's volume
  35976. */
  35977. volume?: number;
  35978. /**
  35979. * Is it a spatial sound?
  35980. */
  35981. spatialSound?: boolean;
  35982. /**
  35983. * Maximum distance to hear that sound
  35984. */
  35985. maxDistance?: number;
  35986. /**
  35987. * Uses user defined attenuation function
  35988. */
  35989. useCustomAttenuation?: boolean;
  35990. /**
  35991. * Define the roll off factor of spatial sounds.
  35992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35993. */
  35994. rolloffFactor?: number;
  35995. /**
  35996. * Define the reference distance the sound should be heard perfectly.
  35997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35998. */
  35999. refDistance?: number;
  36000. /**
  36001. * Define the distance attenuation model the sound will follow.
  36002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36003. */
  36004. distanceModel?: string;
  36005. /**
  36006. * Defines the playback speed (1 by default)
  36007. */
  36008. playbackRate?: number;
  36009. /**
  36010. * Defines if the sound is from a streaming source
  36011. */
  36012. streaming?: boolean;
  36013. /**
  36014. * Defines an optional length (in seconds) inside the sound file
  36015. */
  36016. length?: number;
  36017. /**
  36018. * Defines an optional offset (in seconds) inside the sound file
  36019. */
  36020. offset?: number;
  36021. /**
  36022. * If true, URLs will not be required to state the audio file codec to use.
  36023. */
  36024. skipCodecCheck?: boolean;
  36025. }
  36026. /**
  36027. * Defines a sound that can be played in the application.
  36028. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36030. */
  36031. export class Sound {
  36032. /**
  36033. * The name of the sound in the scene.
  36034. */
  36035. name: string;
  36036. /**
  36037. * Does the sound autoplay once loaded.
  36038. */
  36039. autoplay: boolean;
  36040. /**
  36041. * Does the sound loop after it finishes playing once.
  36042. */
  36043. loop: boolean;
  36044. /**
  36045. * Does the sound use a custom attenuation curve to simulate the falloff
  36046. * happening when the source gets further away from the camera.
  36047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36048. */
  36049. useCustomAttenuation: boolean;
  36050. /**
  36051. * The sound track id this sound belongs to.
  36052. */
  36053. soundTrackId: number;
  36054. /**
  36055. * Is this sound currently played.
  36056. */
  36057. isPlaying: boolean;
  36058. /**
  36059. * Is this sound currently paused.
  36060. */
  36061. isPaused: boolean;
  36062. /**
  36063. * Does this sound enables spatial sound.
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36065. */
  36066. spatialSound: boolean;
  36067. /**
  36068. * Define the reference distance the sound should be heard perfectly.
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36070. */
  36071. refDistance: number;
  36072. /**
  36073. * Define the roll off factor of spatial sounds.
  36074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36075. */
  36076. rolloffFactor: number;
  36077. /**
  36078. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36080. */
  36081. maxDistance: number;
  36082. /**
  36083. * Define the distance attenuation model the sound will follow.
  36084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36085. */
  36086. distanceModel: string;
  36087. /**
  36088. * @hidden
  36089. * Back Compat
  36090. **/
  36091. onended: () => any;
  36092. /**
  36093. * Observable event when the current playing sound finishes.
  36094. */
  36095. onEndedObservable: Observable<Sound>;
  36096. private _panningModel;
  36097. private _playbackRate;
  36098. private _streaming;
  36099. private _startTime;
  36100. private _startOffset;
  36101. private _position;
  36102. /** @hidden */
  36103. _positionInEmitterSpace: boolean;
  36104. private _localDirection;
  36105. private _volume;
  36106. private _isReadyToPlay;
  36107. private _isDirectional;
  36108. private _readyToPlayCallback;
  36109. private _audioBuffer;
  36110. private _soundSource;
  36111. private _streamingSource;
  36112. private _soundPanner;
  36113. private _soundGain;
  36114. private _inputAudioNode;
  36115. private _outputAudioNode;
  36116. private _coneInnerAngle;
  36117. private _coneOuterAngle;
  36118. private _coneOuterGain;
  36119. private _scene;
  36120. private _connectedTransformNode;
  36121. private _customAttenuationFunction;
  36122. private _registerFunc;
  36123. private _isOutputConnected;
  36124. private _htmlAudioElement;
  36125. private _urlType;
  36126. private _length?;
  36127. private _offset?;
  36128. /** @hidden */
  36129. static _SceneComponentInitialization: (scene: Scene) => void;
  36130. /**
  36131. * Create a sound and attach it to a scene
  36132. * @param name Name of your sound
  36133. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36134. * @param scene defines the scene the sound belongs to
  36135. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36136. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36137. */
  36138. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36139. /**
  36140. * Release the sound and its associated resources
  36141. */
  36142. dispose(): void;
  36143. /**
  36144. * Gets if the sounds is ready to be played or not.
  36145. * @returns true if ready, otherwise false
  36146. */
  36147. isReady(): boolean;
  36148. private _soundLoaded;
  36149. /**
  36150. * Sets the data of the sound from an audiobuffer
  36151. * @param audioBuffer The audioBuffer containing the data
  36152. */
  36153. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36154. /**
  36155. * Updates the current sounds options such as maxdistance, loop...
  36156. * @param options A JSON object containing values named as the object properties
  36157. */
  36158. updateOptions(options: ISoundOptions): void;
  36159. private _createSpatialParameters;
  36160. private _updateSpatialParameters;
  36161. /**
  36162. * Switch the panning model to HRTF:
  36163. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36165. */
  36166. switchPanningModelToHRTF(): void;
  36167. /**
  36168. * Switch the panning model to Equal Power:
  36169. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36171. */
  36172. switchPanningModelToEqualPower(): void;
  36173. private _switchPanningModel;
  36174. /**
  36175. * Connect this sound to a sound track audio node like gain...
  36176. * @param soundTrackAudioNode the sound track audio node to connect to
  36177. */
  36178. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36179. /**
  36180. * Transform this sound into a directional source
  36181. * @param coneInnerAngle Size of the inner cone in degree
  36182. * @param coneOuterAngle Size of the outer cone in degree
  36183. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36184. */
  36185. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36186. /**
  36187. * Gets or sets the inner angle for the directional cone.
  36188. */
  36189. /**
  36190. * Gets or sets the inner angle for the directional cone.
  36191. */
  36192. directionalConeInnerAngle: number;
  36193. /**
  36194. * Gets or sets the outer angle for the directional cone.
  36195. */
  36196. /**
  36197. * Gets or sets the outer angle for the directional cone.
  36198. */
  36199. directionalConeOuterAngle: number;
  36200. /**
  36201. * Sets the position of the emitter if spatial sound is enabled
  36202. * @param newPosition Defines the new posisiton
  36203. */
  36204. setPosition(newPosition: Vector3): void;
  36205. /**
  36206. * Sets the local direction of the emitter if spatial sound is enabled
  36207. * @param newLocalDirection Defines the new local direction
  36208. */
  36209. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36210. private _updateDirection;
  36211. /** @hidden */
  36212. updateDistanceFromListener(): void;
  36213. /**
  36214. * Sets a new custom attenuation function for the sound.
  36215. * @param callback Defines the function used for the attenuation
  36216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36217. */
  36218. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36219. /**
  36220. * Play the sound
  36221. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36222. * @param offset (optional) Start the sound at a specific time in seconds
  36223. * @param length (optional) Sound duration (in seconds)
  36224. */
  36225. play(time?: number, offset?: number, length?: number): void;
  36226. private _onended;
  36227. /**
  36228. * Stop the sound
  36229. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36230. */
  36231. stop(time?: number): void;
  36232. /**
  36233. * Put the sound in pause
  36234. */
  36235. pause(): void;
  36236. /**
  36237. * Sets a dedicated volume for this sounds
  36238. * @param newVolume Define the new volume of the sound
  36239. * @param time Define time for gradual change to new volume
  36240. */
  36241. setVolume(newVolume: number, time?: number): void;
  36242. /**
  36243. * Set the sound play back rate
  36244. * @param newPlaybackRate Define the playback rate the sound should be played at
  36245. */
  36246. setPlaybackRate(newPlaybackRate: number): void;
  36247. /**
  36248. * Gets the volume of the sound.
  36249. * @returns the volume of the sound
  36250. */
  36251. getVolume(): number;
  36252. /**
  36253. * Attach the sound to a dedicated mesh
  36254. * @param transformNode The transform node to connect the sound with
  36255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36256. */
  36257. attachToMesh(transformNode: TransformNode): void;
  36258. /**
  36259. * Detach the sound from the previously attached mesh
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36261. */
  36262. detachFromMesh(): void;
  36263. private _onRegisterAfterWorldMatrixUpdate;
  36264. /**
  36265. * Clone the current sound in the scene.
  36266. * @returns the new sound clone
  36267. */
  36268. clone(): Nullable<Sound>;
  36269. /**
  36270. * Gets the current underlying audio buffer containing the data
  36271. * @returns the audio buffer
  36272. */
  36273. getAudioBuffer(): Nullable<AudioBuffer>;
  36274. /**
  36275. * Serializes the Sound in a JSON representation
  36276. * @returns the JSON representation of the sound
  36277. */
  36278. serialize(): any;
  36279. /**
  36280. * Parse a JSON representation of a sound to innstantiate in a given scene
  36281. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36282. * @param scene Define the scene the new parsed sound should be created in
  36283. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36284. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36285. * @returns the newly parsed sound
  36286. */
  36287. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36288. }
  36289. }
  36290. declare module "babylonjs/Actions/directAudioActions" {
  36291. import { Action } from "babylonjs/Actions/action";
  36292. import { Condition } from "babylonjs/Actions/condition";
  36293. import { Sound } from "babylonjs/Audio/sound";
  36294. /**
  36295. * This defines an action helpful to play a defined sound on a triggered action.
  36296. */
  36297. export class PlaySoundAction extends Action {
  36298. private _sound;
  36299. /**
  36300. * Instantiate the action
  36301. * @param triggerOptions defines the trigger options
  36302. * @param sound defines the sound to play
  36303. * @param condition defines the trigger related conditions
  36304. */
  36305. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36306. /** @hidden */
  36307. _prepare(): void;
  36308. /**
  36309. * Execute the action and play the sound.
  36310. */
  36311. execute(): void;
  36312. /**
  36313. * Serializes the actions and its related information.
  36314. * @param parent defines the object to serialize in
  36315. * @returns the serialized object
  36316. */
  36317. serialize(parent: any): any;
  36318. }
  36319. /**
  36320. * This defines an action helpful to stop a defined sound on a triggered action.
  36321. */
  36322. export class StopSoundAction extends Action {
  36323. private _sound;
  36324. /**
  36325. * Instantiate the action
  36326. * @param triggerOptions defines the trigger options
  36327. * @param sound defines the sound to stop
  36328. * @param condition defines the trigger related conditions
  36329. */
  36330. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36331. /** @hidden */
  36332. _prepare(): void;
  36333. /**
  36334. * Execute the action and stop the sound.
  36335. */
  36336. execute(): void;
  36337. /**
  36338. * Serializes the actions and its related information.
  36339. * @param parent defines the object to serialize in
  36340. * @returns the serialized object
  36341. */
  36342. serialize(parent: any): any;
  36343. }
  36344. }
  36345. declare module "babylonjs/Actions/interpolateValueAction" {
  36346. import { Action } from "babylonjs/Actions/action";
  36347. import { Condition } from "babylonjs/Actions/condition";
  36348. import { Observable } from "babylonjs/Misc/observable";
  36349. /**
  36350. * This defines an action responsible to change the value of a property
  36351. * by interpolating between its current value and the newly set one once triggered.
  36352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36353. */
  36354. export class InterpolateValueAction extends Action {
  36355. /**
  36356. * Defines the path of the property where the value should be interpolated
  36357. */
  36358. propertyPath: string;
  36359. /**
  36360. * Defines the target value at the end of the interpolation.
  36361. */
  36362. value: any;
  36363. /**
  36364. * Defines the time it will take for the property to interpolate to the value.
  36365. */
  36366. duration: number;
  36367. /**
  36368. * Defines if the other scene animations should be stopped when the action has been triggered
  36369. */
  36370. stopOtherAnimations?: boolean;
  36371. /**
  36372. * Defines a callback raised once the interpolation animation has been done.
  36373. */
  36374. onInterpolationDone?: () => void;
  36375. /**
  36376. * Observable triggered once the interpolation animation has been done.
  36377. */
  36378. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36379. private _target;
  36380. private _effectiveTarget;
  36381. private _property;
  36382. /**
  36383. * Instantiate the action
  36384. * @param triggerOptions defines the trigger options
  36385. * @param target defines the object containing the value to interpolate
  36386. * @param propertyPath defines the path to the property in the target object
  36387. * @param value defines the target value at the end of the interpolation
  36388. * @param duration deines the time it will take for the property to interpolate to the value.
  36389. * @param condition defines the trigger related conditions
  36390. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36391. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36392. */
  36393. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36394. /** @hidden */
  36395. _prepare(): void;
  36396. /**
  36397. * Execute the action starts the value interpolation.
  36398. */
  36399. execute(): void;
  36400. /**
  36401. * Serializes the actions and its related information.
  36402. * @param parent defines the object to serialize in
  36403. * @returns the serialized object
  36404. */
  36405. serialize(parent: any): any;
  36406. }
  36407. }
  36408. declare module "babylonjs/Actions/index" {
  36409. export * from "babylonjs/Actions/abstractActionManager";
  36410. export * from "babylonjs/Actions/action";
  36411. export * from "babylonjs/Actions/actionEvent";
  36412. export * from "babylonjs/Actions/actionManager";
  36413. export * from "babylonjs/Actions/condition";
  36414. export * from "babylonjs/Actions/directActions";
  36415. export * from "babylonjs/Actions/directAudioActions";
  36416. export * from "babylonjs/Actions/interpolateValueAction";
  36417. }
  36418. declare module "babylonjs/Animations/index" {
  36419. export * from "babylonjs/Animations/animatable";
  36420. export * from "babylonjs/Animations/animation";
  36421. export * from "babylonjs/Animations/animationGroup";
  36422. export * from "babylonjs/Animations/animationPropertiesOverride";
  36423. export * from "babylonjs/Animations/easing";
  36424. export * from "babylonjs/Animations/runtimeAnimation";
  36425. export * from "babylonjs/Animations/animationEvent";
  36426. export * from "babylonjs/Animations/animationGroup";
  36427. export * from "babylonjs/Animations/animationKey";
  36428. export * from "babylonjs/Animations/animationRange";
  36429. export * from "babylonjs/Animations/animatable.interface";
  36430. }
  36431. declare module "babylonjs/Audio/soundTrack" {
  36432. import { Sound } from "babylonjs/Audio/sound";
  36433. import { Analyser } from "babylonjs/Audio/analyser";
  36434. import { Scene } from "babylonjs/scene";
  36435. /**
  36436. * Options allowed during the creation of a sound track.
  36437. */
  36438. export interface ISoundTrackOptions {
  36439. /**
  36440. * The volume the sound track should take during creation
  36441. */
  36442. volume?: number;
  36443. /**
  36444. * Define if the sound track is the main sound track of the scene
  36445. */
  36446. mainTrack?: boolean;
  36447. }
  36448. /**
  36449. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36450. * It will be also used in a future release to apply effects on a specific track.
  36451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36452. */
  36453. export class SoundTrack {
  36454. /**
  36455. * The unique identifier of the sound track in the scene.
  36456. */
  36457. id: number;
  36458. /**
  36459. * The list of sounds included in the sound track.
  36460. */
  36461. soundCollection: Array<Sound>;
  36462. private _outputAudioNode;
  36463. private _scene;
  36464. private _isMainTrack;
  36465. private _connectedAnalyser;
  36466. private _options;
  36467. private _isInitialized;
  36468. /**
  36469. * Creates a new sound track.
  36470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36471. * @param scene Define the scene the sound track belongs to
  36472. * @param options
  36473. */
  36474. constructor(scene: Scene, options?: ISoundTrackOptions);
  36475. private _initializeSoundTrackAudioGraph;
  36476. /**
  36477. * Release the sound track and its associated resources
  36478. */
  36479. dispose(): void;
  36480. /**
  36481. * Adds a sound to this sound track
  36482. * @param sound define the cound to add
  36483. * @ignoreNaming
  36484. */
  36485. AddSound(sound: Sound): void;
  36486. /**
  36487. * Removes a sound to this sound track
  36488. * @param sound define the cound to remove
  36489. * @ignoreNaming
  36490. */
  36491. RemoveSound(sound: Sound): void;
  36492. /**
  36493. * Set a global volume for the full sound track.
  36494. * @param newVolume Define the new volume of the sound track
  36495. */
  36496. setVolume(newVolume: number): void;
  36497. /**
  36498. * Switch the panning model to HRTF:
  36499. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36501. */
  36502. switchPanningModelToHRTF(): void;
  36503. /**
  36504. * Switch the panning model to Equal Power:
  36505. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36507. */
  36508. switchPanningModelToEqualPower(): void;
  36509. /**
  36510. * Connect the sound track to an audio analyser allowing some amazing
  36511. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36513. * @param analyser The analyser to connect to the engine
  36514. */
  36515. connectToAnalyser(analyser: Analyser): void;
  36516. }
  36517. }
  36518. declare module "babylonjs/Audio/audioSceneComponent" {
  36519. import { Sound } from "babylonjs/Audio/sound";
  36520. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36521. import { Nullable } from "babylonjs/types";
  36522. import { Vector3 } from "babylonjs/Maths/math.vector";
  36523. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36524. import { Scene } from "babylonjs/scene";
  36525. import { AbstractScene } from "babylonjs/abstractScene";
  36526. import "babylonjs/Audio/audioEngine";
  36527. module "babylonjs/abstractScene" {
  36528. interface AbstractScene {
  36529. /**
  36530. * The list of sounds used in the scene.
  36531. */
  36532. sounds: Nullable<Array<Sound>>;
  36533. }
  36534. }
  36535. module "babylonjs/scene" {
  36536. interface Scene {
  36537. /**
  36538. * @hidden
  36539. * Backing field
  36540. */
  36541. _mainSoundTrack: SoundTrack;
  36542. /**
  36543. * The main sound track played by the scene.
  36544. * It cotains your primary collection of sounds.
  36545. */
  36546. mainSoundTrack: SoundTrack;
  36547. /**
  36548. * The list of sound tracks added to the scene
  36549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36550. */
  36551. soundTracks: Nullable<Array<SoundTrack>>;
  36552. /**
  36553. * Gets a sound using a given name
  36554. * @param name defines the name to search for
  36555. * @return the found sound or null if not found at all.
  36556. */
  36557. getSoundByName(name: string): Nullable<Sound>;
  36558. /**
  36559. * Gets or sets if audio support is enabled
  36560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36561. */
  36562. audioEnabled: boolean;
  36563. /**
  36564. * Gets or sets if audio will be output to headphones
  36565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36566. */
  36567. headphone: boolean;
  36568. /**
  36569. * Gets or sets custom audio listener position provider
  36570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36571. */
  36572. audioListenerPositionProvider: Nullable<() => Vector3>;
  36573. }
  36574. }
  36575. /**
  36576. * Defines the sound scene component responsible to manage any sounds
  36577. * in a given scene.
  36578. */
  36579. export class AudioSceneComponent implements ISceneSerializableComponent {
  36580. /**
  36581. * The component name helpfull to identify the component in the list of scene components.
  36582. */
  36583. readonly name: string;
  36584. /**
  36585. * The scene the component belongs to.
  36586. */
  36587. scene: Scene;
  36588. private _audioEnabled;
  36589. /**
  36590. * Gets whether audio is enabled or not.
  36591. * Please use related enable/disable method to switch state.
  36592. */
  36593. readonly audioEnabled: boolean;
  36594. private _headphone;
  36595. /**
  36596. * Gets whether audio is outputing to headphone or not.
  36597. * Please use the according Switch methods to change output.
  36598. */
  36599. readonly headphone: boolean;
  36600. private _audioListenerPositionProvider;
  36601. /**
  36602. * Gets the current audio listener position provider
  36603. */
  36604. /**
  36605. * Sets a custom listener position for all sounds in the scene
  36606. * By default, this is the position of the first active camera
  36607. */
  36608. audioListenerPositionProvider: Nullable<() => Vector3>;
  36609. /**
  36610. * Creates a new instance of the component for the given scene
  36611. * @param scene Defines the scene to register the component in
  36612. */
  36613. constructor(scene: Scene);
  36614. /**
  36615. * Registers the component in a given scene
  36616. */
  36617. register(): void;
  36618. /**
  36619. * Rebuilds the elements related to this component in case of
  36620. * context lost for instance.
  36621. */
  36622. rebuild(): void;
  36623. /**
  36624. * Serializes the component data to the specified json object
  36625. * @param serializationObject The object to serialize to
  36626. */
  36627. serialize(serializationObject: any): void;
  36628. /**
  36629. * Adds all the elements from the container to the scene
  36630. * @param container the container holding the elements
  36631. */
  36632. addFromContainer(container: AbstractScene): void;
  36633. /**
  36634. * Removes all the elements in the container from the scene
  36635. * @param container contains the elements to remove
  36636. * @param dispose if the removed element should be disposed (default: false)
  36637. */
  36638. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36639. /**
  36640. * Disposes the component and the associated ressources.
  36641. */
  36642. dispose(): void;
  36643. /**
  36644. * Disables audio in the associated scene.
  36645. */
  36646. disableAudio(): void;
  36647. /**
  36648. * Enables audio in the associated scene.
  36649. */
  36650. enableAudio(): void;
  36651. /**
  36652. * Switch audio to headphone output.
  36653. */
  36654. switchAudioModeForHeadphones(): void;
  36655. /**
  36656. * Switch audio to normal speakers.
  36657. */
  36658. switchAudioModeForNormalSpeakers(): void;
  36659. private _afterRender;
  36660. }
  36661. }
  36662. declare module "babylonjs/Audio/weightedsound" {
  36663. import { Sound } from "babylonjs/Audio/sound";
  36664. /**
  36665. * Wraps one or more Sound objects and selects one with random weight for playback.
  36666. */
  36667. export class WeightedSound {
  36668. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36669. loop: boolean;
  36670. private _coneInnerAngle;
  36671. private _coneOuterAngle;
  36672. private _volume;
  36673. /** A Sound is currently playing. */
  36674. isPlaying: boolean;
  36675. /** A Sound is currently paused. */
  36676. isPaused: boolean;
  36677. private _sounds;
  36678. private _weights;
  36679. private _currentIndex?;
  36680. /**
  36681. * Creates a new WeightedSound from the list of sounds given.
  36682. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36683. * @param sounds Array of Sounds that will be selected from.
  36684. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36685. */
  36686. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36687. /**
  36688. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36689. */
  36690. /**
  36691. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36692. */
  36693. directionalConeInnerAngle: number;
  36694. /**
  36695. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36696. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36697. */
  36698. /**
  36699. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36700. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36701. */
  36702. directionalConeOuterAngle: number;
  36703. /**
  36704. * Playback volume.
  36705. */
  36706. /**
  36707. * Playback volume.
  36708. */
  36709. volume: number;
  36710. private _onended;
  36711. /**
  36712. * Suspend playback
  36713. */
  36714. pause(): void;
  36715. /**
  36716. * Stop playback
  36717. */
  36718. stop(): void;
  36719. /**
  36720. * Start playback.
  36721. * @param startOffset Position the clip head at a specific time in seconds.
  36722. */
  36723. play(startOffset?: number): void;
  36724. }
  36725. }
  36726. declare module "babylonjs/Audio/index" {
  36727. export * from "babylonjs/Audio/analyser";
  36728. export * from "babylonjs/Audio/audioEngine";
  36729. export * from "babylonjs/Audio/audioSceneComponent";
  36730. export * from "babylonjs/Audio/sound";
  36731. export * from "babylonjs/Audio/soundTrack";
  36732. export * from "babylonjs/Audio/weightedsound";
  36733. }
  36734. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36735. import { Behavior } from "babylonjs/Behaviors/behavior";
  36736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36737. import { BackEase } from "babylonjs/Animations/easing";
  36738. /**
  36739. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36741. */
  36742. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36743. /**
  36744. * Gets the name of the behavior.
  36745. */
  36746. readonly name: string;
  36747. /**
  36748. * The easing function used by animations
  36749. */
  36750. static EasingFunction: BackEase;
  36751. /**
  36752. * The easing mode used by animations
  36753. */
  36754. static EasingMode: number;
  36755. /**
  36756. * The duration of the animation, in milliseconds
  36757. */
  36758. transitionDuration: number;
  36759. /**
  36760. * Length of the distance animated by the transition when lower radius is reached
  36761. */
  36762. lowerRadiusTransitionRange: number;
  36763. /**
  36764. * Length of the distance animated by the transition when upper radius is reached
  36765. */
  36766. upperRadiusTransitionRange: number;
  36767. private _autoTransitionRange;
  36768. /**
  36769. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36770. */
  36771. /**
  36772. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36773. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36774. */
  36775. autoTransitionRange: boolean;
  36776. private _attachedCamera;
  36777. private _onAfterCheckInputsObserver;
  36778. private _onMeshTargetChangedObserver;
  36779. /**
  36780. * Initializes the behavior.
  36781. */
  36782. init(): void;
  36783. /**
  36784. * Attaches the behavior to its arc rotate camera.
  36785. * @param camera Defines the camera to attach the behavior to
  36786. */
  36787. attach(camera: ArcRotateCamera): void;
  36788. /**
  36789. * Detaches the behavior from its current arc rotate camera.
  36790. */
  36791. detach(): void;
  36792. private _radiusIsAnimating;
  36793. private _radiusBounceTransition;
  36794. private _animatables;
  36795. private _cachedWheelPrecision;
  36796. /**
  36797. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36798. * @param radiusLimit The limit to check against.
  36799. * @return Bool to indicate if at limit.
  36800. */
  36801. private _isRadiusAtLimit;
  36802. /**
  36803. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36804. * @param radiusDelta The delta by which to animate to. Can be negative.
  36805. */
  36806. private _applyBoundRadiusAnimation;
  36807. /**
  36808. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36809. */
  36810. protected _clearAnimationLocks(): void;
  36811. /**
  36812. * Stops and removes all animations that have been applied to the camera
  36813. */
  36814. stopAllAnimations(): void;
  36815. }
  36816. }
  36817. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36818. import { Behavior } from "babylonjs/Behaviors/behavior";
  36819. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36820. import { ExponentialEase } from "babylonjs/Animations/easing";
  36821. import { Nullable } from "babylonjs/types";
  36822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36823. import { Vector3 } from "babylonjs/Maths/math.vector";
  36824. /**
  36825. * 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.
  36826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36827. */
  36828. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36829. /**
  36830. * Gets the name of the behavior.
  36831. */
  36832. readonly name: string;
  36833. private _mode;
  36834. private _radiusScale;
  36835. private _positionScale;
  36836. private _defaultElevation;
  36837. private _elevationReturnTime;
  36838. private _elevationReturnWaitTime;
  36839. private _zoomStopsAnimation;
  36840. private _framingTime;
  36841. /**
  36842. * The easing function used by animations
  36843. */
  36844. static EasingFunction: ExponentialEase;
  36845. /**
  36846. * The easing mode used by animations
  36847. */
  36848. static EasingMode: number;
  36849. /**
  36850. * Sets the current mode used by the behavior
  36851. */
  36852. /**
  36853. * Gets current mode used by the behavior.
  36854. */
  36855. mode: number;
  36856. /**
  36857. * Sets the scale applied to the radius (1 by default)
  36858. */
  36859. /**
  36860. * Gets the scale applied to the radius
  36861. */
  36862. radiusScale: number;
  36863. /**
  36864. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36865. */
  36866. /**
  36867. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36868. */
  36869. positionScale: number;
  36870. /**
  36871. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36872. * behaviour is triggered, in radians.
  36873. */
  36874. /**
  36875. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36876. * behaviour is triggered, in radians.
  36877. */
  36878. defaultElevation: number;
  36879. /**
  36880. * Sets the time (in milliseconds) taken to return to the default beta position.
  36881. * Negative value indicates camera should not return to default.
  36882. */
  36883. /**
  36884. * Gets the time (in milliseconds) taken to return to the default beta position.
  36885. * Negative value indicates camera should not return to default.
  36886. */
  36887. elevationReturnTime: number;
  36888. /**
  36889. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36890. */
  36891. /**
  36892. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36893. */
  36894. elevationReturnWaitTime: number;
  36895. /**
  36896. * Sets the flag that indicates if user zooming should stop animation.
  36897. */
  36898. /**
  36899. * Gets the flag that indicates if user zooming should stop animation.
  36900. */
  36901. zoomStopsAnimation: boolean;
  36902. /**
  36903. * Sets the transition time when framing the mesh, in milliseconds
  36904. */
  36905. /**
  36906. * Gets the transition time when framing the mesh, in milliseconds
  36907. */
  36908. framingTime: number;
  36909. /**
  36910. * Define if the behavior should automatically change the configured
  36911. * camera limits and sensibilities.
  36912. */
  36913. autoCorrectCameraLimitsAndSensibility: boolean;
  36914. private _onPrePointerObservableObserver;
  36915. private _onAfterCheckInputsObserver;
  36916. private _onMeshTargetChangedObserver;
  36917. private _attachedCamera;
  36918. private _isPointerDown;
  36919. private _lastInteractionTime;
  36920. /**
  36921. * Initializes the behavior.
  36922. */
  36923. init(): void;
  36924. /**
  36925. * Attaches the behavior to its arc rotate camera.
  36926. * @param camera Defines the camera to attach the behavior to
  36927. */
  36928. attach(camera: ArcRotateCamera): void;
  36929. /**
  36930. * Detaches the behavior from its current arc rotate camera.
  36931. */
  36932. detach(): void;
  36933. private _animatables;
  36934. private _betaIsAnimating;
  36935. private _betaTransition;
  36936. private _radiusTransition;
  36937. private _vectorTransition;
  36938. /**
  36939. * Targets the given mesh and updates zoom level accordingly.
  36940. * @param mesh The mesh to target.
  36941. * @param radius Optional. If a cached radius position already exists, overrides default.
  36942. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36943. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36944. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36945. */
  36946. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36947. /**
  36948. * Targets the given mesh with its children and updates zoom level accordingly.
  36949. * @param mesh The mesh to target.
  36950. * @param radius Optional. If a cached radius position already exists, overrides default.
  36951. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36952. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36953. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36954. */
  36955. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36956. /**
  36957. * Targets the given meshes with their children and updates zoom level accordingly.
  36958. * @param meshes The mesh to target.
  36959. * @param radius Optional. If a cached radius position already exists, overrides default.
  36960. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36961. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36962. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36963. */
  36964. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36965. /**
  36966. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36967. * @param minimumWorld Determines the smaller position of the bounding box extend
  36968. * @param maximumWorld Determines the bigger position of the bounding box extend
  36969. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36970. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36971. */
  36972. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36973. /**
  36974. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36975. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36976. * frustum width.
  36977. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36978. * to fully enclose the mesh in the viewing frustum.
  36979. */
  36980. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36981. /**
  36982. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36983. * is automatically returned to its default position (expected to be above ground plane).
  36984. */
  36985. private _maintainCameraAboveGround;
  36986. /**
  36987. * Returns the frustum slope based on the canvas ratio and camera FOV
  36988. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36989. */
  36990. private _getFrustumSlope;
  36991. /**
  36992. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36993. */
  36994. private _clearAnimationLocks;
  36995. /**
  36996. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36997. */
  36998. private _applyUserInteraction;
  36999. /**
  37000. * Stops and removes all animations that have been applied to the camera
  37001. */
  37002. stopAllAnimations(): void;
  37003. /**
  37004. * Gets a value indicating if the user is moving the camera
  37005. */
  37006. readonly isUserIsMoving: boolean;
  37007. /**
  37008. * The camera can move all the way towards the mesh.
  37009. */
  37010. static IgnoreBoundsSizeMode: number;
  37011. /**
  37012. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37013. */
  37014. static FitFrustumSidesMode: number;
  37015. }
  37016. }
  37017. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37018. import { Nullable } from "babylonjs/types";
  37019. import { Camera } from "babylonjs/Cameras/camera";
  37020. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37021. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37022. /**
  37023. * Base class for Camera Pointer Inputs.
  37024. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37025. * for example usage.
  37026. */
  37027. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37028. /**
  37029. * Defines the camera the input is attached to.
  37030. */
  37031. abstract camera: Camera;
  37032. /**
  37033. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37034. */
  37035. protected _altKey: boolean;
  37036. protected _ctrlKey: boolean;
  37037. protected _metaKey: boolean;
  37038. protected _shiftKey: boolean;
  37039. /**
  37040. * Which mouse buttons were pressed at time of last mouse event.
  37041. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37042. */
  37043. protected _buttonsPressed: number;
  37044. /**
  37045. * Defines the buttons associated with the input to handle camera move.
  37046. */
  37047. buttons: number[];
  37048. /**
  37049. * Attach the input controls to a specific dom element to get the input from.
  37050. * @param element Defines the element the controls should be listened from
  37051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37052. */
  37053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37054. /**
  37055. * Detach the current controls from the specified dom element.
  37056. * @param element Defines the element to stop listening the inputs from
  37057. */
  37058. detachControl(element: Nullable<HTMLElement>): void;
  37059. /**
  37060. * Gets the class name of the current input.
  37061. * @returns the class name
  37062. */
  37063. getClassName(): string;
  37064. /**
  37065. * Get the friendly name associated with the input class.
  37066. * @returns the input friendly name
  37067. */
  37068. getSimpleName(): string;
  37069. /**
  37070. * Called on pointer POINTERDOUBLETAP event.
  37071. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37072. */
  37073. protected onDoubleTap(type: string): void;
  37074. /**
  37075. * Called on pointer POINTERMOVE event if only a single touch is active.
  37076. * Override this method to provide functionality.
  37077. */
  37078. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37079. /**
  37080. * Called on pointer POINTERMOVE event if multiple touches are active.
  37081. * Override this method to provide functionality.
  37082. */
  37083. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37084. /**
  37085. * Called on JS contextmenu event.
  37086. * Override this method to provide functionality.
  37087. */
  37088. protected onContextMenu(evt: PointerEvent): void;
  37089. /**
  37090. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37091. * press.
  37092. * Override this method to provide functionality.
  37093. */
  37094. protected onButtonDown(evt: PointerEvent): void;
  37095. /**
  37096. * Called each time a new POINTERUP event occurs. Ie, for each button
  37097. * release.
  37098. * Override this method to provide functionality.
  37099. */
  37100. protected onButtonUp(evt: PointerEvent): void;
  37101. /**
  37102. * Called when window becomes inactive.
  37103. * Override this method to provide functionality.
  37104. */
  37105. protected onLostFocus(): void;
  37106. private _pointerInput;
  37107. private _observer;
  37108. private _onLostFocus;
  37109. private pointA;
  37110. private pointB;
  37111. }
  37112. }
  37113. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37114. import { Nullable } from "babylonjs/types";
  37115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37116. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37117. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37118. /**
  37119. * Manage the pointers inputs to control an arc rotate camera.
  37120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37121. */
  37122. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37123. /**
  37124. * Defines the camera the input is attached to.
  37125. */
  37126. camera: ArcRotateCamera;
  37127. /**
  37128. * Gets the class name of the current input.
  37129. * @returns the class name
  37130. */
  37131. getClassName(): string;
  37132. /**
  37133. * Defines the buttons associated with the input to handle camera move.
  37134. */
  37135. buttons: number[];
  37136. /**
  37137. * Defines the pointer angular sensibility along the X axis or how fast is
  37138. * the camera rotating.
  37139. */
  37140. angularSensibilityX: number;
  37141. /**
  37142. * Defines the pointer angular sensibility along the Y axis or how fast is
  37143. * the camera rotating.
  37144. */
  37145. angularSensibilityY: number;
  37146. /**
  37147. * Defines the pointer pinch precision or how fast is the camera zooming.
  37148. */
  37149. pinchPrecision: number;
  37150. /**
  37151. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37152. * from 0.
  37153. * It defines the percentage of current camera.radius to use as delta when
  37154. * pinch zoom is used.
  37155. */
  37156. pinchDeltaPercentage: number;
  37157. /**
  37158. * Defines the pointer panning sensibility or how fast is the camera moving.
  37159. */
  37160. panningSensibility: number;
  37161. /**
  37162. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37163. */
  37164. multiTouchPanning: boolean;
  37165. /**
  37166. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37167. * zoom (pinch) through multitouch.
  37168. */
  37169. multiTouchPanAndZoom: boolean;
  37170. /**
  37171. * Revers pinch action direction.
  37172. */
  37173. pinchInwards: boolean;
  37174. private _isPanClick;
  37175. private _twoFingerActivityCount;
  37176. private _isPinching;
  37177. /**
  37178. * Called on pointer POINTERMOVE event if only a single touch is active.
  37179. */
  37180. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37181. /**
  37182. * Called on pointer POINTERDOUBLETAP event.
  37183. */
  37184. protected onDoubleTap(type: string): void;
  37185. /**
  37186. * Called on pointer POINTERMOVE event if multiple touches are active.
  37187. */
  37188. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37189. /**
  37190. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37191. * press.
  37192. */
  37193. protected onButtonDown(evt: PointerEvent): void;
  37194. /**
  37195. * Called each time a new POINTERUP event occurs. Ie, for each button
  37196. * release.
  37197. */
  37198. protected onButtonUp(evt: PointerEvent): void;
  37199. /**
  37200. * Called when window becomes inactive.
  37201. */
  37202. protected onLostFocus(): void;
  37203. }
  37204. }
  37205. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37206. import { Nullable } from "babylonjs/types";
  37207. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37209. /**
  37210. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37212. */
  37213. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37214. /**
  37215. * Defines the camera the input is attached to.
  37216. */
  37217. camera: ArcRotateCamera;
  37218. /**
  37219. * Defines the list of key codes associated with the up action (increase alpha)
  37220. */
  37221. keysUp: number[];
  37222. /**
  37223. * Defines the list of key codes associated with the down action (decrease alpha)
  37224. */
  37225. keysDown: number[];
  37226. /**
  37227. * Defines the list of key codes associated with the left action (increase beta)
  37228. */
  37229. keysLeft: number[];
  37230. /**
  37231. * Defines the list of key codes associated with the right action (decrease beta)
  37232. */
  37233. keysRight: number[];
  37234. /**
  37235. * Defines the list of key codes associated with the reset action.
  37236. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37237. */
  37238. keysReset: number[];
  37239. /**
  37240. * Defines the panning sensibility of the inputs.
  37241. * (How fast is the camera paning)
  37242. */
  37243. panningSensibility: number;
  37244. /**
  37245. * Defines the zooming sensibility of the inputs.
  37246. * (How fast is the camera zooming)
  37247. */
  37248. zoomingSensibility: number;
  37249. /**
  37250. * Defines wether maintaining the alt key down switch the movement mode from
  37251. * orientation to zoom.
  37252. */
  37253. useAltToZoom: boolean;
  37254. /**
  37255. * Rotation speed of the camera
  37256. */
  37257. angularSpeed: number;
  37258. private _keys;
  37259. private _ctrlPressed;
  37260. private _altPressed;
  37261. private _onCanvasBlurObserver;
  37262. private _onKeyboardObserver;
  37263. private _engine;
  37264. private _scene;
  37265. /**
  37266. * Attach the input controls to a specific dom element to get the input from.
  37267. * @param element Defines the element the controls should be listened from
  37268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37269. */
  37270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37271. /**
  37272. * Detach the current controls from the specified dom element.
  37273. * @param element Defines the element to stop listening the inputs from
  37274. */
  37275. detachControl(element: Nullable<HTMLElement>): void;
  37276. /**
  37277. * Update the current camera state depending on the inputs that have been used this frame.
  37278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37279. */
  37280. checkInputs(): void;
  37281. /**
  37282. * Gets the class name of the current intput.
  37283. * @returns the class name
  37284. */
  37285. getClassName(): string;
  37286. /**
  37287. * Get the friendly name associated with the input class.
  37288. * @returns the input friendly name
  37289. */
  37290. getSimpleName(): string;
  37291. }
  37292. }
  37293. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37294. import { Nullable } from "babylonjs/types";
  37295. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37296. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37297. /**
  37298. * Manage the mouse wheel inputs to control an arc rotate camera.
  37299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37300. */
  37301. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37302. /**
  37303. * Defines the camera the input is attached to.
  37304. */
  37305. camera: ArcRotateCamera;
  37306. /**
  37307. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37308. */
  37309. wheelPrecision: number;
  37310. /**
  37311. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37312. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37313. */
  37314. wheelDeltaPercentage: number;
  37315. private _wheel;
  37316. private _observer;
  37317. private computeDeltaFromMouseWheelLegacyEvent;
  37318. /**
  37319. * Attach the input controls to a specific dom element to get the input from.
  37320. * @param element Defines the element the controls should be listened from
  37321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37322. */
  37323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37324. /**
  37325. * Detach the current controls from the specified dom element.
  37326. * @param element Defines the element to stop listening the inputs from
  37327. */
  37328. detachControl(element: Nullable<HTMLElement>): void;
  37329. /**
  37330. * Gets the class name of the current intput.
  37331. * @returns the class name
  37332. */
  37333. getClassName(): string;
  37334. /**
  37335. * Get the friendly name associated with the input class.
  37336. * @returns the input friendly name
  37337. */
  37338. getSimpleName(): string;
  37339. }
  37340. }
  37341. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37342. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37343. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37344. /**
  37345. * Default Inputs manager for the ArcRotateCamera.
  37346. * It groups all the default supported inputs for ease of use.
  37347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37348. */
  37349. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37350. /**
  37351. * Instantiates a new ArcRotateCameraInputsManager.
  37352. * @param camera Defines the camera the inputs belong to
  37353. */
  37354. constructor(camera: ArcRotateCamera);
  37355. /**
  37356. * Add mouse wheel input support to the input manager.
  37357. * @returns the current input manager
  37358. */
  37359. addMouseWheel(): ArcRotateCameraInputsManager;
  37360. /**
  37361. * Add pointers input support to the input manager.
  37362. * @returns the current input manager
  37363. */
  37364. addPointers(): ArcRotateCameraInputsManager;
  37365. /**
  37366. * Add keyboard input support to the input manager.
  37367. * @returns the current input manager
  37368. */
  37369. addKeyboard(): ArcRotateCameraInputsManager;
  37370. }
  37371. }
  37372. declare module "babylonjs/Cameras/arcRotateCamera" {
  37373. import { Observable } from "babylonjs/Misc/observable";
  37374. import { Nullable } from "babylonjs/types";
  37375. import { Scene } from "babylonjs/scene";
  37376. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37378. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37379. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37380. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37381. import { Camera } from "babylonjs/Cameras/camera";
  37382. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37383. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37384. import { Collider } from "babylonjs/Collisions/collider";
  37385. /**
  37386. * This represents an orbital type of camera.
  37387. *
  37388. * 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.
  37389. * 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.
  37390. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37391. */
  37392. export class ArcRotateCamera extends TargetCamera {
  37393. /**
  37394. * Defines the rotation angle of the camera along the longitudinal axis.
  37395. */
  37396. alpha: number;
  37397. /**
  37398. * Defines the rotation angle of the camera along the latitudinal axis.
  37399. */
  37400. beta: number;
  37401. /**
  37402. * Defines the radius of the camera from it s target point.
  37403. */
  37404. radius: number;
  37405. protected _target: Vector3;
  37406. protected _targetHost: Nullable<AbstractMesh>;
  37407. /**
  37408. * Defines the target point of the camera.
  37409. * The camera looks towards it form the radius distance.
  37410. */
  37411. target: Vector3;
  37412. /**
  37413. * Define the current local position of the camera in the scene
  37414. */
  37415. position: Vector3;
  37416. protected _upVector: Vector3;
  37417. protected _upToYMatrix: Matrix;
  37418. protected _YToUpMatrix: Matrix;
  37419. /**
  37420. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37421. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37422. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37423. */
  37424. upVector: Vector3;
  37425. /**
  37426. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37427. */
  37428. setMatUp(): void;
  37429. /**
  37430. * Current inertia value on the longitudinal axis.
  37431. * The bigger this number the longer it will take for the camera to stop.
  37432. */
  37433. inertialAlphaOffset: number;
  37434. /**
  37435. * Current inertia value on the latitudinal axis.
  37436. * The bigger this number the longer it will take for the camera to stop.
  37437. */
  37438. inertialBetaOffset: number;
  37439. /**
  37440. * Current inertia value on the radius axis.
  37441. * The bigger this number the longer it will take for the camera to stop.
  37442. */
  37443. inertialRadiusOffset: number;
  37444. /**
  37445. * Minimum allowed angle on the longitudinal axis.
  37446. * This can help limiting how the Camera is able to move in the scene.
  37447. */
  37448. lowerAlphaLimit: Nullable<number>;
  37449. /**
  37450. * Maximum allowed angle on the longitudinal axis.
  37451. * This can help limiting how the Camera is able to move in the scene.
  37452. */
  37453. upperAlphaLimit: Nullable<number>;
  37454. /**
  37455. * Minimum allowed angle on the latitudinal axis.
  37456. * This can help limiting how the Camera is able to move in the scene.
  37457. */
  37458. lowerBetaLimit: number;
  37459. /**
  37460. * Maximum allowed angle on the latitudinal axis.
  37461. * This can help limiting how the Camera is able to move in the scene.
  37462. */
  37463. upperBetaLimit: number;
  37464. /**
  37465. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37466. * This can help limiting how the Camera is able to move in the scene.
  37467. */
  37468. lowerRadiusLimit: Nullable<number>;
  37469. /**
  37470. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37471. * This can help limiting how the Camera is able to move in the scene.
  37472. */
  37473. upperRadiusLimit: Nullable<number>;
  37474. /**
  37475. * Defines the current inertia value used during panning of the camera along the X axis.
  37476. */
  37477. inertialPanningX: number;
  37478. /**
  37479. * Defines the current inertia value used during panning of the camera along the Y axis.
  37480. */
  37481. inertialPanningY: number;
  37482. /**
  37483. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37484. * Basically if your fingers moves away from more than this distance you will be considered
  37485. * in pinch mode.
  37486. */
  37487. pinchToPanMaxDistance: number;
  37488. /**
  37489. * Defines the maximum distance the camera can pan.
  37490. * This could help keeping the cammera always in your scene.
  37491. */
  37492. panningDistanceLimit: Nullable<number>;
  37493. /**
  37494. * Defines the target of the camera before paning.
  37495. */
  37496. panningOriginTarget: Vector3;
  37497. /**
  37498. * Defines the value of the inertia used during panning.
  37499. * 0 would mean stop inertia and one would mean no decelleration at all.
  37500. */
  37501. panningInertia: number;
  37502. /**
  37503. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37504. */
  37505. angularSensibilityX: number;
  37506. /**
  37507. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37508. */
  37509. angularSensibilityY: number;
  37510. /**
  37511. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37512. */
  37513. pinchPrecision: number;
  37514. /**
  37515. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37516. * It will be used instead of pinchDeltaPrecision if different from 0.
  37517. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37518. */
  37519. pinchDeltaPercentage: number;
  37520. /**
  37521. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37522. */
  37523. panningSensibility: number;
  37524. /**
  37525. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37526. */
  37527. keysUp: number[];
  37528. /**
  37529. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37530. */
  37531. keysDown: number[];
  37532. /**
  37533. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37534. */
  37535. keysLeft: number[];
  37536. /**
  37537. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37538. */
  37539. keysRight: number[];
  37540. /**
  37541. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37542. */
  37543. wheelPrecision: number;
  37544. /**
  37545. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37546. * It will be used instead of pinchDeltaPrecision if different from 0.
  37547. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37548. */
  37549. wheelDeltaPercentage: number;
  37550. /**
  37551. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37552. */
  37553. zoomOnFactor: number;
  37554. /**
  37555. * Defines a screen offset for the camera position.
  37556. */
  37557. targetScreenOffset: Vector2;
  37558. /**
  37559. * Allows the camera to be completely reversed.
  37560. * If false the camera can not arrive upside down.
  37561. */
  37562. allowUpsideDown: boolean;
  37563. /**
  37564. * Define if double tap/click is used to restore the previously saved state of the camera.
  37565. */
  37566. useInputToRestoreState: boolean;
  37567. /** @hidden */
  37568. _viewMatrix: Matrix;
  37569. /** @hidden */
  37570. _useCtrlForPanning: boolean;
  37571. /** @hidden */
  37572. _panningMouseButton: number;
  37573. /**
  37574. * Defines the input associated to the camera.
  37575. */
  37576. inputs: ArcRotateCameraInputsManager;
  37577. /** @hidden */
  37578. _reset: () => void;
  37579. /**
  37580. * Defines the allowed panning axis.
  37581. */
  37582. panningAxis: Vector3;
  37583. protected _localDirection: Vector3;
  37584. protected _transformedDirection: Vector3;
  37585. private _bouncingBehavior;
  37586. /**
  37587. * Gets the bouncing behavior of the camera if it has been enabled.
  37588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37589. */
  37590. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37591. /**
  37592. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37594. */
  37595. useBouncingBehavior: boolean;
  37596. private _framingBehavior;
  37597. /**
  37598. * Gets the framing behavior of the camera if it has been enabled.
  37599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37600. */
  37601. readonly framingBehavior: Nullable<FramingBehavior>;
  37602. /**
  37603. * Defines if the framing behavior of the camera is enabled on the camera.
  37604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37605. */
  37606. useFramingBehavior: boolean;
  37607. private _autoRotationBehavior;
  37608. /**
  37609. * Gets the auto rotation behavior of the camera if it has been enabled.
  37610. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37611. */
  37612. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37613. /**
  37614. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37615. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37616. */
  37617. useAutoRotationBehavior: boolean;
  37618. /**
  37619. * Observable triggered when the mesh target has been changed on the camera.
  37620. */
  37621. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37622. /**
  37623. * Event raised when the camera is colliding with a mesh.
  37624. */
  37625. onCollide: (collidedMesh: AbstractMesh) => void;
  37626. /**
  37627. * Defines whether the camera should check collision with the objects oh the scene.
  37628. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37629. */
  37630. checkCollisions: boolean;
  37631. /**
  37632. * Defines the collision radius of the camera.
  37633. * This simulates a sphere around the camera.
  37634. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37635. */
  37636. collisionRadius: Vector3;
  37637. protected _collider: Collider;
  37638. protected _previousPosition: Vector3;
  37639. protected _collisionVelocity: Vector3;
  37640. protected _newPosition: Vector3;
  37641. protected _previousAlpha: number;
  37642. protected _previousBeta: number;
  37643. protected _previousRadius: number;
  37644. protected _collisionTriggered: boolean;
  37645. protected _targetBoundingCenter: Nullable<Vector3>;
  37646. private _computationVector;
  37647. /**
  37648. * Instantiates a new ArcRotateCamera in a given scene
  37649. * @param name Defines the name of the camera
  37650. * @param alpha Defines the camera rotation along the logitudinal axis
  37651. * @param beta Defines the camera rotation along the latitudinal axis
  37652. * @param radius Defines the camera distance from its target
  37653. * @param target Defines the camera target
  37654. * @param scene Defines the scene the camera belongs to
  37655. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37656. */
  37657. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37658. /** @hidden */
  37659. _initCache(): void;
  37660. /** @hidden */
  37661. _updateCache(ignoreParentClass?: boolean): void;
  37662. protected _getTargetPosition(): Vector3;
  37663. private _storedAlpha;
  37664. private _storedBeta;
  37665. private _storedRadius;
  37666. private _storedTarget;
  37667. private _storedTargetScreenOffset;
  37668. /**
  37669. * Stores the current state of the camera (alpha, beta, radius and target)
  37670. * @returns the camera itself
  37671. */
  37672. storeState(): Camera;
  37673. /**
  37674. * @hidden
  37675. * Restored camera state. You must call storeState() first
  37676. */
  37677. _restoreStateValues(): boolean;
  37678. /** @hidden */
  37679. _isSynchronizedViewMatrix(): boolean;
  37680. /**
  37681. * Attached controls to the current camera.
  37682. * @param element Defines the element the controls should be listened from
  37683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37684. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37685. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37686. */
  37687. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37688. /**
  37689. * Detach the current controls from the camera.
  37690. * The camera will stop reacting to inputs.
  37691. * @param element Defines the element to stop listening the inputs from
  37692. */
  37693. detachControl(element: HTMLElement): void;
  37694. /** @hidden */
  37695. _checkInputs(): void;
  37696. protected _checkLimits(): void;
  37697. /**
  37698. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37699. */
  37700. rebuildAnglesAndRadius(): void;
  37701. /**
  37702. * Use a position to define the current camera related information like alpha, beta and radius
  37703. * @param position Defines the position to set the camera at
  37704. */
  37705. setPosition(position: Vector3): void;
  37706. /**
  37707. * Defines the target the camera should look at.
  37708. * This will automatically adapt alpha beta and radius to fit within the new target.
  37709. * @param target Defines the new target as a Vector or a mesh
  37710. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37711. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37712. */
  37713. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37714. /** @hidden */
  37715. _getViewMatrix(): Matrix;
  37716. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37717. /**
  37718. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37719. * @param meshes Defines the mesh to zoom on
  37720. * @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)
  37721. */
  37722. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37723. /**
  37724. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37725. * The target will be changed but the radius
  37726. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37727. * @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)
  37728. */
  37729. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37730. min: Vector3;
  37731. max: Vector3;
  37732. distance: number;
  37733. }, doNotUpdateMaxZ?: boolean): void;
  37734. /**
  37735. * @override
  37736. * Override Camera.createRigCamera
  37737. */
  37738. createRigCamera(name: string, cameraIndex: number): Camera;
  37739. /**
  37740. * @hidden
  37741. * @override
  37742. * Override Camera._updateRigCameras
  37743. */
  37744. _updateRigCameras(): void;
  37745. /**
  37746. * Destroy the camera and release the current resources hold by it.
  37747. */
  37748. dispose(): void;
  37749. /**
  37750. * Gets the current object class name.
  37751. * @return the class name
  37752. */
  37753. getClassName(): string;
  37754. }
  37755. }
  37756. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37757. import { Behavior } from "babylonjs/Behaviors/behavior";
  37758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37759. /**
  37760. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37762. */
  37763. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37764. /**
  37765. * Gets the name of the behavior.
  37766. */
  37767. readonly name: string;
  37768. private _zoomStopsAnimation;
  37769. private _idleRotationSpeed;
  37770. private _idleRotationWaitTime;
  37771. private _idleRotationSpinupTime;
  37772. /**
  37773. * Sets the flag that indicates if user zooming should stop animation.
  37774. */
  37775. /**
  37776. * Gets the flag that indicates if user zooming should stop animation.
  37777. */
  37778. zoomStopsAnimation: boolean;
  37779. /**
  37780. * Sets the default speed at which the camera rotates around the model.
  37781. */
  37782. /**
  37783. * Gets the default speed at which the camera rotates around the model.
  37784. */
  37785. idleRotationSpeed: number;
  37786. /**
  37787. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37788. */
  37789. /**
  37790. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37791. */
  37792. idleRotationWaitTime: number;
  37793. /**
  37794. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37795. */
  37796. /**
  37797. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37798. */
  37799. idleRotationSpinupTime: number;
  37800. /**
  37801. * Gets a value indicating if the camera is currently rotating because of this behavior
  37802. */
  37803. readonly rotationInProgress: boolean;
  37804. private _onPrePointerObservableObserver;
  37805. private _onAfterCheckInputsObserver;
  37806. private _attachedCamera;
  37807. private _isPointerDown;
  37808. private _lastFrameTime;
  37809. private _lastInteractionTime;
  37810. private _cameraRotationSpeed;
  37811. /**
  37812. * Initializes the behavior.
  37813. */
  37814. init(): void;
  37815. /**
  37816. * Attaches the behavior to its arc rotate camera.
  37817. * @param camera Defines the camera to attach the behavior to
  37818. */
  37819. attach(camera: ArcRotateCamera): void;
  37820. /**
  37821. * Detaches the behavior from its current arc rotate camera.
  37822. */
  37823. detach(): void;
  37824. /**
  37825. * Returns true if user is scrolling.
  37826. * @return true if user is scrolling.
  37827. */
  37828. private _userIsZooming;
  37829. private _lastFrameRadius;
  37830. private _shouldAnimationStopForInteraction;
  37831. /**
  37832. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37833. */
  37834. private _applyUserInteraction;
  37835. private _userIsMoving;
  37836. }
  37837. }
  37838. declare module "babylonjs/Behaviors/Cameras/index" {
  37839. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37840. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37841. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37842. }
  37843. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37844. import { Mesh } from "babylonjs/Meshes/mesh";
  37845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37846. import { Behavior } from "babylonjs/Behaviors/behavior";
  37847. /**
  37848. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37849. */
  37850. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37851. private ui;
  37852. /**
  37853. * The name of the behavior
  37854. */
  37855. name: string;
  37856. /**
  37857. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37858. */
  37859. distanceAwayFromFace: number;
  37860. /**
  37861. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37862. */
  37863. distanceAwayFromBottomOfFace: number;
  37864. private _faceVectors;
  37865. private _target;
  37866. private _scene;
  37867. private _onRenderObserver;
  37868. private _tmpMatrix;
  37869. private _tmpVector;
  37870. /**
  37871. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37872. * @param ui The transform node that should be attched to the mesh
  37873. */
  37874. constructor(ui: TransformNode);
  37875. /**
  37876. * Initializes the behavior
  37877. */
  37878. init(): void;
  37879. private _closestFace;
  37880. private _zeroVector;
  37881. private _lookAtTmpMatrix;
  37882. private _lookAtToRef;
  37883. /**
  37884. * Attaches the AttachToBoxBehavior to the passed in mesh
  37885. * @param target The mesh that the specified node will be attached to
  37886. */
  37887. attach(target: Mesh): void;
  37888. /**
  37889. * Detaches the behavior from the mesh
  37890. */
  37891. detach(): void;
  37892. }
  37893. }
  37894. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37895. import { Behavior } from "babylonjs/Behaviors/behavior";
  37896. import { Mesh } from "babylonjs/Meshes/mesh";
  37897. /**
  37898. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37899. */
  37900. export class FadeInOutBehavior implements Behavior<Mesh> {
  37901. /**
  37902. * Time in milliseconds to delay before fading in (Default: 0)
  37903. */
  37904. delay: number;
  37905. /**
  37906. * Time in milliseconds for the mesh to fade in (Default: 300)
  37907. */
  37908. fadeInTime: number;
  37909. private _millisecondsPerFrame;
  37910. private _hovered;
  37911. private _hoverValue;
  37912. private _ownerNode;
  37913. /**
  37914. * Instatiates the FadeInOutBehavior
  37915. */
  37916. constructor();
  37917. /**
  37918. * The name of the behavior
  37919. */
  37920. readonly name: string;
  37921. /**
  37922. * Initializes the behavior
  37923. */
  37924. init(): void;
  37925. /**
  37926. * Attaches the fade behavior on the passed in mesh
  37927. * @param ownerNode The mesh that will be faded in/out once attached
  37928. */
  37929. attach(ownerNode: Mesh): void;
  37930. /**
  37931. * Detaches the behavior from the mesh
  37932. */
  37933. detach(): void;
  37934. /**
  37935. * Triggers the mesh to begin fading in or out
  37936. * @param value if the object should fade in or out (true to fade in)
  37937. */
  37938. fadeIn(value: boolean): void;
  37939. private _update;
  37940. private _setAllVisibility;
  37941. }
  37942. }
  37943. declare module "babylonjs/Misc/pivotTools" {
  37944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37945. /**
  37946. * Class containing a set of static utilities functions for managing Pivots
  37947. * @hidden
  37948. */
  37949. export class PivotTools {
  37950. private static _PivotCached;
  37951. private static _OldPivotPoint;
  37952. private static _PivotTranslation;
  37953. private static _PivotTmpVector;
  37954. /** @hidden */
  37955. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37956. /** @hidden */
  37957. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37958. }
  37959. }
  37960. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37961. import { Scene } from "babylonjs/scene";
  37962. import { Vector4 } from "babylonjs/Maths/math.vector";
  37963. import { Mesh } from "babylonjs/Meshes/mesh";
  37964. import { Nullable } from "babylonjs/types";
  37965. import { Plane } from "babylonjs/Maths/math.plane";
  37966. /**
  37967. * Class containing static functions to help procedurally build meshes
  37968. */
  37969. export class PlaneBuilder {
  37970. /**
  37971. * Creates a plane mesh
  37972. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37973. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37974. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37978. * @param name defines the name of the mesh
  37979. * @param options defines the options used to create the mesh
  37980. * @param scene defines the hosting scene
  37981. * @returns the plane mesh
  37982. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37983. */
  37984. static CreatePlane(name: string, options: {
  37985. size?: number;
  37986. width?: number;
  37987. height?: number;
  37988. sideOrientation?: number;
  37989. frontUVs?: Vector4;
  37990. backUVs?: Vector4;
  37991. updatable?: boolean;
  37992. sourcePlane?: Plane;
  37993. }, scene?: Nullable<Scene>): Mesh;
  37994. }
  37995. }
  37996. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37997. import { Behavior } from "babylonjs/Behaviors/behavior";
  37998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37999. import { Observable } from "babylonjs/Misc/observable";
  38000. import { Vector3 } from "babylonjs/Maths/math.vector";
  38001. import { Ray } from "babylonjs/Culling/ray";
  38002. import "babylonjs/Meshes/Builders/planeBuilder";
  38003. /**
  38004. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38005. */
  38006. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38007. private static _AnyMouseID;
  38008. /**
  38009. * Abstract mesh the behavior is set on
  38010. */
  38011. attachedNode: AbstractMesh;
  38012. private _dragPlane;
  38013. private _scene;
  38014. private _pointerObserver;
  38015. private _beforeRenderObserver;
  38016. private static _planeScene;
  38017. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38018. /**
  38019. * 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)
  38020. */
  38021. maxDragAngle: number;
  38022. /**
  38023. * @hidden
  38024. */
  38025. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38026. /**
  38027. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38028. */
  38029. currentDraggingPointerID: number;
  38030. /**
  38031. * The last position where the pointer hit the drag plane in world space
  38032. */
  38033. lastDragPosition: Vector3;
  38034. /**
  38035. * If the behavior is currently in a dragging state
  38036. */
  38037. dragging: boolean;
  38038. /**
  38039. * 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)
  38040. */
  38041. dragDeltaRatio: number;
  38042. /**
  38043. * If the drag plane orientation should be updated during the dragging (Default: true)
  38044. */
  38045. updateDragPlane: boolean;
  38046. private _debugMode;
  38047. private _moving;
  38048. /**
  38049. * Fires each time the attached mesh is dragged with the pointer
  38050. * * delta between last drag position and current drag position in world space
  38051. * * dragDistance along the drag axis
  38052. * * dragPlaneNormal normal of the current drag plane used during the drag
  38053. * * dragPlanePoint in world space where the drag intersects the drag plane
  38054. */
  38055. onDragObservable: Observable<{
  38056. delta: Vector3;
  38057. dragPlanePoint: Vector3;
  38058. dragPlaneNormal: Vector3;
  38059. dragDistance: number;
  38060. pointerId: number;
  38061. }>;
  38062. /**
  38063. * Fires each time a drag begins (eg. mouse down on mesh)
  38064. */
  38065. onDragStartObservable: Observable<{
  38066. dragPlanePoint: Vector3;
  38067. pointerId: number;
  38068. }>;
  38069. /**
  38070. * Fires each time a drag ends (eg. mouse release after drag)
  38071. */
  38072. onDragEndObservable: Observable<{
  38073. dragPlanePoint: Vector3;
  38074. pointerId: number;
  38075. }>;
  38076. /**
  38077. * If the attached mesh should be moved when dragged
  38078. */
  38079. moveAttached: boolean;
  38080. /**
  38081. * If the drag behavior will react to drag events (Default: true)
  38082. */
  38083. enabled: boolean;
  38084. /**
  38085. * If pointer events should start and release the drag (Default: true)
  38086. */
  38087. startAndReleaseDragOnPointerEvents: boolean;
  38088. /**
  38089. * If camera controls should be detached during the drag
  38090. */
  38091. detachCameraControls: boolean;
  38092. /**
  38093. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38094. */
  38095. useObjectOrienationForDragging: boolean;
  38096. private _options;
  38097. /**
  38098. * Creates a pointer drag behavior that can be attached to a mesh
  38099. * @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)
  38100. */
  38101. constructor(options?: {
  38102. dragAxis?: Vector3;
  38103. dragPlaneNormal?: Vector3;
  38104. });
  38105. /**
  38106. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38107. */
  38108. validateDrag: (targetPosition: Vector3) => boolean;
  38109. /**
  38110. * The name of the behavior
  38111. */
  38112. readonly name: string;
  38113. /**
  38114. * Initializes the behavior
  38115. */
  38116. init(): void;
  38117. private _tmpVector;
  38118. private _alternatePickedPoint;
  38119. private _worldDragAxis;
  38120. private _targetPosition;
  38121. private _attachedElement;
  38122. /**
  38123. * Attaches the drag behavior the passed in mesh
  38124. * @param ownerNode The mesh that will be dragged around once attached
  38125. * @param predicate Predicate to use for pick filtering
  38126. */
  38127. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38128. /**
  38129. * Force relase the drag action by code.
  38130. */
  38131. releaseDrag(): void;
  38132. private _startDragRay;
  38133. private _lastPointerRay;
  38134. /**
  38135. * Simulates the start of a pointer drag event on the behavior
  38136. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38137. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38138. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38139. */
  38140. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38141. private _startDrag;
  38142. private _dragDelta;
  38143. private _moveDrag;
  38144. private _pickWithRayOnDragPlane;
  38145. private _pointA;
  38146. private _pointB;
  38147. private _pointC;
  38148. private _lineA;
  38149. private _lineB;
  38150. private _localAxis;
  38151. private _lookAt;
  38152. private _updateDragPlanePosition;
  38153. /**
  38154. * Detaches the behavior from the mesh
  38155. */
  38156. detach(): void;
  38157. }
  38158. }
  38159. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38160. import { Mesh } from "babylonjs/Meshes/mesh";
  38161. import { Behavior } from "babylonjs/Behaviors/behavior";
  38162. /**
  38163. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38164. */
  38165. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38166. private _dragBehaviorA;
  38167. private _dragBehaviorB;
  38168. private _startDistance;
  38169. private _initialScale;
  38170. private _targetScale;
  38171. private _ownerNode;
  38172. private _sceneRenderObserver;
  38173. /**
  38174. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38175. */
  38176. constructor();
  38177. /**
  38178. * The name of the behavior
  38179. */
  38180. readonly name: string;
  38181. /**
  38182. * Initializes the behavior
  38183. */
  38184. init(): void;
  38185. private _getCurrentDistance;
  38186. /**
  38187. * Attaches the scale behavior the passed in mesh
  38188. * @param ownerNode The mesh that will be scaled around once attached
  38189. */
  38190. attach(ownerNode: Mesh): void;
  38191. /**
  38192. * Detaches the behavior from the mesh
  38193. */
  38194. detach(): void;
  38195. }
  38196. }
  38197. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38198. import { Behavior } from "babylonjs/Behaviors/behavior";
  38199. import { Mesh } from "babylonjs/Meshes/mesh";
  38200. import { Observable } from "babylonjs/Misc/observable";
  38201. /**
  38202. * 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
  38203. */
  38204. export class SixDofDragBehavior implements Behavior<Mesh> {
  38205. private static _virtualScene;
  38206. private _ownerNode;
  38207. private _sceneRenderObserver;
  38208. private _scene;
  38209. private _targetPosition;
  38210. private _virtualOriginMesh;
  38211. private _virtualDragMesh;
  38212. private _pointerObserver;
  38213. private _moving;
  38214. private _startingOrientation;
  38215. /**
  38216. * 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)
  38217. */
  38218. private zDragFactor;
  38219. /**
  38220. * If the object should rotate to face the drag origin
  38221. */
  38222. rotateDraggedObject: boolean;
  38223. /**
  38224. * If the behavior is currently in a dragging state
  38225. */
  38226. dragging: boolean;
  38227. /**
  38228. * 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)
  38229. */
  38230. dragDeltaRatio: number;
  38231. /**
  38232. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38233. */
  38234. currentDraggingPointerID: number;
  38235. /**
  38236. * If camera controls should be detached during the drag
  38237. */
  38238. detachCameraControls: boolean;
  38239. /**
  38240. * Fires each time a drag starts
  38241. */
  38242. onDragStartObservable: Observable<{}>;
  38243. /**
  38244. * Fires each time a drag ends (eg. mouse release after drag)
  38245. */
  38246. onDragEndObservable: Observable<{}>;
  38247. /**
  38248. * 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
  38249. */
  38250. constructor();
  38251. /**
  38252. * The name of the behavior
  38253. */
  38254. readonly name: string;
  38255. /**
  38256. * Initializes the behavior
  38257. */
  38258. init(): void;
  38259. /**
  38260. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38261. */
  38262. private readonly _pointerCamera;
  38263. /**
  38264. * Attaches the scale behavior the passed in mesh
  38265. * @param ownerNode The mesh that will be scaled around once attached
  38266. */
  38267. attach(ownerNode: Mesh): void;
  38268. /**
  38269. * Detaches the behavior from the mesh
  38270. */
  38271. detach(): void;
  38272. }
  38273. }
  38274. declare module "babylonjs/Behaviors/Meshes/index" {
  38275. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38276. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38277. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38278. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38279. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38280. }
  38281. declare module "babylonjs/Behaviors/index" {
  38282. export * from "babylonjs/Behaviors/behavior";
  38283. export * from "babylonjs/Behaviors/Cameras/index";
  38284. export * from "babylonjs/Behaviors/Meshes/index";
  38285. }
  38286. declare module "babylonjs/Bones/boneIKController" {
  38287. import { Bone } from "babylonjs/Bones/bone";
  38288. import { Vector3 } from "babylonjs/Maths/math.vector";
  38289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38290. import { Nullable } from "babylonjs/types";
  38291. /**
  38292. * Class used to apply inverse kinematics to bones
  38293. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38294. */
  38295. export class BoneIKController {
  38296. private static _tmpVecs;
  38297. private static _tmpQuat;
  38298. private static _tmpMats;
  38299. /**
  38300. * Gets or sets the target mesh
  38301. */
  38302. targetMesh: AbstractMesh;
  38303. /** Gets or sets the mesh used as pole */
  38304. poleTargetMesh: AbstractMesh;
  38305. /**
  38306. * Gets or sets the bone used as pole
  38307. */
  38308. poleTargetBone: Nullable<Bone>;
  38309. /**
  38310. * Gets or sets the target position
  38311. */
  38312. targetPosition: Vector3;
  38313. /**
  38314. * Gets or sets the pole target position
  38315. */
  38316. poleTargetPosition: Vector3;
  38317. /**
  38318. * Gets or sets the pole target local offset
  38319. */
  38320. poleTargetLocalOffset: Vector3;
  38321. /**
  38322. * Gets or sets the pole angle
  38323. */
  38324. poleAngle: number;
  38325. /**
  38326. * Gets or sets the mesh associated with the controller
  38327. */
  38328. mesh: AbstractMesh;
  38329. /**
  38330. * 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)
  38331. */
  38332. slerpAmount: number;
  38333. private _bone1Quat;
  38334. private _bone1Mat;
  38335. private _bone2Ang;
  38336. private _bone1;
  38337. private _bone2;
  38338. private _bone1Length;
  38339. private _bone2Length;
  38340. private _maxAngle;
  38341. private _maxReach;
  38342. private _rightHandedSystem;
  38343. private _bendAxis;
  38344. private _slerping;
  38345. private _adjustRoll;
  38346. /**
  38347. * Gets or sets maximum allowed angle
  38348. */
  38349. maxAngle: number;
  38350. /**
  38351. * Creates a new BoneIKController
  38352. * @param mesh defines the mesh to control
  38353. * @param bone defines the bone to control
  38354. * @param options defines options to set up the controller
  38355. */
  38356. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38357. targetMesh?: AbstractMesh;
  38358. poleTargetMesh?: AbstractMesh;
  38359. poleTargetBone?: Bone;
  38360. poleTargetLocalOffset?: Vector3;
  38361. poleAngle?: number;
  38362. bendAxis?: Vector3;
  38363. maxAngle?: number;
  38364. slerpAmount?: number;
  38365. });
  38366. private _setMaxAngle;
  38367. /**
  38368. * Force the controller to update the bones
  38369. */
  38370. update(): void;
  38371. }
  38372. }
  38373. declare module "babylonjs/Bones/boneLookController" {
  38374. import { Vector3 } from "babylonjs/Maths/math.vector";
  38375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38376. import { Bone } from "babylonjs/Bones/bone";
  38377. import { Space } from "babylonjs/Maths/math.axis";
  38378. /**
  38379. * Class used to make a bone look toward a point in space
  38380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38381. */
  38382. export class BoneLookController {
  38383. private static _tmpVecs;
  38384. private static _tmpQuat;
  38385. private static _tmpMats;
  38386. /**
  38387. * The target Vector3 that the bone will look at
  38388. */
  38389. target: Vector3;
  38390. /**
  38391. * The mesh that the bone is attached to
  38392. */
  38393. mesh: AbstractMesh;
  38394. /**
  38395. * The bone that will be looking to the target
  38396. */
  38397. bone: Bone;
  38398. /**
  38399. * The up axis of the coordinate system that is used when the bone is rotated
  38400. */
  38401. upAxis: Vector3;
  38402. /**
  38403. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38404. */
  38405. upAxisSpace: Space;
  38406. /**
  38407. * Used to make an adjustment to the yaw of the bone
  38408. */
  38409. adjustYaw: number;
  38410. /**
  38411. * Used to make an adjustment to the pitch of the bone
  38412. */
  38413. adjustPitch: number;
  38414. /**
  38415. * Used to make an adjustment to the roll of the bone
  38416. */
  38417. adjustRoll: number;
  38418. /**
  38419. * 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)
  38420. */
  38421. slerpAmount: number;
  38422. private _minYaw;
  38423. private _maxYaw;
  38424. private _minPitch;
  38425. private _maxPitch;
  38426. private _minYawSin;
  38427. private _minYawCos;
  38428. private _maxYawSin;
  38429. private _maxYawCos;
  38430. private _midYawConstraint;
  38431. private _minPitchTan;
  38432. private _maxPitchTan;
  38433. private _boneQuat;
  38434. private _slerping;
  38435. private _transformYawPitch;
  38436. private _transformYawPitchInv;
  38437. private _firstFrameSkipped;
  38438. private _yawRange;
  38439. private _fowardAxis;
  38440. /**
  38441. * Gets or sets the minimum yaw angle that the bone can look to
  38442. */
  38443. minYaw: number;
  38444. /**
  38445. * Gets or sets the maximum yaw angle that the bone can look to
  38446. */
  38447. maxYaw: number;
  38448. /**
  38449. * Gets or sets the minimum pitch angle that the bone can look to
  38450. */
  38451. minPitch: number;
  38452. /**
  38453. * Gets or sets the maximum pitch angle that the bone can look to
  38454. */
  38455. maxPitch: number;
  38456. /**
  38457. * Create a BoneLookController
  38458. * @param mesh the mesh that the bone belongs to
  38459. * @param bone the bone that will be looking to the target
  38460. * @param target the target Vector3 to look at
  38461. * @param options optional settings:
  38462. * * maxYaw: the maximum angle the bone will yaw to
  38463. * * minYaw: the minimum angle the bone will yaw to
  38464. * * maxPitch: the maximum angle the bone will pitch to
  38465. * * minPitch: the minimum angle the bone will yaw to
  38466. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38467. * * upAxis: the up axis of the coordinate system
  38468. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38469. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38470. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38471. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38472. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38473. * * adjustRoll: used to make an adjustment to the roll of the bone
  38474. **/
  38475. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38476. maxYaw?: number;
  38477. minYaw?: number;
  38478. maxPitch?: number;
  38479. minPitch?: number;
  38480. slerpAmount?: number;
  38481. upAxis?: Vector3;
  38482. upAxisSpace?: Space;
  38483. yawAxis?: Vector3;
  38484. pitchAxis?: Vector3;
  38485. adjustYaw?: number;
  38486. adjustPitch?: number;
  38487. adjustRoll?: number;
  38488. });
  38489. /**
  38490. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38491. */
  38492. update(): void;
  38493. private _getAngleDiff;
  38494. private _getAngleBetween;
  38495. private _isAngleBetween;
  38496. }
  38497. }
  38498. declare module "babylonjs/Bones/index" {
  38499. export * from "babylonjs/Bones/bone";
  38500. export * from "babylonjs/Bones/boneIKController";
  38501. export * from "babylonjs/Bones/boneLookController";
  38502. export * from "babylonjs/Bones/skeleton";
  38503. }
  38504. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38505. import { Nullable } from "babylonjs/types";
  38506. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38508. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38509. /**
  38510. * Manage the gamepad inputs to control an arc rotate camera.
  38511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38512. */
  38513. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38514. /**
  38515. * Defines the camera the input is attached to.
  38516. */
  38517. camera: ArcRotateCamera;
  38518. /**
  38519. * Defines the gamepad the input is gathering event from.
  38520. */
  38521. gamepad: Nullable<Gamepad>;
  38522. /**
  38523. * Defines the gamepad rotation sensiblity.
  38524. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38525. */
  38526. gamepadRotationSensibility: number;
  38527. /**
  38528. * Defines the gamepad move sensiblity.
  38529. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38530. */
  38531. gamepadMoveSensibility: number;
  38532. private _yAxisScale;
  38533. /**
  38534. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38535. */
  38536. invertYAxis: boolean;
  38537. private _onGamepadConnectedObserver;
  38538. private _onGamepadDisconnectedObserver;
  38539. /**
  38540. * Attach the input controls to a specific dom element to get the input from.
  38541. * @param element Defines the element the controls should be listened from
  38542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38543. */
  38544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38545. /**
  38546. * Detach the current controls from the specified dom element.
  38547. * @param element Defines the element to stop listening the inputs from
  38548. */
  38549. detachControl(element: Nullable<HTMLElement>): void;
  38550. /**
  38551. * Update the current camera state depending on the inputs that have been used this frame.
  38552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38553. */
  38554. checkInputs(): void;
  38555. /**
  38556. * Gets the class name of the current intput.
  38557. * @returns the class name
  38558. */
  38559. getClassName(): string;
  38560. /**
  38561. * Get the friendly name associated with the input class.
  38562. * @returns the input friendly name
  38563. */
  38564. getSimpleName(): string;
  38565. }
  38566. }
  38567. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38568. import { Nullable } from "babylonjs/types";
  38569. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38571. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38572. interface ArcRotateCameraInputsManager {
  38573. /**
  38574. * Add orientation input support to the input manager.
  38575. * @returns the current input manager
  38576. */
  38577. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38578. }
  38579. }
  38580. /**
  38581. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38583. */
  38584. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38585. /**
  38586. * Defines the camera the input is attached to.
  38587. */
  38588. camera: ArcRotateCamera;
  38589. /**
  38590. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38591. */
  38592. alphaCorrection: number;
  38593. /**
  38594. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38595. */
  38596. gammaCorrection: number;
  38597. private _alpha;
  38598. private _gamma;
  38599. private _dirty;
  38600. private _deviceOrientationHandler;
  38601. /**
  38602. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38603. */
  38604. constructor();
  38605. /**
  38606. * Attach the input controls to a specific dom element to get the input from.
  38607. * @param element Defines the element the controls should be listened from
  38608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38609. */
  38610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38611. /** @hidden */
  38612. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38613. /**
  38614. * Update the current camera state depending on the inputs that have been used this frame.
  38615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38616. */
  38617. checkInputs(): void;
  38618. /**
  38619. * Detach the current controls from the specified dom element.
  38620. * @param element Defines the element to stop listening the inputs from
  38621. */
  38622. detachControl(element: Nullable<HTMLElement>): void;
  38623. /**
  38624. * Gets the class name of the current intput.
  38625. * @returns the class name
  38626. */
  38627. getClassName(): string;
  38628. /**
  38629. * Get the friendly name associated with the input class.
  38630. * @returns the input friendly name
  38631. */
  38632. getSimpleName(): string;
  38633. }
  38634. }
  38635. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38636. import { Nullable } from "babylonjs/types";
  38637. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38638. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38639. /**
  38640. * Listen to mouse events to control the camera.
  38641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38642. */
  38643. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38644. /**
  38645. * Defines the camera the input is attached to.
  38646. */
  38647. camera: FlyCamera;
  38648. /**
  38649. * Defines if touch is enabled. (Default is true.)
  38650. */
  38651. touchEnabled: boolean;
  38652. /**
  38653. * Defines the buttons associated with the input to handle camera rotation.
  38654. */
  38655. buttons: number[];
  38656. /**
  38657. * Assign buttons for Yaw control.
  38658. */
  38659. buttonsYaw: number[];
  38660. /**
  38661. * Assign buttons for Pitch control.
  38662. */
  38663. buttonsPitch: number[];
  38664. /**
  38665. * Assign buttons for Roll control.
  38666. */
  38667. buttonsRoll: number[];
  38668. /**
  38669. * Detect if any button is being pressed while mouse is moved.
  38670. * -1 = Mouse locked.
  38671. * 0 = Left button.
  38672. * 1 = Middle Button.
  38673. * 2 = Right Button.
  38674. */
  38675. activeButton: number;
  38676. /**
  38677. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38678. * Higher values reduce its sensitivity.
  38679. */
  38680. angularSensibility: number;
  38681. private _mousemoveCallback;
  38682. private _observer;
  38683. private _rollObserver;
  38684. private previousPosition;
  38685. private noPreventDefault;
  38686. private element;
  38687. /**
  38688. * Listen to mouse events to control the camera.
  38689. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. constructor(touchEnabled?: boolean);
  38693. /**
  38694. * Attach the mouse control to the HTML DOM element.
  38695. * @param element Defines the element that listens to the input events.
  38696. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38697. */
  38698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38699. /**
  38700. * Detach the current controls from the specified dom element.
  38701. * @param element Defines the element to stop listening the inputs from
  38702. */
  38703. detachControl(element: Nullable<HTMLElement>): void;
  38704. /**
  38705. * Gets the class name of the current input.
  38706. * @returns the class name.
  38707. */
  38708. getClassName(): string;
  38709. /**
  38710. * Get the friendly name associated with the input class.
  38711. * @returns the input's friendly name.
  38712. */
  38713. getSimpleName(): string;
  38714. private _pointerInput;
  38715. private _onMouseMove;
  38716. /**
  38717. * Rotate camera by mouse offset.
  38718. */
  38719. private rotateCamera;
  38720. }
  38721. }
  38722. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38723. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38724. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38725. /**
  38726. * Default Inputs manager for the FlyCamera.
  38727. * It groups all the default supported inputs for ease of use.
  38728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38729. */
  38730. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38731. /**
  38732. * Instantiates a new FlyCameraInputsManager.
  38733. * @param camera Defines the camera the inputs belong to.
  38734. */
  38735. constructor(camera: FlyCamera);
  38736. /**
  38737. * Add keyboard input support to the input manager.
  38738. * @returns the new FlyCameraKeyboardMoveInput().
  38739. */
  38740. addKeyboard(): FlyCameraInputsManager;
  38741. /**
  38742. * Add mouse input support to the input manager.
  38743. * @param touchEnabled Enable touch screen support.
  38744. * @returns the new FlyCameraMouseInput().
  38745. */
  38746. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38747. }
  38748. }
  38749. declare module "babylonjs/Cameras/flyCamera" {
  38750. import { Scene } from "babylonjs/scene";
  38751. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38753. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38754. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38755. /**
  38756. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38757. * such as in a 3D Space Shooter or a Flight Simulator.
  38758. */
  38759. export class FlyCamera extends TargetCamera {
  38760. /**
  38761. * Define the collision ellipsoid of the camera.
  38762. * This is helpful for simulating a camera body, like a player's body.
  38763. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38764. */
  38765. ellipsoid: Vector3;
  38766. /**
  38767. * Define an offset for the position of the ellipsoid around the camera.
  38768. * This can be helpful if the camera is attached away from the player's body center,
  38769. * such as at its head.
  38770. */
  38771. ellipsoidOffset: Vector3;
  38772. /**
  38773. * Enable or disable collisions of the camera with the rest of the scene objects.
  38774. */
  38775. checkCollisions: boolean;
  38776. /**
  38777. * Enable or disable gravity on the camera.
  38778. */
  38779. applyGravity: boolean;
  38780. /**
  38781. * Define the current direction the camera is moving to.
  38782. */
  38783. cameraDirection: Vector3;
  38784. /**
  38785. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38786. * This overrides and empties cameraRotation.
  38787. */
  38788. rotationQuaternion: Quaternion;
  38789. /**
  38790. * Track Roll to maintain the wanted Rolling when looking around.
  38791. */
  38792. _trackRoll: number;
  38793. /**
  38794. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38795. */
  38796. rollCorrect: number;
  38797. /**
  38798. * Mimic a banked turn, Rolling the camera when Yawing.
  38799. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38800. */
  38801. bankedTurn: boolean;
  38802. /**
  38803. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38804. */
  38805. bankedTurnLimit: number;
  38806. /**
  38807. * Value of 0 disables the banked Roll.
  38808. * Value of 1 is equal to the Yaw angle in radians.
  38809. */
  38810. bankedTurnMultiplier: number;
  38811. /**
  38812. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38813. */
  38814. inputs: FlyCameraInputsManager;
  38815. /**
  38816. * Gets the input sensibility for mouse input.
  38817. * Higher values reduce sensitivity.
  38818. */
  38819. /**
  38820. * Sets the input sensibility for a mouse input.
  38821. * Higher values reduce sensitivity.
  38822. */
  38823. angularSensibility: number;
  38824. /**
  38825. * Get the keys for camera movement forward.
  38826. */
  38827. /**
  38828. * Set the keys for camera movement forward.
  38829. */
  38830. keysForward: number[];
  38831. /**
  38832. * Get the keys for camera movement backward.
  38833. */
  38834. keysBackward: number[];
  38835. /**
  38836. * Get the keys for camera movement up.
  38837. */
  38838. /**
  38839. * Set the keys for camera movement up.
  38840. */
  38841. keysUp: number[];
  38842. /**
  38843. * Get the keys for camera movement down.
  38844. */
  38845. /**
  38846. * Set the keys for camera movement down.
  38847. */
  38848. keysDown: number[];
  38849. /**
  38850. * Get the keys for camera movement left.
  38851. */
  38852. /**
  38853. * Set the keys for camera movement left.
  38854. */
  38855. keysLeft: number[];
  38856. /**
  38857. * Set the keys for camera movement right.
  38858. */
  38859. /**
  38860. * Set the keys for camera movement right.
  38861. */
  38862. keysRight: number[];
  38863. /**
  38864. * Event raised when the camera collides with a mesh in the scene.
  38865. */
  38866. onCollide: (collidedMesh: AbstractMesh) => void;
  38867. private _collider;
  38868. private _needMoveForGravity;
  38869. private _oldPosition;
  38870. private _diffPosition;
  38871. private _newPosition;
  38872. /** @hidden */
  38873. _localDirection: Vector3;
  38874. /** @hidden */
  38875. _transformedDirection: Vector3;
  38876. /**
  38877. * Instantiates a FlyCamera.
  38878. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38879. * such as in a 3D Space Shooter or a Flight Simulator.
  38880. * @param name Define the name of the camera in the scene.
  38881. * @param position Define the starting position of the camera in the scene.
  38882. * @param scene Define the scene the camera belongs to.
  38883. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38884. */
  38885. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38886. /**
  38887. * Attach a control to the HTML DOM element.
  38888. * @param element Defines the element that listens to the input events.
  38889. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38890. */
  38891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38892. /**
  38893. * Detach a control from the HTML DOM element.
  38894. * The camera will stop reacting to that input.
  38895. * @param element Defines the element that listens to the input events.
  38896. */
  38897. detachControl(element: HTMLElement): void;
  38898. private _collisionMask;
  38899. /**
  38900. * Get the mask that the camera ignores in collision events.
  38901. */
  38902. /**
  38903. * Set the mask that the camera ignores in collision events.
  38904. */
  38905. collisionMask: number;
  38906. /** @hidden */
  38907. _collideWithWorld(displacement: Vector3): void;
  38908. /** @hidden */
  38909. private _onCollisionPositionChange;
  38910. /** @hidden */
  38911. _checkInputs(): void;
  38912. /** @hidden */
  38913. _decideIfNeedsToMove(): boolean;
  38914. /** @hidden */
  38915. _updatePosition(): void;
  38916. /**
  38917. * Restore the Roll to its target value at the rate specified.
  38918. * @param rate - Higher means slower restoring.
  38919. * @hidden
  38920. */
  38921. restoreRoll(rate: number): void;
  38922. /**
  38923. * Destroy the camera and release the current resources held by it.
  38924. */
  38925. dispose(): void;
  38926. /**
  38927. * Get the current object class name.
  38928. * @returns the class name.
  38929. */
  38930. getClassName(): string;
  38931. }
  38932. }
  38933. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38934. import { Nullable } from "babylonjs/types";
  38935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38936. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38937. /**
  38938. * Listen to keyboard events to control the camera.
  38939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38940. */
  38941. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38942. /**
  38943. * Defines the camera the input is attached to.
  38944. */
  38945. camera: FlyCamera;
  38946. /**
  38947. * The list of keyboard keys used to control the forward move of the camera.
  38948. */
  38949. keysForward: number[];
  38950. /**
  38951. * The list of keyboard keys used to control the backward move of the camera.
  38952. */
  38953. keysBackward: number[];
  38954. /**
  38955. * The list of keyboard keys used to control the forward move of the camera.
  38956. */
  38957. keysUp: number[];
  38958. /**
  38959. * The list of keyboard keys used to control the backward move of the camera.
  38960. */
  38961. keysDown: number[];
  38962. /**
  38963. * The list of keyboard keys used to control the right strafe move of the camera.
  38964. */
  38965. keysRight: number[];
  38966. /**
  38967. * The list of keyboard keys used to control the left strafe move of the camera.
  38968. */
  38969. keysLeft: number[];
  38970. private _keys;
  38971. private _onCanvasBlurObserver;
  38972. private _onKeyboardObserver;
  38973. private _engine;
  38974. private _scene;
  38975. /**
  38976. * Attach the input controls to a specific dom element to get the input from.
  38977. * @param element Defines the element the controls should be listened from
  38978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38979. */
  38980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38981. /**
  38982. * Detach the current controls from the specified dom element.
  38983. * @param element Defines the element to stop listening the inputs from
  38984. */
  38985. detachControl(element: Nullable<HTMLElement>): void;
  38986. /**
  38987. * Gets the class name of the current intput.
  38988. * @returns the class name
  38989. */
  38990. getClassName(): string;
  38991. /** @hidden */
  38992. _onLostFocus(e: FocusEvent): void;
  38993. /**
  38994. * Get the friendly name associated with the input class.
  38995. * @returns the input friendly name
  38996. */
  38997. getSimpleName(): string;
  38998. /**
  38999. * Update the current camera state depending on the inputs that have been used this frame.
  39000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39001. */
  39002. checkInputs(): void;
  39003. }
  39004. }
  39005. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39006. import { Nullable } from "babylonjs/types";
  39007. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39008. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39009. /**
  39010. * Manage the mouse wheel inputs to control a follow camera.
  39011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39012. */
  39013. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39014. /**
  39015. * Defines the camera the input is attached to.
  39016. */
  39017. camera: FollowCamera;
  39018. /**
  39019. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39020. */
  39021. axisControlRadius: boolean;
  39022. /**
  39023. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39024. */
  39025. axisControlHeight: boolean;
  39026. /**
  39027. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39028. */
  39029. axisControlRotation: boolean;
  39030. /**
  39031. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39032. * relation to mouseWheel events.
  39033. */
  39034. wheelPrecision: number;
  39035. /**
  39036. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39037. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39038. */
  39039. wheelDeltaPercentage: number;
  39040. private _wheel;
  39041. private _observer;
  39042. /**
  39043. * Attach the input controls to a specific dom element to get the input from.
  39044. * @param element Defines the element the controls should be listened from
  39045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39046. */
  39047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39048. /**
  39049. * Detach the current controls from the specified dom element.
  39050. * @param element Defines the element to stop listening the inputs from
  39051. */
  39052. detachControl(element: Nullable<HTMLElement>): void;
  39053. /**
  39054. * Gets the class name of the current intput.
  39055. * @returns the class name
  39056. */
  39057. getClassName(): string;
  39058. /**
  39059. * Get the friendly name associated with the input class.
  39060. * @returns the input friendly name
  39061. */
  39062. getSimpleName(): string;
  39063. }
  39064. }
  39065. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39066. import { Nullable } from "babylonjs/types";
  39067. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39068. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39069. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39070. /**
  39071. * Manage the pointers inputs to control an follow camera.
  39072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39073. */
  39074. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39075. /**
  39076. * Defines the camera the input is attached to.
  39077. */
  39078. camera: FollowCamera;
  39079. /**
  39080. * Gets the class name of the current input.
  39081. * @returns the class name
  39082. */
  39083. getClassName(): string;
  39084. /**
  39085. * Defines the pointer angular sensibility along the X axis or how fast is
  39086. * the camera rotating.
  39087. * A negative number will reverse the axis direction.
  39088. */
  39089. angularSensibilityX: number;
  39090. /**
  39091. * Defines the pointer angular sensibility along the Y axis or how fast is
  39092. * the camera rotating.
  39093. * A negative number will reverse the axis direction.
  39094. */
  39095. angularSensibilityY: number;
  39096. /**
  39097. * Defines the pointer pinch precision or how fast is the camera zooming.
  39098. * A negative number will reverse the axis direction.
  39099. */
  39100. pinchPrecision: number;
  39101. /**
  39102. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39103. * from 0.
  39104. * It defines the percentage of current camera.radius to use as delta when
  39105. * pinch zoom is used.
  39106. */
  39107. pinchDeltaPercentage: number;
  39108. /**
  39109. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39110. */
  39111. axisXControlRadius: boolean;
  39112. /**
  39113. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39114. */
  39115. axisXControlHeight: boolean;
  39116. /**
  39117. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39118. */
  39119. axisXControlRotation: boolean;
  39120. /**
  39121. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39122. */
  39123. axisYControlRadius: boolean;
  39124. /**
  39125. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39126. */
  39127. axisYControlHeight: boolean;
  39128. /**
  39129. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39130. */
  39131. axisYControlRotation: boolean;
  39132. /**
  39133. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39134. */
  39135. axisPinchControlRadius: boolean;
  39136. /**
  39137. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39138. */
  39139. axisPinchControlHeight: boolean;
  39140. /**
  39141. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39142. */
  39143. axisPinchControlRotation: boolean;
  39144. /**
  39145. * Log error messages if basic misconfiguration has occurred.
  39146. */
  39147. warningEnable: boolean;
  39148. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39149. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39150. private _warningCounter;
  39151. private _warning;
  39152. }
  39153. }
  39154. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39155. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39156. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39157. /**
  39158. * Default Inputs manager for the FollowCamera.
  39159. * It groups all the default supported inputs for ease of use.
  39160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39161. */
  39162. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39163. /**
  39164. * Instantiates a new FollowCameraInputsManager.
  39165. * @param camera Defines the camera the inputs belong to
  39166. */
  39167. constructor(camera: FollowCamera);
  39168. /**
  39169. * Add keyboard input support to the input manager.
  39170. * @returns the current input manager
  39171. */
  39172. addKeyboard(): FollowCameraInputsManager;
  39173. /**
  39174. * Add mouse wheel input support to the input manager.
  39175. * @returns the current input manager
  39176. */
  39177. addMouseWheel(): FollowCameraInputsManager;
  39178. /**
  39179. * Add pointers input support to the input manager.
  39180. * @returns the current input manager
  39181. */
  39182. addPointers(): FollowCameraInputsManager;
  39183. /**
  39184. * Add orientation input support to the input manager.
  39185. * @returns the current input manager
  39186. */
  39187. addVRDeviceOrientation(): FollowCameraInputsManager;
  39188. }
  39189. }
  39190. declare module "babylonjs/Cameras/followCamera" {
  39191. import { Nullable } from "babylonjs/types";
  39192. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39193. import { Scene } from "babylonjs/scene";
  39194. import { Vector3 } from "babylonjs/Maths/math.vector";
  39195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39196. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39197. /**
  39198. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39199. * an arc rotate version arcFollowCamera are available.
  39200. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39201. */
  39202. export class FollowCamera extends TargetCamera {
  39203. /**
  39204. * Distance the follow camera should follow an object at
  39205. */
  39206. radius: number;
  39207. /**
  39208. * Minimum allowed distance of the camera to the axis of rotation
  39209. * (The camera can not get closer).
  39210. * This can help limiting how the Camera is able to move in the scene.
  39211. */
  39212. lowerRadiusLimit: Nullable<number>;
  39213. /**
  39214. * Maximum allowed distance of the camera to the axis of rotation
  39215. * (The camera can not get further).
  39216. * This can help limiting how the Camera is able to move in the scene.
  39217. */
  39218. upperRadiusLimit: Nullable<number>;
  39219. /**
  39220. * Define a rotation offset between the camera and the object it follows
  39221. */
  39222. rotationOffset: number;
  39223. /**
  39224. * Minimum allowed angle to camera position relative to target object.
  39225. * This can help limiting how the Camera is able to move in the scene.
  39226. */
  39227. lowerRotationOffsetLimit: Nullable<number>;
  39228. /**
  39229. * Maximum allowed angle to camera position relative to target object.
  39230. * This can help limiting how the Camera is able to move in the scene.
  39231. */
  39232. upperRotationOffsetLimit: Nullable<number>;
  39233. /**
  39234. * Define a height offset between the camera and the object it follows.
  39235. * It can help following an object from the top (like a car chaing a plane)
  39236. */
  39237. heightOffset: number;
  39238. /**
  39239. * Minimum allowed height of camera position relative to target object.
  39240. * This can help limiting how the Camera is able to move in the scene.
  39241. */
  39242. lowerHeightOffsetLimit: Nullable<number>;
  39243. /**
  39244. * Maximum allowed height of camera position relative to target object.
  39245. * This can help limiting how the Camera is able to move in the scene.
  39246. */
  39247. upperHeightOffsetLimit: Nullable<number>;
  39248. /**
  39249. * Define how fast the camera can accelerate to follow it s target.
  39250. */
  39251. cameraAcceleration: number;
  39252. /**
  39253. * Define the speed limit of the camera following an object.
  39254. */
  39255. maxCameraSpeed: number;
  39256. /**
  39257. * Define the target of the camera.
  39258. */
  39259. lockedTarget: Nullable<AbstractMesh>;
  39260. /**
  39261. * Defines the input associated with the camera.
  39262. */
  39263. inputs: FollowCameraInputsManager;
  39264. /**
  39265. * Instantiates the follow camera.
  39266. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39267. * @param name Define the name of the camera in the scene
  39268. * @param position Define the position of the camera
  39269. * @param scene Define the scene the camera belong to
  39270. * @param lockedTarget Define the target of the camera
  39271. */
  39272. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39273. private _follow;
  39274. /**
  39275. * Attached controls to the current camera.
  39276. * @param element Defines the element the controls should be listened from
  39277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39278. */
  39279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39280. /**
  39281. * Detach the current controls from the camera.
  39282. * The camera will stop reacting to inputs.
  39283. * @param element Defines the element to stop listening the inputs from
  39284. */
  39285. detachControl(element: HTMLElement): void;
  39286. /** @hidden */
  39287. _checkInputs(): void;
  39288. private _checkLimits;
  39289. /**
  39290. * Gets the camera class name.
  39291. * @returns the class name
  39292. */
  39293. getClassName(): string;
  39294. }
  39295. /**
  39296. * Arc Rotate version of the follow camera.
  39297. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39298. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39299. */
  39300. export class ArcFollowCamera extends TargetCamera {
  39301. /** The longitudinal angle of the camera */
  39302. alpha: number;
  39303. /** The latitudinal angle of the camera */
  39304. beta: number;
  39305. /** The radius of the camera from its target */
  39306. radius: number;
  39307. /** Define the camera target (the messh it should follow) */
  39308. target: Nullable<AbstractMesh>;
  39309. private _cartesianCoordinates;
  39310. /**
  39311. * Instantiates a new ArcFollowCamera
  39312. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39313. * @param name Define the name of the camera
  39314. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39315. * @param beta Define the rotation angle of the camera around the elevation axis
  39316. * @param radius Define the radius of the camera from its target point
  39317. * @param target Define the target of the camera
  39318. * @param scene Define the scene the camera belongs to
  39319. */
  39320. constructor(name: string,
  39321. /** The longitudinal angle of the camera */
  39322. alpha: number,
  39323. /** The latitudinal angle of the camera */
  39324. beta: number,
  39325. /** The radius of the camera from its target */
  39326. radius: number,
  39327. /** Define the camera target (the messh it should follow) */
  39328. target: Nullable<AbstractMesh>, scene: Scene);
  39329. private _follow;
  39330. /** @hidden */
  39331. _checkInputs(): void;
  39332. /**
  39333. * Returns the class name of the object.
  39334. * It is mostly used internally for serialization purposes.
  39335. */
  39336. getClassName(): string;
  39337. }
  39338. }
  39339. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39340. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39341. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39342. import { Nullable } from "babylonjs/types";
  39343. /**
  39344. * Manage the keyboard inputs to control the movement of a follow camera.
  39345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39346. */
  39347. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39348. /**
  39349. * Defines the camera the input is attached to.
  39350. */
  39351. camera: FollowCamera;
  39352. /**
  39353. * Defines the list of key codes associated with the up action (increase heightOffset)
  39354. */
  39355. keysHeightOffsetIncr: number[];
  39356. /**
  39357. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39358. */
  39359. keysHeightOffsetDecr: number[];
  39360. /**
  39361. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39362. */
  39363. keysHeightOffsetModifierAlt: boolean;
  39364. /**
  39365. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39366. */
  39367. keysHeightOffsetModifierCtrl: boolean;
  39368. /**
  39369. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39370. */
  39371. keysHeightOffsetModifierShift: boolean;
  39372. /**
  39373. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39374. */
  39375. keysRotationOffsetIncr: number[];
  39376. /**
  39377. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39378. */
  39379. keysRotationOffsetDecr: number[];
  39380. /**
  39381. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39382. */
  39383. keysRotationOffsetModifierAlt: boolean;
  39384. /**
  39385. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39386. */
  39387. keysRotationOffsetModifierCtrl: boolean;
  39388. /**
  39389. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39390. */
  39391. keysRotationOffsetModifierShift: boolean;
  39392. /**
  39393. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39394. */
  39395. keysRadiusIncr: number[];
  39396. /**
  39397. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39398. */
  39399. keysRadiusDecr: number[];
  39400. /**
  39401. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39402. */
  39403. keysRadiusModifierAlt: boolean;
  39404. /**
  39405. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39406. */
  39407. keysRadiusModifierCtrl: boolean;
  39408. /**
  39409. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39410. */
  39411. keysRadiusModifierShift: boolean;
  39412. /**
  39413. * Defines the rate of change of heightOffset.
  39414. */
  39415. heightSensibility: number;
  39416. /**
  39417. * Defines the rate of change of rotationOffset.
  39418. */
  39419. rotationSensibility: number;
  39420. /**
  39421. * Defines the rate of change of radius.
  39422. */
  39423. radiusSensibility: number;
  39424. private _keys;
  39425. private _ctrlPressed;
  39426. private _altPressed;
  39427. private _shiftPressed;
  39428. private _onCanvasBlurObserver;
  39429. private _onKeyboardObserver;
  39430. private _engine;
  39431. private _scene;
  39432. /**
  39433. * Attach the input controls to a specific dom element to get the input from.
  39434. * @param element Defines the element the controls should be listened from
  39435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39436. */
  39437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39438. /**
  39439. * Detach the current controls from the specified dom element.
  39440. * @param element Defines the element to stop listening the inputs from
  39441. */
  39442. detachControl(element: Nullable<HTMLElement>): void;
  39443. /**
  39444. * Update the current camera state depending on the inputs that have been used this frame.
  39445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39446. */
  39447. checkInputs(): void;
  39448. /**
  39449. * Gets the class name of the current input.
  39450. * @returns the class name
  39451. */
  39452. getClassName(): string;
  39453. /**
  39454. * Get the friendly name associated with the input class.
  39455. * @returns the input friendly name
  39456. */
  39457. getSimpleName(): string;
  39458. /**
  39459. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39460. * allow modification of the heightOffset value.
  39461. */
  39462. private _modifierHeightOffset;
  39463. /**
  39464. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39465. * allow modification of the rotationOffset value.
  39466. */
  39467. private _modifierRotationOffset;
  39468. /**
  39469. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39470. * allow modification of the radius value.
  39471. */
  39472. private _modifierRadius;
  39473. }
  39474. }
  39475. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39476. import { Nullable } from "babylonjs/types";
  39477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39478. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39479. import { Observable } from "babylonjs/Misc/observable";
  39480. module "babylonjs/Cameras/freeCameraInputsManager" {
  39481. interface FreeCameraInputsManager {
  39482. /**
  39483. * @hidden
  39484. */
  39485. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39486. /**
  39487. * Add orientation input support to the input manager.
  39488. * @returns the current input manager
  39489. */
  39490. addDeviceOrientation(): FreeCameraInputsManager;
  39491. }
  39492. }
  39493. /**
  39494. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39495. * Screen rotation is taken into account.
  39496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39497. */
  39498. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39499. private _camera;
  39500. private _screenOrientationAngle;
  39501. private _constantTranform;
  39502. private _screenQuaternion;
  39503. private _alpha;
  39504. private _beta;
  39505. private _gamma;
  39506. /**
  39507. * Can be used to detect if a device orientation sensor is availible on a device
  39508. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39509. * @returns a promise that will resolve on orientation change
  39510. */
  39511. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39512. /**
  39513. * @hidden
  39514. */
  39515. _onDeviceOrientationChangedObservable: Observable<void>;
  39516. /**
  39517. * Instantiates a new input
  39518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39519. */
  39520. constructor();
  39521. /**
  39522. * Define the camera controlled by the input.
  39523. */
  39524. camera: FreeCamera;
  39525. /**
  39526. * Attach the input controls to a specific dom element to get the input from.
  39527. * @param element Defines the element the controls should be listened from
  39528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39529. */
  39530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39531. private _orientationChanged;
  39532. private _deviceOrientation;
  39533. /**
  39534. * Detach the current controls from the specified dom element.
  39535. * @param element Defines the element to stop listening the inputs from
  39536. */
  39537. detachControl(element: Nullable<HTMLElement>): void;
  39538. /**
  39539. * Update the current camera state depending on the inputs that have been used this frame.
  39540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39541. */
  39542. checkInputs(): void;
  39543. /**
  39544. * Gets the class name of the current intput.
  39545. * @returns the class name
  39546. */
  39547. getClassName(): string;
  39548. /**
  39549. * Get the friendly name associated with the input class.
  39550. * @returns the input friendly name
  39551. */
  39552. getSimpleName(): string;
  39553. }
  39554. }
  39555. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39556. import { Nullable } from "babylonjs/types";
  39557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39558. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39559. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39560. /**
  39561. * Manage the gamepad inputs to control a free camera.
  39562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39563. */
  39564. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39565. /**
  39566. * Define the camera the input is attached to.
  39567. */
  39568. camera: FreeCamera;
  39569. /**
  39570. * Define the Gamepad controlling the input
  39571. */
  39572. gamepad: Nullable<Gamepad>;
  39573. /**
  39574. * Defines the gamepad rotation sensiblity.
  39575. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39576. */
  39577. gamepadAngularSensibility: number;
  39578. /**
  39579. * Defines the gamepad move sensiblity.
  39580. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39581. */
  39582. gamepadMoveSensibility: number;
  39583. private _yAxisScale;
  39584. /**
  39585. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39586. */
  39587. invertYAxis: boolean;
  39588. private _onGamepadConnectedObserver;
  39589. private _onGamepadDisconnectedObserver;
  39590. private _cameraTransform;
  39591. private _deltaTransform;
  39592. private _vector3;
  39593. private _vector2;
  39594. /**
  39595. * Attach the input controls to a specific dom element to get the input from.
  39596. * @param element Defines the element the controls should be listened from
  39597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39598. */
  39599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39600. /**
  39601. * Detach the current controls from the specified dom element.
  39602. * @param element Defines the element to stop listening the inputs from
  39603. */
  39604. detachControl(element: Nullable<HTMLElement>): void;
  39605. /**
  39606. * Update the current camera state depending on the inputs that have been used this frame.
  39607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39608. */
  39609. checkInputs(): void;
  39610. /**
  39611. * Gets the class name of the current intput.
  39612. * @returns the class name
  39613. */
  39614. getClassName(): string;
  39615. /**
  39616. * Get the friendly name associated with the input class.
  39617. * @returns the input friendly name
  39618. */
  39619. getSimpleName(): string;
  39620. }
  39621. }
  39622. declare module "babylonjs/Misc/virtualJoystick" {
  39623. import { Nullable } from "babylonjs/types";
  39624. import { Vector3 } from "babylonjs/Maths/math.vector";
  39625. /**
  39626. * Defines the potential axis of a Joystick
  39627. */
  39628. export enum JoystickAxis {
  39629. /** X axis */
  39630. X = 0,
  39631. /** Y axis */
  39632. Y = 1,
  39633. /** Z axis */
  39634. Z = 2
  39635. }
  39636. /**
  39637. * Class used to define virtual joystick (used in touch mode)
  39638. */
  39639. export class VirtualJoystick {
  39640. /**
  39641. * Gets or sets a boolean indicating that left and right values must be inverted
  39642. */
  39643. reverseLeftRight: boolean;
  39644. /**
  39645. * Gets or sets a boolean indicating that up and down values must be inverted
  39646. */
  39647. reverseUpDown: boolean;
  39648. /**
  39649. * Gets the offset value for the position (ie. the change of the position value)
  39650. */
  39651. deltaPosition: Vector3;
  39652. /**
  39653. * Gets a boolean indicating if the virtual joystick was pressed
  39654. */
  39655. pressed: boolean;
  39656. /**
  39657. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39658. */
  39659. static Canvas: Nullable<HTMLCanvasElement>;
  39660. private static _globalJoystickIndex;
  39661. private static vjCanvasContext;
  39662. private static vjCanvasWidth;
  39663. private static vjCanvasHeight;
  39664. private static halfWidth;
  39665. private _action;
  39666. private _axisTargetedByLeftAndRight;
  39667. private _axisTargetedByUpAndDown;
  39668. private _joystickSensibility;
  39669. private _inversedSensibility;
  39670. private _joystickPointerID;
  39671. private _joystickColor;
  39672. private _joystickPointerPos;
  39673. private _joystickPreviousPointerPos;
  39674. private _joystickPointerStartPos;
  39675. private _deltaJoystickVector;
  39676. private _leftJoystick;
  39677. private _touches;
  39678. private _onPointerDownHandlerRef;
  39679. private _onPointerMoveHandlerRef;
  39680. private _onPointerUpHandlerRef;
  39681. private _onResize;
  39682. /**
  39683. * Creates a new virtual joystick
  39684. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39685. */
  39686. constructor(leftJoystick?: boolean);
  39687. /**
  39688. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39689. * @param newJoystickSensibility defines the new sensibility
  39690. */
  39691. setJoystickSensibility(newJoystickSensibility: number): void;
  39692. private _onPointerDown;
  39693. private _onPointerMove;
  39694. private _onPointerUp;
  39695. /**
  39696. * Change the color of the virtual joystick
  39697. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39698. */
  39699. setJoystickColor(newColor: string): void;
  39700. /**
  39701. * Defines a callback to call when the joystick is touched
  39702. * @param action defines the callback
  39703. */
  39704. setActionOnTouch(action: () => any): void;
  39705. /**
  39706. * Defines which axis you'd like to control for left & right
  39707. * @param axis defines the axis to use
  39708. */
  39709. setAxisForLeftRight(axis: JoystickAxis): void;
  39710. /**
  39711. * Defines which axis you'd like to control for up & down
  39712. * @param axis defines the axis to use
  39713. */
  39714. setAxisForUpDown(axis: JoystickAxis): void;
  39715. private _drawVirtualJoystick;
  39716. /**
  39717. * Release internal HTML canvas
  39718. */
  39719. releaseCanvas(): void;
  39720. }
  39721. }
  39722. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39723. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39724. import { Nullable } from "babylonjs/types";
  39725. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39726. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39727. module "babylonjs/Cameras/freeCameraInputsManager" {
  39728. interface FreeCameraInputsManager {
  39729. /**
  39730. * Add virtual joystick input support to the input manager.
  39731. * @returns the current input manager
  39732. */
  39733. addVirtualJoystick(): FreeCameraInputsManager;
  39734. }
  39735. }
  39736. /**
  39737. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39739. */
  39740. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39741. /**
  39742. * Defines the camera the input is attached to.
  39743. */
  39744. camera: FreeCamera;
  39745. private _leftjoystick;
  39746. private _rightjoystick;
  39747. /**
  39748. * Gets the left stick of the virtual joystick.
  39749. * @returns The virtual Joystick
  39750. */
  39751. getLeftJoystick(): VirtualJoystick;
  39752. /**
  39753. * Gets the right stick of the virtual joystick.
  39754. * @returns The virtual Joystick
  39755. */
  39756. getRightJoystick(): VirtualJoystick;
  39757. /**
  39758. * Update the current camera state depending on the inputs that have been used this frame.
  39759. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39760. */
  39761. checkInputs(): void;
  39762. /**
  39763. * Attach the input controls to a specific dom element to get the input from.
  39764. * @param element Defines the element the controls should be listened from
  39765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39766. */
  39767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39768. /**
  39769. * Detach the current controls from the specified dom element.
  39770. * @param element Defines the element to stop listening the inputs from
  39771. */
  39772. detachControl(element: Nullable<HTMLElement>): void;
  39773. /**
  39774. * Gets the class name of the current intput.
  39775. * @returns the class name
  39776. */
  39777. getClassName(): string;
  39778. /**
  39779. * Get the friendly name associated with the input class.
  39780. * @returns the input friendly name
  39781. */
  39782. getSimpleName(): string;
  39783. }
  39784. }
  39785. declare module "babylonjs/Cameras/Inputs/index" {
  39786. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39787. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39788. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39789. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39790. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39791. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39792. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39793. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39794. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39795. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39796. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39797. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39798. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39799. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39800. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39801. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39802. }
  39803. declare module "babylonjs/Cameras/touchCamera" {
  39804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39805. import { Scene } from "babylonjs/scene";
  39806. import { Vector3 } from "babylonjs/Maths/math.vector";
  39807. /**
  39808. * This represents a FPS type of camera controlled by touch.
  39809. * This is like a universal camera minus the Gamepad controls.
  39810. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39811. */
  39812. export class TouchCamera extends FreeCamera {
  39813. /**
  39814. * Defines the touch sensibility for rotation.
  39815. * The higher the faster.
  39816. */
  39817. touchAngularSensibility: number;
  39818. /**
  39819. * Defines the touch sensibility for move.
  39820. * The higher the faster.
  39821. */
  39822. touchMoveSensibility: number;
  39823. /**
  39824. * Instantiates a new touch camera.
  39825. * This represents a FPS type of camera controlled by touch.
  39826. * This is like a universal camera minus the Gamepad controls.
  39827. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39828. * @param name Define the name of the camera in the scene
  39829. * @param position Define the start position of the camera in the scene
  39830. * @param scene Define the scene the camera belongs to
  39831. */
  39832. constructor(name: string, position: Vector3, scene: Scene);
  39833. /**
  39834. * Gets the current object class name.
  39835. * @return the class name
  39836. */
  39837. getClassName(): string;
  39838. /** @hidden */
  39839. _setupInputs(): void;
  39840. }
  39841. }
  39842. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39843. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39844. import { Scene } from "babylonjs/scene";
  39845. import { Vector3 } from "babylonjs/Maths/math.vector";
  39846. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39847. import { Axis } from "babylonjs/Maths/math.axis";
  39848. /**
  39849. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39850. * being tilted forward or back and left or right.
  39851. */
  39852. export class DeviceOrientationCamera extends FreeCamera {
  39853. private _initialQuaternion;
  39854. private _quaternionCache;
  39855. private _tmpDragQuaternion;
  39856. private _disablePointerInputWhenUsingDeviceOrientation;
  39857. /**
  39858. * Creates a new device orientation camera
  39859. * @param name The name of the camera
  39860. * @param position The start position camera
  39861. * @param scene The scene the camera belongs to
  39862. */
  39863. constructor(name: string, position: Vector3, scene: Scene);
  39864. /**
  39865. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39866. */
  39867. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39868. private _dragFactor;
  39869. /**
  39870. * Enabled turning on the y axis when the orientation sensor is active
  39871. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39872. */
  39873. enableHorizontalDragging(dragFactor?: number): void;
  39874. /**
  39875. * Gets the current instance class name ("DeviceOrientationCamera").
  39876. * This helps avoiding instanceof at run time.
  39877. * @returns the class name
  39878. */
  39879. getClassName(): string;
  39880. /**
  39881. * @hidden
  39882. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39883. */
  39884. _checkInputs(): void;
  39885. /**
  39886. * Reset the camera to its default orientation on the specified axis only.
  39887. * @param axis The axis to reset
  39888. */
  39889. resetToCurrentRotation(axis?: Axis): void;
  39890. }
  39891. }
  39892. declare module "babylonjs/Gamepads/xboxGamepad" {
  39893. import { Observable } from "babylonjs/Misc/observable";
  39894. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39895. /**
  39896. * Defines supported buttons for XBox360 compatible gamepads
  39897. */
  39898. export enum Xbox360Button {
  39899. /** A */
  39900. A = 0,
  39901. /** B */
  39902. B = 1,
  39903. /** X */
  39904. X = 2,
  39905. /** Y */
  39906. Y = 3,
  39907. /** Start */
  39908. Start = 4,
  39909. /** Back */
  39910. Back = 5,
  39911. /** Left button */
  39912. LB = 6,
  39913. /** Right button */
  39914. RB = 7,
  39915. /** Left stick */
  39916. LeftStick = 8,
  39917. /** Right stick */
  39918. RightStick = 9
  39919. }
  39920. /** Defines values for XBox360 DPad */
  39921. export enum Xbox360Dpad {
  39922. /** Up */
  39923. Up = 0,
  39924. /** Down */
  39925. Down = 1,
  39926. /** Left */
  39927. Left = 2,
  39928. /** Right */
  39929. Right = 3
  39930. }
  39931. /**
  39932. * Defines a XBox360 gamepad
  39933. */
  39934. export class Xbox360Pad extends Gamepad {
  39935. private _leftTrigger;
  39936. private _rightTrigger;
  39937. private _onlefttriggerchanged;
  39938. private _onrighttriggerchanged;
  39939. private _onbuttondown;
  39940. private _onbuttonup;
  39941. private _ondpaddown;
  39942. private _ondpadup;
  39943. /** Observable raised when a button is pressed */
  39944. onButtonDownObservable: Observable<Xbox360Button>;
  39945. /** Observable raised when a button is released */
  39946. onButtonUpObservable: Observable<Xbox360Button>;
  39947. /** Observable raised when a pad is pressed */
  39948. onPadDownObservable: Observable<Xbox360Dpad>;
  39949. /** Observable raised when a pad is released */
  39950. onPadUpObservable: Observable<Xbox360Dpad>;
  39951. private _buttonA;
  39952. private _buttonB;
  39953. private _buttonX;
  39954. private _buttonY;
  39955. private _buttonBack;
  39956. private _buttonStart;
  39957. private _buttonLB;
  39958. private _buttonRB;
  39959. private _buttonLeftStick;
  39960. private _buttonRightStick;
  39961. private _dPadUp;
  39962. private _dPadDown;
  39963. private _dPadLeft;
  39964. private _dPadRight;
  39965. private _isXboxOnePad;
  39966. /**
  39967. * Creates a new XBox360 gamepad object
  39968. * @param id defines the id of this gamepad
  39969. * @param index defines its index
  39970. * @param gamepad defines the internal HTML gamepad object
  39971. * @param xboxOne defines if it is a XBox One gamepad
  39972. */
  39973. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39974. /**
  39975. * Defines the callback to call when left trigger is pressed
  39976. * @param callback defines the callback to use
  39977. */
  39978. onlefttriggerchanged(callback: (value: number) => void): void;
  39979. /**
  39980. * Defines the callback to call when right trigger is pressed
  39981. * @param callback defines the callback to use
  39982. */
  39983. onrighttriggerchanged(callback: (value: number) => void): void;
  39984. /**
  39985. * Gets the left trigger value
  39986. */
  39987. /**
  39988. * Sets the left trigger value
  39989. */
  39990. leftTrigger: number;
  39991. /**
  39992. * Gets the right trigger value
  39993. */
  39994. /**
  39995. * Sets the right trigger value
  39996. */
  39997. rightTrigger: number;
  39998. /**
  39999. * Defines the callback to call when a button is pressed
  40000. * @param callback defines the callback to use
  40001. */
  40002. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40003. /**
  40004. * Defines the callback to call when a button is released
  40005. * @param callback defines the callback to use
  40006. */
  40007. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40008. /**
  40009. * Defines the callback to call when a pad is pressed
  40010. * @param callback defines the callback to use
  40011. */
  40012. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40013. /**
  40014. * Defines the callback to call when a pad is released
  40015. * @param callback defines the callback to use
  40016. */
  40017. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40018. private _setButtonValue;
  40019. private _setDPadValue;
  40020. /**
  40021. * Gets the value of the `A` button
  40022. */
  40023. /**
  40024. * Sets the value of the `A` button
  40025. */
  40026. buttonA: number;
  40027. /**
  40028. * Gets the value of the `B` button
  40029. */
  40030. /**
  40031. * Sets the value of the `B` button
  40032. */
  40033. buttonB: number;
  40034. /**
  40035. * Gets the value of the `X` button
  40036. */
  40037. /**
  40038. * Sets the value of the `X` button
  40039. */
  40040. buttonX: number;
  40041. /**
  40042. * Gets the value of the `Y` button
  40043. */
  40044. /**
  40045. * Sets the value of the `Y` button
  40046. */
  40047. buttonY: number;
  40048. /**
  40049. * Gets the value of the `Start` button
  40050. */
  40051. /**
  40052. * Sets the value of the `Start` button
  40053. */
  40054. buttonStart: number;
  40055. /**
  40056. * Gets the value of the `Back` button
  40057. */
  40058. /**
  40059. * Sets the value of the `Back` button
  40060. */
  40061. buttonBack: number;
  40062. /**
  40063. * Gets the value of the `Left` button
  40064. */
  40065. /**
  40066. * Sets the value of the `Left` button
  40067. */
  40068. buttonLB: number;
  40069. /**
  40070. * Gets the value of the `Right` button
  40071. */
  40072. /**
  40073. * Sets the value of the `Right` button
  40074. */
  40075. buttonRB: number;
  40076. /**
  40077. * Gets the value of the Left joystick
  40078. */
  40079. /**
  40080. * Sets the value of the Left joystick
  40081. */
  40082. buttonLeftStick: number;
  40083. /**
  40084. * Gets the value of the Right joystick
  40085. */
  40086. /**
  40087. * Sets the value of the Right joystick
  40088. */
  40089. buttonRightStick: number;
  40090. /**
  40091. * Gets the value of D-pad up
  40092. */
  40093. /**
  40094. * Sets the value of D-pad up
  40095. */
  40096. dPadUp: number;
  40097. /**
  40098. * Gets the value of D-pad down
  40099. */
  40100. /**
  40101. * Sets the value of D-pad down
  40102. */
  40103. dPadDown: number;
  40104. /**
  40105. * Gets the value of D-pad left
  40106. */
  40107. /**
  40108. * Sets the value of D-pad left
  40109. */
  40110. dPadLeft: number;
  40111. /**
  40112. * Gets the value of D-pad right
  40113. */
  40114. /**
  40115. * Sets the value of D-pad right
  40116. */
  40117. dPadRight: number;
  40118. /**
  40119. * Force the gamepad to synchronize with device values
  40120. */
  40121. update(): void;
  40122. /**
  40123. * Disposes the gamepad
  40124. */
  40125. dispose(): void;
  40126. }
  40127. }
  40128. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40129. import { Observable } from "babylonjs/Misc/observable";
  40130. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40131. /**
  40132. * Defines supported buttons for DualShock compatible gamepads
  40133. */
  40134. export enum DualShockButton {
  40135. /** Cross */
  40136. Cross = 0,
  40137. /** Circle */
  40138. Circle = 1,
  40139. /** Square */
  40140. Square = 2,
  40141. /** Triangle */
  40142. Triangle = 3,
  40143. /** Options */
  40144. Options = 4,
  40145. /** Share */
  40146. Share = 5,
  40147. /** L1 */
  40148. L1 = 6,
  40149. /** R1 */
  40150. R1 = 7,
  40151. /** Left stick */
  40152. LeftStick = 8,
  40153. /** Right stick */
  40154. RightStick = 9
  40155. }
  40156. /** Defines values for DualShock DPad */
  40157. export enum DualShockDpad {
  40158. /** Up */
  40159. Up = 0,
  40160. /** Down */
  40161. Down = 1,
  40162. /** Left */
  40163. Left = 2,
  40164. /** Right */
  40165. Right = 3
  40166. }
  40167. /**
  40168. * Defines a DualShock gamepad
  40169. */
  40170. export class DualShockPad extends Gamepad {
  40171. private _leftTrigger;
  40172. private _rightTrigger;
  40173. private _onlefttriggerchanged;
  40174. private _onrighttriggerchanged;
  40175. private _onbuttondown;
  40176. private _onbuttonup;
  40177. private _ondpaddown;
  40178. private _ondpadup;
  40179. /** Observable raised when a button is pressed */
  40180. onButtonDownObservable: Observable<DualShockButton>;
  40181. /** Observable raised when a button is released */
  40182. onButtonUpObservable: Observable<DualShockButton>;
  40183. /** Observable raised when a pad is pressed */
  40184. onPadDownObservable: Observable<DualShockDpad>;
  40185. /** Observable raised when a pad is released */
  40186. onPadUpObservable: Observable<DualShockDpad>;
  40187. private _buttonCross;
  40188. private _buttonCircle;
  40189. private _buttonSquare;
  40190. private _buttonTriangle;
  40191. private _buttonShare;
  40192. private _buttonOptions;
  40193. private _buttonL1;
  40194. private _buttonR1;
  40195. private _buttonLeftStick;
  40196. private _buttonRightStick;
  40197. private _dPadUp;
  40198. private _dPadDown;
  40199. private _dPadLeft;
  40200. private _dPadRight;
  40201. /**
  40202. * Creates a new DualShock gamepad object
  40203. * @param id defines the id of this gamepad
  40204. * @param index defines its index
  40205. * @param gamepad defines the internal HTML gamepad object
  40206. */
  40207. constructor(id: string, index: number, gamepad: any);
  40208. /**
  40209. * Defines the callback to call when left trigger is pressed
  40210. * @param callback defines the callback to use
  40211. */
  40212. onlefttriggerchanged(callback: (value: number) => void): void;
  40213. /**
  40214. * Defines the callback to call when right trigger is pressed
  40215. * @param callback defines the callback to use
  40216. */
  40217. onrighttriggerchanged(callback: (value: number) => void): void;
  40218. /**
  40219. * Gets the left trigger value
  40220. */
  40221. /**
  40222. * Sets the left trigger value
  40223. */
  40224. leftTrigger: number;
  40225. /**
  40226. * Gets the right trigger value
  40227. */
  40228. /**
  40229. * Sets the right trigger value
  40230. */
  40231. rightTrigger: number;
  40232. /**
  40233. * Defines the callback to call when a button is pressed
  40234. * @param callback defines the callback to use
  40235. */
  40236. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40237. /**
  40238. * Defines the callback to call when a button is released
  40239. * @param callback defines the callback to use
  40240. */
  40241. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40242. /**
  40243. * Defines the callback to call when a pad is pressed
  40244. * @param callback defines the callback to use
  40245. */
  40246. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40247. /**
  40248. * Defines the callback to call when a pad is released
  40249. * @param callback defines the callback to use
  40250. */
  40251. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40252. private _setButtonValue;
  40253. private _setDPadValue;
  40254. /**
  40255. * Gets the value of the `Cross` button
  40256. */
  40257. /**
  40258. * Sets the value of the `Cross` button
  40259. */
  40260. buttonCross: number;
  40261. /**
  40262. * Gets the value of the `Circle` button
  40263. */
  40264. /**
  40265. * Sets the value of the `Circle` button
  40266. */
  40267. buttonCircle: number;
  40268. /**
  40269. * Gets the value of the `Square` button
  40270. */
  40271. /**
  40272. * Sets the value of the `Square` button
  40273. */
  40274. buttonSquare: number;
  40275. /**
  40276. * Gets the value of the `Triangle` button
  40277. */
  40278. /**
  40279. * Sets the value of the `Triangle` button
  40280. */
  40281. buttonTriangle: number;
  40282. /**
  40283. * Gets the value of the `Options` button
  40284. */
  40285. /**
  40286. * Sets the value of the `Options` button
  40287. */
  40288. buttonOptions: number;
  40289. /**
  40290. * Gets the value of the `Share` button
  40291. */
  40292. /**
  40293. * Sets the value of the `Share` button
  40294. */
  40295. buttonShare: number;
  40296. /**
  40297. * Gets the value of the `L1` button
  40298. */
  40299. /**
  40300. * Sets the value of the `L1` button
  40301. */
  40302. buttonL1: number;
  40303. /**
  40304. * Gets the value of the `R1` button
  40305. */
  40306. /**
  40307. * Sets the value of the `R1` button
  40308. */
  40309. buttonR1: number;
  40310. /**
  40311. * Gets the value of the Left joystick
  40312. */
  40313. /**
  40314. * Sets the value of the Left joystick
  40315. */
  40316. buttonLeftStick: number;
  40317. /**
  40318. * Gets the value of the Right joystick
  40319. */
  40320. /**
  40321. * Sets the value of the Right joystick
  40322. */
  40323. buttonRightStick: number;
  40324. /**
  40325. * Gets the value of D-pad up
  40326. */
  40327. /**
  40328. * Sets the value of D-pad up
  40329. */
  40330. dPadUp: number;
  40331. /**
  40332. * Gets the value of D-pad down
  40333. */
  40334. /**
  40335. * Sets the value of D-pad down
  40336. */
  40337. dPadDown: number;
  40338. /**
  40339. * Gets the value of D-pad left
  40340. */
  40341. /**
  40342. * Sets the value of D-pad left
  40343. */
  40344. dPadLeft: number;
  40345. /**
  40346. * Gets the value of D-pad right
  40347. */
  40348. /**
  40349. * Sets the value of D-pad right
  40350. */
  40351. dPadRight: number;
  40352. /**
  40353. * Force the gamepad to synchronize with device values
  40354. */
  40355. update(): void;
  40356. /**
  40357. * Disposes the gamepad
  40358. */
  40359. dispose(): void;
  40360. }
  40361. }
  40362. declare module "babylonjs/Gamepads/gamepadManager" {
  40363. import { Observable } from "babylonjs/Misc/observable";
  40364. import { Nullable } from "babylonjs/types";
  40365. import { Scene } from "babylonjs/scene";
  40366. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40367. /**
  40368. * Manager for handling gamepads
  40369. */
  40370. export class GamepadManager {
  40371. private _scene?;
  40372. private _babylonGamepads;
  40373. private _oneGamepadConnected;
  40374. /** @hidden */
  40375. _isMonitoring: boolean;
  40376. private _gamepadEventSupported;
  40377. private _gamepadSupport;
  40378. /**
  40379. * observable to be triggered when the gamepad controller has been connected
  40380. */
  40381. onGamepadConnectedObservable: Observable<Gamepad>;
  40382. /**
  40383. * observable to be triggered when the gamepad controller has been disconnected
  40384. */
  40385. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40386. private _onGamepadConnectedEvent;
  40387. private _onGamepadDisconnectedEvent;
  40388. /**
  40389. * Initializes the gamepad manager
  40390. * @param _scene BabylonJS scene
  40391. */
  40392. constructor(_scene?: Scene | undefined);
  40393. /**
  40394. * The gamepads in the game pad manager
  40395. */
  40396. readonly gamepads: Gamepad[];
  40397. /**
  40398. * Get the gamepad controllers based on type
  40399. * @param type The type of gamepad controller
  40400. * @returns Nullable gamepad
  40401. */
  40402. getGamepadByType(type?: number): Nullable<Gamepad>;
  40403. /**
  40404. * Disposes the gamepad manager
  40405. */
  40406. dispose(): void;
  40407. private _addNewGamepad;
  40408. private _startMonitoringGamepads;
  40409. private _stopMonitoringGamepads;
  40410. /** @hidden */
  40411. _checkGamepadsStatus(): void;
  40412. private _updateGamepadObjects;
  40413. }
  40414. }
  40415. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40416. import { Nullable } from "babylonjs/types";
  40417. import { Scene } from "babylonjs/scene";
  40418. import { ISceneComponent } from "babylonjs/sceneComponent";
  40419. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40420. module "babylonjs/scene" {
  40421. interface Scene {
  40422. /** @hidden */
  40423. _gamepadManager: Nullable<GamepadManager>;
  40424. /**
  40425. * Gets the gamepad manager associated with the scene
  40426. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40427. */
  40428. gamepadManager: GamepadManager;
  40429. }
  40430. }
  40431. module "babylonjs/Cameras/freeCameraInputsManager" {
  40432. /**
  40433. * Interface representing a free camera inputs manager
  40434. */
  40435. interface FreeCameraInputsManager {
  40436. /**
  40437. * Adds gamepad input support to the FreeCameraInputsManager.
  40438. * @returns the FreeCameraInputsManager
  40439. */
  40440. addGamepad(): FreeCameraInputsManager;
  40441. }
  40442. }
  40443. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40444. /**
  40445. * Interface representing an arc rotate camera inputs manager
  40446. */
  40447. interface ArcRotateCameraInputsManager {
  40448. /**
  40449. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40450. * @returns the camera inputs manager
  40451. */
  40452. addGamepad(): ArcRotateCameraInputsManager;
  40453. }
  40454. }
  40455. /**
  40456. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40457. */
  40458. export class GamepadSystemSceneComponent implements ISceneComponent {
  40459. /**
  40460. * The component name helpfull to identify the component in the list of scene components.
  40461. */
  40462. readonly name: string;
  40463. /**
  40464. * The scene the component belongs to.
  40465. */
  40466. scene: Scene;
  40467. /**
  40468. * Creates a new instance of the component for the given scene
  40469. * @param scene Defines the scene to register the component in
  40470. */
  40471. constructor(scene: Scene);
  40472. /**
  40473. * Registers the component in a given scene
  40474. */
  40475. register(): void;
  40476. /**
  40477. * Rebuilds the elements related to this component in case of
  40478. * context lost for instance.
  40479. */
  40480. rebuild(): void;
  40481. /**
  40482. * Disposes the component and the associated ressources
  40483. */
  40484. dispose(): void;
  40485. private _beforeCameraUpdate;
  40486. }
  40487. }
  40488. declare module "babylonjs/Cameras/universalCamera" {
  40489. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40490. import { Scene } from "babylonjs/scene";
  40491. import { Vector3 } from "babylonjs/Maths/math.vector";
  40492. import "babylonjs/Gamepads/gamepadSceneComponent";
  40493. /**
  40494. * 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,
  40495. * which still works and will still be found in many Playgrounds.
  40496. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40497. */
  40498. export class UniversalCamera extends TouchCamera {
  40499. /**
  40500. * Defines the gamepad rotation sensiblity.
  40501. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40502. */
  40503. gamepadAngularSensibility: number;
  40504. /**
  40505. * Defines the gamepad move sensiblity.
  40506. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40507. */
  40508. gamepadMoveSensibility: number;
  40509. /**
  40510. * 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,
  40511. * which still works and will still be found in many Playgrounds.
  40512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40513. * @param name Define the name of the camera in the scene
  40514. * @param position Define the start position of the camera in the scene
  40515. * @param scene Define the scene the camera belongs to
  40516. */
  40517. constructor(name: string, position: Vector3, scene: Scene);
  40518. /**
  40519. * Gets the current object class name.
  40520. * @return the class name
  40521. */
  40522. getClassName(): string;
  40523. }
  40524. }
  40525. declare module "babylonjs/Cameras/gamepadCamera" {
  40526. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40527. import { Scene } from "babylonjs/scene";
  40528. import { Vector3 } from "babylonjs/Maths/math.vector";
  40529. /**
  40530. * This represents a FPS type of camera. This is only here for back compat purpose.
  40531. * Please use the UniversalCamera instead as both are identical.
  40532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40533. */
  40534. export class GamepadCamera extends UniversalCamera {
  40535. /**
  40536. * Instantiates a new Gamepad Camera
  40537. * This represents a FPS type of camera. This is only here for back compat purpose.
  40538. * Please use the UniversalCamera instead as both are identical.
  40539. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40540. * @param name Define the name of the camera in the scene
  40541. * @param position Define the start position of the camera in the scene
  40542. * @param scene Define the scene the camera belongs to
  40543. */
  40544. constructor(name: string, position: Vector3, scene: Scene);
  40545. /**
  40546. * Gets the current object class name.
  40547. * @return the class name
  40548. */
  40549. getClassName(): string;
  40550. }
  40551. }
  40552. declare module "babylonjs/Shaders/pass.fragment" {
  40553. /** @hidden */
  40554. export var passPixelShader: {
  40555. name: string;
  40556. shader: string;
  40557. };
  40558. }
  40559. declare module "babylonjs/Shaders/passCube.fragment" {
  40560. /** @hidden */
  40561. export var passCubePixelShader: {
  40562. name: string;
  40563. shader: string;
  40564. };
  40565. }
  40566. declare module "babylonjs/PostProcesses/passPostProcess" {
  40567. import { Nullable } from "babylonjs/types";
  40568. import { Camera } from "babylonjs/Cameras/camera";
  40569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40570. import { Engine } from "babylonjs/Engines/engine";
  40571. import "babylonjs/Shaders/pass.fragment";
  40572. import "babylonjs/Shaders/passCube.fragment";
  40573. /**
  40574. * PassPostProcess which produces an output the same as it's input
  40575. */
  40576. export class PassPostProcess extends PostProcess {
  40577. /**
  40578. * Creates the PassPostProcess
  40579. * @param name The name of the effect.
  40580. * @param options The required width/height ratio to downsize to before computing the render pass.
  40581. * @param camera The camera to apply the render pass to.
  40582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40583. * @param engine The engine which the post process will be applied. (default: current engine)
  40584. * @param reusable If the post process can be reused on the same frame. (default: false)
  40585. * @param textureType The type of texture to be used when performing the post processing.
  40586. * @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)
  40587. */
  40588. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40589. }
  40590. /**
  40591. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40592. */
  40593. export class PassCubePostProcess extends PostProcess {
  40594. private _face;
  40595. /**
  40596. * Gets or sets the cube face to display.
  40597. * * 0 is +X
  40598. * * 1 is -X
  40599. * * 2 is +Y
  40600. * * 3 is -Y
  40601. * * 4 is +Z
  40602. * * 5 is -Z
  40603. */
  40604. face: number;
  40605. /**
  40606. * Creates the PassCubePostProcess
  40607. * @param name The name of the effect.
  40608. * @param options The required width/height ratio to downsize to before computing the render pass.
  40609. * @param camera The camera to apply the render pass to.
  40610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40611. * @param engine The engine which the post process will be applied. (default: current engine)
  40612. * @param reusable If the post process can be reused on the same frame. (default: false)
  40613. * @param textureType The type of texture to be used when performing the post processing.
  40614. * @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)
  40615. */
  40616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40617. }
  40618. }
  40619. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40620. /** @hidden */
  40621. export var anaglyphPixelShader: {
  40622. name: string;
  40623. shader: string;
  40624. };
  40625. }
  40626. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40627. import { Engine } from "babylonjs/Engines/engine";
  40628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40629. import { Camera } from "babylonjs/Cameras/camera";
  40630. import "babylonjs/Shaders/anaglyph.fragment";
  40631. /**
  40632. * Postprocess used to generate anaglyphic rendering
  40633. */
  40634. export class AnaglyphPostProcess extends PostProcess {
  40635. private _passedProcess;
  40636. /**
  40637. * Creates a new AnaglyphPostProcess
  40638. * @param name defines postprocess name
  40639. * @param options defines creation options or target ratio scale
  40640. * @param rigCameras defines cameras using this postprocess
  40641. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40642. * @param engine defines hosting engine
  40643. * @param reusable defines if the postprocess will be reused multiple times per frame
  40644. */
  40645. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40646. }
  40647. }
  40648. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40649. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40650. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40651. import { Scene } from "babylonjs/scene";
  40652. import { Vector3 } from "babylonjs/Maths/math.vector";
  40653. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40654. /**
  40655. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40656. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40657. */
  40658. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40659. /**
  40660. * Creates a new AnaglyphArcRotateCamera
  40661. * @param name defines camera name
  40662. * @param alpha defines alpha angle (in radians)
  40663. * @param beta defines beta angle (in radians)
  40664. * @param radius defines radius
  40665. * @param target defines camera target
  40666. * @param interaxialDistance defines distance between each color axis
  40667. * @param scene defines the hosting scene
  40668. */
  40669. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40670. /**
  40671. * Gets camera class name
  40672. * @returns AnaglyphArcRotateCamera
  40673. */
  40674. getClassName(): string;
  40675. }
  40676. }
  40677. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40678. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40679. import { Scene } from "babylonjs/scene";
  40680. import { Vector3 } from "babylonjs/Maths/math.vector";
  40681. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40682. /**
  40683. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40684. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40685. */
  40686. export class AnaglyphFreeCamera extends FreeCamera {
  40687. /**
  40688. * Creates a new AnaglyphFreeCamera
  40689. * @param name defines camera name
  40690. * @param position defines initial position
  40691. * @param interaxialDistance defines distance between each color axis
  40692. * @param scene defines the hosting scene
  40693. */
  40694. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40695. /**
  40696. * Gets camera class name
  40697. * @returns AnaglyphFreeCamera
  40698. */
  40699. getClassName(): string;
  40700. }
  40701. }
  40702. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40703. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40704. import { Scene } from "babylonjs/scene";
  40705. import { Vector3 } from "babylonjs/Maths/math.vector";
  40706. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40707. /**
  40708. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40709. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40710. */
  40711. export class AnaglyphGamepadCamera extends GamepadCamera {
  40712. /**
  40713. * Creates a new AnaglyphGamepadCamera
  40714. * @param name defines camera name
  40715. * @param position defines initial position
  40716. * @param interaxialDistance defines distance between each color axis
  40717. * @param scene defines the hosting scene
  40718. */
  40719. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40720. /**
  40721. * Gets camera class name
  40722. * @returns AnaglyphGamepadCamera
  40723. */
  40724. getClassName(): string;
  40725. }
  40726. }
  40727. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40728. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40729. import { Scene } from "babylonjs/scene";
  40730. import { Vector3 } from "babylonjs/Maths/math.vector";
  40731. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40732. /**
  40733. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40734. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40735. */
  40736. export class AnaglyphUniversalCamera extends UniversalCamera {
  40737. /**
  40738. * Creates a new AnaglyphUniversalCamera
  40739. * @param name defines camera name
  40740. * @param position defines initial position
  40741. * @param interaxialDistance defines distance between each color axis
  40742. * @param scene defines the hosting scene
  40743. */
  40744. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40745. /**
  40746. * Gets camera class name
  40747. * @returns AnaglyphUniversalCamera
  40748. */
  40749. getClassName(): string;
  40750. }
  40751. }
  40752. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40753. /** @hidden */
  40754. export var stereoscopicInterlacePixelShader: {
  40755. name: string;
  40756. shader: string;
  40757. };
  40758. }
  40759. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40760. import { Camera } from "babylonjs/Cameras/camera";
  40761. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40762. import { Engine } from "babylonjs/Engines/engine";
  40763. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40764. /**
  40765. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40766. */
  40767. export class StereoscopicInterlacePostProcess extends PostProcess {
  40768. private _stepSize;
  40769. private _passedProcess;
  40770. /**
  40771. * Initializes a StereoscopicInterlacePostProcess
  40772. * @param name The name of the effect.
  40773. * @param rigCameras The rig cameras to be appled to the post process
  40774. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40776. * @param engine The engine which the post process will be applied. (default: current engine)
  40777. * @param reusable If the post process can be reused on the same frame. (default: false)
  40778. */
  40779. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40780. }
  40781. }
  40782. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40783. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40784. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40785. import { Scene } from "babylonjs/scene";
  40786. import { Vector3 } from "babylonjs/Maths/math.vector";
  40787. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40788. /**
  40789. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40790. * @see http://doc.babylonjs.com/features/cameras
  40791. */
  40792. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40793. /**
  40794. * Creates a new StereoscopicArcRotateCamera
  40795. * @param name defines camera name
  40796. * @param alpha defines alpha angle (in radians)
  40797. * @param beta defines beta angle (in radians)
  40798. * @param radius defines radius
  40799. * @param target defines camera target
  40800. * @param interaxialDistance defines distance between each color axis
  40801. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40802. * @param scene defines the hosting scene
  40803. */
  40804. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40805. /**
  40806. * Gets camera class name
  40807. * @returns StereoscopicArcRotateCamera
  40808. */
  40809. getClassName(): string;
  40810. }
  40811. }
  40812. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40814. import { Scene } from "babylonjs/scene";
  40815. import { Vector3 } from "babylonjs/Maths/math.vector";
  40816. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40817. /**
  40818. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40819. * @see http://doc.babylonjs.com/features/cameras
  40820. */
  40821. export class StereoscopicFreeCamera extends FreeCamera {
  40822. /**
  40823. * Creates a new StereoscopicFreeCamera
  40824. * @param name defines camera name
  40825. * @param position defines initial position
  40826. * @param interaxialDistance defines distance between each color axis
  40827. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40828. * @param scene defines the hosting scene
  40829. */
  40830. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40831. /**
  40832. * Gets camera class name
  40833. * @returns StereoscopicFreeCamera
  40834. */
  40835. getClassName(): string;
  40836. }
  40837. }
  40838. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40839. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40840. import { Scene } from "babylonjs/scene";
  40841. import { Vector3 } from "babylonjs/Maths/math.vector";
  40842. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40843. /**
  40844. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40845. * @see http://doc.babylonjs.com/features/cameras
  40846. */
  40847. export class StereoscopicGamepadCamera extends GamepadCamera {
  40848. /**
  40849. * Creates a new StereoscopicGamepadCamera
  40850. * @param name defines camera name
  40851. * @param position defines initial position
  40852. * @param interaxialDistance defines distance between each color axis
  40853. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40854. * @param scene defines the hosting scene
  40855. */
  40856. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40857. /**
  40858. * Gets camera class name
  40859. * @returns StereoscopicGamepadCamera
  40860. */
  40861. getClassName(): string;
  40862. }
  40863. }
  40864. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40865. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40866. import { Scene } from "babylonjs/scene";
  40867. import { Vector3 } from "babylonjs/Maths/math.vector";
  40868. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40869. /**
  40870. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40871. * @see http://doc.babylonjs.com/features/cameras
  40872. */
  40873. export class StereoscopicUniversalCamera extends UniversalCamera {
  40874. /**
  40875. * Creates a new StereoscopicUniversalCamera
  40876. * @param name defines camera name
  40877. * @param position defines initial position
  40878. * @param interaxialDistance defines distance between each color axis
  40879. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40880. * @param scene defines the hosting scene
  40881. */
  40882. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40883. /**
  40884. * Gets camera class name
  40885. * @returns StereoscopicUniversalCamera
  40886. */
  40887. getClassName(): string;
  40888. }
  40889. }
  40890. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40891. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40892. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40893. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40894. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40895. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40896. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40897. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40898. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40899. }
  40900. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40901. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40902. import { Scene } from "babylonjs/scene";
  40903. import { Vector3 } from "babylonjs/Maths/math.vector";
  40904. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40905. /**
  40906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40907. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40908. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40909. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40910. */
  40911. export class VirtualJoysticksCamera extends FreeCamera {
  40912. /**
  40913. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40914. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40915. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40916. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40917. * @param name Define the name of the camera in the scene
  40918. * @param position Define the start position of the camera in the scene
  40919. * @param scene Define the scene the camera belongs to
  40920. */
  40921. constructor(name: string, position: Vector3, scene: Scene);
  40922. /**
  40923. * Gets the current object class name.
  40924. * @return the class name
  40925. */
  40926. getClassName(): string;
  40927. }
  40928. }
  40929. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40930. import { Matrix } from "babylonjs/Maths/math.vector";
  40931. /**
  40932. * This represents all the required metrics to create a VR camera.
  40933. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40934. */
  40935. export class VRCameraMetrics {
  40936. /**
  40937. * Define the horizontal resolution off the screen.
  40938. */
  40939. hResolution: number;
  40940. /**
  40941. * Define the vertical resolution off the screen.
  40942. */
  40943. vResolution: number;
  40944. /**
  40945. * Define the horizontal screen size.
  40946. */
  40947. hScreenSize: number;
  40948. /**
  40949. * Define the vertical screen size.
  40950. */
  40951. vScreenSize: number;
  40952. /**
  40953. * Define the vertical screen center position.
  40954. */
  40955. vScreenCenter: number;
  40956. /**
  40957. * Define the distance of the eyes to the screen.
  40958. */
  40959. eyeToScreenDistance: number;
  40960. /**
  40961. * Define the distance between both lenses
  40962. */
  40963. lensSeparationDistance: number;
  40964. /**
  40965. * Define the distance between both viewer's eyes.
  40966. */
  40967. interpupillaryDistance: number;
  40968. /**
  40969. * Define the distortion factor of the VR postprocess.
  40970. * Please, touch with care.
  40971. */
  40972. distortionK: number[];
  40973. /**
  40974. * Define the chromatic aberration correction factors for the VR post process.
  40975. */
  40976. chromaAbCorrection: number[];
  40977. /**
  40978. * Define the scale factor of the post process.
  40979. * The smaller the better but the slower.
  40980. */
  40981. postProcessScaleFactor: number;
  40982. /**
  40983. * Define an offset for the lens center.
  40984. */
  40985. lensCenterOffset: number;
  40986. /**
  40987. * Define if the current vr camera should compensate the distortion of the lense or not.
  40988. */
  40989. compensateDistortion: boolean;
  40990. /**
  40991. * Defines if multiview should be enabled when rendering (Default: false)
  40992. */
  40993. multiviewEnabled: boolean;
  40994. /**
  40995. * Gets the rendering aspect ratio based on the provided resolutions.
  40996. */
  40997. readonly aspectRatio: number;
  40998. /**
  40999. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41000. */
  41001. readonly aspectRatioFov: number;
  41002. /**
  41003. * @hidden
  41004. */
  41005. readonly leftHMatrix: Matrix;
  41006. /**
  41007. * @hidden
  41008. */
  41009. readonly rightHMatrix: Matrix;
  41010. /**
  41011. * @hidden
  41012. */
  41013. readonly leftPreViewMatrix: Matrix;
  41014. /**
  41015. * @hidden
  41016. */
  41017. readonly rightPreViewMatrix: Matrix;
  41018. /**
  41019. * Get the default VRMetrics based on the most generic setup.
  41020. * @returns the default vr metrics
  41021. */
  41022. static GetDefault(): VRCameraMetrics;
  41023. }
  41024. }
  41025. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41026. /** @hidden */
  41027. export var vrDistortionCorrectionPixelShader: {
  41028. name: string;
  41029. shader: string;
  41030. };
  41031. }
  41032. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41033. import { Camera } from "babylonjs/Cameras/camera";
  41034. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41036. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41037. /**
  41038. * VRDistortionCorrectionPostProcess used for mobile VR
  41039. */
  41040. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41041. private _isRightEye;
  41042. private _distortionFactors;
  41043. private _postProcessScaleFactor;
  41044. private _lensCenterOffset;
  41045. private _scaleIn;
  41046. private _scaleFactor;
  41047. private _lensCenter;
  41048. /**
  41049. * Initializes the VRDistortionCorrectionPostProcess
  41050. * @param name The name of the effect.
  41051. * @param camera The camera to apply the render pass to.
  41052. * @param isRightEye If this is for the right eye distortion
  41053. * @param vrMetrics All the required metrics for the VR camera
  41054. */
  41055. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41056. }
  41057. }
  41058. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41059. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41061. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41062. import { Scene } from "babylonjs/scene";
  41063. import { Vector3 } from "babylonjs/Maths/math.vector";
  41064. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41065. import "babylonjs/Cameras/RigModes/vrRigMode";
  41066. /**
  41067. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41068. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41069. */
  41070. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41071. /**
  41072. * Creates a new VRDeviceOrientationArcRotateCamera
  41073. * @param name defines camera name
  41074. * @param alpha defines the camera rotation along the logitudinal axis
  41075. * @param beta defines the camera rotation along the latitudinal axis
  41076. * @param radius defines the camera distance from its target
  41077. * @param target defines the camera target
  41078. * @param scene defines the scene the camera belongs to
  41079. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41080. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41081. */
  41082. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41083. /**
  41084. * Gets camera class name
  41085. * @returns VRDeviceOrientationArcRotateCamera
  41086. */
  41087. getClassName(): string;
  41088. }
  41089. }
  41090. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41091. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41092. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41093. import { Scene } from "babylonjs/scene";
  41094. import { Vector3 } from "babylonjs/Maths/math.vector";
  41095. import "babylonjs/Cameras/RigModes/vrRigMode";
  41096. /**
  41097. * Camera used to simulate VR rendering (based on FreeCamera)
  41098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41099. */
  41100. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41101. /**
  41102. * Creates a new VRDeviceOrientationFreeCamera
  41103. * @param name defines camera name
  41104. * @param position defines the start position of the camera
  41105. * @param scene defines the scene the camera belongs to
  41106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41108. */
  41109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41110. /**
  41111. * Gets camera class name
  41112. * @returns VRDeviceOrientationFreeCamera
  41113. */
  41114. getClassName(): string;
  41115. }
  41116. }
  41117. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41118. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41119. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41120. import { Scene } from "babylonjs/scene";
  41121. import { Vector3 } from "babylonjs/Maths/math.vector";
  41122. import "babylonjs/Gamepads/gamepadSceneComponent";
  41123. /**
  41124. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41125. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41126. */
  41127. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41128. /**
  41129. * Creates a new VRDeviceOrientationGamepadCamera
  41130. * @param name defines camera name
  41131. * @param position defines the start position of the camera
  41132. * @param scene defines the scene the camera belongs to
  41133. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41134. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41135. */
  41136. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41137. /**
  41138. * Gets camera class name
  41139. * @returns VRDeviceOrientationGamepadCamera
  41140. */
  41141. getClassName(): string;
  41142. }
  41143. }
  41144. declare module "babylonjs/Materials/pushMaterial" {
  41145. import { Nullable } from "babylonjs/types";
  41146. import { Scene } from "babylonjs/scene";
  41147. import { Matrix } from "babylonjs/Maths/math.vector";
  41148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41149. import { Mesh } from "babylonjs/Meshes/mesh";
  41150. import { Material } from "babylonjs/Materials/material";
  41151. import { Effect } from "babylonjs/Materials/effect";
  41152. /**
  41153. * Base class of materials working in push mode in babylon JS
  41154. * @hidden
  41155. */
  41156. export class PushMaterial extends Material {
  41157. protected _activeEffect: Effect;
  41158. protected _normalMatrix: Matrix;
  41159. /**
  41160. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41161. * This means that the material can keep using a previous shader while a new one is being compiled.
  41162. * This is mostly used when shader parallel compilation is supported (true by default)
  41163. */
  41164. allowShaderHotSwapping: boolean;
  41165. constructor(name: string, scene: Scene);
  41166. getEffect(): Effect;
  41167. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41168. /**
  41169. * Binds the given world matrix to the active effect
  41170. *
  41171. * @param world the matrix to bind
  41172. */
  41173. bindOnlyWorldMatrix(world: Matrix): void;
  41174. /**
  41175. * Binds the given normal matrix to the active effect
  41176. *
  41177. * @param normalMatrix the matrix to bind
  41178. */
  41179. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41180. bind(world: Matrix, mesh?: Mesh): void;
  41181. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41182. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41183. }
  41184. }
  41185. declare module "babylonjs/Materials/materialFlags" {
  41186. /**
  41187. * This groups all the flags used to control the materials channel.
  41188. */
  41189. export class MaterialFlags {
  41190. private static _DiffuseTextureEnabled;
  41191. /**
  41192. * Are diffuse textures enabled in the application.
  41193. */
  41194. static DiffuseTextureEnabled: boolean;
  41195. private static _AmbientTextureEnabled;
  41196. /**
  41197. * Are ambient textures enabled in the application.
  41198. */
  41199. static AmbientTextureEnabled: boolean;
  41200. private static _OpacityTextureEnabled;
  41201. /**
  41202. * Are opacity textures enabled in the application.
  41203. */
  41204. static OpacityTextureEnabled: boolean;
  41205. private static _ReflectionTextureEnabled;
  41206. /**
  41207. * Are reflection textures enabled in the application.
  41208. */
  41209. static ReflectionTextureEnabled: boolean;
  41210. private static _EmissiveTextureEnabled;
  41211. /**
  41212. * Are emissive textures enabled in the application.
  41213. */
  41214. static EmissiveTextureEnabled: boolean;
  41215. private static _SpecularTextureEnabled;
  41216. /**
  41217. * Are specular textures enabled in the application.
  41218. */
  41219. static SpecularTextureEnabled: boolean;
  41220. private static _BumpTextureEnabled;
  41221. /**
  41222. * Are bump textures enabled in the application.
  41223. */
  41224. static BumpTextureEnabled: boolean;
  41225. private static _LightmapTextureEnabled;
  41226. /**
  41227. * Are lightmap textures enabled in the application.
  41228. */
  41229. static LightmapTextureEnabled: boolean;
  41230. private static _RefractionTextureEnabled;
  41231. /**
  41232. * Are refraction textures enabled in the application.
  41233. */
  41234. static RefractionTextureEnabled: boolean;
  41235. private static _ColorGradingTextureEnabled;
  41236. /**
  41237. * Are color grading textures enabled in the application.
  41238. */
  41239. static ColorGradingTextureEnabled: boolean;
  41240. private static _FresnelEnabled;
  41241. /**
  41242. * Are fresnels enabled in the application.
  41243. */
  41244. static FresnelEnabled: boolean;
  41245. private static _ClearCoatTextureEnabled;
  41246. /**
  41247. * Are clear coat textures enabled in the application.
  41248. */
  41249. static ClearCoatTextureEnabled: boolean;
  41250. private static _ClearCoatBumpTextureEnabled;
  41251. /**
  41252. * Are clear coat bump textures enabled in the application.
  41253. */
  41254. static ClearCoatBumpTextureEnabled: boolean;
  41255. private static _ClearCoatTintTextureEnabled;
  41256. /**
  41257. * Are clear coat tint textures enabled in the application.
  41258. */
  41259. static ClearCoatTintTextureEnabled: boolean;
  41260. private static _SheenTextureEnabled;
  41261. /**
  41262. * Are sheen textures enabled in the application.
  41263. */
  41264. static SheenTextureEnabled: boolean;
  41265. private static _AnisotropicTextureEnabled;
  41266. /**
  41267. * Are anisotropic textures enabled in the application.
  41268. */
  41269. static AnisotropicTextureEnabled: boolean;
  41270. private static _ThicknessTextureEnabled;
  41271. /**
  41272. * Are thickness textures enabled in the application.
  41273. */
  41274. static ThicknessTextureEnabled: boolean;
  41275. }
  41276. }
  41277. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41278. /** @hidden */
  41279. export var defaultFragmentDeclaration: {
  41280. name: string;
  41281. shader: string;
  41282. };
  41283. }
  41284. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41285. /** @hidden */
  41286. export var defaultUboDeclaration: {
  41287. name: string;
  41288. shader: string;
  41289. };
  41290. }
  41291. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41292. /** @hidden */
  41293. export var lightFragmentDeclaration: {
  41294. name: string;
  41295. shader: string;
  41296. };
  41297. }
  41298. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41299. /** @hidden */
  41300. export var lightUboDeclaration: {
  41301. name: string;
  41302. shader: string;
  41303. };
  41304. }
  41305. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41306. /** @hidden */
  41307. export var lightsFragmentFunctions: {
  41308. name: string;
  41309. shader: string;
  41310. };
  41311. }
  41312. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41313. /** @hidden */
  41314. export var shadowsFragmentFunctions: {
  41315. name: string;
  41316. shader: string;
  41317. };
  41318. }
  41319. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41320. /** @hidden */
  41321. export var fresnelFunction: {
  41322. name: string;
  41323. shader: string;
  41324. };
  41325. }
  41326. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41327. /** @hidden */
  41328. export var reflectionFunction: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41334. /** @hidden */
  41335. export var bumpFragmentFunctions: {
  41336. name: string;
  41337. shader: string;
  41338. };
  41339. }
  41340. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41341. /** @hidden */
  41342. export var logDepthDeclaration: {
  41343. name: string;
  41344. shader: string;
  41345. };
  41346. }
  41347. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41348. /** @hidden */
  41349. export var bumpFragment: {
  41350. name: string;
  41351. shader: string;
  41352. };
  41353. }
  41354. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41355. /** @hidden */
  41356. export var depthPrePass: {
  41357. name: string;
  41358. shader: string;
  41359. };
  41360. }
  41361. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41362. /** @hidden */
  41363. export var lightFragment: {
  41364. name: string;
  41365. shader: string;
  41366. };
  41367. }
  41368. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41369. /** @hidden */
  41370. export var logDepthFragment: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/default.fragment" {
  41376. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41377. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41378. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41379. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41380. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41381. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41382. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41383. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41384. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41385. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41386. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41387. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41388. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41389. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41390. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41391. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41392. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41393. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41394. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41395. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41396. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41397. /** @hidden */
  41398. export var defaultPixelShader: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41404. /** @hidden */
  41405. export var defaultVertexDeclaration: {
  41406. name: string;
  41407. shader: string;
  41408. };
  41409. }
  41410. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41411. /** @hidden */
  41412. export var bumpVertexDeclaration: {
  41413. name: string;
  41414. shader: string;
  41415. };
  41416. }
  41417. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41418. /** @hidden */
  41419. export var bumpVertex: {
  41420. name: string;
  41421. shader: string;
  41422. };
  41423. }
  41424. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41425. /** @hidden */
  41426. export var fogVertex: {
  41427. name: string;
  41428. shader: string;
  41429. };
  41430. }
  41431. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41432. /** @hidden */
  41433. export var shadowsVertex: {
  41434. name: string;
  41435. shader: string;
  41436. };
  41437. }
  41438. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41439. /** @hidden */
  41440. export var pointCloudVertex: {
  41441. name: string;
  41442. shader: string;
  41443. };
  41444. }
  41445. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41446. /** @hidden */
  41447. export var logDepthVertex: {
  41448. name: string;
  41449. shader: string;
  41450. };
  41451. }
  41452. declare module "babylonjs/Shaders/default.vertex" {
  41453. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41454. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41455. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41457. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41458. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41460. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41461. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41462. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41465. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41469. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41471. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41472. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41473. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41474. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41475. /** @hidden */
  41476. export var defaultVertexShader: {
  41477. name: string;
  41478. shader: string;
  41479. };
  41480. }
  41481. declare module "babylonjs/Materials/standardMaterial" {
  41482. import { SmartArray } from "babylonjs/Misc/smartArray";
  41483. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41484. import { Nullable } from "babylonjs/types";
  41485. import { Scene } from "babylonjs/scene";
  41486. import { Matrix } from "babylonjs/Maths/math.vector";
  41487. import { Color3 } from "babylonjs/Maths/math.color";
  41488. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41490. import { Mesh } from "babylonjs/Meshes/mesh";
  41491. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41492. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41493. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41494. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41495. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41498. import "babylonjs/Shaders/default.fragment";
  41499. import "babylonjs/Shaders/default.vertex";
  41500. /** @hidden */
  41501. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41502. MAINUV1: boolean;
  41503. MAINUV2: boolean;
  41504. DIFFUSE: boolean;
  41505. DIFFUSEDIRECTUV: number;
  41506. AMBIENT: boolean;
  41507. AMBIENTDIRECTUV: number;
  41508. OPACITY: boolean;
  41509. OPACITYDIRECTUV: number;
  41510. OPACITYRGB: boolean;
  41511. REFLECTION: boolean;
  41512. EMISSIVE: boolean;
  41513. EMISSIVEDIRECTUV: number;
  41514. SPECULAR: boolean;
  41515. SPECULARDIRECTUV: number;
  41516. BUMP: boolean;
  41517. BUMPDIRECTUV: number;
  41518. PARALLAX: boolean;
  41519. PARALLAXOCCLUSION: boolean;
  41520. SPECULAROVERALPHA: boolean;
  41521. CLIPPLANE: boolean;
  41522. CLIPPLANE2: boolean;
  41523. CLIPPLANE3: boolean;
  41524. CLIPPLANE4: boolean;
  41525. ALPHATEST: boolean;
  41526. DEPTHPREPASS: boolean;
  41527. ALPHAFROMDIFFUSE: boolean;
  41528. POINTSIZE: boolean;
  41529. FOG: boolean;
  41530. SPECULARTERM: boolean;
  41531. DIFFUSEFRESNEL: boolean;
  41532. OPACITYFRESNEL: boolean;
  41533. REFLECTIONFRESNEL: boolean;
  41534. REFRACTIONFRESNEL: boolean;
  41535. EMISSIVEFRESNEL: boolean;
  41536. FRESNEL: boolean;
  41537. NORMAL: boolean;
  41538. UV1: boolean;
  41539. UV2: boolean;
  41540. VERTEXCOLOR: boolean;
  41541. VERTEXALPHA: boolean;
  41542. NUM_BONE_INFLUENCERS: number;
  41543. BonesPerMesh: number;
  41544. BONETEXTURE: boolean;
  41545. INSTANCES: boolean;
  41546. GLOSSINESS: boolean;
  41547. ROUGHNESS: boolean;
  41548. EMISSIVEASILLUMINATION: boolean;
  41549. LINKEMISSIVEWITHDIFFUSE: boolean;
  41550. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41551. LIGHTMAP: boolean;
  41552. LIGHTMAPDIRECTUV: number;
  41553. OBJECTSPACE_NORMALMAP: boolean;
  41554. USELIGHTMAPASSHADOWMAP: boolean;
  41555. REFLECTIONMAP_3D: boolean;
  41556. REFLECTIONMAP_SPHERICAL: boolean;
  41557. REFLECTIONMAP_PLANAR: boolean;
  41558. REFLECTIONMAP_CUBIC: boolean;
  41559. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41560. REFLECTIONMAP_PROJECTION: boolean;
  41561. REFLECTIONMAP_SKYBOX: boolean;
  41562. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41563. REFLECTIONMAP_EXPLICIT: boolean;
  41564. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41565. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41566. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41567. INVERTCUBICMAP: boolean;
  41568. LOGARITHMICDEPTH: boolean;
  41569. REFRACTION: boolean;
  41570. REFRACTIONMAP_3D: boolean;
  41571. REFLECTIONOVERALPHA: boolean;
  41572. TWOSIDEDLIGHTING: boolean;
  41573. SHADOWFLOAT: boolean;
  41574. MORPHTARGETS: boolean;
  41575. MORPHTARGETS_NORMAL: boolean;
  41576. MORPHTARGETS_TANGENT: boolean;
  41577. MORPHTARGETS_UV: boolean;
  41578. NUM_MORPH_INFLUENCERS: number;
  41579. NONUNIFORMSCALING: boolean;
  41580. PREMULTIPLYALPHA: boolean;
  41581. IMAGEPROCESSING: boolean;
  41582. VIGNETTE: boolean;
  41583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41584. VIGNETTEBLENDMODEOPAQUE: boolean;
  41585. TONEMAPPING: boolean;
  41586. TONEMAPPING_ACES: boolean;
  41587. CONTRAST: boolean;
  41588. COLORCURVES: boolean;
  41589. COLORGRADING: boolean;
  41590. COLORGRADING3D: boolean;
  41591. SAMPLER3DGREENDEPTH: boolean;
  41592. SAMPLER3DBGRMAP: boolean;
  41593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41594. MULTIVIEW: boolean;
  41595. /**
  41596. * If the reflection texture on this material is in linear color space
  41597. * @hidden
  41598. */
  41599. IS_REFLECTION_LINEAR: boolean;
  41600. /**
  41601. * If the refraction texture on this material is in linear color space
  41602. * @hidden
  41603. */
  41604. IS_REFRACTION_LINEAR: boolean;
  41605. EXPOSURE: boolean;
  41606. constructor();
  41607. setReflectionMode(modeToEnable: string): void;
  41608. }
  41609. /**
  41610. * This is the default material used in Babylon. It is the best trade off between quality
  41611. * and performances.
  41612. * @see http://doc.babylonjs.com/babylon101/materials
  41613. */
  41614. export class StandardMaterial extends PushMaterial {
  41615. private _diffuseTexture;
  41616. /**
  41617. * The basic texture of the material as viewed under a light.
  41618. */
  41619. diffuseTexture: Nullable<BaseTexture>;
  41620. private _ambientTexture;
  41621. /**
  41622. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41623. */
  41624. ambientTexture: Nullable<BaseTexture>;
  41625. private _opacityTexture;
  41626. /**
  41627. * Define the transparency of the material from a texture.
  41628. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41629. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41630. */
  41631. opacityTexture: Nullable<BaseTexture>;
  41632. private _reflectionTexture;
  41633. /**
  41634. * Define the texture used to display the reflection.
  41635. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41636. */
  41637. reflectionTexture: Nullable<BaseTexture>;
  41638. private _emissiveTexture;
  41639. /**
  41640. * Define texture of the material as if self lit.
  41641. * This will be mixed in the final result even in the absence of light.
  41642. */
  41643. emissiveTexture: Nullable<BaseTexture>;
  41644. private _specularTexture;
  41645. /**
  41646. * Define how the color and intensity of the highlight given by the light in the material.
  41647. */
  41648. specularTexture: Nullable<BaseTexture>;
  41649. private _bumpTexture;
  41650. /**
  41651. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41652. * 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.
  41653. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41654. */
  41655. bumpTexture: Nullable<BaseTexture>;
  41656. private _lightmapTexture;
  41657. /**
  41658. * Complex lighting can be computationally expensive to compute at runtime.
  41659. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41660. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41661. */
  41662. lightmapTexture: Nullable<BaseTexture>;
  41663. private _refractionTexture;
  41664. /**
  41665. * Define the texture used to display the refraction.
  41666. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41667. */
  41668. refractionTexture: Nullable<BaseTexture>;
  41669. /**
  41670. * The color of the material lit by the environmental background lighting.
  41671. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41672. */
  41673. ambientColor: Color3;
  41674. /**
  41675. * The basic color of the material as viewed under a light.
  41676. */
  41677. diffuseColor: Color3;
  41678. /**
  41679. * Define how the color and intensity of the highlight given by the light in the material.
  41680. */
  41681. specularColor: Color3;
  41682. /**
  41683. * Define the color of the material as if self lit.
  41684. * This will be mixed in the final result even in the absence of light.
  41685. */
  41686. emissiveColor: Color3;
  41687. /**
  41688. * Defines how sharp are the highlights in the material.
  41689. * The bigger the value the sharper giving a more glossy feeling to the result.
  41690. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41691. */
  41692. specularPower: number;
  41693. private _useAlphaFromDiffuseTexture;
  41694. /**
  41695. * Does the transparency come from the diffuse texture alpha channel.
  41696. */
  41697. useAlphaFromDiffuseTexture: boolean;
  41698. private _useEmissiveAsIllumination;
  41699. /**
  41700. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41701. */
  41702. useEmissiveAsIllumination: boolean;
  41703. private _linkEmissiveWithDiffuse;
  41704. /**
  41705. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41706. * the emissive level when the final color is close to one.
  41707. */
  41708. linkEmissiveWithDiffuse: boolean;
  41709. private _useSpecularOverAlpha;
  41710. /**
  41711. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41712. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41713. */
  41714. useSpecularOverAlpha: boolean;
  41715. private _useReflectionOverAlpha;
  41716. /**
  41717. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41718. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41719. */
  41720. useReflectionOverAlpha: boolean;
  41721. private _disableLighting;
  41722. /**
  41723. * Does lights from the scene impacts this material.
  41724. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41725. */
  41726. disableLighting: boolean;
  41727. private _useObjectSpaceNormalMap;
  41728. /**
  41729. * Allows using an object space normal map (instead of tangent space).
  41730. */
  41731. useObjectSpaceNormalMap: boolean;
  41732. private _useParallax;
  41733. /**
  41734. * Is parallax enabled or not.
  41735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41736. */
  41737. useParallax: boolean;
  41738. private _useParallaxOcclusion;
  41739. /**
  41740. * Is parallax occlusion enabled or not.
  41741. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41742. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41743. */
  41744. useParallaxOcclusion: boolean;
  41745. /**
  41746. * 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.
  41747. */
  41748. parallaxScaleBias: number;
  41749. private _roughness;
  41750. /**
  41751. * Helps to define how blurry the reflections should appears in the material.
  41752. */
  41753. roughness: number;
  41754. /**
  41755. * In case of refraction, define the value of the index of refraction.
  41756. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41757. */
  41758. indexOfRefraction: number;
  41759. /**
  41760. * Invert the refraction texture alongside the y axis.
  41761. * It can be useful with procedural textures or probe for instance.
  41762. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41763. */
  41764. invertRefractionY: boolean;
  41765. /**
  41766. * Defines the alpha limits in alpha test mode.
  41767. */
  41768. alphaCutOff: number;
  41769. private _useLightmapAsShadowmap;
  41770. /**
  41771. * In case of light mapping, define whether the map contains light or shadow informations.
  41772. */
  41773. useLightmapAsShadowmap: boolean;
  41774. private _diffuseFresnelParameters;
  41775. /**
  41776. * Define the diffuse fresnel parameters of the material.
  41777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41778. */
  41779. diffuseFresnelParameters: FresnelParameters;
  41780. private _opacityFresnelParameters;
  41781. /**
  41782. * Define the opacity fresnel parameters of the material.
  41783. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41784. */
  41785. opacityFresnelParameters: FresnelParameters;
  41786. private _reflectionFresnelParameters;
  41787. /**
  41788. * Define the reflection fresnel parameters of the material.
  41789. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41790. */
  41791. reflectionFresnelParameters: FresnelParameters;
  41792. private _refractionFresnelParameters;
  41793. /**
  41794. * Define the refraction fresnel parameters of the material.
  41795. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41796. */
  41797. refractionFresnelParameters: FresnelParameters;
  41798. private _emissiveFresnelParameters;
  41799. /**
  41800. * Define the emissive fresnel parameters of the material.
  41801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41802. */
  41803. emissiveFresnelParameters: FresnelParameters;
  41804. private _useReflectionFresnelFromSpecular;
  41805. /**
  41806. * If true automatically deducts the fresnels values from the material specularity.
  41807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41808. */
  41809. useReflectionFresnelFromSpecular: boolean;
  41810. private _useGlossinessFromSpecularMapAlpha;
  41811. /**
  41812. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41813. */
  41814. useGlossinessFromSpecularMapAlpha: boolean;
  41815. private _maxSimultaneousLights;
  41816. /**
  41817. * Defines the maximum number of lights that can be used in the material
  41818. */
  41819. maxSimultaneousLights: number;
  41820. private _invertNormalMapX;
  41821. /**
  41822. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41823. */
  41824. invertNormalMapX: boolean;
  41825. private _invertNormalMapY;
  41826. /**
  41827. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41828. */
  41829. invertNormalMapY: boolean;
  41830. private _twoSidedLighting;
  41831. /**
  41832. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41833. */
  41834. twoSidedLighting: boolean;
  41835. /**
  41836. * Default configuration related to image processing available in the standard Material.
  41837. */
  41838. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41839. /**
  41840. * Gets the image processing configuration used either in this material.
  41841. */
  41842. /**
  41843. * Sets the Default image processing configuration used either in the this material.
  41844. *
  41845. * If sets to null, the scene one is in use.
  41846. */
  41847. imageProcessingConfiguration: ImageProcessingConfiguration;
  41848. /**
  41849. * Keep track of the image processing observer to allow dispose and replace.
  41850. */
  41851. private _imageProcessingObserver;
  41852. /**
  41853. * Attaches a new image processing configuration to the Standard Material.
  41854. * @param configuration
  41855. */
  41856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41857. /**
  41858. * Gets wether the color curves effect is enabled.
  41859. */
  41860. /**
  41861. * Sets wether the color curves effect is enabled.
  41862. */
  41863. cameraColorCurvesEnabled: boolean;
  41864. /**
  41865. * Gets wether the color grading effect is enabled.
  41866. */
  41867. /**
  41868. * Gets wether the color grading effect is enabled.
  41869. */
  41870. cameraColorGradingEnabled: boolean;
  41871. /**
  41872. * Gets wether tonemapping is enabled or not.
  41873. */
  41874. /**
  41875. * Sets wether tonemapping is enabled or not
  41876. */
  41877. cameraToneMappingEnabled: boolean;
  41878. /**
  41879. * The camera exposure used on this material.
  41880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41881. * This corresponds to a photographic exposure.
  41882. */
  41883. /**
  41884. * The camera exposure used on this material.
  41885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41886. * This corresponds to a photographic exposure.
  41887. */
  41888. cameraExposure: number;
  41889. /**
  41890. * Gets The camera contrast used on this material.
  41891. */
  41892. /**
  41893. * Sets The camera contrast used on this material.
  41894. */
  41895. cameraContrast: number;
  41896. /**
  41897. * Gets the Color Grading 2D Lookup Texture.
  41898. */
  41899. /**
  41900. * Sets the Color Grading 2D Lookup Texture.
  41901. */
  41902. cameraColorGradingTexture: Nullable<BaseTexture>;
  41903. /**
  41904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41906. * 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;
  41907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41908. */
  41909. /**
  41910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41912. * 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;
  41913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41914. */
  41915. cameraColorCurves: Nullable<ColorCurves>;
  41916. /**
  41917. * Custom callback helping to override the default shader used in the material.
  41918. */
  41919. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41920. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41921. protected _worldViewProjectionMatrix: Matrix;
  41922. protected _globalAmbientColor: Color3;
  41923. protected _useLogarithmicDepth: boolean;
  41924. protected _rebuildInParallel: boolean;
  41925. /**
  41926. * Instantiates a new standard material.
  41927. * This is the default material used in Babylon. It is the best trade off between quality
  41928. * and performances.
  41929. * @see http://doc.babylonjs.com/babylon101/materials
  41930. * @param name Define the name of the material in the scene
  41931. * @param scene Define the scene the material belong to
  41932. */
  41933. constructor(name: string, scene: Scene);
  41934. /**
  41935. * Gets a boolean indicating that current material needs to register RTT
  41936. */
  41937. readonly hasRenderTargetTextures: boolean;
  41938. /**
  41939. * Gets the current class name of the material e.g. "StandardMaterial"
  41940. * Mainly use in serialization.
  41941. * @returns the class name
  41942. */
  41943. getClassName(): string;
  41944. /**
  41945. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41946. * You can try switching to logarithmic depth.
  41947. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41948. */
  41949. useLogarithmicDepth: boolean;
  41950. /**
  41951. * Specifies if the material will require alpha blending
  41952. * @returns a boolean specifying if alpha blending is needed
  41953. */
  41954. needAlphaBlending(): boolean;
  41955. /**
  41956. * Specifies if this material should be rendered in alpha test mode
  41957. * @returns a boolean specifying if an alpha test is needed.
  41958. */
  41959. needAlphaTesting(): boolean;
  41960. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41961. /**
  41962. * Get the texture used for alpha test purpose.
  41963. * @returns the diffuse texture in case of the standard material.
  41964. */
  41965. getAlphaTestTexture(): Nullable<BaseTexture>;
  41966. /**
  41967. * Get if the submesh is ready to be used and all its information available.
  41968. * Child classes can use it to update shaders
  41969. * @param mesh defines the mesh to check
  41970. * @param subMesh defines which submesh to check
  41971. * @param useInstances specifies that instances should be used
  41972. * @returns a boolean indicating that the submesh is ready or not
  41973. */
  41974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41975. /**
  41976. * Builds the material UBO layouts.
  41977. * Used internally during the effect preparation.
  41978. */
  41979. buildUniformLayout(): void;
  41980. /**
  41981. * Unbinds the material from the mesh
  41982. */
  41983. unbind(): void;
  41984. /**
  41985. * Binds the submesh to this material by preparing the effect and shader to draw
  41986. * @param world defines the world transformation matrix
  41987. * @param mesh defines the mesh containing the submesh
  41988. * @param subMesh defines the submesh to bind the material to
  41989. */
  41990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41991. /**
  41992. * Get the list of animatables in the material.
  41993. * @returns the list of animatables object used in the material
  41994. */
  41995. getAnimatables(): IAnimatable[];
  41996. /**
  41997. * Gets the active textures from the material
  41998. * @returns an array of textures
  41999. */
  42000. getActiveTextures(): BaseTexture[];
  42001. /**
  42002. * Specifies if the material uses a texture
  42003. * @param texture defines the texture to check against the material
  42004. * @returns a boolean specifying if the material uses the texture
  42005. */
  42006. hasTexture(texture: BaseTexture): boolean;
  42007. /**
  42008. * Disposes the material
  42009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42011. */
  42012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42013. /**
  42014. * Makes a duplicate of the material, and gives it a new name
  42015. * @param name defines the new name for the duplicated material
  42016. * @returns the cloned material
  42017. */
  42018. clone(name: string): StandardMaterial;
  42019. /**
  42020. * Serializes this material in a JSON representation
  42021. * @returns the serialized material object
  42022. */
  42023. serialize(): any;
  42024. /**
  42025. * Creates a standard material from parsed material data
  42026. * @param source defines the JSON representation of the material
  42027. * @param scene defines the hosting scene
  42028. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42029. * @returns a new standard material
  42030. */
  42031. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42032. /**
  42033. * Are diffuse textures enabled in the application.
  42034. */
  42035. static DiffuseTextureEnabled: boolean;
  42036. /**
  42037. * Are ambient textures enabled in the application.
  42038. */
  42039. static AmbientTextureEnabled: boolean;
  42040. /**
  42041. * Are opacity textures enabled in the application.
  42042. */
  42043. static OpacityTextureEnabled: boolean;
  42044. /**
  42045. * Are reflection textures enabled in the application.
  42046. */
  42047. static ReflectionTextureEnabled: boolean;
  42048. /**
  42049. * Are emissive textures enabled in the application.
  42050. */
  42051. static EmissiveTextureEnabled: boolean;
  42052. /**
  42053. * Are specular textures enabled in the application.
  42054. */
  42055. static SpecularTextureEnabled: boolean;
  42056. /**
  42057. * Are bump textures enabled in the application.
  42058. */
  42059. static BumpTextureEnabled: boolean;
  42060. /**
  42061. * Are lightmap textures enabled in the application.
  42062. */
  42063. static LightmapTextureEnabled: boolean;
  42064. /**
  42065. * Are refraction textures enabled in the application.
  42066. */
  42067. static RefractionTextureEnabled: boolean;
  42068. /**
  42069. * Are color grading textures enabled in the application.
  42070. */
  42071. static ColorGradingTextureEnabled: boolean;
  42072. /**
  42073. * Are fresnels enabled in the application.
  42074. */
  42075. static FresnelEnabled: boolean;
  42076. }
  42077. }
  42078. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42079. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42080. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42081. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42082. /** @hidden */
  42083. export var imageProcessingPixelShader: {
  42084. name: string;
  42085. shader: string;
  42086. };
  42087. }
  42088. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42089. import { Nullable } from "babylonjs/types";
  42090. import { Color4 } from "babylonjs/Maths/math.color";
  42091. import { Camera } from "babylonjs/Cameras/camera";
  42092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42093. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42094. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42095. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42096. import { Engine } from "babylonjs/Engines/engine";
  42097. import "babylonjs/Shaders/imageProcessing.fragment";
  42098. import "babylonjs/Shaders/postprocess.vertex";
  42099. /**
  42100. * ImageProcessingPostProcess
  42101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42102. */
  42103. export class ImageProcessingPostProcess extends PostProcess {
  42104. /**
  42105. * Default configuration related to image processing available in the PBR Material.
  42106. */
  42107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42108. /**
  42109. * Gets the image processing configuration used either in this material.
  42110. */
  42111. /**
  42112. * Sets the Default image processing configuration used either in the this material.
  42113. *
  42114. * If sets to null, the scene one is in use.
  42115. */
  42116. imageProcessingConfiguration: ImageProcessingConfiguration;
  42117. /**
  42118. * Keep track of the image processing observer to allow dispose and replace.
  42119. */
  42120. private _imageProcessingObserver;
  42121. /**
  42122. * Attaches a new image processing configuration to the PBR Material.
  42123. * @param configuration
  42124. */
  42125. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42126. /**
  42127. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42128. */
  42129. /**
  42130. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42131. */
  42132. colorCurves: Nullable<ColorCurves>;
  42133. /**
  42134. * Gets wether the color curves effect is enabled.
  42135. */
  42136. /**
  42137. * Sets wether the color curves effect is enabled.
  42138. */
  42139. colorCurvesEnabled: boolean;
  42140. /**
  42141. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42142. */
  42143. /**
  42144. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42145. */
  42146. colorGradingTexture: Nullable<BaseTexture>;
  42147. /**
  42148. * Gets wether the color grading effect is enabled.
  42149. */
  42150. /**
  42151. * Gets wether the color grading effect is enabled.
  42152. */
  42153. colorGradingEnabled: boolean;
  42154. /**
  42155. * Gets exposure used in the effect.
  42156. */
  42157. /**
  42158. * Sets exposure used in the effect.
  42159. */
  42160. exposure: number;
  42161. /**
  42162. * Gets wether tonemapping is enabled or not.
  42163. */
  42164. /**
  42165. * Sets wether tonemapping is enabled or not
  42166. */
  42167. toneMappingEnabled: boolean;
  42168. /**
  42169. * Gets the type of tone mapping effect.
  42170. */
  42171. /**
  42172. * Sets the type of tone mapping effect.
  42173. */
  42174. toneMappingType: number;
  42175. /**
  42176. * Gets contrast used in the effect.
  42177. */
  42178. /**
  42179. * Sets contrast used in the effect.
  42180. */
  42181. contrast: number;
  42182. /**
  42183. * Gets Vignette stretch size.
  42184. */
  42185. /**
  42186. * Sets Vignette stretch size.
  42187. */
  42188. vignetteStretch: number;
  42189. /**
  42190. * Gets Vignette centre X Offset.
  42191. */
  42192. /**
  42193. * Sets Vignette centre X Offset.
  42194. */
  42195. vignetteCentreX: number;
  42196. /**
  42197. * Gets Vignette centre Y Offset.
  42198. */
  42199. /**
  42200. * Sets Vignette centre Y Offset.
  42201. */
  42202. vignetteCentreY: number;
  42203. /**
  42204. * Gets Vignette weight or intensity of the vignette effect.
  42205. */
  42206. /**
  42207. * Sets Vignette weight or intensity of the vignette effect.
  42208. */
  42209. vignetteWeight: number;
  42210. /**
  42211. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42212. * if vignetteEnabled is set to true.
  42213. */
  42214. /**
  42215. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42216. * if vignetteEnabled is set to true.
  42217. */
  42218. vignetteColor: Color4;
  42219. /**
  42220. * Gets Camera field of view used by the Vignette effect.
  42221. */
  42222. /**
  42223. * Sets Camera field of view used by the Vignette effect.
  42224. */
  42225. vignetteCameraFov: number;
  42226. /**
  42227. * Gets the vignette blend mode allowing different kind of effect.
  42228. */
  42229. /**
  42230. * Sets the vignette blend mode allowing different kind of effect.
  42231. */
  42232. vignetteBlendMode: number;
  42233. /**
  42234. * Gets wether the vignette effect is enabled.
  42235. */
  42236. /**
  42237. * Sets wether the vignette effect is enabled.
  42238. */
  42239. vignetteEnabled: boolean;
  42240. private _fromLinearSpace;
  42241. /**
  42242. * Gets wether the input of the processing is in Gamma or Linear Space.
  42243. */
  42244. /**
  42245. * Sets wether the input of the processing is in Gamma or Linear Space.
  42246. */
  42247. fromLinearSpace: boolean;
  42248. /**
  42249. * Defines cache preventing GC.
  42250. */
  42251. private _defines;
  42252. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42253. /**
  42254. * "ImageProcessingPostProcess"
  42255. * @returns "ImageProcessingPostProcess"
  42256. */
  42257. getClassName(): string;
  42258. protected _updateParameters(): void;
  42259. dispose(camera?: Camera): void;
  42260. }
  42261. }
  42262. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42263. import { Scene } from "babylonjs/scene";
  42264. import { Color3 } from "babylonjs/Maths/math.color";
  42265. import { Mesh } from "babylonjs/Meshes/mesh";
  42266. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42267. import { Nullable } from "babylonjs/types";
  42268. /**
  42269. * Class containing static functions to help procedurally build meshes
  42270. */
  42271. export class GroundBuilder {
  42272. /**
  42273. * Creates a ground mesh
  42274. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42275. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42277. * @param name defines the name of the mesh
  42278. * @param options defines the options used to create the mesh
  42279. * @param scene defines the hosting scene
  42280. * @returns the ground mesh
  42281. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42282. */
  42283. static CreateGround(name: string, options: {
  42284. width?: number;
  42285. height?: number;
  42286. subdivisions?: number;
  42287. subdivisionsX?: number;
  42288. subdivisionsY?: number;
  42289. updatable?: boolean;
  42290. }, scene: any): Mesh;
  42291. /**
  42292. * Creates a tiled ground mesh
  42293. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42294. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42295. * * 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
  42296. * * 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
  42297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42298. * @param name defines the name of the mesh
  42299. * @param options defines the options used to create the mesh
  42300. * @param scene defines the hosting scene
  42301. * @returns the tiled ground mesh
  42302. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42303. */
  42304. static CreateTiledGround(name: string, options: {
  42305. xmin: number;
  42306. zmin: number;
  42307. xmax: number;
  42308. zmax: number;
  42309. subdivisions?: {
  42310. w: number;
  42311. h: number;
  42312. };
  42313. precision?: {
  42314. w: number;
  42315. h: number;
  42316. };
  42317. updatable?: boolean;
  42318. }, scene?: Nullable<Scene>): Mesh;
  42319. /**
  42320. * Creates a ground mesh from a height map
  42321. * * The parameter `url` sets the URL of the height map image resource.
  42322. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42323. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42324. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42325. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42326. * * 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.
  42327. * * 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).
  42328. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42330. * @param name defines the name of the mesh
  42331. * @param url defines the url to the height map
  42332. * @param options defines the options used to create the mesh
  42333. * @param scene defines the hosting scene
  42334. * @returns the ground mesh
  42335. * @see https://doc.babylonjs.com/babylon101/height_map
  42336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42337. */
  42338. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42339. width?: number;
  42340. height?: number;
  42341. subdivisions?: number;
  42342. minHeight?: number;
  42343. maxHeight?: number;
  42344. colorFilter?: Color3;
  42345. alphaFilter?: number;
  42346. updatable?: boolean;
  42347. onReady?: (mesh: GroundMesh) => void;
  42348. }, scene?: Nullable<Scene>): GroundMesh;
  42349. }
  42350. }
  42351. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42352. import { Vector4 } from "babylonjs/Maths/math.vector";
  42353. import { Mesh } from "babylonjs/Meshes/mesh";
  42354. /**
  42355. * Class containing static functions to help procedurally build meshes
  42356. */
  42357. export class TorusBuilder {
  42358. /**
  42359. * Creates a torus mesh
  42360. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42361. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42362. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42366. * @param name defines the name of the mesh
  42367. * @param options defines the options used to create the mesh
  42368. * @param scene defines the hosting scene
  42369. * @returns the torus mesh
  42370. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42371. */
  42372. static CreateTorus(name: string, options: {
  42373. diameter?: number;
  42374. thickness?: number;
  42375. tessellation?: number;
  42376. updatable?: boolean;
  42377. sideOrientation?: number;
  42378. frontUVs?: Vector4;
  42379. backUVs?: Vector4;
  42380. }, scene: any): Mesh;
  42381. }
  42382. }
  42383. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42384. import { Vector4 } from "babylonjs/Maths/math.vector";
  42385. import { Color4 } from "babylonjs/Maths/math.color";
  42386. import { Mesh } from "babylonjs/Meshes/mesh";
  42387. /**
  42388. * Class containing static functions to help procedurally build meshes
  42389. */
  42390. export class CylinderBuilder {
  42391. /**
  42392. * Creates a cylinder or a cone mesh
  42393. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42394. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42395. * * 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.
  42396. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42397. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42398. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42399. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42400. * * 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).
  42401. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42402. * * 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).
  42403. * * 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
  42404. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42405. * * 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
  42406. * * 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.
  42407. * * If `enclose` is false, a ring surface is one element.
  42408. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42409. * * 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
  42410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42413. * @param name defines the name of the mesh
  42414. * @param options defines the options used to create the mesh
  42415. * @param scene defines the hosting scene
  42416. * @returns the cylinder mesh
  42417. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42418. */
  42419. static CreateCylinder(name: string, options: {
  42420. height?: number;
  42421. diameterTop?: number;
  42422. diameterBottom?: number;
  42423. diameter?: number;
  42424. tessellation?: number;
  42425. subdivisions?: number;
  42426. arc?: number;
  42427. faceColors?: Color4[];
  42428. faceUV?: Vector4[];
  42429. updatable?: boolean;
  42430. hasRings?: boolean;
  42431. enclose?: boolean;
  42432. cap?: number;
  42433. sideOrientation?: number;
  42434. frontUVs?: Vector4;
  42435. backUVs?: Vector4;
  42436. }, scene: any): Mesh;
  42437. }
  42438. }
  42439. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42440. import { Observable } from "babylonjs/Misc/observable";
  42441. import { Nullable } from "babylonjs/types";
  42442. import { Camera } from "babylonjs/Cameras/camera";
  42443. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42444. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42445. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42446. import { Scene } from "babylonjs/scene";
  42447. import { Vector3 } from "babylonjs/Maths/math.vector";
  42448. import { Color3 } from "babylonjs/Maths/math.color";
  42449. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42451. import { Mesh } from "babylonjs/Meshes/mesh";
  42452. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42453. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42454. import "babylonjs/Meshes/Builders/groundBuilder";
  42455. import "babylonjs/Meshes/Builders/torusBuilder";
  42456. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42457. import "babylonjs/Gamepads/gamepadSceneComponent";
  42458. import "babylonjs/Animations/animatable";
  42459. /**
  42460. * Options to modify the vr teleportation behavior.
  42461. */
  42462. export interface VRTeleportationOptions {
  42463. /**
  42464. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42465. */
  42466. floorMeshName?: string;
  42467. /**
  42468. * A list of meshes to be used as the teleportation floor. (default: empty)
  42469. */
  42470. floorMeshes?: Mesh[];
  42471. }
  42472. /**
  42473. * Options to modify the vr experience helper's behavior.
  42474. */
  42475. export interface VRExperienceHelperOptions extends WebVROptions {
  42476. /**
  42477. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42478. */
  42479. createDeviceOrientationCamera?: boolean;
  42480. /**
  42481. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42482. */
  42483. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42484. /**
  42485. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42486. */
  42487. laserToggle?: boolean;
  42488. /**
  42489. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42490. */
  42491. floorMeshes?: Mesh[];
  42492. /**
  42493. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42494. */
  42495. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42496. }
  42497. /**
  42498. * Event containing information after VR has been entered
  42499. */
  42500. export class OnAfterEnteringVRObservableEvent {
  42501. /**
  42502. * If entering vr was successful
  42503. */
  42504. success: boolean;
  42505. }
  42506. /**
  42507. * Helps to quickly add VR support to an existing scene.
  42508. * See http://doc.babylonjs.com/how_to/webvr_helper
  42509. */
  42510. export class VRExperienceHelper {
  42511. /** Options to modify the vr experience helper's behavior. */
  42512. webVROptions: VRExperienceHelperOptions;
  42513. private _scene;
  42514. private _position;
  42515. private _btnVR;
  42516. private _btnVRDisplayed;
  42517. private _webVRsupported;
  42518. private _webVRready;
  42519. private _webVRrequesting;
  42520. private _webVRpresenting;
  42521. private _hasEnteredVR;
  42522. private _fullscreenVRpresenting;
  42523. private _canvas;
  42524. private _webVRCamera;
  42525. private _vrDeviceOrientationCamera;
  42526. private _deviceOrientationCamera;
  42527. private _existingCamera;
  42528. private _onKeyDown;
  42529. private _onVrDisplayPresentChange;
  42530. private _onVRDisplayChanged;
  42531. private _onVRRequestPresentStart;
  42532. private _onVRRequestPresentComplete;
  42533. /**
  42534. * 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)
  42535. */
  42536. enableGazeEvenWhenNoPointerLock: boolean;
  42537. /**
  42538. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42539. */
  42540. exitVROnDoubleTap: boolean;
  42541. /**
  42542. * Observable raised right before entering VR.
  42543. */
  42544. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42545. /**
  42546. * Observable raised when entering VR has completed.
  42547. */
  42548. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42549. /**
  42550. * Observable raised when exiting VR.
  42551. */
  42552. onExitingVRObservable: Observable<VRExperienceHelper>;
  42553. /**
  42554. * Observable raised when controller mesh is loaded.
  42555. */
  42556. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42557. /** Return this.onEnteringVRObservable
  42558. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42559. */
  42560. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42561. /** Return this.onExitingVRObservable
  42562. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42563. */
  42564. readonly onExitingVR: Observable<VRExperienceHelper>;
  42565. /** Return this.onControllerMeshLoadedObservable
  42566. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42567. */
  42568. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42569. private _rayLength;
  42570. private _useCustomVRButton;
  42571. private _teleportationRequested;
  42572. private _teleportActive;
  42573. private _floorMeshName;
  42574. private _floorMeshesCollection;
  42575. private _rotationAllowed;
  42576. private _teleportBackwardsVector;
  42577. private _teleportationTarget;
  42578. private _isDefaultTeleportationTarget;
  42579. private _postProcessMove;
  42580. private _teleportationFillColor;
  42581. private _teleportationBorderColor;
  42582. private _rotationAngle;
  42583. private _haloCenter;
  42584. private _cameraGazer;
  42585. private _padSensibilityUp;
  42586. private _padSensibilityDown;
  42587. private _leftController;
  42588. private _rightController;
  42589. /**
  42590. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42591. */
  42592. onNewMeshSelected: Observable<AbstractMesh>;
  42593. /**
  42594. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42595. * This observable will provide the mesh and the controller used to select the mesh
  42596. */
  42597. onMeshSelectedWithController: Observable<{
  42598. mesh: AbstractMesh;
  42599. controller: WebVRController;
  42600. }>;
  42601. /**
  42602. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42603. */
  42604. onNewMeshPicked: Observable<PickingInfo>;
  42605. private _circleEase;
  42606. /**
  42607. * Observable raised before camera teleportation
  42608. */
  42609. onBeforeCameraTeleport: Observable<Vector3>;
  42610. /**
  42611. * Observable raised after camera teleportation
  42612. */
  42613. onAfterCameraTeleport: Observable<Vector3>;
  42614. /**
  42615. * Observable raised when current selected mesh gets unselected
  42616. */
  42617. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42618. private _raySelectionPredicate;
  42619. /**
  42620. * To be optionaly changed by user to define custom ray selection
  42621. */
  42622. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42623. /**
  42624. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42625. */
  42626. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42627. /**
  42628. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42629. */
  42630. teleportationEnabled: boolean;
  42631. private _defaultHeight;
  42632. private _teleportationInitialized;
  42633. private _interactionsEnabled;
  42634. private _interactionsRequested;
  42635. private _displayGaze;
  42636. private _displayLaserPointer;
  42637. /**
  42638. * The mesh used to display where the user is going to teleport.
  42639. */
  42640. /**
  42641. * Sets the mesh to be used to display where the user is going to teleport.
  42642. */
  42643. teleportationTarget: Mesh;
  42644. /**
  42645. * 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
  42646. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42647. * See http://doc.babylonjs.com/resources/baking_transformations
  42648. */
  42649. gazeTrackerMesh: Mesh;
  42650. /**
  42651. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42652. */
  42653. updateGazeTrackerScale: boolean;
  42654. /**
  42655. * If the gaze trackers color should be updated when selecting meshes
  42656. */
  42657. updateGazeTrackerColor: boolean;
  42658. /**
  42659. * If the controller laser color should be updated when selecting meshes
  42660. */
  42661. updateControllerLaserColor: boolean;
  42662. /**
  42663. * The gaze tracking mesh corresponding to the left controller
  42664. */
  42665. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42666. /**
  42667. * The gaze tracking mesh corresponding to the right controller
  42668. */
  42669. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42670. /**
  42671. * If the ray of the gaze should be displayed.
  42672. */
  42673. /**
  42674. * Sets if the ray of the gaze should be displayed.
  42675. */
  42676. displayGaze: boolean;
  42677. /**
  42678. * If the ray of the LaserPointer should be displayed.
  42679. */
  42680. /**
  42681. * Sets if the ray of the LaserPointer should be displayed.
  42682. */
  42683. displayLaserPointer: boolean;
  42684. /**
  42685. * The deviceOrientationCamera used as the camera when not in VR.
  42686. */
  42687. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42688. /**
  42689. * Based on the current WebVR support, returns the current VR camera used.
  42690. */
  42691. readonly currentVRCamera: Nullable<Camera>;
  42692. /**
  42693. * The webVRCamera which is used when in VR.
  42694. */
  42695. readonly webVRCamera: WebVRFreeCamera;
  42696. /**
  42697. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42698. */
  42699. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42700. /**
  42701. * The html button that is used to trigger entering into VR.
  42702. */
  42703. readonly vrButton: Nullable<HTMLButtonElement>;
  42704. private readonly _teleportationRequestInitiated;
  42705. /**
  42706. * Defines wether or not Pointer lock should be requested when switching to
  42707. * full screen.
  42708. */
  42709. requestPointerLockOnFullScreen: boolean;
  42710. /**
  42711. * Instantiates a VRExperienceHelper.
  42712. * Helps to quickly add VR support to an existing scene.
  42713. * @param scene The scene the VRExperienceHelper belongs to.
  42714. * @param webVROptions Options to modify the vr experience helper's behavior.
  42715. */
  42716. constructor(scene: Scene,
  42717. /** Options to modify the vr experience helper's behavior. */
  42718. webVROptions?: VRExperienceHelperOptions);
  42719. private _onDefaultMeshLoaded;
  42720. private _onResize;
  42721. private _onFullscreenChange;
  42722. /**
  42723. * Gets a value indicating if we are currently in VR mode.
  42724. */
  42725. readonly isInVRMode: boolean;
  42726. private onVrDisplayPresentChange;
  42727. private onVRDisplayChanged;
  42728. private moveButtonToBottomRight;
  42729. private displayVRButton;
  42730. private updateButtonVisibility;
  42731. private _cachedAngularSensibility;
  42732. /**
  42733. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42734. * Otherwise, will use the fullscreen API.
  42735. */
  42736. enterVR(): void;
  42737. /**
  42738. * Attempt to exit VR, or fullscreen.
  42739. */
  42740. exitVR(): void;
  42741. /**
  42742. * The position of the vr experience helper.
  42743. */
  42744. /**
  42745. * Sets the position of the vr experience helper.
  42746. */
  42747. position: Vector3;
  42748. /**
  42749. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42750. */
  42751. enableInteractions(): void;
  42752. private readonly _noControllerIsActive;
  42753. private beforeRender;
  42754. private _isTeleportationFloor;
  42755. /**
  42756. * Adds a floor mesh to be used for teleportation.
  42757. * @param floorMesh the mesh to be used for teleportation.
  42758. */
  42759. addFloorMesh(floorMesh: Mesh): void;
  42760. /**
  42761. * Removes a floor mesh from being used for teleportation.
  42762. * @param floorMesh the mesh to be removed.
  42763. */
  42764. removeFloorMesh(floorMesh: Mesh): void;
  42765. /**
  42766. * Enables interactions and teleportation using the VR controllers and gaze.
  42767. * @param vrTeleportationOptions options to modify teleportation behavior.
  42768. */
  42769. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42770. private _onNewGamepadConnected;
  42771. private _tryEnableInteractionOnController;
  42772. private _onNewGamepadDisconnected;
  42773. private _enableInteractionOnController;
  42774. private _checkTeleportWithRay;
  42775. private _checkRotate;
  42776. private _checkTeleportBackwards;
  42777. private _enableTeleportationOnController;
  42778. private _createTeleportationCircles;
  42779. private _displayTeleportationTarget;
  42780. private _hideTeleportationTarget;
  42781. private _rotateCamera;
  42782. private _moveTeleportationSelectorTo;
  42783. private _workingVector;
  42784. private _workingQuaternion;
  42785. private _workingMatrix;
  42786. /**
  42787. * Teleports the users feet to the desired location
  42788. * @param location The location where the user's feet should be placed
  42789. */
  42790. teleportCamera(location: Vector3): void;
  42791. private _convertNormalToDirectionOfRay;
  42792. private _castRayAndSelectObject;
  42793. private _notifySelectedMeshUnselected;
  42794. /**
  42795. * Sets the color of the laser ray from the vr controllers.
  42796. * @param color new color for the ray.
  42797. */
  42798. changeLaserColor(color: Color3): void;
  42799. /**
  42800. * Sets the color of the ray from the vr headsets gaze.
  42801. * @param color new color for the ray.
  42802. */
  42803. changeGazeColor(color: Color3): void;
  42804. /**
  42805. * Exits VR and disposes of the vr experience helper
  42806. */
  42807. dispose(): void;
  42808. /**
  42809. * Gets the name of the VRExperienceHelper class
  42810. * @returns "VRExperienceHelper"
  42811. */
  42812. getClassName(): string;
  42813. }
  42814. }
  42815. declare module "babylonjs/Cameras/VR/index" {
  42816. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42817. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42818. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42819. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42820. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42821. export * from "babylonjs/Cameras/VR/webVRCamera";
  42822. }
  42823. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42824. import { Observable } from "babylonjs/Misc/observable";
  42825. import { Nullable } from "babylonjs/types";
  42826. import { IDisposable, Scene } from "babylonjs/scene";
  42827. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42828. /**
  42829. * Manages an XRSession to work with Babylon's engine
  42830. * @see https://doc.babylonjs.com/how_to/webxr
  42831. */
  42832. export class WebXRSessionManager implements IDisposable {
  42833. private scene;
  42834. /**
  42835. * Fires every time a new xrFrame arrives which can be used to update the camera
  42836. */
  42837. onXRFrameObservable: Observable<any>;
  42838. /**
  42839. * Fires when the xr session is ended either by the device or manually done
  42840. */
  42841. onXRSessionEnded: Observable<any>;
  42842. /**
  42843. * Underlying xr session
  42844. */
  42845. session: XRSession;
  42846. /**
  42847. * Type of reference space used when creating the session
  42848. */
  42849. referenceSpace: XRReferenceSpace;
  42850. /** @hidden */
  42851. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42852. /**
  42853. * Current XR frame
  42854. */
  42855. currentFrame: Nullable<XRFrame>;
  42856. private _xrNavigator;
  42857. private baseLayer;
  42858. /**
  42859. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42860. * @param scene The scene which the session should be created for
  42861. */
  42862. constructor(scene: Scene);
  42863. /**
  42864. * Initializes the manager
  42865. * After initialization enterXR can be called to start an XR session
  42866. * @returns Promise which resolves after it is initialized
  42867. */
  42868. initializeAsync(): Promise<void>;
  42869. /**
  42870. * Initializes an xr session
  42871. * @param xrSessionMode mode to initialize
  42872. * @returns a promise which will resolve once the session has been initialized
  42873. */
  42874. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42875. /**
  42876. * Sets the reference space on the xr session
  42877. * @param referenceSpace space to set
  42878. * @returns a promise that will resolve once the reference space has been set
  42879. */
  42880. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42881. /**
  42882. * Updates the render state of the session
  42883. * @param state state to set
  42884. * @returns a promise that resolves once the render state has been updated
  42885. */
  42886. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42887. /**
  42888. * Starts rendering to the xr layer
  42889. * @returns a promise that will resolve once rendering has started
  42890. */
  42891. startRenderingToXRAsync(): Promise<void>;
  42892. /**
  42893. * Stops the xrSession and restores the renderloop
  42894. * @returns Promise which resolves after it exits XR
  42895. */
  42896. exitXRAsync(): Promise<unknown>;
  42897. /**
  42898. * Checks if a session would be supported for the creation options specified
  42899. * @param sessionMode session mode to check if supported eg. immersive-vr
  42900. * @returns true if supported
  42901. */
  42902. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42903. /**
  42904. * @hidden
  42905. * Converts the render layer of xrSession to a render target
  42906. * @param session session to create render target for
  42907. * @param scene scene the new render target should be created for
  42908. */
  42909. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42910. /**
  42911. * Disposes of the session manager
  42912. */
  42913. dispose(): void;
  42914. }
  42915. }
  42916. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42917. import { Scene } from "babylonjs/scene";
  42918. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42919. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42920. /**
  42921. * WebXR Camera which holds the views for the xrSession
  42922. * @see https://doc.babylonjs.com/how_to/webxr
  42923. */
  42924. export class WebXRCamera extends FreeCamera {
  42925. private static _TmpMatrix;
  42926. /**
  42927. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42928. * @param name the name of the camera
  42929. * @param scene the scene to add the camera to
  42930. */
  42931. constructor(name: string, scene: Scene);
  42932. private _updateNumberOfRigCameras;
  42933. /** @hidden */
  42934. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42935. /**
  42936. * Updates the cameras position from the current pose information of the XR session
  42937. * @param xrSessionManager the session containing pose information
  42938. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42939. */
  42940. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42944. import { Nullable } from "babylonjs/types";
  42945. import { IDisposable } from "babylonjs/scene";
  42946. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42947. /**
  42948. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42949. */
  42950. export class WebXRManagedOutputCanvas implements IDisposable {
  42951. private helper;
  42952. private _canvas;
  42953. /**
  42954. * xrpresent context of the canvas which can be used to display/mirror xr content
  42955. */
  42956. canvasContext: WebGLRenderingContext;
  42957. /**
  42958. * xr layer for the canvas
  42959. */
  42960. xrLayer: Nullable<XRWebGLLayer>;
  42961. /**
  42962. * Initializes the xr layer for the session
  42963. * @param xrSession xr session
  42964. * @returns a promise that will resolve once the XR Layer has been created
  42965. */
  42966. initializeXRLayerAsync(xrSession: any): any;
  42967. /**
  42968. * Initializes the canvas to be added/removed upon entering/exiting xr
  42969. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42970. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42971. */
  42972. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42973. /**
  42974. * Disposes of the object
  42975. */
  42976. dispose(): void;
  42977. private _setManagedOutputCanvas;
  42978. private _addCanvas;
  42979. private _removeCanvas;
  42980. }
  42981. }
  42982. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42983. import { Observable } from "babylonjs/Misc/observable";
  42984. import { IDisposable, Scene } from "babylonjs/scene";
  42985. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42987. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42988. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42989. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42990. /**
  42991. * States of the webXR experience
  42992. */
  42993. export enum WebXRState {
  42994. /**
  42995. * Transitioning to being in XR mode
  42996. */
  42997. ENTERING_XR = 0,
  42998. /**
  42999. * Transitioning to non XR mode
  43000. */
  43001. EXITING_XR = 1,
  43002. /**
  43003. * In XR mode and presenting
  43004. */
  43005. IN_XR = 2,
  43006. /**
  43007. * Not entered XR mode
  43008. */
  43009. NOT_IN_XR = 3
  43010. }
  43011. /**
  43012. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43013. * @see https://doc.babylonjs.com/how_to/webxr
  43014. */
  43015. export class WebXRExperienceHelper implements IDisposable {
  43016. private scene;
  43017. /**
  43018. * 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
  43019. */
  43020. container: AbstractMesh;
  43021. /**
  43022. * Camera used to render xr content
  43023. */
  43024. camera: WebXRCamera;
  43025. /**
  43026. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43027. */
  43028. state: WebXRState;
  43029. private _setState;
  43030. private static _TmpVector;
  43031. /**
  43032. * Fires when the state of the experience helper has changed
  43033. */
  43034. onStateChangedObservable: Observable<WebXRState>;
  43035. /** Session manager used to keep track of xr session */
  43036. sessionManager: WebXRSessionManager;
  43037. private _nonVRCamera;
  43038. private _originalSceneAutoClear;
  43039. private _supported;
  43040. /**
  43041. * Creates the experience helper
  43042. * @param scene the scene to attach the experience helper to
  43043. * @returns a promise for the experience helper
  43044. */
  43045. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43046. /**
  43047. * Creates a WebXRExperienceHelper
  43048. * @param scene The scene the helper should be created in
  43049. */
  43050. private constructor();
  43051. /**
  43052. * Exits XR mode and returns the scene to its original state
  43053. * @returns promise that resolves after xr mode has exited
  43054. */
  43055. exitXRAsync(): Promise<unknown>;
  43056. /**
  43057. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43058. * @param sessionCreationOptions options for the XR session
  43059. * @param referenceSpaceType frame of reference of the XR session
  43060. * @param outputCanvas the output canvas that will be used to enter XR mode
  43061. * @returns promise that resolves after xr mode has entered
  43062. */
  43063. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43064. /**
  43065. * Updates the global position of the camera by moving the camera's container
  43066. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43067. * @param position The desired global position of the camera
  43068. */
  43069. setPositionOfCameraUsingContainer(position: Vector3): void;
  43070. /**
  43071. * Rotates the xr camera by rotating the camera's container around the camera's position
  43072. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43073. * @param rotation the desired quaternion rotation to apply to the camera
  43074. */
  43075. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43076. /**
  43077. * Disposes of the experience helper
  43078. */
  43079. dispose(): void;
  43080. }
  43081. }
  43082. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43083. import { Nullable } from "babylonjs/types";
  43084. import { Observable } from "babylonjs/Misc/observable";
  43085. import { IDisposable, Scene } from "babylonjs/scene";
  43086. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43087. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43088. /**
  43089. * Button which can be used to enter a different mode of XR
  43090. */
  43091. export class WebXREnterExitUIButton {
  43092. /** button element */
  43093. element: HTMLElement;
  43094. /** XR initialization options for the button */
  43095. sessionMode: XRSessionMode;
  43096. /** Reference space type */
  43097. referenceSpaceType: XRReferenceSpaceType;
  43098. /**
  43099. * Creates a WebXREnterExitUIButton
  43100. * @param element button element
  43101. * @param sessionMode XR initialization session mode
  43102. * @param referenceSpaceType the type of reference space to be used
  43103. */
  43104. constructor(
  43105. /** button element */
  43106. element: HTMLElement,
  43107. /** XR initialization options for the button */
  43108. sessionMode: XRSessionMode,
  43109. /** Reference space type */
  43110. referenceSpaceType: XRReferenceSpaceType);
  43111. /**
  43112. * Overwritable function which can be used to update the button's visuals when the state changes
  43113. * @param activeButton the current active button in the UI
  43114. */
  43115. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43116. }
  43117. /**
  43118. * Options to create the webXR UI
  43119. */
  43120. export class WebXREnterExitUIOptions {
  43121. /**
  43122. * Context to enter xr with
  43123. */
  43124. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43125. /**
  43126. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43127. */
  43128. customButtons?: Array<WebXREnterExitUIButton>;
  43129. }
  43130. /**
  43131. * UI to allow the user to enter/exit XR mode
  43132. */
  43133. export class WebXREnterExitUI implements IDisposable {
  43134. private scene;
  43135. private _overlay;
  43136. private _buttons;
  43137. private _activeButton;
  43138. /**
  43139. * Fired every time the active button is changed.
  43140. *
  43141. * When xr is entered via a button that launches xr that button will be the callback parameter
  43142. *
  43143. * When exiting xr the callback parameter will be null)
  43144. */
  43145. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43146. /**
  43147. * Creates UI to allow the user to enter/exit XR mode
  43148. * @param scene the scene to add the ui to
  43149. * @param helper the xr experience helper to enter/exit xr with
  43150. * @param options options to configure the UI
  43151. * @returns the created ui
  43152. */
  43153. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43154. private constructor();
  43155. private _updateButtons;
  43156. /**
  43157. * Disposes of the object
  43158. */
  43159. dispose(): void;
  43160. }
  43161. }
  43162. declare module "babylonjs/Cameras/XR/webXRController" {
  43163. import { Nullable } from "babylonjs/types";
  43164. import { Observable } from "babylonjs/Misc/observable";
  43165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43166. import { Ray } from "babylonjs/Culling/ray";
  43167. import { Scene } from "babylonjs/scene";
  43168. /**
  43169. * Represents an XR input
  43170. */
  43171. export class WebXRController {
  43172. private scene;
  43173. /** The underlying input source for the controller */
  43174. inputSource: XRInputSource;
  43175. private parentContainer;
  43176. /**
  43177. * 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
  43178. */
  43179. grip?: AbstractMesh;
  43180. /**
  43181. * Pointer which can be used to select objects or attach a visible laser to
  43182. */
  43183. pointer: AbstractMesh;
  43184. /**
  43185. * Event that fires when the controller is removed/disposed
  43186. */
  43187. onDisposeObservable: Observable<{}>;
  43188. private _tmpMatrix;
  43189. private _tmpQuaternion;
  43190. private _tmpVector;
  43191. /**
  43192. * Creates the controller
  43193. * @see https://doc.babylonjs.com/how_to/webxr
  43194. * @param scene the scene which the controller should be associated to
  43195. * @param inputSource the underlying input source for the controller
  43196. * @param parentContainer parent that the controller meshes should be children of
  43197. */
  43198. constructor(scene: Scene,
  43199. /** The underlying input source for the controller */
  43200. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43201. /**
  43202. * Updates the controller pose based on the given XRFrame
  43203. * @param xrFrame xr frame to update the pose with
  43204. * @param referenceSpace reference space to use
  43205. */
  43206. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43207. /**
  43208. * Gets a world space ray coming from the controller
  43209. * @param result the resulting ray
  43210. */
  43211. getWorldPointerRayToRef(result: Ray): void;
  43212. /**
  43213. * Disposes of the object
  43214. */
  43215. dispose(): void;
  43216. }
  43217. }
  43218. declare module "babylonjs/Cameras/XR/webXRInput" {
  43219. import { Observable } from "babylonjs/Misc/observable";
  43220. import { IDisposable } from "babylonjs/scene";
  43221. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43222. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43223. /**
  43224. * XR input used to track XR inputs such as controllers/rays
  43225. */
  43226. export class WebXRInput implements IDisposable {
  43227. /**
  43228. * Base experience the input listens to
  43229. */
  43230. baseExperience: WebXRExperienceHelper;
  43231. /**
  43232. * XR controllers being tracked
  43233. */
  43234. controllers: Array<WebXRController>;
  43235. private _frameObserver;
  43236. private _stateObserver;
  43237. /**
  43238. * Event when a controller has been connected/added
  43239. */
  43240. onControllerAddedObservable: Observable<WebXRController>;
  43241. /**
  43242. * Event when a controller has been removed/disconnected
  43243. */
  43244. onControllerRemovedObservable: Observable<WebXRController>;
  43245. /**
  43246. * Initializes the WebXRInput
  43247. * @param baseExperience experience helper which the input should be created for
  43248. */
  43249. constructor(
  43250. /**
  43251. * Base experience the input listens to
  43252. */
  43253. baseExperience: WebXRExperienceHelper);
  43254. private _onInputSourcesChange;
  43255. private _addAndRemoveControllers;
  43256. /**
  43257. * Disposes of the object
  43258. */
  43259. dispose(): void;
  43260. }
  43261. }
  43262. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43264. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43265. /**
  43266. * Enables teleportation
  43267. */
  43268. export class WebXRControllerTeleportation {
  43269. private _teleportationFillColor;
  43270. private _teleportationBorderColor;
  43271. private _tmpRay;
  43272. private _tmpVector;
  43273. /**
  43274. * Creates a WebXRControllerTeleportation
  43275. * @param input input manager to add teleportation to
  43276. * @param floorMeshes floormeshes which can be teleported to
  43277. */
  43278. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43279. }
  43280. }
  43281. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43282. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43283. /**
  43284. * Handles pointer input automatically for the pointer of XR controllers
  43285. */
  43286. export class WebXRControllerPointerSelection {
  43287. private static _idCounter;
  43288. private _tmpRay;
  43289. /**
  43290. * Creates a WebXRControllerPointerSelection
  43291. * @param input input manager to setup pointer selection
  43292. */
  43293. constructor(input: WebXRInput);
  43294. private _convertNormalToDirectionOfRay;
  43295. private _updatePointerDistance;
  43296. }
  43297. }
  43298. declare module "babylonjs/Loading/sceneLoader" {
  43299. import { Observable } from "babylonjs/Misc/observable";
  43300. import { Nullable } from "babylonjs/types";
  43301. import { Scene } from "babylonjs/scene";
  43302. import { Engine } from "babylonjs/Engines/engine";
  43303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43304. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43305. import { AssetContainer } from "babylonjs/assetContainer";
  43306. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43307. import { Skeleton } from "babylonjs/Bones/skeleton";
  43308. /**
  43309. * Class used to represent data loading progression
  43310. */
  43311. export class SceneLoaderProgressEvent {
  43312. /** defines if data length to load can be evaluated */
  43313. readonly lengthComputable: boolean;
  43314. /** defines the loaded data length */
  43315. readonly loaded: number;
  43316. /** defines the data length to load */
  43317. readonly total: number;
  43318. /**
  43319. * Create a new progress event
  43320. * @param lengthComputable defines if data length to load can be evaluated
  43321. * @param loaded defines the loaded data length
  43322. * @param total defines the data length to load
  43323. */
  43324. constructor(
  43325. /** defines if data length to load can be evaluated */
  43326. lengthComputable: boolean,
  43327. /** defines the loaded data length */
  43328. loaded: number,
  43329. /** defines the data length to load */
  43330. total: number);
  43331. /**
  43332. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43333. * @param event defines the source event
  43334. * @returns a new SceneLoaderProgressEvent
  43335. */
  43336. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43337. }
  43338. /**
  43339. * Interface used by SceneLoader plugins to define supported file extensions
  43340. */
  43341. export interface ISceneLoaderPluginExtensions {
  43342. /**
  43343. * Defines the list of supported extensions
  43344. */
  43345. [extension: string]: {
  43346. isBinary: boolean;
  43347. };
  43348. }
  43349. /**
  43350. * Interface used by SceneLoader plugin factory
  43351. */
  43352. export interface ISceneLoaderPluginFactory {
  43353. /**
  43354. * Defines the name of the factory
  43355. */
  43356. name: string;
  43357. /**
  43358. * Function called to create a new plugin
  43359. * @return the new plugin
  43360. */
  43361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43362. /**
  43363. * Boolean indicating if the plugin can direct load specific data
  43364. */
  43365. canDirectLoad?: (data: string) => boolean;
  43366. }
  43367. /**
  43368. * Interface used to define a SceneLoader plugin
  43369. */
  43370. export interface ISceneLoaderPlugin {
  43371. /**
  43372. * The friendly name of this plugin.
  43373. */
  43374. name: string;
  43375. /**
  43376. * The file extensions supported by this plugin.
  43377. */
  43378. extensions: string | ISceneLoaderPluginExtensions;
  43379. /**
  43380. * Import meshes into a scene.
  43381. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43382. * @param scene The scene to import into
  43383. * @param data The data to import
  43384. * @param rootUrl The root url for scene and resources
  43385. * @param meshes The meshes array to import into
  43386. * @param particleSystems The particle systems array to import into
  43387. * @param skeletons The skeletons array to import into
  43388. * @param onError The callback when import fails
  43389. * @returns True if successful or false otherwise
  43390. */
  43391. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43392. /**
  43393. * Load into a scene.
  43394. * @param scene The scene to load into
  43395. * @param data The data to import
  43396. * @param rootUrl The root url for scene and resources
  43397. * @param onError The callback when import fails
  43398. * @returns true if successful or false otherwise
  43399. */
  43400. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43401. /**
  43402. * The callback that returns true if the data can be directly loaded.
  43403. */
  43404. canDirectLoad?: (data: string) => boolean;
  43405. /**
  43406. * The callback that allows custom handling of the root url based on the response url.
  43407. */
  43408. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43409. /**
  43410. * Load into an asset container.
  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 onError The callback when import fails
  43415. * @returns The loaded asset container
  43416. */
  43417. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43418. }
  43419. /**
  43420. * Interface used to define an async SceneLoader plugin
  43421. */
  43422. export interface ISceneLoaderPluginAsync {
  43423. /**
  43424. * The friendly name of this plugin.
  43425. */
  43426. name: string;
  43427. /**
  43428. * The file extensions supported by this plugin.
  43429. */
  43430. extensions: string | ISceneLoaderPluginExtensions;
  43431. /**
  43432. * Import meshes into a scene.
  43433. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43434. * @param scene The scene to import into
  43435. * @param data The data to import
  43436. * @param rootUrl The root url for scene and resources
  43437. * @param onProgress The callback when the load progresses
  43438. * @param fileName Defines the name of the file to load
  43439. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43440. */
  43441. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43442. meshes: AbstractMesh[];
  43443. particleSystems: IParticleSystem[];
  43444. skeletons: Skeleton[];
  43445. animationGroups: AnimationGroup[];
  43446. }>;
  43447. /**
  43448. * Load into a scene.
  43449. * @param scene The scene to load into
  43450. * @param data The data to import
  43451. * @param rootUrl The root url for scene and resources
  43452. * @param onProgress The callback when the load progresses
  43453. * @param fileName Defines the name of the file to load
  43454. * @returns Nothing
  43455. */
  43456. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43457. /**
  43458. * The callback that returns true if the data can be directly loaded.
  43459. */
  43460. canDirectLoad?: (data: string) => boolean;
  43461. /**
  43462. * The callback that allows custom handling of the root url based on the response url.
  43463. */
  43464. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43465. /**
  43466. * Load into an asset container.
  43467. * @param scene The scene to load into
  43468. * @param data The data to import
  43469. * @param rootUrl The root url for scene and resources
  43470. * @param onProgress The callback when the load progresses
  43471. * @param fileName Defines the name of the file to load
  43472. * @returns The loaded asset container
  43473. */
  43474. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43475. }
  43476. /**
  43477. * Class used to load scene from various file formats using registered plugins
  43478. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43479. */
  43480. export class SceneLoader {
  43481. /**
  43482. * No logging while loading
  43483. */
  43484. static readonly NO_LOGGING: number;
  43485. /**
  43486. * Minimal logging while loading
  43487. */
  43488. static readonly MINIMAL_LOGGING: number;
  43489. /**
  43490. * Summary logging while loading
  43491. */
  43492. static readonly SUMMARY_LOGGING: number;
  43493. /**
  43494. * Detailled logging while loading
  43495. */
  43496. static readonly DETAILED_LOGGING: number;
  43497. /**
  43498. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43499. */
  43500. static ForceFullSceneLoadingForIncremental: boolean;
  43501. /**
  43502. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43503. */
  43504. static ShowLoadingScreen: boolean;
  43505. /**
  43506. * Defines the current logging level (while loading the scene)
  43507. * @ignorenaming
  43508. */
  43509. static loggingLevel: number;
  43510. /**
  43511. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43512. */
  43513. static CleanBoneMatrixWeights: boolean;
  43514. /**
  43515. * Event raised when a plugin is used to load a scene
  43516. */
  43517. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43518. private static _registeredPlugins;
  43519. private static _getDefaultPlugin;
  43520. private static _getPluginForExtension;
  43521. private static _getPluginForDirectLoad;
  43522. private static _getPluginForFilename;
  43523. private static _getDirectLoad;
  43524. private static _loadData;
  43525. private static _getFileInfo;
  43526. /**
  43527. * Gets a plugin that can load the given extension
  43528. * @param extension defines the extension to load
  43529. * @returns a plugin or null if none works
  43530. */
  43531. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43532. /**
  43533. * Gets a boolean indicating that the given extension can be loaded
  43534. * @param extension defines the extension to load
  43535. * @returns true if the extension is supported
  43536. */
  43537. static IsPluginForExtensionAvailable(extension: string): boolean;
  43538. /**
  43539. * Adds a new plugin to the list of registered plugins
  43540. * @param plugin defines the plugin to add
  43541. */
  43542. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43543. /**
  43544. * Import meshes into a scene
  43545. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43546. * @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)
  43547. * @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)
  43548. * @param scene the instance of BABYLON.Scene to append to
  43549. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43550. * @param onProgress a callback with a progress event for each file being loaded
  43551. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The loaded plugin
  43554. */
  43555. 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>;
  43556. /**
  43557. * Import meshes into a scene
  43558. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43559. * @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)
  43560. * @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)
  43561. * @param scene the instance of BABYLON.Scene to append to
  43562. * @param onProgress a callback with a progress event for each file being loaded
  43563. * @param pluginExtension the extension used to determine the plugin
  43564. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43565. */
  43566. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43567. meshes: AbstractMesh[];
  43568. particleSystems: IParticleSystem[];
  43569. skeletons: Skeleton[];
  43570. animationGroups: AnimationGroup[];
  43571. }>;
  43572. /**
  43573. * Load a scene
  43574. * @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)
  43575. * @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)
  43576. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43577. * @param onSuccess a callback with the scene when import succeeds
  43578. * @param onProgress a callback with a progress event for each file being loaded
  43579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43580. * @param pluginExtension the extension used to determine the plugin
  43581. * @returns The loaded plugin
  43582. */
  43583. 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>;
  43584. /**
  43585. * Load a scene
  43586. * @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)
  43587. * @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)
  43588. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43589. * @param onProgress a callback with a progress event for each file being loaded
  43590. * @param pluginExtension the extension used to determine the plugin
  43591. * @returns The loaded scene
  43592. */
  43593. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43594. /**
  43595. * Append a scene
  43596. * @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)
  43597. * @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)
  43598. * @param scene is the instance of BABYLON.Scene to append to
  43599. * @param onSuccess a callback with the scene when import succeeds
  43600. * @param onProgress a callback with a progress event for each file being loaded
  43601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43602. * @param pluginExtension the extension used to determine the plugin
  43603. * @returns The loaded plugin
  43604. */
  43605. 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>;
  43606. /**
  43607. * Append a scene
  43608. * @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)
  43609. * @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)
  43610. * @param scene is the instance of BABYLON.Scene to append to
  43611. * @param onProgress a callback with a progress event for each file being loaded
  43612. * @param pluginExtension the extension used to determine the plugin
  43613. * @returns The given scene
  43614. */
  43615. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43616. /**
  43617. * Load a scene into an asset container
  43618. * @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)
  43619. * @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)
  43620. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43621. * @param onSuccess a callback with the scene when import succeeds
  43622. * @param onProgress a callback with a progress event for each file being loaded
  43623. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43624. * @param pluginExtension the extension used to determine the plugin
  43625. * @returns The loaded plugin
  43626. */
  43627. 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>;
  43628. /**
  43629. * Load a scene into an asset container
  43630. * @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)
  43631. * @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)
  43632. * @param scene is the instance of Scene to append to
  43633. * @param onProgress a callback with a progress event for each file being loaded
  43634. * @param pluginExtension the extension used to determine the plugin
  43635. * @returns The loaded asset container
  43636. */
  43637. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43638. }
  43639. }
  43640. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43641. import { Scene } from "babylonjs/scene";
  43642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43643. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43644. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43645. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43646. /**
  43647. * Generic Controller
  43648. */
  43649. export class GenericController extends WebVRController {
  43650. /**
  43651. * Base Url for the controller model.
  43652. */
  43653. static readonly MODEL_BASE_URL: string;
  43654. /**
  43655. * File name for the controller model.
  43656. */
  43657. static readonly MODEL_FILENAME: string;
  43658. /**
  43659. * Creates a new GenericController from a gamepad
  43660. * @param vrGamepad the gamepad that the controller should be created from
  43661. */
  43662. constructor(vrGamepad: any);
  43663. /**
  43664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43665. * @param scene scene in which to add meshes
  43666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43667. */
  43668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43669. /**
  43670. * Called once for each button that changed state since the last frame
  43671. * @param buttonIdx Which button index changed
  43672. * @param state New state of the button
  43673. * @param changes Which properties on the state changed since last frame
  43674. */
  43675. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43676. }
  43677. }
  43678. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43679. import { Observable } from "babylonjs/Misc/observable";
  43680. import { Scene } from "babylonjs/scene";
  43681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43682. import { Ray } from "babylonjs/Culling/ray";
  43683. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43684. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43685. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43686. /**
  43687. * Defines the WindowsMotionController object that the state of the windows motion controller
  43688. */
  43689. export class WindowsMotionController extends WebVRController {
  43690. /**
  43691. * The base url used to load the left and right controller models
  43692. */
  43693. static MODEL_BASE_URL: string;
  43694. /**
  43695. * The name of the left controller model file
  43696. */
  43697. static MODEL_LEFT_FILENAME: string;
  43698. /**
  43699. * The name of the right controller model file
  43700. */
  43701. static MODEL_RIGHT_FILENAME: string;
  43702. /**
  43703. * The controller name prefix for this controller type
  43704. */
  43705. static readonly GAMEPAD_ID_PREFIX: string;
  43706. /**
  43707. * The controller id pattern for this controller type
  43708. */
  43709. private static readonly GAMEPAD_ID_PATTERN;
  43710. private _loadedMeshInfo;
  43711. private readonly _mapping;
  43712. /**
  43713. * Fired when the trackpad on this controller is clicked
  43714. */
  43715. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43716. /**
  43717. * Fired when the trackpad on this controller is modified
  43718. */
  43719. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43720. /**
  43721. * The current x and y values of this controller's trackpad
  43722. */
  43723. trackpad: StickValues;
  43724. /**
  43725. * Creates a new WindowsMotionController from a gamepad
  43726. * @param vrGamepad the gamepad that the controller should be created from
  43727. */
  43728. constructor(vrGamepad: any);
  43729. /**
  43730. * Fired when the trigger on this controller is modified
  43731. */
  43732. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43733. /**
  43734. * Fired when the menu button on this controller is modified
  43735. */
  43736. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43737. /**
  43738. * Fired when the grip button on this controller is modified
  43739. */
  43740. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43741. /**
  43742. * Fired when the thumbstick button on this controller is modified
  43743. */
  43744. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43745. /**
  43746. * Fired when the touchpad button on this controller is modified
  43747. */
  43748. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43749. /**
  43750. * Fired when the touchpad values on this controller are modified
  43751. */
  43752. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43753. private _updateTrackpad;
  43754. /**
  43755. * Called once per frame by the engine.
  43756. */
  43757. update(): void;
  43758. /**
  43759. * Called once for each button that changed state since the last frame
  43760. * @param buttonIdx Which button index changed
  43761. * @param state New state of the button
  43762. * @param changes Which properties on the state changed since last frame
  43763. */
  43764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43765. /**
  43766. * Moves the buttons on the controller mesh based on their current state
  43767. * @param buttonName the name of the button to move
  43768. * @param buttonValue the value of the button which determines the buttons new position
  43769. */
  43770. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43771. /**
  43772. * Moves the axis on the controller mesh based on its current state
  43773. * @param axis the index of the axis
  43774. * @param axisValue the value of the axis which determines the meshes new position
  43775. * @hidden
  43776. */
  43777. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43778. /**
  43779. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43780. * @param scene scene in which to add meshes
  43781. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43782. */
  43783. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43784. /**
  43785. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43786. * can be transformed by button presses and axes values, based on this._mapping.
  43787. *
  43788. * @param scene scene in which the meshes exist
  43789. * @param meshes list of meshes that make up the controller model to process
  43790. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43791. */
  43792. private processModel;
  43793. private createMeshInfo;
  43794. /**
  43795. * Gets the ray of the controller in the direction the controller is pointing
  43796. * @param length the length the resulting ray should be
  43797. * @returns a ray in the direction the controller is pointing
  43798. */
  43799. getForwardRay(length?: number): Ray;
  43800. /**
  43801. * Disposes of the controller
  43802. */
  43803. dispose(): void;
  43804. }
  43805. }
  43806. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43807. import { Observable } from "babylonjs/Misc/observable";
  43808. import { Scene } from "babylonjs/scene";
  43809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43810. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43811. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43812. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43813. /**
  43814. * Oculus Touch Controller
  43815. */
  43816. export class OculusTouchController extends WebVRController {
  43817. /**
  43818. * Base Url for the controller model.
  43819. */
  43820. static MODEL_BASE_URL: string;
  43821. /**
  43822. * File name for the left controller model.
  43823. */
  43824. static MODEL_LEFT_FILENAME: string;
  43825. /**
  43826. * File name for the right controller model.
  43827. */
  43828. static MODEL_RIGHT_FILENAME: string;
  43829. /**
  43830. * Base Url for the Quest controller model.
  43831. */
  43832. static QUEST_MODEL_BASE_URL: string;
  43833. /**
  43834. * @hidden
  43835. * If the controllers are running on a device that needs the updated Quest controller models
  43836. */
  43837. static _IsQuest: boolean;
  43838. /**
  43839. * Fired when the secondary trigger on this controller is modified
  43840. */
  43841. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43842. /**
  43843. * Fired when the thumb rest on this controller is modified
  43844. */
  43845. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43846. /**
  43847. * Creates a new OculusTouchController from a gamepad
  43848. * @param vrGamepad the gamepad that the controller should be created from
  43849. */
  43850. constructor(vrGamepad: any);
  43851. /**
  43852. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43853. * @param scene scene in which to add meshes
  43854. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43855. */
  43856. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43857. /**
  43858. * Fired when the A button on this controller is modified
  43859. */
  43860. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43861. /**
  43862. * Fired when the B button on this controller is modified
  43863. */
  43864. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43865. /**
  43866. * Fired when the X button on this controller is modified
  43867. */
  43868. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43869. /**
  43870. * Fired when the Y button on this controller is modified
  43871. */
  43872. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43873. /**
  43874. * Called once for each button that changed state since the last frame
  43875. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43876. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43877. * 2) secondary trigger (same)
  43878. * 3) A (right) X (left), touch, pressed = value
  43879. * 4) B / Y
  43880. * 5) thumb rest
  43881. * @param buttonIdx Which button index changed
  43882. * @param state New state of the button
  43883. * @param changes Which properties on the state changed since last frame
  43884. */
  43885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43886. }
  43887. }
  43888. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43889. import { Scene } from "babylonjs/scene";
  43890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43891. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43892. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43893. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43894. import { Observable } from "babylonjs/Misc/observable";
  43895. /**
  43896. * Vive Controller
  43897. */
  43898. export class ViveController extends WebVRController {
  43899. /**
  43900. * Base Url for the controller model.
  43901. */
  43902. static MODEL_BASE_URL: string;
  43903. /**
  43904. * File name for the controller model.
  43905. */
  43906. static MODEL_FILENAME: string;
  43907. /**
  43908. * Creates a new ViveController from a gamepad
  43909. * @param vrGamepad the gamepad that the controller should be created from
  43910. */
  43911. constructor(vrGamepad: any);
  43912. /**
  43913. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43914. * @param scene scene in which to add meshes
  43915. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43916. */
  43917. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43918. /**
  43919. * Fired when the left button on this controller is modified
  43920. */
  43921. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43922. /**
  43923. * Fired when the right button on this controller is modified
  43924. */
  43925. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43926. /**
  43927. * Fired when the menu button on this controller is modified
  43928. */
  43929. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43930. /**
  43931. * Called once for each button that changed state since the last frame
  43932. * Vive mapping:
  43933. * 0: touchpad
  43934. * 1: trigger
  43935. * 2: left AND right buttons
  43936. * 3: menu button
  43937. * @param buttonIdx Which button index changed
  43938. * @param state New state of the button
  43939. * @param changes Which properties on the state changed since last frame
  43940. */
  43941. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43942. }
  43943. }
  43944. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43945. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43946. /**
  43947. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43948. */
  43949. export class WebXRControllerModelLoader {
  43950. /**
  43951. * Creates the WebXRControllerModelLoader
  43952. * @param input xr input that creates the controllers
  43953. */
  43954. constructor(input: WebXRInput);
  43955. }
  43956. }
  43957. declare module "babylonjs/Cameras/XR/index" {
  43958. export * from "babylonjs/Cameras/XR/webXRCamera";
  43959. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43960. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43961. export * from "babylonjs/Cameras/XR/webXRInput";
  43962. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43963. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43964. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43965. export * from "babylonjs/Cameras/XR/webXRController";
  43966. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43967. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43968. }
  43969. declare module "babylonjs/Cameras/RigModes/index" {
  43970. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43971. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43972. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43973. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43974. }
  43975. declare module "babylonjs/Cameras/index" {
  43976. export * from "babylonjs/Cameras/Inputs/index";
  43977. export * from "babylonjs/Cameras/cameraInputsManager";
  43978. export * from "babylonjs/Cameras/camera";
  43979. export * from "babylonjs/Cameras/targetCamera";
  43980. export * from "babylonjs/Cameras/freeCamera";
  43981. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43982. export * from "babylonjs/Cameras/touchCamera";
  43983. export * from "babylonjs/Cameras/arcRotateCamera";
  43984. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43985. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43986. export * from "babylonjs/Cameras/flyCamera";
  43987. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43988. export * from "babylonjs/Cameras/followCamera";
  43989. export * from "babylonjs/Cameras/followCameraInputsManager";
  43990. export * from "babylonjs/Cameras/gamepadCamera";
  43991. export * from "babylonjs/Cameras/Stereoscopic/index";
  43992. export * from "babylonjs/Cameras/universalCamera";
  43993. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43994. export * from "babylonjs/Cameras/VR/index";
  43995. export * from "babylonjs/Cameras/XR/index";
  43996. export * from "babylonjs/Cameras/RigModes/index";
  43997. }
  43998. declare module "babylonjs/Collisions/index" {
  43999. export * from "babylonjs/Collisions/collider";
  44000. export * from "babylonjs/Collisions/collisionCoordinator";
  44001. export * from "babylonjs/Collisions/pickingInfo";
  44002. export * from "babylonjs/Collisions/intersectionInfo";
  44003. export * from "babylonjs/Collisions/meshCollisionData";
  44004. }
  44005. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44006. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44007. import { Vector3 } from "babylonjs/Maths/math.vector";
  44008. import { Ray } from "babylonjs/Culling/ray";
  44009. import { Plane } from "babylonjs/Maths/math.plane";
  44010. /**
  44011. * Contains an array of blocks representing the octree
  44012. */
  44013. export interface IOctreeContainer<T> {
  44014. /**
  44015. * Blocks within the octree
  44016. */
  44017. blocks: Array<OctreeBlock<T>>;
  44018. }
  44019. /**
  44020. * Class used to store a cell in an octree
  44021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44022. */
  44023. export class OctreeBlock<T> {
  44024. /**
  44025. * Gets the content of the current block
  44026. */
  44027. entries: T[];
  44028. /**
  44029. * Gets the list of block children
  44030. */
  44031. blocks: Array<OctreeBlock<T>>;
  44032. private _depth;
  44033. private _maxDepth;
  44034. private _capacity;
  44035. private _minPoint;
  44036. private _maxPoint;
  44037. private _boundingVectors;
  44038. private _creationFunc;
  44039. /**
  44040. * Creates a new block
  44041. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44042. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44043. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44044. * @param depth defines the current depth of this block in the octree
  44045. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44046. * @param creationFunc defines a callback to call when an element is added to the block
  44047. */
  44048. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44049. /**
  44050. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44051. */
  44052. readonly capacity: number;
  44053. /**
  44054. * Gets the minimum vector (in world space) of the block's bounding box
  44055. */
  44056. readonly minPoint: Vector3;
  44057. /**
  44058. * Gets the maximum vector (in world space) of the block's bounding box
  44059. */
  44060. readonly maxPoint: Vector3;
  44061. /**
  44062. * Add a new element to this block
  44063. * @param entry defines the element to add
  44064. */
  44065. addEntry(entry: T): void;
  44066. /**
  44067. * Remove an element from this block
  44068. * @param entry defines the element to remove
  44069. */
  44070. removeEntry(entry: T): void;
  44071. /**
  44072. * Add an array of elements to this block
  44073. * @param entries defines the array of elements to add
  44074. */
  44075. addEntries(entries: T[]): void;
  44076. /**
  44077. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44078. * @param frustumPlanes defines the frustum planes to test
  44079. * @param selection defines the array to store current content if selection is positive
  44080. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44081. */
  44082. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44083. /**
  44084. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44085. * @param sphereCenter defines the bounding sphere center
  44086. * @param sphereRadius defines the bounding sphere radius
  44087. * @param selection defines the array to store current content if selection is positive
  44088. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44089. */
  44090. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44091. /**
  44092. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44093. * @param ray defines the ray to test with
  44094. * @param selection defines the array to store current content if selection is positive
  44095. */
  44096. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44097. /**
  44098. * Subdivide the content into child blocks (this block will then be empty)
  44099. */
  44100. createInnerBlocks(): void;
  44101. /**
  44102. * @hidden
  44103. */
  44104. 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;
  44105. }
  44106. }
  44107. declare module "babylonjs/Culling/Octrees/octree" {
  44108. import { SmartArray } from "babylonjs/Misc/smartArray";
  44109. import { Vector3 } from "babylonjs/Maths/math.vector";
  44110. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44112. import { Ray } from "babylonjs/Culling/ray";
  44113. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44114. import { Plane } from "babylonjs/Maths/math.plane";
  44115. /**
  44116. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44117. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44118. */
  44119. export class Octree<T> {
  44120. /** 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.) */
  44121. maxDepth: number;
  44122. /**
  44123. * Blocks within the octree containing objects
  44124. */
  44125. blocks: Array<OctreeBlock<T>>;
  44126. /**
  44127. * Content stored in the octree
  44128. */
  44129. dynamicContent: T[];
  44130. private _maxBlockCapacity;
  44131. private _selectionContent;
  44132. private _creationFunc;
  44133. /**
  44134. * Creates a octree
  44135. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44136. * @param creationFunc function to be used to instatiate the octree
  44137. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44138. * @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.)
  44139. */
  44140. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44141. /** 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.) */
  44142. maxDepth?: number);
  44143. /**
  44144. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44145. * @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);
  44146. * @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);
  44147. * @param entries meshes to be added to the octree blocks
  44148. */
  44149. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44150. /**
  44151. * Adds a mesh to the octree
  44152. * @param entry Mesh to add to the octree
  44153. */
  44154. addMesh(entry: T): void;
  44155. /**
  44156. * Remove an element from the octree
  44157. * @param entry defines the element to remove
  44158. */
  44159. removeMesh(entry: T): void;
  44160. /**
  44161. * Selects an array of meshes within the frustum
  44162. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44163. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44164. * @returns array of meshes within the frustum
  44165. */
  44166. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44167. /**
  44168. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44169. * @param sphereCenter defines the bounding sphere center
  44170. * @param sphereRadius defines the bounding sphere radius
  44171. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44172. * @returns an array of objects that intersect the sphere
  44173. */
  44174. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44175. /**
  44176. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44177. * @param ray defines the ray to test with
  44178. * @returns array of intersected objects
  44179. */
  44180. intersectsRay(ray: Ray): SmartArray<T>;
  44181. /**
  44182. * Adds a mesh into the octree block if it intersects the block
  44183. */
  44184. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44185. /**
  44186. * Adds a submesh into the octree block if it intersects the block
  44187. */
  44188. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44189. }
  44190. }
  44191. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44192. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44193. import { Scene } from "babylonjs/scene";
  44194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44196. import { Ray } from "babylonjs/Culling/ray";
  44197. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44198. import { Collider } from "babylonjs/Collisions/collider";
  44199. module "babylonjs/scene" {
  44200. interface Scene {
  44201. /**
  44202. * @hidden
  44203. * Backing Filed
  44204. */
  44205. _selectionOctree: Octree<AbstractMesh>;
  44206. /**
  44207. * Gets the octree used to boost mesh selection (picking)
  44208. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44209. */
  44210. selectionOctree: Octree<AbstractMesh>;
  44211. /**
  44212. * Creates or updates the octree used to boost selection (picking)
  44213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44214. * @param maxCapacity defines the maximum capacity per leaf
  44215. * @param maxDepth defines the maximum depth of the octree
  44216. * @returns an octree of AbstractMesh
  44217. */
  44218. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44219. }
  44220. }
  44221. module "babylonjs/Meshes/abstractMesh" {
  44222. interface AbstractMesh {
  44223. /**
  44224. * @hidden
  44225. * Backing Field
  44226. */
  44227. _submeshesOctree: Octree<SubMesh>;
  44228. /**
  44229. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44230. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44231. * @param maxCapacity defines the maximum size of each block (64 by default)
  44232. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44233. * @returns the new octree
  44234. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44235. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44236. */
  44237. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44238. }
  44239. }
  44240. /**
  44241. * Defines the octree scene component responsible to manage any octrees
  44242. * in a given scene.
  44243. */
  44244. export class OctreeSceneComponent {
  44245. /**
  44246. * The component name help to identify the component in the list of scene components.
  44247. */
  44248. readonly name: string;
  44249. /**
  44250. * The scene the component belongs to.
  44251. */
  44252. scene: Scene;
  44253. /**
  44254. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44255. */
  44256. readonly checksIsEnabled: boolean;
  44257. /**
  44258. * Creates a new instance of the component for the given scene
  44259. * @param scene Defines the scene to register the component in
  44260. */
  44261. constructor(scene: Scene);
  44262. /**
  44263. * Registers the component in a given scene
  44264. */
  44265. register(): void;
  44266. /**
  44267. * Return the list of active meshes
  44268. * @returns the list of active meshes
  44269. */
  44270. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44271. /**
  44272. * Return the list of active sub meshes
  44273. * @param mesh The mesh to get the candidates sub meshes from
  44274. * @returns the list of active sub meshes
  44275. */
  44276. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44277. private _tempRay;
  44278. /**
  44279. * Return the list of sub meshes intersecting with a given local ray
  44280. * @param mesh defines the mesh to find the submesh for
  44281. * @param localRay defines the ray in local space
  44282. * @returns the list of intersecting sub meshes
  44283. */
  44284. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44285. /**
  44286. * Return the list of sub meshes colliding with a collider
  44287. * @param mesh defines the mesh to find the submesh for
  44288. * @param collider defines the collider to evaluate the collision against
  44289. * @returns the list of colliding sub meshes
  44290. */
  44291. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44292. /**
  44293. * Rebuilds the elements related to this component in case of
  44294. * context lost for instance.
  44295. */
  44296. rebuild(): void;
  44297. /**
  44298. * Disposes the component and the associated ressources.
  44299. */
  44300. dispose(): void;
  44301. }
  44302. }
  44303. declare module "babylonjs/Culling/Octrees/index" {
  44304. export * from "babylonjs/Culling/Octrees/octree";
  44305. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44306. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44307. }
  44308. declare module "babylonjs/Culling/index" {
  44309. export * from "babylonjs/Culling/boundingBox";
  44310. export * from "babylonjs/Culling/boundingInfo";
  44311. export * from "babylonjs/Culling/boundingSphere";
  44312. export * from "babylonjs/Culling/Octrees/index";
  44313. export * from "babylonjs/Culling/ray";
  44314. }
  44315. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44316. import { IDisposable, Scene } from "babylonjs/scene";
  44317. import { Nullable } from "babylonjs/types";
  44318. import { Observable } from "babylonjs/Misc/observable";
  44319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44320. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44321. import { Camera } from "babylonjs/Cameras/camera";
  44322. /**
  44323. * Renders a layer on top of an existing scene
  44324. */
  44325. export class UtilityLayerRenderer implements IDisposable {
  44326. /** the original scene that will be rendered on top of */
  44327. originalScene: Scene;
  44328. private _pointerCaptures;
  44329. private _lastPointerEvents;
  44330. private static _DefaultUtilityLayer;
  44331. private static _DefaultKeepDepthUtilityLayer;
  44332. private _sharedGizmoLight;
  44333. private _renderCamera;
  44334. /**
  44335. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44336. * @returns the camera that is used when rendering the utility layer
  44337. */
  44338. getRenderCamera(): Nullable<Camera>;
  44339. /**
  44340. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44341. * @param cam the camera that should be used when rendering the utility layer
  44342. */
  44343. setRenderCamera(cam: Nullable<Camera>): void;
  44344. /**
  44345. * @hidden
  44346. * Light which used by gizmos to get light shading
  44347. */
  44348. _getSharedGizmoLight(): HemisphericLight;
  44349. /**
  44350. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44351. */
  44352. pickUtilitySceneFirst: boolean;
  44353. /**
  44354. * 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)
  44355. */
  44356. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44357. /**
  44358. * 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)
  44359. */
  44360. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44361. /**
  44362. * The scene that is rendered on top of the original scene
  44363. */
  44364. utilityLayerScene: Scene;
  44365. /**
  44366. * If the utility layer should automatically be rendered on top of existing scene
  44367. */
  44368. shouldRender: boolean;
  44369. /**
  44370. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44371. */
  44372. onlyCheckPointerDownEvents: boolean;
  44373. /**
  44374. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44375. */
  44376. processAllEvents: boolean;
  44377. /**
  44378. * Observable raised when the pointer move from the utility layer scene to the main scene
  44379. */
  44380. onPointerOutObservable: Observable<number>;
  44381. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44382. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44383. private _afterRenderObserver;
  44384. private _sceneDisposeObserver;
  44385. private _originalPointerObserver;
  44386. /**
  44387. * Instantiates a UtilityLayerRenderer
  44388. * @param originalScene the original scene that will be rendered on top of
  44389. * @param handleEvents boolean indicating if the utility layer should handle events
  44390. */
  44391. constructor(
  44392. /** the original scene that will be rendered on top of */
  44393. originalScene: Scene, handleEvents?: boolean);
  44394. private _notifyObservers;
  44395. /**
  44396. * Renders the utility layers scene on top of the original scene
  44397. */
  44398. render(): void;
  44399. /**
  44400. * Disposes of the renderer
  44401. */
  44402. dispose(): void;
  44403. private _updateCamera;
  44404. }
  44405. }
  44406. declare module "babylonjs/Gizmos/gizmo" {
  44407. import { Nullable } from "babylonjs/types";
  44408. import { IDisposable } from "babylonjs/scene";
  44409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44410. import { Mesh } from "babylonjs/Meshes/mesh";
  44411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44412. /**
  44413. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44414. */
  44415. export class Gizmo implements IDisposable {
  44416. /** The utility layer the gizmo will be added to */
  44417. gizmoLayer: UtilityLayerRenderer;
  44418. /**
  44419. * The root mesh of the gizmo
  44420. */
  44421. _rootMesh: Mesh;
  44422. private _attachedMesh;
  44423. /**
  44424. * Ratio for the scale of the gizmo (Default: 1)
  44425. */
  44426. scaleRatio: number;
  44427. /**
  44428. * If a custom mesh has been set (Default: false)
  44429. */
  44430. protected _customMeshSet: boolean;
  44431. /**
  44432. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44433. * * When set, interactions will be enabled
  44434. */
  44435. attachedMesh: Nullable<AbstractMesh>;
  44436. /**
  44437. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44438. * @param mesh The mesh to replace the default mesh of the gizmo
  44439. */
  44440. setCustomMesh(mesh: Mesh): void;
  44441. /**
  44442. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44443. */
  44444. updateGizmoRotationToMatchAttachedMesh: boolean;
  44445. /**
  44446. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44447. */
  44448. updateGizmoPositionToMatchAttachedMesh: boolean;
  44449. /**
  44450. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44451. */
  44452. updateScale: boolean;
  44453. protected _interactionsEnabled: boolean;
  44454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44455. private _beforeRenderObserver;
  44456. private _tempVector;
  44457. /**
  44458. * Creates a gizmo
  44459. * @param gizmoLayer The utility layer the gizmo will be added to
  44460. */
  44461. constructor(
  44462. /** The utility layer the gizmo will be added to */
  44463. gizmoLayer?: UtilityLayerRenderer);
  44464. /**
  44465. * Updates the gizmo to match the attached mesh's position/rotation
  44466. */
  44467. protected _update(): void;
  44468. /**
  44469. * Disposes of the gizmo
  44470. */
  44471. dispose(): void;
  44472. }
  44473. }
  44474. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44475. import { Observable } from "babylonjs/Misc/observable";
  44476. import { Nullable } from "babylonjs/types";
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Color3 } from "babylonjs/Maths/math.color";
  44479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44481. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44482. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44484. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44485. import { Scene } from "babylonjs/scene";
  44486. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44487. /**
  44488. * Single plane drag gizmo
  44489. */
  44490. export class PlaneDragGizmo extends Gizmo {
  44491. /**
  44492. * Drag behavior responsible for the gizmos dragging interactions
  44493. */
  44494. dragBehavior: PointerDragBehavior;
  44495. private _pointerObserver;
  44496. /**
  44497. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44498. */
  44499. snapDistance: number;
  44500. /**
  44501. * Event that fires each time the gizmo snaps to a new location.
  44502. * * snapDistance is the the change in distance
  44503. */
  44504. onSnapObservable: Observable<{
  44505. snapDistance: number;
  44506. }>;
  44507. private _plane;
  44508. private _coloredMaterial;
  44509. private _hoverMaterial;
  44510. private _isEnabled;
  44511. private _parent;
  44512. /** @hidden */
  44513. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44514. /** @hidden */
  44515. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44516. /**
  44517. * Creates a PlaneDragGizmo
  44518. * @param gizmoLayer The utility layer the gizmo will be added to
  44519. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44520. * @param color The color of the gizmo
  44521. */
  44522. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44524. /**
  44525. * If the gizmo is enabled
  44526. */
  44527. isEnabled: boolean;
  44528. /**
  44529. * Disposes of the gizmo
  44530. */
  44531. dispose(): void;
  44532. }
  44533. }
  44534. declare module "babylonjs/Gizmos/positionGizmo" {
  44535. import { Observable } from "babylonjs/Misc/observable";
  44536. import { Nullable } from "babylonjs/types";
  44537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44538. import { Mesh } from "babylonjs/Meshes/mesh";
  44539. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44540. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44541. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44542. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44543. /**
  44544. * Gizmo that enables dragging a mesh along 3 axis
  44545. */
  44546. export class PositionGizmo extends Gizmo {
  44547. /**
  44548. * Internal gizmo used for interactions on the x axis
  44549. */
  44550. xGizmo: AxisDragGizmo;
  44551. /**
  44552. * Internal gizmo used for interactions on the y axis
  44553. */
  44554. yGizmo: AxisDragGizmo;
  44555. /**
  44556. * Internal gizmo used for interactions on the z axis
  44557. */
  44558. zGizmo: AxisDragGizmo;
  44559. /**
  44560. * Internal gizmo used for interactions on the yz plane
  44561. */
  44562. xPlaneGizmo: PlaneDragGizmo;
  44563. /**
  44564. * Internal gizmo used for interactions on the xz plane
  44565. */
  44566. yPlaneGizmo: PlaneDragGizmo;
  44567. /**
  44568. * Internal gizmo used for interactions on the xy plane
  44569. */
  44570. zPlaneGizmo: PlaneDragGizmo;
  44571. /**
  44572. * private variables
  44573. */
  44574. private _meshAttached;
  44575. private _updateGizmoRotationToMatchAttachedMesh;
  44576. private _snapDistance;
  44577. private _scaleRatio;
  44578. /** Fires an event when any of it's sub gizmos are dragged */
  44579. onDragStartObservable: Observable<unknown>;
  44580. /** Fires an event when any of it's sub gizmos are released from dragging */
  44581. onDragEndObservable: Observable<unknown>;
  44582. /**
  44583. * If set to true, planar drag is enabled
  44584. */
  44585. private _planarGizmoEnabled;
  44586. attachedMesh: Nullable<AbstractMesh>;
  44587. /**
  44588. * Creates a PositionGizmo
  44589. * @param gizmoLayer The utility layer the gizmo will be added to
  44590. */
  44591. constructor(gizmoLayer?: UtilityLayerRenderer);
  44592. /**
  44593. * If the planar drag gizmo is enabled
  44594. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44595. */
  44596. planarGizmoEnabled: boolean;
  44597. updateGizmoRotationToMatchAttachedMesh: boolean;
  44598. /**
  44599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44600. */
  44601. snapDistance: number;
  44602. /**
  44603. * Ratio for the scale of the gizmo (Default: 1)
  44604. */
  44605. scaleRatio: number;
  44606. /**
  44607. * Disposes of the gizmo
  44608. */
  44609. dispose(): void;
  44610. /**
  44611. * CustomMeshes are not supported by this gizmo
  44612. * @param mesh The mesh to replace the default mesh of the gizmo
  44613. */
  44614. setCustomMesh(mesh: Mesh): void;
  44615. }
  44616. }
  44617. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44618. import { Observable } from "babylonjs/Misc/observable";
  44619. import { Nullable } from "babylonjs/types";
  44620. import { Vector3 } from "babylonjs/Maths/math.vector";
  44621. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44623. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44624. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44625. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44626. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44627. import { Scene } from "babylonjs/scene";
  44628. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44629. import { Color3 } from "babylonjs/Maths/math.color";
  44630. /**
  44631. * Single axis drag gizmo
  44632. */
  44633. export class AxisDragGizmo extends Gizmo {
  44634. /**
  44635. * Drag behavior responsible for the gizmos dragging interactions
  44636. */
  44637. dragBehavior: PointerDragBehavior;
  44638. private _pointerObserver;
  44639. /**
  44640. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44641. */
  44642. snapDistance: number;
  44643. /**
  44644. * Event that fires each time the gizmo snaps to a new location.
  44645. * * snapDistance is the the change in distance
  44646. */
  44647. onSnapObservable: Observable<{
  44648. snapDistance: number;
  44649. }>;
  44650. private _isEnabled;
  44651. private _parent;
  44652. private _arrow;
  44653. private _coloredMaterial;
  44654. private _hoverMaterial;
  44655. /** @hidden */
  44656. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44657. /** @hidden */
  44658. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44659. /**
  44660. * Creates an AxisDragGizmo
  44661. * @param gizmoLayer The utility layer the gizmo will be added to
  44662. * @param dragAxis The axis which the gizmo will be able to drag on
  44663. * @param color The color of the gizmo
  44664. */
  44665. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44666. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44667. /**
  44668. * If the gizmo is enabled
  44669. */
  44670. isEnabled: boolean;
  44671. /**
  44672. * Disposes of the gizmo
  44673. */
  44674. dispose(): void;
  44675. }
  44676. }
  44677. declare module "babylonjs/Debug/axesViewer" {
  44678. import { Vector3 } from "babylonjs/Maths/math.vector";
  44679. import { Nullable } from "babylonjs/types";
  44680. import { Scene } from "babylonjs/scene";
  44681. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44682. /**
  44683. * The Axes viewer will show 3 axes in a specific point in space
  44684. */
  44685. export class AxesViewer {
  44686. private _xAxis;
  44687. private _yAxis;
  44688. private _zAxis;
  44689. private _scaleLinesFactor;
  44690. private _instanced;
  44691. /**
  44692. * Gets the hosting scene
  44693. */
  44694. scene: Scene;
  44695. /**
  44696. * Gets or sets a number used to scale line length
  44697. */
  44698. scaleLines: number;
  44699. /** Gets the node hierarchy used to render x-axis */
  44700. readonly xAxis: TransformNode;
  44701. /** Gets the node hierarchy used to render y-axis */
  44702. readonly yAxis: TransformNode;
  44703. /** Gets the node hierarchy used to render z-axis */
  44704. readonly zAxis: TransformNode;
  44705. /**
  44706. * Creates a new AxesViewer
  44707. * @param scene defines the hosting scene
  44708. * @param scaleLines defines a number used to scale line length (1 by default)
  44709. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44710. * @param xAxis defines the node hierarchy used to render the x-axis
  44711. * @param yAxis defines the node hierarchy used to render the y-axis
  44712. * @param zAxis defines the node hierarchy used to render the z-axis
  44713. */
  44714. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44715. /**
  44716. * Force the viewer to update
  44717. * @param position defines the position of the viewer
  44718. * @param xaxis defines the x axis of the viewer
  44719. * @param yaxis defines the y axis of the viewer
  44720. * @param zaxis defines the z axis of the viewer
  44721. */
  44722. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44723. /**
  44724. * Creates an instance of this axes viewer.
  44725. * @returns a new axes viewer with instanced meshes
  44726. */
  44727. createInstance(): AxesViewer;
  44728. /** Releases resources */
  44729. dispose(): void;
  44730. private static _SetRenderingGroupId;
  44731. }
  44732. }
  44733. declare module "babylonjs/Debug/boneAxesViewer" {
  44734. import { Nullable } from "babylonjs/types";
  44735. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44736. import { Vector3 } from "babylonjs/Maths/math.vector";
  44737. import { Mesh } from "babylonjs/Meshes/mesh";
  44738. import { Bone } from "babylonjs/Bones/bone";
  44739. import { Scene } from "babylonjs/scene";
  44740. /**
  44741. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44742. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44743. */
  44744. export class BoneAxesViewer extends AxesViewer {
  44745. /**
  44746. * Gets or sets the target mesh where to display the axes viewer
  44747. */
  44748. mesh: Nullable<Mesh>;
  44749. /**
  44750. * Gets or sets the target bone where to display the axes viewer
  44751. */
  44752. bone: Nullable<Bone>;
  44753. /** Gets current position */
  44754. pos: Vector3;
  44755. /** Gets direction of X axis */
  44756. xaxis: Vector3;
  44757. /** Gets direction of Y axis */
  44758. yaxis: Vector3;
  44759. /** Gets direction of Z axis */
  44760. zaxis: Vector3;
  44761. /**
  44762. * Creates a new BoneAxesViewer
  44763. * @param scene defines the hosting scene
  44764. * @param bone defines the target bone
  44765. * @param mesh defines the target mesh
  44766. * @param scaleLines defines a scaling factor for line length (1 by default)
  44767. */
  44768. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44769. /**
  44770. * Force the viewer to update
  44771. */
  44772. update(): void;
  44773. /** Releases resources */
  44774. dispose(): void;
  44775. }
  44776. }
  44777. declare module "babylonjs/Debug/debugLayer" {
  44778. import { Scene } from "babylonjs/scene";
  44779. /**
  44780. * Interface used to define scene explorer extensibility option
  44781. */
  44782. export interface IExplorerExtensibilityOption {
  44783. /**
  44784. * Define the option label
  44785. */
  44786. label: string;
  44787. /**
  44788. * Defines the action to execute on click
  44789. */
  44790. action: (entity: any) => void;
  44791. }
  44792. /**
  44793. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44794. */
  44795. export interface IExplorerExtensibilityGroup {
  44796. /**
  44797. * Defines a predicate to test if a given type mut be extended
  44798. */
  44799. predicate: (entity: any) => boolean;
  44800. /**
  44801. * Gets the list of options added to a type
  44802. */
  44803. entries: IExplorerExtensibilityOption[];
  44804. }
  44805. /**
  44806. * Interface used to define the options to use to create the Inspector
  44807. */
  44808. export interface IInspectorOptions {
  44809. /**
  44810. * Display in overlay mode (default: false)
  44811. */
  44812. overlay?: boolean;
  44813. /**
  44814. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44815. */
  44816. globalRoot?: HTMLElement;
  44817. /**
  44818. * Display the Scene explorer
  44819. */
  44820. showExplorer?: boolean;
  44821. /**
  44822. * Display the property inspector
  44823. */
  44824. showInspector?: boolean;
  44825. /**
  44826. * Display in embed mode (both panes on the right)
  44827. */
  44828. embedMode?: boolean;
  44829. /**
  44830. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44831. */
  44832. handleResize?: boolean;
  44833. /**
  44834. * Allow the panes to popup (default: true)
  44835. */
  44836. enablePopup?: boolean;
  44837. /**
  44838. * Allow the panes to be closed by users (default: true)
  44839. */
  44840. enableClose?: boolean;
  44841. /**
  44842. * Optional list of extensibility entries
  44843. */
  44844. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44845. /**
  44846. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44847. */
  44848. inspectorURL?: string;
  44849. }
  44850. module "babylonjs/scene" {
  44851. interface Scene {
  44852. /**
  44853. * @hidden
  44854. * Backing field
  44855. */
  44856. _debugLayer: DebugLayer;
  44857. /**
  44858. * Gets the debug layer (aka Inspector) associated with the scene
  44859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44860. */
  44861. debugLayer: DebugLayer;
  44862. }
  44863. }
  44864. /**
  44865. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44866. * what is happening in your scene
  44867. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44868. */
  44869. export class DebugLayer {
  44870. /**
  44871. * Define the url to get the inspector script from.
  44872. * By default it uses the babylonjs CDN.
  44873. * @ignoreNaming
  44874. */
  44875. static InspectorURL: string;
  44876. private _scene;
  44877. private BJSINSPECTOR;
  44878. private _onPropertyChangedObservable?;
  44879. /**
  44880. * Observable triggered when a property is changed through the inspector.
  44881. */
  44882. readonly onPropertyChangedObservable: any;
  44883. /**
  44884. * Instantiates a new debug layer.
  44885. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44886. * what is happening in your scene
  44887. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44888. * @param scene Defines the scene to inspect
  44889. */
  44890. constructor(scene: Scene);
  44891. /** Creates the inspector window. */
  44892. private _createInspector;
  44893. /**
  44894. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44895. * @param entity defines the entity to select
  44896. * @param lineContainerTitle defines the specific block to highlight
  44897. */
  44898. select(entity: any, lineContainerTitle?: string): void;
  44899. /** Get the inspector from bundle or global */
  44900. private _getGlobalInspector;
  44901. /**
  44902. * Get if the inspector is visible or not.
  44903. * @returns true if visible otherwise, false
  44904. */
  44905. isVisible(): boolean;
  44906. /**
  44907. * Hide the inspector and close its window.
  44908. */
  44909. hide(): void;
  44910. /**
  44911. * Launch the debugLayer.
  44912. * @param config Define the configuration of the inspector
  44913. * @return a promise fulfilled when the debug layer is visible
  44914. */
  44915. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44916. }
  44917. }
  44918. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44919. import { Nullable } from "babylonjs/types";
  44920. import { Scene } from "babylonjs/scene";
  44921. import { Vector4 } from "babylonjs/Maths/math.vector";
  44922. import { Color4 } from "babylonjs/Maths/math.color";
  44923. import { Mesh } from "babylonjs/Meshes/mesh";
  44924. /**
  44925. * Class containing static functions to help procedurally build meshes
  44926. */
  44927. export class BoxBuilder {
  44928. /**
  44929. * Creates a box mesh
  44930. * * The parameter `size` sets the size (float) of each box side (default 1)
  44931. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44932. * * 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)
  44933. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44937. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44938. * @param name defines the name of the mesh
  44939. * @param options defines the options used to create the mesh
  44940. * @param scene defines the hosting scene
  44941. * @returns the box mesh
  44942. */
  44943. static CreateBox(name: string, options: {
  44944. size?: number;
  44945. width?: number;
  44946. height?: number;
  44947. depth?: number;
  44948. faceUV?: Vector4[];
  44949. faceColors?: Color4[];
  44950. sideOrientation?: number;
  44951. frontUVs?: Vector4;
  44952. backUVs?: Vector4;
  44953. wrap?: boolean;
  44954. topBaseAt?: number;
  44955. bottomBaseAt?: number;
  44956. updatable?: boolean;
  44957. }, scene?: Nullable<Scene>): Mesh;
  44958. }
  44959. }
  44960. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44961. import { Vector4 } from "babylonjs/Maths/math.vector";
  44962. import { Mesh } from "babylonjs/Meshes/mesh";
  44963. import { Scene } from "babylonjs/scene";
  44964. import { Nullable } from "babylonjs/types";
  44965. /**
  44966. * Class containing static functions to help procedurally build meshes
  44967. */
  44968. export class SphereBuilder {
  44969. /**
  44970. * Creates a sphere mesh
  44971. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44972. * * 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`)
  44973. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44974. * * 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
  44975. * * 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)
  44976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44979. * @param name defines the name of the mesh
  44980. * @param options defines the options used to create the mesh
  44981. * @param scene defines the hosting scene
  44982. * @returns the sphere mesh
  44983. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44984. */
  44985. static CreateSphere(name: string, options: {
  44986. segments?: number;
  44987. diameter?: number;
  44988. diameterX?: number;
  44989. diameterY?: number;
  44990. diameterZ?: number;
  44991. arc?: number;
  44992. slice?: number;
  44993. sideOrientation?: number;
  44994. frontUVs?: Vector4;
  44995. backUVs?: Vector4;
  44996. updatable?: boolean;
  44997. }, scene?: Nullable<Scene>): Mesh;
  44998. }
  44999. }
  45000. declare module "babylonjs/Debug/physicsViewer" {
  45001. import { Nullable } from "babylonjs/types";
  45002. import { Scene } from "babylonjs/scene";
  45003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45004. import { Mesh } from "babylonjs/Meshes/mesh";
  45005. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45006. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45007. /**
  45008. * Used to show the physics impostor around the specific mesh
  45009. */
  45010. export class PhysicsViewer {
  45011. /** @hidden */
  45012. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45013. /** @hidden */
  45014. protected _meshes: Array<Nullable<AbstractMesh>>;
  45015. /** @hidden */
  45016. protected _scene: Nullable<Scene>;
  45017. /** @hidden */
  45018. protected _numMeshes: number;
  45019. /** @hidden */
  45020. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45021. private _renderFunction;
  45022. private _utilityLayer;
  45023. private _debugBoxMesh;
  45024. private _debugSphereMesh;
  45025. private _debugCylinderMesh;
  45026. private _debugMaterial;
  45027. private _debugMeshMeshes;
  45028. /**
  45029. * Creates a new PhysicsViewer
  45030. * @param scene defines the hosting scene
  45031. */
  45032. constructor(scene: Scene);
  45033. /** @hidden */
  45034. protected _updateDebugMeshes(): void;
  45035. /**
  45036. * Renders a specified physic impostor
  45037. * @param impostor defines the impostor to render
  45038. * @param targetMesh defines the mesh represented by the impostor
  45039. * @returns the new debug mesh used to render the impostor
  45040. */
  45041. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45042. /**
  45043. * Hides a specified physic impostor
  45044. * @param impostor defines the impostor to hide
  45045. */
  45046. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45047. private _getDebugMaterial;
  45048. private _getDebugBoxMesh;
  45049. private _getDebugSphereMesh;
  45050. private _getDebugCylinderMesh;
  45051. private _getDebugMeshMesh;
  45052. private _getDebugMesh;
  45053. /** Releases all resources */
  45054. dispose(): void;
  45055. }
  45056. }
  45057. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45058. import { Vector3 } from "babylonjs/Maths/math.vector";
  45059. import { Color4 } from "babylonjs/Maths/math.color";
  45060. import { Nullable } from "babylonjs/types";
  45061. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45062. import { Scene } from "babylonjs/scene";
  45063. /**
  45064. * Class containing static functions to help procedurally build meshes
  45065. */
  45066. export class LinesBuilder {
  45067. /**
  45068. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45069. * * 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
  45070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45071. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45072. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45073. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45075. * * 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
  45076. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45079. * @param name defines the name of the new line system
  45080. * @param options defines the options used to create the line system
  45081. * @param scene defines the hosting scene
  45082. * @returns a new line system mesh
  45083. */
  45084. static CreateLineSystem(name: string, options: {
  45085. lines: Vector3[][];
  45086. updatable?: boolean;
  45087. instance?: Nullable<LinesMesh>;
  45088. colors?: Nullable<Color4[][]>;
  45089. useVertexAlpha?: boolean;
  45090. }, scene: Nullable<Scene>): LinesMesh;
  45091. /**
  45092. * Creates a line mesh
  45093. * 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
  45094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45095. * * The parameter `points` is an array successive Vector3
  45096. * * 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
  45097. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45099. * * When updating an instance, remember that only point positions can change, not the number of points
  45100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45102. * @param name defines the name of the new line system
  45103. * @param options defines the options used to create the line system
  45104. * @param scene defines the hosting scene
  45105. * @returns a new line mesh
  45106. */
  45107. static CreateLines(name: string, options: {
  45108. points: Vector3[];
  45109. updatable?: boolean;
  45110. instance?: Nullable<LinesMesh>;
  45111. colors?: Color4[];
  45112. useVertexAlpha?: boolean;
  45113. }, scene?: Nullable<Scene>): LinesMesh;
  45114. /**
  45115. * Creates a dashed line mesh
  45116. * * 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
  45117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45118. * * The parameter `points` is an array successive Vector3
  45119. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45120. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45121. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45122. * * 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
  45123. * * When updating an instance, remember that only point positions can change, not the number of points
  45124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45125. * @param name defines the name of the mesh
  45126. * @param options defines the options used to create the mesh
  45127. * @param scene defines the hosting scene
  45128. * @returns the dashed line mesh
  45129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45130. */
  45131. static CreateDashedLines(name: string, options: {
  45132. points: Vector3[];
  45133. dashSize?: number;
  45134. gapSize?: number;
  45135. dashNb?: number;
  45136. updatable?: boolean;
  45137. instance?: LinesMesh;
  45138. }, scene?: Nullable<Scene>): LinesMesh;
  45139. }
  45140. }
  45141. declare module "babylonjs/Debug/rayHelper" {
  45142. import { Nullable } from "babylonjs/types";
  45143. import { Ray } from "babylonjs/Culling/ray";
  45144. import { Vector3 } from "babylonjs/Maths/math.vector";
  45145. import { Color3 } from "babylonjs/Maths/math.color";
  45146. import { Scene } from "babylonjs/scene";
  45147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45148. import "babylonjs/Meshes/Builders/linesBuilder";
  45149. /**
  45150. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45151. * in order to better appreciate the issue one might have.
  45152. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45153. */
  45154. export class RayHelper {
  45155. /**
  45156. * Defines the ray we are currently tryin to visualize.
  45157. */
  45158. ray: Nullable<Ray>;
  45159. private _renderPoints;
  45160. private _renderLine;
  45161. private _renderFunction;
  45162. private _scene;
  45163. private _updateToMeshFunction;
  45164. private _attachedToMesh;
  45165. private _meshSpaceDirection;
  45166. private _meshSpaceOrigin;
  45167. /**
  45168. * Helper function to create a colored helper in a scene in one line.
  45169. * @param ray Defines the ray we are currently tryin to visualize
  45170. * @param scene Defines the scene the ray is used in
  45171. * @param color Defines the color we want to see the ray in
  45172. * @returns The newly created ray helper.
  45173. */
  45174. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45175. /**
  45176. * Instantiate a new ray helper.
  45177. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45178. * in order to better appreciate the issue one might have.
  45179. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45180. * @param ray Defines the ray we are currently tryin to visualize
  45181. */
  45182. constructor(ray: Ray);
  45183. /**
  45184. * Shows the ray we are willing to debug.
  45185. * @param scene Defines the scene the ray needs to be rendered in
  45186. * @param color Defines the color the ray needs to be rendered in
  45187. */
  45188. show(scene: Scene, color?: Color3): void;
  45189. /**
  45190. * Hides the ray we are debugging.
  45191. */
  45192. hide(): void;
  45193. private _render;
  45194. /**
  45195. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45196. * @param mesh Defines the mesh we want the helper attached to
  45197. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45198. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45199. * @param length Defines the length of the ray
  45200. */
  45201. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45202. /**
  45203. * Detach the ray helper from the mesh it has previously been attached to.
  45204. */
  45205. detachFromMesh(): void;
  45206. private _updateToMesh;
  45207. /**
  45208. * Dispose the helper and release its associated resources.
  45209. */
  45210. dispose(): void;
  45211. }
  45212. }
  45213. declare module "babylonjs/Debug/skeletonViewer" {
  45214. import { Color3 } from "babylonjs/Maths/math.color";
  45215. import { Scene } from "babylonjs/scene";
  45216. import { Nullable } from "babylonjs/types";
  45217. import { Skeleton } from "babylonjs/Bones/skeleton";
  45218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45219. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45220. /**
  45221. * Class used to render a debug view of a given skeleton
  45222. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45223. */
  45224. export class SkeletonViewer {
  45225. /** defines the skeleton to render */
  45226. skeleton: Skeleton;
  45227. /** defines the mesh attached to the skeleton */
  45228. mesh: AbstractMesh;
  45229. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45230. autoUpdateBonesMatrices: boolean;
  45231. /** defines the rendering group id to use with the viewer */
  45232. renderingGroupId: number;
  45233. /** Gets or sets the color used to render the skeleton */
  45234. color: Color3;
  45235. private _scene;
  45236. private _debugLines;
  45237. private _debugMesh;
  45238. private _isEnabled;
  45239. private _renderFunction;
  45240. private _utilityLayer;
  45241. /**
  45242. * Returns the mesh used to render the bones
  45243. */
  45244. readonly debugMesh: Nullable<LinesMesh>;
  45245. /**
  45246. * Creates a new SkeletonViewer
  45247. * @param skeleton defines the skeleton to render
  45248. * @param mesh defines the mesh attached to the skeleton
  45249. * @param scene defines the hosting scene
  45250. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45251. * @param renderingGroupId defines the rendering group id to use with the viewer
  45252. */
  45253. constructor(
  45254. /** defines the skeleton to render */
  45255. skeleton: Skeleton,
  45256. /** defines the mesh attached to the skeleton */
  45257. mesh: AbstractMesh, scene: Scene,
  45258. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45259. autoUpdateBonesMatrices?: boolean,
  45260. /** defines the rendering group id to use with the viewer */
  45261. renderingGroupId?: number);
  45262. /** Gets or sets a boolean indicating if the viewer is enabled */
  45263. isEnabled: boolean;
  45264. private _getBonePosition;
  45265. private _getLinesForBonesWithLength;
  45266. private _getLinesForBonesNoLength;
  45267. /** Update the viewer to sync with current skeleton state */
  45268. update(): void;
  45269. /** Release associated resources */
  45270. dispose(): void;
  45271. }
  45272. }
  45273. declare module "babylonjs/Debug/index" {
  45274. export * from "babylonjs/Debug/axesViewer";
  45275. export * from "babylonjs/Debug/boneAxesViewer";
  45276. export * from "babylonjs/Debug/debugLayer";
  45277. export * from "babylonjs/Debug/physicsViewer";
  45278. export * from "babylonjs/Debug/rayHelper";
  45279. export * from "babylonjs/Debug/skeletonViewer";
  45280. }
  45281. declare module "babylonjs/Engines/nullEngine" {
  45282. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45283. import { Scene } from "babylonjs/scene";
  45284. import { Engine } from "babylonjs/Engines/engine";
  45285. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45286. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45288. import { Effect } from "babylonjs/Materials/effect";
  45289. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45291. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45292. /**
  45293. * Options to create the null engine
  45294. */
  45295. export class NullEngineOptions {
  45296. /**
  45297. * Render width (Default: 512)
  45298. */
  45299. renderWidth: number;
  45300. /**
  45301. * Render height (Default: 256)
  45302. */
  45303. renderHeight: number;
  45304. /**
  45305. * Texture size (Default: 512)
  45306. */
  45307. textureSize: number;
  45308. /**
  45309. * If delta time between frames should be constant
  45310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45311. */
  45312. deterministicLockstep: boolean;
  45313. /**
  45314. * Maximum about of steps between frames (Default: 4)
  45315. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45316. */
  45317. lockstepMaxSteps: number;
  45318. }
  45319. /**
  45320. * The null engine class provides support for headless version of babylon.js.
  45321. * This can be used in server side scenario or for testing purposes
  45322. */
  45323. export class NullEngine extends Engine {
  45324. private _options;
  45325. /**
  45326. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45328. * @returns true if engine is in deterministic lock step mode
  45329. */
  45330. isDeterministicLockStep(): boolean;
  45331. /**
  45332. * Gets the max steps when engine is running in deterministic lock step
  45333. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45334. * @returns the max steps
  45335. */
  45336. getLockstepMaxSteps(): number;
  45337. /**
  45338. * Gets the current hardware scaling level.
  45339. * By default the hardware scaling level is computed from the window device ratio.
  45340. * 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.
  45341. * @returns a number indicating the current hardware scaling level
  45342. */
  45343. getHardwareScalingLevel(): number;
  45344. constructor(options?: NullEngineOptions);
  45345. /**
  45346. * Creates a vertex buffer
  45347. * @param vertices the data for the vertex buffer
  45348. * @returns the new WebGL static buffer
  45349. */
  45350. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45351. /**
  45352. * Creates a new index buffer
  45353. * @param indices defines the content of the index buffer
  45354. * @param updatable defines if the index buffer must be updatable
  45355. * @returns a new webGL buffer
  45356. */
  45357. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45358. /**
  45359. * Clear the current render buffer or the current render target (if any is set up)
  45360. * @param color defines the color to use
  45361. * @param backBuffer defines if the back buffer must be cleared
  45362. * @param depth defines if the depth buffer must be cleared
  45363. * @param stencil defines if the stencil buffer must be cleared
  45364. */
  45365. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45366. /**
  45367. * Gets the current render width
  45368. * @param useScreen defines if screen size must be used (or the current render target if any)
  45369. * @returns a number defining the current render width
  45370. */
  45371. getRenderWidth(useScreen?: boolean): number;
  45372. /**
  45373. * Gets the current render height
  45374. * @param useScreen defines if screen size must be used (or the current render target if any)
  45375. * @returns a number defining the current render height
  45376. */
  45377. getRenderHeight(useScreen?: boolean): number;
  45378. /**
  45379. * Set the WebGL's viewport
  45380. * @param viewport defines the viewport element to be used
  45381. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45382. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45383. */
  45384. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45385. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45386. /**
  45387. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45388. * @param pipelineContext defines the pipeline context to use
  45389. * @param uniformsNames defines the list of uniform names
  45390. * @returns an array of webGL uniform locations
  45391. */
  45392. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45393. /**
  45394. * Gets the lsit of active attributes for a given webGL program
  45395. * @param pipelineContext defines the pipeline context to use
  45396. * @param attributesNames defines the list of attribute names to get
  45397. * @returns an array of indices indicating the offset of each attribute
  45398. */
  45399. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45400. /**
  45401. * Binds an effect to the webGL context
  45402. * @param effect defines the effect to bind
  45403. */
  45404. bindSamplers(effect: Effect): void;
  45405. /**
  45406. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45407. * @param effect defines the effect to activate
  45408. */
  45409. enableEffect(effect: Effect): void;
  45410. /**
  45411. * Set various states to the webGL context
  45412. * @param culling defines backface culling state
  45413. * @param zOffset defines the value to apply to zOffset (0 by default)
  45414. * @param force defines if states must be applied even if cache is up to date
  45415. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45416. */
  45417. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45418. /**
  45419. * Set the value of an uniform to an array of int32
  45420. * @param uniform defines the webGL uniform location where to store the value
  45421. * @param array defines the array of int32 to store
  45422. */
  45423. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45424. /**
  45425. * Set the value of an uniform to an array of int32 (stored as vec2)
  45426. * @param uniform defines the webGL uniform location where to store the value
  45427. * @param array defines the array of int32 to store
  45428. */
  45429. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45430. /**
  45431. * Set the value of an uniform to an array of int32 (stored as vec3)
  45432. * @param uniform defines the webGL uniform location where to store the value
  45433. * @param array defines the array of int32 to store
  45434. */
  45435. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45436. /**
  45437. * Set the value of an uniform to an array of int32 (stored as vec4)
  45438. * @param uniform defines the webGL uniform location where to store the value
  45439. * @param array defines the array of int32 to store
  45440. */
  45441. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45442. /**
  45443. * Set the value of an uniform to an array of float32
  45444. * @param uniform defines the webGL uniform location where to store the value
  45445. * @param array defines the array of float32 to store
  45446. */
  45447. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45448. /**
  45449. * Set the value of an uniform to an array of float32 (stored as vec2)
  45450. * @param uniform defines the webGL uniform location where to store the value
  45451. * @param array defines the array of float32 to store
  45452. */
  45453. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45454. /**
  45455. * Set the value of an uniform to an array of float32 (stored as vec3)
  45456. * @param uniform defines the webGL uniform location where to store the value
  45457. * @param array defines the array of float32 to store
  45458. */
  45459. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45460. /**
  45461. * Set the value of an uniform to an array of float32 (stored as vec4)
  45462. * @param uniform defines the webGL uniform location where to store the value
  45463. * @param array defines the array of float32 to store
  45464. */
  45465. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45466. /**
  45467. * Set the value of an uniform to an array of number
  45468. * @param uniform defines the webGL uniform location where to store the value
  45469. * @param array defines the array of number to store
  45470. */
  45471. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45472. /**
  45473. * Set the value of an uniform to an array of number (stored as vec2)
  45474. * @param uniform defines the webGL uniform location where to store the value
  45475. * @param array defines the array of number to store
  45476. */
  45477. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45478. /**
  45479. * Set the value of an uniform to an array of number (stored as vec3)
  45480. * @param uniform defines the webGL uniform location where to store the value
  45481. * @param array defines the array of number to store
  45482. */
  45483. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45484. /**
  45485. * Set the value of an uniform to an array of number (stored as vec4)
  45486. * @param uniform defines the webGL uniform location where to store the value
  45487. * @param array defines the array of number to store
  45488. */
  45489. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45490. /**
  45491. * Set the value of an uniform to an array of float32 (stored as matrices)
  45492. * @param uniform defines the webGL uniform location where to store the value
  45493. * @param matrices defines the array of float32 to store
  45494. */
  45495. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45496. /**
  45497. * Set the value of an uniform to a matrix (3x3)
  45498. * @param uniform defines the webGL uniform location where to store the value
  45499. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45500. */
  45501. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45502. /**
  45503. * Set the value of an uniform to a matrix (2x2)
  45504. * @param uniform defines the webGL uniform location where to store the value
  45505. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45506. */
  45507. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45508. /**
  45509. * Set the value of an uniform to a number (float)
  45510. * @param uniform defines the webGL uniform location where to store the value
  45511. * @param value defines the float number to store
  45512. */
  45513. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45514. /**
  45515. * Set the value of an uniform to a vec2
  45516. * @param uniform defines the webGL uniform location where to store the value
  45517. * @param x defines the 1st component of the value
  45518. * @param y defines the 2nd component of the value
  45519. */
  45520. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45521. /**
  45522. * Set the value of an uniform to a vec3
  45523. * @param uniform defines the webGL uniform location where to store the value
  45524. * @param x defines the 1st component of the value
  45525. * @param y defines the 2nd component of the value
  45526. * @param z defines the 3rd component of the value
  45527. */
  45528. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45529. /**
  45530. * Set the value of an uniform to a boolean
  45531. * @param uniform defines the webGL uniform location where to store the value
  45532. * @param bool defines the boolean to store
  45533. */
  45534. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45535. /**
  45536. * Set the value of an uniform to a vec4
  45537. * @param uniform defines the webGL uniform location where to store the value
  45538. * @param x defines the 1st component of the value
  45539. * @param y defines the 2nd component of the value
  45540. * @param z defines the 3rd component of the value
  45541. * @param w defines the 4th component of the value
  45542. */
  45543. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45544. /**
  45545. * Sets the current alpha mode
  45546. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45547. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45549. */
  45550. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45551. /**
  45552. * Bind webGl buffers directly to the webGL context
  45553. * @param vertexBuffers defines the vertex buffer to bind
  45554. * @param indexBuffer defines the index buffer to bind
  45555. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45556. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45557. * @param effect defines the effect associated with the vertex buffer
  45558. */
  45559. bindBuffers(vertexBuffers: {
  45560. [key: string]: VertexBuffer;
  45561. }, indexBuffer: DataBuffer, effect: Effect): void;
  45562. /**
  45563. * Force the entire cache to be cleared
  45564. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45565. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45566. */
  45567. wipeCaches(bruteForce?: boolean): void;
  45568. /**
  45569. * Send a draw order
  45570. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45571. * @param indexStart defines the starting index
  45572. * @param indexCount defines the number of index to draw
  45573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45574. */
  45575. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45576. /**
  45577. * Draw a list of indexed primitives
  45578. * @param fillMode defines the primitive to use
  45579. * @param indexStart defines the starting index
  45580. * @param indexCount defines the number of index to draw
  45581. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45582. */
  45583. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45584. /**
  45585. * Draw a list of unindexed primitives
  45586. * @param fillMode defines the primitive to use
  45587. * @param verticesStart defines the index of first vertex to draw
  45588. * @param verticesCount defines the count of vertices to draw
  45589. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45590. */
  45591. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45592. /** @hidden */
  45593. _createTexture(): WebGLTexture;
  45594. /** @hidden */
  45595. _releaseTexture(texture: InternalTexture): void;
  45596. /**
  45597. * Usually called from Texture.ts.
  45598. * Passed information to create a WebGLTexture
  45599. * @param urlArg defines a value which contains one of the following:
  45600. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45601. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45602. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45603. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45604. * @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)
  45605. * @param scene needed for loading to the correct scene
  45606. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45607. * @param onLoad optional callback to be called upon successful completion
  45608. * @param onError optional callback to be called upon failure
  45609. * @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
  45610. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45611. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45612. * @param forcedExtension defines the extension to use to pick the right loader
  45613. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45614. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45615. */
  45616. 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;
  45617. /**
  45618. * Creates a new render target texture
  45619. * @param size defines the size of the texture
  45620. * @param options defines the options used to create the texture
  45621. * @returns a new render target texture stored in an InternalTexture
  45622. */
  45623. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45624. /**
  45625. * Update the sampling mode of a given texture
  45626. * @param samplingMode defines the required sampling mode
  45627. * @param texture defines the texture to update
  45628. */
  45629. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45630. /**
  45631. * Binds the frame buffer to the specified texture.
  45632. * @param texture The texture to render to or null for the default canvas
  45633. * @param faceIndex The face of the texture to render to in case of cube texture
  45634. * @param requiredWidth The width of the target to render to
  45635. * @param requiredHeight The height of the target to render to
  45636. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45637. * @param depthStencilTexture The depth stencil texture to use to render
  45638. * @param lodLevel defines le lod level to bind to the frame buffer
  45639. */
  45640. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45641. /**
  45642. * Unbind the current render target texture from the webGL context
  45643. * @param texture defines the render target texture to unbind
  45644. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45645. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45646. */
  45647. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45648. /**
  45649. * Creates a dynamic vertex buffer
  45650. * @param vertices the data for the dynamic vertex buffer
  45651. * @returns the new WebGL dynamic buffer
  45652. */
  45653. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45654. /**
  45655. * Update the content of a dynamic texture
  45656. * @param texture defines the texture to update
  45657. * @param canvas defines the canvas containing the source
  45658. * @param invertY defines if data must be stored with Y axis inverted
  45659. * @param premulAlpha defines if alpha is stored as premultiplied
  45660. * @param format defines the format of the data
  45661. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45662. */
  45663. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45664. /**
  45665. * Gets a boolean indicating if all created effects are ready
  45666. * @returns true if all effects are ready
  45667. */
  45668. areAllEffectsReady(): boolean;
  45669. /**
  45670. * @hidden
  45671. * Get the current error code of the webGL context
  45672. * @returns the error code
  45673. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45674. */
  45675. getError(): number;
  45676. /** @hidden */
  45677. _getUnpackAlignement(): number;
  45678. /** @hidden */
  45679. _unpackFlipY(value: boolean): void;
  45680. /**
  45681. * Update a dynamic index buffer
  45682. * @param indexBuffer defines the target index buffer
  45683. * @param indices defines the data to update
  45684. * @param offset defines the offset in the target index buffer where update should start
  45685. */
  45686. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45687. /**
  45688. * Updates a dynamic vertex buffer.
  45689. * @param vertexBuffer the vertex buffer to update
  45690. * @param vertices the data used to update the vertex buffer
  45691. * @param byteOffset the byte offset of the data (optional)
  45692. * @param byteLength the byte length of the data (optional)
  45693. */
  45694. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45695. /** @hidden */
  45696. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45697. /** @hidden */
  45698. _bindTexture(channel: number, texture: InternalTexture): void;
  45699. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45700. /**
  45701. * 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
  45702. */
  45703. releaseEffects(): void;
  45704. displayLoadingUI(): void;
  45705. hideLoadingUI(): void;
  45706. /** @hidden */
  45707. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45708. /** @hidden */
  45709. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45710. /** @hidden */
  45711. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45712. /** @hidden */
  45713. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45714. }
  45715. }
  45716. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45717. import { Nullable, int } from "babylonjs/types";
  45718. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45719. /** @hidden */
  45720. export class _OcclusionDataStorage {
  45721. /** @hidden */
  45722. occlusionInternalRetryCounter: number;
  45723. /** @hidden */
  45724. isOcclusionQueryInProgress: boolean;
  45725. /** @hidden */
  45726. isOccluded: boolean;
  45727. /** @hidden */
  45728. occlusionRetryCount: number;
  45729. /** @hidden */
  45730. occlusionType: number;
  45731. /** @hidden */
  45732. occlusionQueryAlgorithmType: number;
  45733. }
  45734. module "babylonjs/Engines/engine" {
  45735. interface Engine {
  45736. /**
  45737. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45738. * @return the new query
  45739. */
  45740. createQuery(): WebGLQuery;
  45741. /**
  45742. * Delete and release a webGL query
  45743. * @param query defines the query to delete
  45744. * @return the current engine
  45745. */
  45746. deleteQuery(query: WebGLQuery): Engine;
  45747. /**
  45748. * Check if a given query has resolved and got its value
  45749. * @param query defines the query to check
  45750. * @returns true if the query got its value
  45751. */
  45752. isQueryResultAvailable(query: WebGLQuery): boolean;
  45753. /**
  45754. * Gets the value of a given query
  45755. * @param query defines the query to check
  45756. * @returns the value of the query
  45757. */
  45758. getQueryResult(query: WebGLQuery): number;
  45759. /**
  45760. * Initiates an occlusion query
  45761. * @param algorithmType defines the algorithm to use
  45762. * @param query defines the query to use
  45763. * @returns the current engine
  45764. * @see http://doc.babylonjs.com/features/occlusionquery
  45765. */
  45766. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45767. /**
  45768. * Ends an occlusion query
  45769. * @see http://doc.babylonjs.com/features/occlusionquery
  45770. * @param algorithmType defines the algorithm to use
  45771. * @returns the current engine
  45772. */
  45773. endOcclusionQuery(algorithmType: number): Engine;
  45774. /**
  45775. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45776. * Please note that only one query can be issued at a time
  45777. * @returns a time token used to track the time span
  45778. */
  45779. startTimeQuery(): Nullable<_TimeToken>;
  45780. /**
  45781. * Ends a time query
  45782. * @param token defines the token used to measure the time span
  45783. * @returns the time spent (in ns)
  45784. */
  45785. endTimeQuery(token: _TimeToken): int;
  45786. /** @hidden */
  45787. _currentNonTimestampToken: Nullable<_TimeToken>;
  45788. /** @hidden */
  45789. _createTimeQuery(): WebGLQuery;
  45790. /** @hidden */
  45791. _deleteTimeQuery(query: WebGLQuery): void;
  45792. /** @hidden */
  45793. _getGlAlgorithmType(algorithmType: number): number;
  45794. /** @hidden */
  45795. _getTimeQueryResult(query: WebGLQuery): any;
  45796. /** @hidden */
  45797. _getTimeQueryAvailability(query: WebGLQuery): any;
  45798. }
  45799. }
  45800. module "babylonjs/Meshes/abstractMesh" {
  45801. interface AbstractMesh {
  45802. /**
  45803. * Backing filed
  45804. * @hidden
  45805. */
  45806. __occlusionDataStorage: _OcclusionDataStorage;
  45807. /**
  45808. * Access property
  45809. * @hidden
  45810. */
  45811. _occlusionDataStorage: _OcclusionDataStorage;
  45812. /**
  45813. * 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.
  45814. * The default value is -1 which means don't break the query and wait till the result
  45815. * @see http://doc.babylonjs.com/features/occlusionquery
  45816. */
  45817. occlusionRetryCount: number;
  45818. /**
  45819. * 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:
  45820. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45821. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45822. * * 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.
  45823. * @see http://doc.babylonjs.com/features/occlusionquery
  45824. */
  45825. occlusionType: number;
  45826. /**
  45827. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45828. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45829. * * 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.
  45830. * @see http://doc.babylonjs.com/features/occlusionquery
  45831. */
  45832. occlusionQueryAlgorithmType: number;
  45833. /**
  45834. * 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
  45835. * @see http://doc.babylonjs.com/features/occlusionquery
  45836. */
  45837. isOccluded: boolean;
  45838. /**
  45839. * Flag to check the progress status of the query
  45840. * @see http://doc.babylonjs.com/features/occlusionquery
  45841. */
  45842. isOcclusionQueryInProgress: boolean;
  45843. }
  45844. }
  45845. }
  45846. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45847. import { Nullable } from "babylonjs/types";
  45848. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45849. /** @hidden */
  45850. export var _forceTransformFeedbackToBundle: boolean;
  45851. module "babylonjs/Engines/engine" {
  45852. interface Engine {
  45853. /**
  45854. * Creates a webGL transform feedback object
  45855. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45856. * @returns the webGL transform feedback object
  45857. */
  45858. createTransformFeedback(): WebGLTransformFeedback;
  45859. /**
  45860. * Delete a webGL transform feedback object
  45861. * @param value defines the webGL transform feedback object to delete
  45862. */
  45863. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45864. /**
  45865. * Bind a webGL transform feedback object to the webgl context
  45866. * @param value defines the webGL transform feedback object to bind
  45867. */
  45868. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45869. /**
  45870. * Begins a transform feedback operation
  45871. * @param usePoints defines if points or triangles must be used
  45872. */
  45873. beginTransformFeedback(usePoints: boolean): void;
  45874. /**
  45875. * Ends a transform feedback operation
  45876. */
  45877. endTransformFeedback(): void;
  45878. /**
  45879. * Specify the varyings to use with transform feedback
  45880. * @param program defines the associated webGL program
  45881. * @param value defines the list of strings representing the varying names
  45882. */
  45883. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45884. /**
  45885. * Bind a webGL buffer for a transform feedback operation
  45886. * @param value defines the webGL buffer to bind
  45887. */
  45888. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45889. }
  45890. }
  45891. }
  45892. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45893. import { Scene } from "babylonjs/scene";
  45894. import { Engine } from "babylonjs/Engines/engine";
  45895. import { Texture } from "babylonjs/Materials/Textures/texture";
  45896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45897. import "babylonjs/Engines/Extensions/engine.multiRender";
  45898. /**
  45899. * Creation options of the multi render target texture.
  45900. */
  45901. export interface IMultiRenderTargetOptions {
  45902. /**
  45903. * Define if the texture needs to create mip maps after render.
  45904. */
  45905. generateMipMaps?: boolean;
  45906. /**
  45907. * Define the types of all the draw buffers we want to create
  45908. */
  45909. types?: number[];
  45910. /**
  45911. * Define the sampling modes of all the draw buffers we want to create
  45912. */
  45913. samplingModes?: number[];
  45914. /**
  45915. * Define if a depth buffer is required
  45916. */
  45917. generateDepthBuffer?: boolean;
  45918. /**
  45919. * Define if a stencil buffer is required
  45920. */
  45921. generateStencilBuffer?: boolean;
  45922. /**
  45923. * Define if a depth texture is required instead of a depth buffer
  45924. */
  45925. generateDepthTexture?: boolean;
  45926. /**
  45927. * Define the number of desired draw buffers
  45928. */
  45929. textureCount?: number;
  45930. /**
  45931. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45932. */
  45933. doNotChangeAspectRatio?: boolean;
  45934. /**
  45935. * Define the default type of the buffers we are creating
  45936. */
  45937. defaultType?: number;
  45938. }
  45939. /**
  45940. * A multi render target, like a render target provides the ability to render to a texture.
  45941. * Unlike the render target, it can render to several draw buffers in one draw.
  45942. * This is specially interesting in deferred rendering or for any effects requiring more than
  45943. * just one color from a single pass.
  45944. */
  45945. export class MultiRenderTarget extends RenderTargetTexture {
  45946. private _internalTextures;
  45947. private _textures;
  45948. private _multiRenderTargetOptions;
  45949. /**
  45950. * Get if draw buffers are currently supported by the used hardware and browser.
  45951. */
  45952. readonly isSupported: boolean;
  45953. /**
  45954. * Get the list of textures generated by the multi render target.
  45955. */
  45956. readonly textures: Texture[];
  45957. /**
  45958. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45959. */
  45960. readonly depthTexture: Texture;
  45961. /**
  45962. * Set the wrapping mode on U of all the textures we are rendering to.
  45963. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45964. */
  45965. wrapU: number;
  45966. /**
  45967. * Set the wrapping mode on V of all the textures we are rendering to.
  45968. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45969. */
  45970. wrapV: number;
  45971. /**
  45972. * Instantiate a new multi render target texture.
  45973. * A multi render target, like a render target provides the ability to render to a texture.
  45974. * Unlike the render target, it can render to several draw buffers in one draw.
  45975. * This is specially interesting in deferred rendering or for any effects requiring more than
  45976. * just one color from a single pass.
  45977. * @param name Define the name of the texture
  45978. * @param size Define the size of the buffers to render to
  45979. * @param count Define the number of target we are rendering into
  45980. * @param scene Define the scene the texture belongs to
  45981. * @param options Define the options used to create the multi render target
  45982. */
  45983. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45984. /** @hidden */
  45985. _rebuild(): void;
  45986. private _createInternalTextures;
  45987. private _createTextures;
  45988. /**
  45989. * Define the number of samples used if MSAA is enabled.
  45990. */
  45991. samples: number;
  45992. /**
  45993. * Resize all the textures in the multi render target.
  45994. * Be carrefull as it will recreate all the data in the new texture.
  45995. * @param size Define the new size
  45996. */
  45997. resize(size: any): void;
  45998. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45999. /**
  46000. * Dispose the render targets and their associated resources
  46001. */
  46002. dispose(): void;
  46003. /**
  46004. * Release all the underlying texture used as draw buffers.
  46005. */
  46006. releaseInternalTextures(): void;
  46007. }
  46008. }
  46009. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46011. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46012. import { Nullable } from "babylonjs/types";
  46013. module "babylonjs/Engines/thinEngine" {
  46014. interface ThinEngine {
  46015. /**
  46016. * Unbind a list of render target textures from the webGL context
  46017. * This is used only when drawBuffer extension or webGL2 are active
  46018. * @param textures defines the render target textures to unbind
  46019. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46020. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46021. */
  46022. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46023. /**
  46024. * Create a multi render target texture
  46025. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46026. * @param size defines the size of the texture
  46027. * @param options defines the creation options
  46028. * @returns the cube texture as an InternalTexture
  46029. */
  46030. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46031. /**
  46032. * Update the sample count for a given multiple render target texture
  46033. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46034. * @param textures defines the textures to update
  46035. * @param samples defines the sample count to set
  46036. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46037. */
  46038. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46039. }
  46040. }
  46041. }
  46042. declare module "babylonjs/Engines/Extensions/index" {
  46043. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46044. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46045. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46046. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46047. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46048. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46049. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46050. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46051. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46052. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46053. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46054. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46055. }
  46056. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46057. import { Nullable } from "babylonjs/types";
  46058. /**
  46059. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46060. */
  46061. export interface CubeMapInfo {
  46062. /**
  46063. * The pixel array for the front face.
  46064. * This is stored in format, left to right, up to down format.
  46065. */
  46066. front: Nullable<ArrayBufferView>;
  46067. /**
  46068. * The pixel array for the back face.
  46069. * This is stored in format, left to right, up to down format.
  46070. */
  46071. back: Nullable<ArrayBufferView>;
  46072. /**
  46073. * The pixel array for the left face.
  46074. * This is stored in format, left to right, up to down format.
  46075. */
  46076. left: Nullable<ArrayBufferView>;
  46077. /**
  46078. * The pixel array for the right face.
  46079. * This is stored in format, left to right, up to down format.
  46080. */
  46081. right: Nullable<ArrayBufferView>;
  46082. /**
  46083. * The pixel array for the up face.
  46084. * This is stored in format, left to right, up to down format.
  46085. */
  46086. up: Nullable<ArrayBufferView>;
  46087. /**
  46088. * The pixel array for the down face.
  46089. * This is stored in format, left to right, up to down format.
  46090. */
  46091. down: Nullable<ArrayBufferView>;
  46092. /**
  46093. * The size of the cubemap stored.
  46094. *
  46095. * Each faces will be size * size pixels.
  46096. */
  46097. size: number;
  46098. /**
  46099. * The format of the texture.
  46100. *
  46101. * RGBA, RGB.
  46102. */
  46103. format: number;
  46104. /**
  46105. * The type of the texture data.
  46106. *
  46107. * UNSIGNED_INT, FLOAT.
  46108. */
  46109. type: number;
  46110. /**
  46111. * Specifies whether the texture is in gamma space.
  46112. */
  46113. gammaSpace: boolean;
  46114. }
  46115. /**
  46116. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46117. */
  46118. export class PanoramaToCubeMapTools {
  46119. private static FACE_FRONT;
  46120. private static FACE_BACK;
  46121. private static FACE_RIGHT;
  46122. private static FACE_LEFT;
  46123. private static FACE_DOWN;
  46124. private static FACE_UP;
  46125. /**
  46126. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46127. *
  46128. * @param float32Array The source data.
  46129. * @param inputWidth The width of the input panorama.
  46130. * @param inputHeight The height of the input panorama.
  46131. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46132. * @return The cubemap data
  46133. */
  46134. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46135. private static CreateCubemapTexture;
  46136. private static CalcProjectionSpherical;
  46137. }
  46138. }
  46139. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46140. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46142. import { Nullable } from "babylonjs/types";
  46143. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46144. /**
  46145. * Helper class dealing with the extraction of spherical polynomial dataArray
  46146. * from a cube map.
  46147. */
  46148. export class CubeMapToSphericalPolynomialTools {
  46149. private static FileFaces;
  46150. /**
  46151. * Converts a texture to the according Spherical Polynomial data.
  46152. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46153. *
  46154. * @param texture The texture to extract the information from.
  46155. * @return The Spherical Polynomial data.
  46156. */
  46157. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46158. /**
  46159. * Converts a cubemap to the according Spherical Polynomial data.
  46160. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46161. *
  46162. * @param cubeInfo The Cube map to extract the information from.
  46163. * @return The Spherical Polynomial data.
  46164. */
  46165. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46166. }
  46167. }
  46168. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46169. import { Nullable } from "babylonjs/types";
  46170. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46171. module "babylonjs/Materials/Textures/baseTexture" {
  46172. interface BaseTexture {
  46173. /**
  46174. * Get the polynomial representation of the texture data.
  46175. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46176. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46177. */
  46178. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46179. }
  46180. }
  46181. }
  46182. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46183. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46184. /** @hidden */
  46185. export var rgbdEncodePixelShader: {
  46186. name: string;
  46187. shader: string;
  46188. };
  46189. }
  46190. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46191. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46192. /** @hidden */
  46193. export var rgbdDecodePixelShader: {
  46194. name: string;
  46195. shader: string;
  46196. };
  46197. }
  46198. declare module "babylonjs/Misc/environmentTextureTools" {
  46199. import { Nullable } from "babylonjs/types";
  46200. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46202. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46203. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46204. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46205. import "babylonjs/Shaders/rgbdEncode.fragment";
  46206. import "babylonjs/Shaders/rgbdDecode.fragment";
  46207. /**
  46208. * Raw texture data and descriptor sufficient for WebGL texture upload
  46209. */
  46210. export interface EnvironmentTextureInfo {
  46211. /**
  46212. * Version of the environment map
  46213. */
  46214. version: number;
  46215. /**
  46216. * Width of image
  46217. */
  46218. width: number;
  46219. /**
  46220. * Irradiance information stored in the file.
  46221. */
  46222. irradiance: any;
  46223. /**
  46224. * Specular information stored in the file.
  46225. */
  46226. specular: any;
  46227. }
  46228. /**
  46229. * Defines One Image in the file. It requires only the position in the file
  46230. * as well as the length.
  46231. */
  46232. interface BufferImageData {
  46233. /**
  46234. * Length of the image data.
  46235. */
  46236. length: number;
  46237. /**
  46238. * Position of the data from the null terminator delimiting the end of the JSON.
  46239. */
  46240. position: number;
  46241. }
  46242. /**
  46243. * Defines the specular data enclosed in the file.
  46244. * This corresponds to the version 1 of the data.
  46245. */
  46246. export interface EnvironmentTextureSpecularInfoV1 {
  46247. /**
  46248. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46249. */
  46250. specularDataPosition?: number;
  46251. /**
  46252. * This contains all the images data needed to reconstruct the cubemap.
  46253. */
  46254. mipmaps: Array<BufferImageData>;
  46255. /**
  46256. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46257. */
  46258. lodGenerationScale: number;
  46259. }
  46260. /**
  46261. * Sets of helpers addressing the serialization and deserialization of environment texture
  46262. * stored in a BabylonJS env file.
  46263. * Those files are usually stored as .env files.
  46264. */
  46265. export class EnvironmentTextureTools {
  46266. /**
  46267. * Magic number identifying the env file.
  46268. */
  46269. private static _MagicBytes;
  46270. /**
  46271. * Gets the environment info from an env file.
  46272. * @param data The array buffer containing the .env bytes.
  46273. * @returns the environment file info (the json header) if successfully parsed.
  46274. */
  46275. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46276. /**
  46277. * Creates an environment texture from a loaded cube texture.
  46278. * @param texture defines the cube texture to convert in env file
  46279. * @return a promise containing the environment data if succesfull.
  46280. */
  46281. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46282. /**
  46283. * Creates a JSON representation of the spherical data.
  46284. * @param texture defines the texture containing the polynomials
  46285. * @return the JSON representation of the spherical info
  46286. */
  46287. private static _CreateEnvTextureIrradiance;
  46288. /**
  46289. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46290. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46291. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46292. * @return the views described by info providing access to the underlying buffer
  46293. */
  46294. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46295. /**
  46296. * Uploads the texture info contained in the env file to the GPU.
  46297. * @param texture defines the internal texture to upload to
  46298. * @param arrayBuffer defines the buffer cotaining the data to load
  46299. * @param info defines the texture info retrieved through the GetEnvInfo method
  46300. * @returns a promise
  46301. */
  46302. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46303. private static _OnImageReadyAsync;
  46304. /**
  46305. * Uploads the levels of image data to the GPU.
  46306. * @param texture defines the internal texture to upload to
  46307. * @param imageData defines the array buffer views of image data [mipmap][face]
  46308. * @returns a promise
  46309. */
  46310. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46311. /**
  46312. * Uploads spherical polynomials information to the texture.
  46313. * @param texture defines the texture we are trying to upload the information to
  46314. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46315. */
  46316. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46317. /** @hidden */
  46318. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46319. }
  46320. }
  46321. declare module "babylonjs/Maths/math.vertexFormat" {
  46322. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46323. /**
  46324. * Contains position and normal vectors for a vertex
  46325. */
  46326. export class PositionNormalVertex {
  46327. /** the position of the vertex (defaut: 0,0,0) */
  46328. position: Vector3;
  46329. /** the normal of the vertex (defaut: 0,1,0) */
  46330. normal: Vector3;
  46331. /**
  46332. * Creates a PositionNormalVertex
  46333. * @param position the position of the vertex (defaut: 0,0,0)
  46334. * @param normal the normal of the vertex (defaut: 0,1,0)
  46335. */
  46336. constructor(
  46337. /** the position of the vertex (defaut: 0,0,0) */
  46338. position?: Vector3,
  46339. /** the normal of the vertex (defaut: 0,1,0) */
  46340. normal?: Vector3);
  46341. /**
  46342. * Clones the PositionNormalVertex
  46343. * @returns the cloned PositionNormalVertex
  46344. */
  46345. clone(): PositionNormalVertex;
  46346. }
  46347. /**
  46348. * Contains position, normal and uv vectors for a vertex
  46349. */
  46350. export class PositionNormalTextureVertex {
  46351. /** the position of the vertex (defaut: 0,0,0) */
  46352. position: Vector3;
  46353. /** the normal of the vertex (defaut: 0,1,0) */
  46354. normal: Vector3;
  46355. /** the uv of the vertex (default: 0,0) */
  46356. uv: Vector2;
  46357. /**
  46358. * Creates a PositionNormalTextureVertex
  46359. * @param position the position of the vertex (defaut: 0,0,0)
  46360. * @param normal the normal of the vertex (defaut: 0,1,0)
  46361. * @param uv the uv of the vertex (default: 0,0)
  46362. */
  46363. constructor(
  46364. /** the position of the vertex (defaut: 0,0,0) */
  46365. position?: Vector3,
  46366. /** the normal of the vertex (defaut: 0,1,0) */
  46367. normal?: Vector3,
  46368. /** the uv of the vertex (default: 0,0) */
  46369. uv?: Vector2);
  46370. /**
  46371. * Clones the PositionNormalTextureVertex
  46372. * @returns the cloned PositionNormalTextureVertex
  46373. */
  46374. clone(): PositionNormalTextureVertex;
  46375. }
  46376. }
  46377. declare module "babylonjs/Maths/math" {
  46378. export * from "babylonjs/Maths/math.axis";
  46379. export * from "babylonjs/Maths/math.color";
  46380. export * from "babylonjs/Maths/math.constants";
  46381. export * from "babylonjs/Maths/math.frustum";
  46382. export * from "babylonjs/Maths/math.path";
  46383. export * from "babylonjs/Maths/math.plane";
  46384. export * from "babylonjs/Maths/math.size";
  46385. export * from "babylonjs/Maths/math.vector";
  46386. export * from "babylonjs/Maths/math.vertexFormat";
  46387. export * from "babylonjs/Maths/math.viewport";
  46388. }
  46389. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46390. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46391. /** @hidden */
  46392. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46393. private _genericAttributeLocation;
  46394. private _varyingLocationCount;
  46395. private _varyingLocationMap;
  46396. private _replacements;
  46397. private _textureCount;
  46398. private _uniforms;
  46399. lineProcessor(line: string): string;
  46400. attributeProcessor(attribute: string): string;
  46401. varyingProcessor(varying: string, isFragment: boolean): string;
  46402. uniformProcessor(uniform: string): string;
  46403. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46404. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46405. }
  46406. }
  46407. declare module "babylonjs/Engines/nativeEngine" {
  46408. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46409. import { Engine } from "babylonjs/Engines/engine";
  46410. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46413. import { Effect } from "babylonjs/Materials/effect";
  46414. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46415. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46416. import { Scene } from "babylonjs/scene";
  46417. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46418. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46419. /**
  46420. * Container for accessors for natively-stored mesh data buffers.
  46421. */
  46422. class NativeDataBuffer extends DataBuffer {
  46423. /**
  46424. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46425. */
  46426. nativeIndexBuffer?: any;
  46427. /**
  46428. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46429. */
  46430. nativeVertexBuffer?: any;
  46431. }
  46432. /** @hidden */
  46433. export class NativeEngine extends Engine {
  46434. private readonly _native;
  46435. getHardwareScalingLevel(): number;
  46436. constructor();
  46437. /**
  46438. * Can be used to override the current requestAnimationFrame requester.
  46439. * @hidden
  46440. */
  46441. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46442. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46443. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46444. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46445. recordVertexArrayObject(vertexBuffers: {
  46446. [key: string]: VertexBuffer;
  46447. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46448. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46449. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46450. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46451. /**
  46452. * Draw a list of indexed primitives
  46453. * @param fillMode defines the primitive to use
  46454. * @param indexStart defines the starting index
  46455. * @param indexCount defines the number of index to draw
  46456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46457. */
  46458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46459. /**
  46460. * Draw a list of unindexed primitives
  46461. * @param fillMode defines the primitive to use
  46462. * @param verticesStart defines the index of first vertex to draw
  46463. * @param verticesCount defines the count of vertices to draw
  46464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46465. */
  46466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46467. createPipelineContext(): IPipelineContext;
  46468. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46469. /** @hidden */
  46470. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46471. /** @hidden */
  46472. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46473. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46474. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46475. protected _setProgram(program: WebGLProgram): void;
  46476. _releaseEffect(effect: Effect): void;
  46477. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46478. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46479. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46480. bindSamplers(effect: Effect): void;
  46481. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46482. getRenderWidth(useScreen?: boolean): number;
  46483. getRenderHeight(useScreen?: boolean): number;
  46484. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46485. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46486. /**
  46487. * Set the z offset to apply to current rendering
  46488. * @param value defines the offset to apply
  46489. */
  46490. setZOffset(value: number): void;
  46491. /**
  46492. * Gets the current value of the zOffset
  46493. * @returns the current zOffset state
  46494. */
  46495. getZOffset(): number;
  46496. /**
  46497. * Enable or disable depth buffering
  46498. * @param enable defines the state to set
  46499. */
  46500. setDepthBuffer(enable: boolean): void;
  46501. /**
  46502. * Gets a boolean indicating if depth writing is enabled
  46503. * @returns the current depth writing state
  46504. */
  46505. getDepthWrite(): boolean;
  46506. /**
  46507. * Enable or disable depth writing
  46508. * @param enable defines the state to set
  46509. */
  46510. setDepthWrite(enable: boolean): void;
  46511. /**
  46512. * Enable or disable color writing
  46513. * @param enable defines the state to set
  46514. */
  46515. setColorWrite(enable: boolean): void;
  46516. /**
  46517. * Gets a boolean indicating if color writing is enabled
  46518. * @returns the current color writing state
  46519. */
  46520. getColorWrite(): boolean;
  46521. /**
  46522. * Sets alpha constants used by some alpha blending modes
  46523. * @param r defines the red component
  46524. * @param g defines the green component
  46525. * @param b defines the blue component
  46526. * @param a defines the alpha component
  46527. */
  46528. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46529. /**
  46530. * Sets the current alpha mode
  46531. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46532. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46534. */
  46535. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46536. /**
  46537. * Gets the current alpha mode
  46538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46539. * @returns the current alpha mode
  46540. */
  46541. getAlphaMode(): number;
  46542. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46543. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46544. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46545. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46546. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46547. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46548. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46549. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46550. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46551. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46552. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46553. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46555. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46556. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46557. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46558. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46559. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46560. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46561. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46562. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46563. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46564. wipeCaches(bruteForce?: boolean): void;
  46565. _createTexture(): WebGLTexture;
  46566. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46567. /**
  46568. * Usually called from BABYLON.Texture.ts.
  46569. * Passed information to create a WebGLTexture
  46570. * @param urlArg defines a value which contains one of the following:
  46571. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46572. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46573. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46575. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46576. * @param scene needed for loading to the correct scene
  46577. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46578. * @param onLoad optional callback to be called upon successful completion
  46579. * @param onError optional callback to be called upon failure
  46580. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46581. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46582. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46583. * @param forcedExtension defines the extension to use to pick the right loader
  46584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46585. */
  46586. 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;
  46587. /**
  46588. * Creates a cube texture
  46589. * @param rootUrl defines the url where the files to load is located
  46590. * @param scene defines the current scene
  46591. * @param files defines the list of files to load (1 per face)
  46592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46593. * @param onLoad defines an optional callback raised when the texture is loaded
  46594. * @param onError defines an optional callback raised if there is an issue to load the texture
  46595. * @param format defines the format of the data
  46596. * @param forcedExtension defines the extension to use to pick the right loader
  46597. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46598. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46599. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46600. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46601. * @returns the cube texture as an InternalTexture
  46602. */
  46603. 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;
  46604. private _getSamplingFilter;
  46605. private static _GetNativeTextureFormat;
  46606. createRenderTargetTexture(size: number | {
  46607. width: number;
  46608. height: number;
  46609. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46610. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46611. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46612. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46613. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46614. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46615. /**
  46616. * Updates a dynamic vertex buffer.
  46617. * @param vertexBuffer the vertex buffer to update
  46618. * @param data the data used to update the vertex buffer
  46619. * @param byteOffset the byte offset of the data (optional)
  46620. * @param byteLength the byte length of the data (optional)
  46621. */
  46622. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46623. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46624. private _updateAnisotropicLevel;
  46625. private _getAddressMode;
  46626. /** @hidden */
  46627. _bindTexture(channel: number, texture: InternalTexture): void;
  46628. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46629. releaseEffects(): void;
  46630. /** @hidden */
  46631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46632. /** @hidden */
  46633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46634. /** @hidden */
  46635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46636. /** @hidden */
  46637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46638. }
  46639. }
  46640. declare module "babylonjs/Engines/index" {
  46641. export * from "babylonjs/Engines/constants";
  46642. export * from "babylonjs/Engines/engineCapabilities";
  46643. export * from "babylonjs/Engines/instancingAttributeInfo";
  46644. export * from "babylonjs/Engines/thinEngine";
  46645. export * from "babylonjs/Engines/engine";
  46646. export * from "babylonjs/Engines/engineStore";
  46647. export * from "babylonjs/Engines/nullEngine";
  46648. export * from "babylonjs/Engines/Extensions/index";
  46649. export * from "babylonjs/Engines/IPipelineContext";
  46650. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46651. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46652. export * from "babylonjs/Engines/nativeEngine";
  46653. }
  46654. declare module "babylonjs/Events/clipboardEvents" {
  46655. /**
  46656. * Gather the list of clipboard event types as constants.
  46657. */
  46658. export class ClipboardEventTypes {
  46659. /**
  46660. * The clipboard event is fired when a copy command is active (pressed).
  46661. */
  46662. static readonly COPY: number;
  46663. /**
  46664. * The clipboard event is fired when a cut command is active (pressed).
  46665. */
  46666. static readonly CUT: number;
  46667. /**
  46668. * The clipboard event is fired when a paste command is active (pressed).
  46669. */
  46670. static readonly PASTE: number;
  46671. }
  46672. /**
  46673. * This class is used to store clipboard related info for the onClipboardObservable event.
  46674. */
  46675. export class ClipboardInfo {
  46676. /**
  46677. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46678. */
  46679. type: number;
  46680. /**
  46681. * Defines the related dom event
  46682. */
  46683. event: ClipboardEvent;
  46684. /**
  46685. *Creates an instance of ClipboardInfo.
  46686. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46687. * @param event Defines the related dom event
  46688. */
  46689. constructor(
  46690. /**
  46691. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46692. */
  46693. type: number,
  46694. /**
  46695. * Defines the related dom event
  46696. */
  46697. event: ClipboardEvent);
  46698. /**
  46699. * Get the clipboard event's type from the keycode.
  46700. * @param keyCode Defines the keyCode for the current keyboard event.
  46701. * @return {number}
  46702. */
  46703. static GetTypeFromCharacter(keyCode: number): number;
  46704. }
  46705. }
  46706. declare module "babylonjs/Events/index" {
  46707. export * from "babylonjs/Events/keyboardEvents";
  46708. export * from "babylonjs/Events/pointerEvents";
  46709. export * from "babylonjs/Events/clipboardEvents";
  46710. }
  46711. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46712. import { Scene } from "babylonjs/scene";
  46713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46714. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46715. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46716. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46717. /**
  46718. * Google Daydream controller
  46719. */
  46720. export class DaydreamController extends WebVRController {
  46721. /**
  46722. * Base Url for the controller model.
  46723. */
  46724. static MODEL_BASE_URL: string;
  46725. /**
  46726. * File name for the controller model.
  46727. */
  46728. static MODEL_FILENAME: string;
  46729. /**
  46730. * Gamepad Id prefix used to identify Daydream Controller.
  46731. */
  46732. static readonly GAMEPAD_ID_PREFIX: string;
  46733. /**
  46734. * Creates a new DaydreamController from a gamepad
  46735. * @param vrGamepad the gamepad that the controller should be created from
  46736. */
  46737. constructor(vrGamepad: any);
  46738. /**
  46739. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46740. * @param scene scene in which to add meshes
  46741. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46742. */
  46743. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46744. /**
  46745. * Called once for each button that changed state since the last frame
  46746. * @param buttonIdx Which button index changed
  46747. * @param state New state of the button
  46748. * @param changes Which properties on the state changed since last frame
  46749. */
  46750. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46751. }
  46752. }
  46753. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46754. import { Scene } from "babylonjs/scene";
  46755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46756. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46757. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46758. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46759. /**
  46760. * Gear VR Controller
  46761. */
  46762. export class GearVRController extends WebVRController {
  46763. /**
  46764. * Base Url for the controller model.
  46765. */
  46766. static MODEL_BASE_URL: string;
  46767. /**
  46768. * File name for the controller model.
  46769. */
  46770. static MODEL_FILENAME: string;
  46771. /**
  46772. * Gamepad Id prefix used to identify this controller.
  46773. */
  46774. static readonly GAMEPAD_ID_PREFIX: string;
  46775. private readonly _buttonIndexToObservableNameMap;
  46776. /**
  46777. * Creates a new GearVRController from a gamepad
  46778. * @param vrGamepad the gamepad that the controller should be created from
  46779. */
  46780. constructor(vrGamepad: any);
  46781. /**
  46782. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46783. * @param scene scene in which to add meshes
  46784. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46785. */
  46786. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46787. /**
  46788. * Called once for each button that changed state since the last frame
  46789. * @param buttonIdx Which button index changed
  46790. * @param state New state of the button
  46791. * @param changes Which properties on the state changed since last frame
  46792. */
  46793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46794. }
  46795. }
  46796. declare module "babylonjs/Gamepads/Controllers/index" {
  46797. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46798. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46799. export * from "babylonjs/Gamepads/Controllers/genericController";
  46800. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46801. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46802. export * from "babylonjs/Gamepads/Controllers/viveController";
  46803. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46804. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46805. }
  46806. declare module "babylonjs/Gamepads/index" {
  46807. export * from "babylonjs/Gamepads/Controllers/index";
  46808. export * from "babylonjs/Gamepads/gamepad";
  46809. export * from "babylonjs/Gamepads/gamepadManager";
  46810. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46811. export * from "babylonjs/Gamepads/xboxGamepad";
  46812. export * from "babylonjs/Gamepads/dualShockGamepad";
  46813. }
  46814. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46815. import { Scene } from "babylonjs/scene";
  46816. import { Vector4 } from "babylonjs/Maths/math.vector";
  46817. import { Color4 } from "babylonjs/Maths/math.color";
  46818. import { Mesh } from "babylonjs/Meshes/mesh";
  46819. import { Nullable } from "babylonjs/types";
  46820. /**
  46821. * Class containing static functions to help procedurally build meshes
  46822. */
  46823. export class PolyhedronBuilder {
  46824. /**
  46825. * Creates a polyhedron mesh
  46826. * * 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
  46827. * * The parameter `size` (positive float, default 1) sets the polygon size
  46828. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46829. * * 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`
  46830. * * 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
  46831. * * 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)`)
  46832. * * 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
  46833. * * 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
  46834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46837. * @param name defines the name of the mesh
  46838. * @param options defines the options used to create the mesh
  46839. * @param scene defines the hosting scene
  46840. * @returns the polyhedron mesh
  46841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46842. */
  46843. static CreatePolyhedron(name: string, options: {
  46844. type?: number;
  46845. size?: number;
  46846. sizeX?: number;
  46847. sizeY?: number;
  46848. sizeZ?: number;
  46849. custom?: any;
  46850. faceUV?: Vector4[];
  46851. faceColors?: Color4[];
  46852. flat?: boolean;
  46853. updatable?: boolean;
  46854. sideOrientation?: number;
  46855. frontUVs?: Vector4;
  46856. backUVs?: Vector4;
  46857. }, scene?: Nullable<Scene>): Mesh;
  46858. }
  46859. }
  46860. declare module "babylonjs/Gizmos/scaleGizmo" {
  46861. import { Observable } from "babylonjs/Misc/observable";
  46862. import { Nullable } from "babylonjs/types";
  46863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46864. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46865. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46866. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46867. /**
  46868. * Gizmo that enables scaling a mesh along 3 axis
  46869. */
  46870. export class ScaleGizmo extends Gizmo {
  46871. /**
  46872. * Internal gizmo used for interactions on the x axis
  46873. */
  46874. xGizmo: AxisScaleGizmo;
  46875. /**
  46876. * Internal gizmo used for interactions on the y axis
  46877. */
  46878. yGizmo: AxisScaleGizmo;
  46879. /**
  46880. * Internal gizmo used for interactions on the z axis
  46881. */
  46882. zGizmo: AxisScaleGizmo;
  46883. /**
  46884. * Internal gizmo used to scale all axis equally
  46885. */
  46886. uniformScaleGizmo: AxisScaleGizmo;
  46887. private _meshAttached;
  46888. private _updateGizmoRotationToMatchAttachedMesh;
  46889. private _snapDistance;
  46890. private _scaleRatio;
  46891. private _uniformScalingMesh;
  46892. private _octahedron;
  46893. /** Fires an event when any of it's sub gizmos are dragged */
  46894. onDragStartObservable: Observable<unknown>;
  46895. /** Fires an event when any of it's sub gizmos are released from dragging */
  46896. onDragEndObservable: Observable<unknown>;
  46897. attachedMesh: Nullable<AbstractMesh>;
  46898. /**
  46899. * Creates a ScaleGizmo
  46900. * @param gizmoLayer The utility layer the gizmo will be added to
  46901. */
  46902. constructor(gizmoLayer?: UtilityLayerRenderer);
  46903. updateGizmoRotationToMatchAttachedMesh: boolean;
  46904. /**
  46905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46906. */
  46907. snapDistance: number;
  46908. /**
  46909. * Ratio for the scale of the gizmo (Default: 1)
  46910. */
  46911. scaleRatio: number;
  46912. /**
  46913. * Disposes of the gizmo
  46914. */
  46915. dispose(): void;
  46916. }
  46917. }
  46918. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46919. import { Observable } from "babylonjs/Misc/observable";
  46920. import { Nullable } from "babylonjs/types";
  46921. import { Vector3 } from "babylonjs/Maths/math.vector";
  46922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46923. import { Mesh } from "babylonjs/Meshes/mesh";
  46924. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46925. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46926. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46927. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46928. import { Color3 } from "babylonjs/Maths/math.color";
  46929. /**
  46930. * Single axis scale gizmo
  46931. */
  46932. export class AxisScaleGizmo extends Gizmo {
  46933. /**
  46934. * Drag behavior responsible for the gizmos dragging interactions
  46935. */
  46936. dragBehavior: PointerDragBehavior;
  46937. private _pointerObserver;
  46938. /**
  46939. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46940. */
  46941. snapDistance: number;
  46942. /**
  46943. * Event that fires each time the gizmo snaps to a new location.
  46944. * * snapDistance is the the change in distance
  46945. */
  46946. onSnapObservable: Observable<{
  46947. snapDistance: number;
  46948. }>;
  46949. /**
  46950. * If the scaling operation should be done on all axis (default: false)
  46951. */
  46952. uniformScaling: boolean;
  46953. private _isEnabled;
  46954. private _parent;
  46955. private _arrow;
  46956. private _coloredMaterial;
  46957. private _hoverMaterial;
  46958. /**
  46959. * Creates an AxisScaleGizmo
  46960. * @param gizmoLayer The utility layer the gizmo will be added to
  46961. * @param dragAxis The axis which the gizmo will be able to scale on
  46962. * @param color The color of the gizmo
  46963. */
  46964. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46965. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46966. /**
  46967. * If the gizmo is enabled
  46968. */
  46969. isEnabled: boolean;
  46970. /**
  46971. * Disposes of the gizmo
  46972. */
  46973. dispose(): void;
  46974. /**
  46975. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46976. * @param mesh The mesh to replace the default mesh of the gizmo
  46977. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46978. */
  46979. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46980. }
  46981. }
  46982. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46983. import { Observable } from "babylonjs/Misc/observable";
  46984. import { Nullable } from "babylonjs/types";
  46985. import { Vector3 } from "babylonjs/Maths/math.vector";
  46986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46987. import { Mesh } from "babylonjs/Meshes/mesh";
  46988. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46989. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46990. import { Color3 } from "babylonjs/Maths/math.color";
  46991. import "babylonjs/Meshes/Builders/boxBuilder";
  46992. /**
  46993. * Bounding box gizmo
  46994. */
  46995. export class BoundingBoxGizmo extends Gizmo {
  46996. private _lineBoundingBox;
  46997. private _rotateSpheresParent;
  46998. private _scaleBoxesParent;
  46999. private _boundingDimensions;
  47000. private _renderObserver;
  47001. private _pointerObserver;
  47002. private _scaleDragSpeed;
  47003. private _tmpQuaternion;
  47004. private _tmpVector;
  47005. private _tmpRotationMatrix;
  47006. /**
  47007. * 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)
  47008. */
  47009. ignoreChildren: boolean;
  47010. /**
  47011. * 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)
  47012. */
  47013. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47014. /**
  47015. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47016. */
  47017. rotationSphereSize: number;
  47018. /**
  47019. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47020. */
  47021. scaleBoxSize: number;
  47022. /**
  47023. * 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)
  47024. */
  47025. fixedDragMeshScreenSize: boolean;
  47026. /**
  47027. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47028. */
  47029. fixedDragMeshScreenSizeDistanceFactor: number;
  47030. /**
  47031. * Fired when a rotation sphere or scale box is dragged
  47032. */
  47033. onDragStartObservable: Observable<{}>;
  47034. /**
  47035. * Fired when a scale box is dragged
  47036. */
  47037. onScaleBoxDragObservable: Observable<{}>;
  47038. /**
  47039. * Fired when a scale box drag is ended
  47040. */
  47041. onScaleBoxDragEndObservable: Observable<{}>;
  47042. /**
  47043. * Fired when a rotation sphere is dragged
  47044. */
  47045. onRotationSphereDragObservable: Observable<{}>;
  47046. /**
  47047. * Fired when a rotation sphere drag is ended
  47048. */
  47049. onRotationSphereDragEndObservable: Observable<{}>;
  47050. /**
  47051. * 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)
  47052. */
  47053. scalePivot: Nullable<Vector3>;
  47054. /**
  47055. * Mesh used as a pivot to rotate the attached mesh
  47056. */
  47057. private _anchorMesh;
  47058. private _existingMeshScale;
  47059. private _dragMesh;
  47060. private pointerDragBehavior;
  47061. private coloredMaterial;
  47062. private hoverColoredMaterial;
  47063. /**
  47064. * Sets the color of the bounding box gizmo
  47065. * @param color the color to set
  47066. */
  47067. setColor(color: Color3): void;
  47068. /**
  47069. * Creates an BoundingBoxGizmo
  47070. * @param gizmoLayer The utility layer the gizmo will be added to
  47071. * @param color The color of the gizmo
  47072. */
  47073. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47074. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47075. private _selectNode;
  47076. /**
  47077. * Updates the bounding box information for the Gizmo
  47078. */
  47079. updateBoundingBox(): void;
  47080. private _updateRotationSpheres;
  47081. private _updateScaleBoxes;
  47082. /**
  47083. * Enables rotation on the specified axis and disables rotation on the others
  47084. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47085. */
  47086. setEnabledRotationAxis(axis: string): void;
  47087. /**
  47088. * Enables/disables scaling
  47089. * @param enable if scaling should be enabled
  47090. */
  47091. setEnabledScaling(enable: boolean): void;
  47092. private _updateDummy;
  47093. /**
  47094. * Enables a pointer drag behavior on the bounding box of the gizmo
  47095. */
  47096. enableDragBehavior(): void;
  47097. /**
  47098. * Disposes of the gizmo
  47099. */
  47100. dispose(): void;
  47101. /**
  47102. * 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)
  47103. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47104. * @returns the bounding box mesh with the passed in mesh as a child
  47105. */
  47106. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47107. /**
  47108. * CustomMeshes are not supported by this gizmo
  47109. * @param mesh The mesh to replace the default mesh of the gizmo
  47110. */
  47111. setCustomMesh(mesh: Mesh): void;
  47112. }
  47113. }
  47114. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47115. import { Observable } from "babylonjs/Misc/observable";
  47116. import { Nullable } from "babylonjs/types";
  47117. import { Vector3 } from "babylonjs/Maths/math.vector";
  47118. import { Color3 } from "babylonjs/Maths/math.color";
  47119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47120. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47121. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47122. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47123. import "babylonjs/Meshes/Builders/linesBuilder";
  47124. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47125. /**
  47126. * Single plane rotation gizmo
  47127. */
  47128. export class PlaneRotationGizmo extends Gizmo {
  47129. /**
  47130. * Drag behavior responsible for the gizmos dragging interactions
  47131. */
  47132. dragBehavior: PointerDragBehavior;
  47133. private _pointerObserver;
  47134. /**
  47135. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47136. */
  47137. snapDistance: number;
  47138. /**
  47139. * Event that fires each time the gizmo snaps to a new location.
  47140. * * snapDistance is the the change in distance
  47141. */
  47142. onSnapObservable: Observable<{
  47143. snapDistance: number;
  47144. }>;
  47145. private _isEnabled;
  47146. private _parent;
  47147. /**
  47148. * Creates a PlaneRotationGizmo
  47149. * @param gizmoLayer The utility layer the gizmo will be added to
  47150. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47151. * @param color The color of the gizmo
  47152. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47153. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47154. */
  47155. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47156. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47157. /**
  47158. * If the gizmo is enabled
  47159. */
  47160. isEnabled: boolean;
  47161. /**
  47162. * Disposes of the gizmo
  47163. */
  47164. dispose(): void;
  47165. }
  47166. }
  47167. declare module "babylonjs/Gizmos/rotationGizmo" {
  47168. import { Observable } from "babylonjs/Misc/observable";
  47169. import { Nullable } from "babylonjs/types";
  47170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47171. import { Mesh } from "babylonjs/Meshes/mesh";
  47172. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47173. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47174. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47175. /**
  47176. * Gizmo that enables rotating a mesh along 3 axis
  47177. */
  47178. export class RotationGizmo extends Gizmo {
  47179. /**
  47180. * Internal gizmo used for interactions on the x axis
  47181. */
  47182. xGizmo: PlaneRotationGizmo;
  47183. /**
  47184. * Internal gizmo used for interactions on the y axis
  47185. */
  47186. yGizmo: PlaneRotationGizmo;
  47187. /**
  47188. * Internal gizmo used for interactions on the z axis
  47189. */
  47190. zGizmo: PlaneRotationGizmo;
  47191. /** Fires an event when any of it's sub gizmos are dragged */
  47192. onDragStartObservable: Observable<unknown>;
  47193. /** Fires an event when any of it's sub gizmos are released from dragging */
  47194. onDragEndObservable: Observable<unknown>;
  47195. private _meshAttached;
  47196. attachedMesh: Nullable<AbstractMesh>;
  47197. /**
  47198. * Creates a RotationGizmo
  47199. * @param gizmoLayer The utility layer the gizmo will be added to
  47200. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47201. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47202. */
  47203. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47204. updateGizmoRotationToMatchAttachedMesh: boolean;
  47205. /**
  47206. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47207. */
  47208. snapDistance: number;
  47209. /**
  47210. * Ratio for the scale of the gizmo (Default: 1)
  47211. */
  47212. scaleRatio: number;
  47213. /**
  47214. * Disposes of the gizmo
  47215. */
  47216. dispose(): void;
  47217. /**
  47218. * CustomMeshes are not supported by this gizmo
  47219. * @param mesh The mesh to replace the default mesh of the gizmo
  47220. */
  47221. setCustomMesh(mesh: Mesh): void;
  47222. }
  47223. }
  47224. declare module "babylonjs/Gizmos/gizmoManager" {
  47225. import { Observable } from "babylonjs/Misc/observable";
  47226. import { Nullable } from "babylonjs/types";
  47227. import { Scene, IDisposable } from "babylonjs/scene";
  47228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47229. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47230. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47231. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47232. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47233. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47234. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47235. /**
  47236. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47237. */
  47238. export class GizmoManager implements IDisposable {
  47239. private scene;
  47240. /**
  47241. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47242. */
  47243. gizmos: {
  47244. positionGizmo: Nullable<PositionGizmo>;
  47245. rotationGizmo: Nullable<RotationGizmo>;
  47246. scaleGizmo: Nullable<ScaleGizmo>;
  47247. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47248. };
  47249. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47250. clearGizmoOnEmptyPointerEvent: boolean;
  47251. /** Fires an event when the manager is attached to a mesh */
  47252. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47253. private _gizmosEnabled;
  47254. private _pointerObserver;
  47255. private _attachedMesh;
  47256. private _boundingBoxColor;
  47257. private _defaultUtilityLayer;
  47258. private _defaultKeepDepthUtilityLayer;
  47259. /**
  47260. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47261. */
  47262. boundingBoxDragBehavior: SixDofDragBehavior;
  47263. /**
  47264. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47265. */
  47266. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47267. /**
  47268. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47269. */
  47270. usePointerToAttachGizmos: boolean;
  47271. /**
  47272. * Utility layer that the bounding box gizmo belongs to
  47273. */
  47274. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47275. /**
  47276. * Utility layer that all gizmos besides bounding box belong to
  47277. */
  47278. readonly utilityLayer: UtilityLayerRenderer;
  47279. /**
  47280. * Instatiates a gizmo manager
  47281. * @param scene the scene to overlay the gizmos on top of
  47282. */
  47283. constructor(scene: Scene);
  47284. /**
  47285. * Attaches a set of gizmos to the specified mesh
  47286. * @param mesh The mesh the gizmo's should be attached to
  47287. */
  47288. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47289. /**
  47290. * If the position gizmo is enabled
  47291. */
  47292. positionGizmoEnabled: boolean;
  47293. /**
  47294. * If the rotation gizmo is enabled
  47295. */
  47296. rotationGizmoEnabled: boolean;
  47297. /**
  47298. * If the scale gizmo is enabled
  47299. */
  47300. scaleGizmoEnabled: boolean;
  47301. /**
  47302. * If the boundingBox gizmo is enabled
  47303. */
  47304. boundingBoxGizmoEnabled: boolean;
  47305. /**
  47306. * Disposes of the gizmo manager
  47307. */
  47308. dispose(): void;
  47309. }
  47310. }
  47311. declare module "babylonjs/Lights/directionalLight" {
  47312. import { Camera } from "babylonjs/Cameras/camera";
  47313. import { Scene } from "babylonjs/scene";
  47314. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47316. import { Light } from "babylonjs/Lights/light";
  47317. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47318. import { Effect } from "babylonjs/Materials/effect";
  47319. /**
  47320. * A directional light is defined by a direction (what a surprise!).
  47321. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47322. * 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.
  47323. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47324. */
  47325. export class DirectionalLight extends ShadowLight {
  47326. private _shadowFrustumSize;
  47327. /**
  47328. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47329. */
  47330. /**
  47331. * Specifies a fix frustum size for the shadow generation.
  47332. */
  47333. shadowFrustumSize: number;
  47334. private _shadowOrthoScale;
  47335. /**
  47336. * Gets the shadow projection scale against the optimal computed one.
  47337. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47338. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47339. */
  47340. /**
  47341. * Sets the shadow projection scale against the optimal computed one.
  47342. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47343. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47344. */
  47345. shadowOrthoScale: number;
  47346. /**
  47347. * Automatically compute the projection matrix to best fit (including all the casters)
  47348. * on each frame.
  47349. */
  47350. autoUpdateExtends: boolean;
  47351. private _orthoLeft;
  47352. private _orthoRight;
  47353. private _orthoTop;
  47354. private _orthoBottom;
  47355. /**
  47356. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47357. * The directional light is emitted from everywhere in the given direction.
  47358. * It can cast shadows.
  47359. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47360. * @param name The friendly name of the light
  47361. * @param direction The direction of the light
  47362. * @param scene The scene the light belongs to
  47363. */
  47364. constructor(name: string, direction: Vector3, scene: Scene);
  47365. /**
  47366. * Returns the string "DirectionalLight".
  47367. * @return The class name
  47368. */
  47369. getClassName(): string;
  47370. /**
  47371. * Returns the integer 1.
  47372. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47373. */
  47374. getTypeID(): number;
  47375. /**
  47376. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47377. * Returns the DirectionalLight Shadow projection matrix.
  47378. */
  47379. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47380. /**
  47381. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47382. * Returns the DirectionalLight Shadow projection matrix.
  47383. */
  47384. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47385. /**
  47386. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47387. * Returns the DirectionalLight Shadow projection matrix.
  47388. */
  47389. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47390. protected _buildUniformLayout(): void;
  47391. /**
  47392. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47393. * @param effect The effect to update
  47394. * @param lightIndex The index of the light in the effect to update
  47395. * @returns The directional light
  47396. */
  47397. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47398. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47399. /**
  47400. * Gets the minZ used for shadow according to both the scene and the light.
  47401. *
  47402. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47403. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47404. * @param activeCamera The camera we are returning the min for
  47405. * @returns the depth min z
  47406. */
  47407. getDepthMinZ(activeCamera: Camera): number;
  47408. /**
  47409. * Gets the maxZ used for shadow according to both the scene and the light.
  47410. *
  47411. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47412. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47413. * @param activeCamera The camera we are returning the max for
  47414. * @returns the depth max z
  47415. */
  47416. getDepthMaxZ(activeCamera: Camera): number;
  47417. /**
  47418. * Prepares the list of defines specific to the light type.
  47419. * @param defines the list of defines
  47420. * @param lightIndex defines the index of the light for the effect
  47421. */
  47422. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47423. }
  47424. }
  47425. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47426. import { Mesh } from "babylonjs/Meshes/mesh";
  47427. /**
  47428. * Class containing static functions to help procedurally build meshes
  47429. */
  47430. export class HemisphereBuilder {
  47431. /**
  47432. * Creates a hemisphere mesh
  47433. * @param name defines the name of the mesh
  47434. * @param options defines the options used to create the mesh
  47435. * @param scene defines the hosting scene
  47436. * @returns the hemisphere mesh
  47437. */
  47438. static CreateHemisphere(name: string, options: {
  47439. segments?: number;
  47440. diameter?: number;
  47441. sideOrientation?: number;
  47442. }, scene: any): Mesh;
  47443. }
  47444. }
  47445. declare module "babylonjs/Lights/spotLight" {
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47450. import { Effect } from "babylonjs/Materials/effect";
  47451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47452. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47453. /**
  47454. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47455. * These values define a cone of light starting from the position, emitting toward the direction.
  47456. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47457. * and the exponent defines the speed of the decay of the light with distance (reach).
  47458. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47459. */
  47460. export class SpotLight extends ShadowLight {
  47461. private _angle;
  47462. private _innerAngle;
  47463. private _cosHalfAngle;
  47464. private _lightAngleScale;
  47465. private _lightAngleOffset;
  47466. /**
  47467. * Gets the cone angle of the spot light in Radians.
  47468. */
  47469. /**
  47470. * Sets the cone angle of the spot light in Radians.
  47471. */
  47472. angle: number;
  47473. /**
  47474. * Only used in gltf falloff mode, this defines the angle where
  47475. * the directional falloff will start before cutting at angle which could be seen
  47476. * as outer angle.
  47477. */
  47478. /**
  47479. * Only used in gltf falloff mode, this defines the angle where
  47480. * the directional falloff will start before cutting at angle which could be seen
  47481. * as outer angle.
  47482. */
  47483. innerAngle: number;
  47484. private _shadowAngleScale;
  47485. /**
  47486. * Allows scaling the angle of the light for shadow generation only.
  47487. */
  47488. /**
  47489. * Allows scaling the angle of the light for shadow generation only.
  47490. */
  47491. shadowAngleScale: number;
  47492. /**
  47493. * The light decay speed with the distance from the emission spot.
  47494. */
  47495. exponent: number;
  47496. private _projectionTextureMatrix;
  47497. /**
  47498. * Allows reading the projecton texture
  47499. */
  47500. readonly projectionTextureMatrix: Matrix;
  47501. protected _projectionTextureLightNear: number;
  47502. /**
  47503. * Gets the near clip of the Spotlight for texture projection.
  47504. */
  47505. /**
  47506. * Sets the near clip of the Spotlight for texture projection.
  47507. */
  47508. projectionTextureLightNear: number;
  47509. protected _projectionTextureLightFar: number;
  47510. /**
  47511. * Gets the far clip of the Spotlight for texture projection.
  47512. */
  47513. /**
  47514. * Sets the far clip of the Spotlight for texture projection.
  47515. */
  47516. projectionTextureLightFar: number;
  47517. protected _projectionTextureUpDirection: Vector3;
  47518. /**
  47519. * Gets the Up vector of the Spotlight for texture projection.
  47520. */
  47521. /**
  47522. * Sets the Up vector of the Spotlight for texture projection.
  47523. */
  47524. projectionTextureUpDirection: Vector3;
  47525. private _projectionTexture;
  47526. /**
  47527. * Gets the projection texture of the light.
  47528. */
  47529. /**
  47530. * Sets the projection texture of the light.
  47531. */
  47532. projectionTexture: Nullable<BaseTexture>;
  47533. private _projectionTextureViewLightDirty;
  47534. private _projectionTextureProjectionLightDirty;
  47535. private _projectionTextureDirty;
  47536. private _projectionTextureViewTargetVector;
  47537. private _projectionTextureViewLightMatrix;
  47538. private _projectionTextureProjectionLightMatrix;
  47539. private _projectionTextureScalingMatrix;
  47540. /**
  47541. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47542. * It can cast shadows.
  47543. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47544. * @param name The light friendly name
  47545. * @param position The position of the spot light in the scene
  47546. * @param direction The direction of the light in the scene
  47547. * @param angle The cone angle of the light in Radians
  47548. * @param exponent The light decay speed with the distance from the emission spot
  47549. * @param scene The scene the lights belongs to
  47550. */
  47551. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47552. /**
  47553. * Returns the string "SpotLight".
  47554. * @returns the class name
  47555. */
  47556. getClassName(): string;
  47557. /**
  47558. * Returns the integer 2.
  47559. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47560. */
  47561. getTypeID(): number;
  47562. /**
  47563. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47564. */
  47565. protected _setDirection(value: Vector3): void;
  47566. /**
  47567. * Overrides the position setter to recompute the projection texture view light Matrix.
  47568. */
  47569. protected _setPosition(value: Vector3): void;
  47570. /**
  47571. * 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.
  47572. * Returns the SpotLight.
  47573. */
  47574. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47575. protected _computeProjectionTextureViewLightMatrix(): void;
  47576. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47577. /**
  47578. * Main function for light texture projection matrix computing.
  47579. */
  47580. protected _computeProjectionTextureMatrix(): void;
  47581. protected _buildUniformLayout(): void;
  47582. private _computeAngleValues;
  47583. /**
  47584. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47585. * @param effect The effect to update
  47586. * @param lightIndex The index of the light in the effect to update
  47587. * @returns The spot light
  47588. */
  47589. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47590. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47591. /**
  47592. * Disposes the light and the associated resources.
  47593. */
  47594. dispose(): void;
  47595. /**
  47596. * Prepares the list of defines specific to the light type.
  47597. * @param defines the list of defines
  47598. * @param lightIndex defines the index of the light for the effect
  47599. */
  47600. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47601. }
  47602. }
  47603. declare module "babylonjs/Gizmos/lightGizmo" {
  47604. import { Nullable } from "babylonjs/types";
  47605. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47606. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47607. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47608. import { Light } from "babylonjs/Lights/light";
  47609. /**
  47610. * Gizmo that enables viewing a light
  47611. */
  47612. export class LightGizmo extends Gizmo {
  47613. private _lightMesh;
  47614. private _material;
  47615. private cachedPosition;
  47616. private cachedForward;
  47617. /**
  47618. * Creates a LightGizmo
  47619. * @param gizmoLayer The utility layer the gizmo will be added to
  47620. */
  47621. constructor(gizmoLayer?: UtilityLayerRenderer);
  47622. private _light;
  47623. /**
  47624. * The light that the gizmo is attached to
  47625. */
  47626. light: Nullable<Light>;
  47627. /**
  47628. * Gets the material used to render the light gizmo
  47629. */
  47630. readonly material: StandardMaterial;
  47631. /**
  47632. * @hidden
  47633. * Updates the gizmo to match the attached mesh's position/rotation
  47634. */
  47635. protected _update(): void;
  47636. private static _Scale;
  47637. /**
  47638. * Creates the lines for a light mesh
  47639. */
  47640. private static _createLightLines;
  47641. /**
  47642. * Disposes of the light gizmo
  47643. */
  47644. dispose(): void;
  47645. private static _CreateHemisphericLightMesh;
  47646. private static _CreatePointLightMesh;
  47647. private static _CreateSpotLightMesh;
  47648. private static _CreateDirectionalLightMesh;
  47649. }
  47650. }
  47651. declare module "babylonjs/Gizmos/index" {
  47652. export * from "babylonjs/Gizmos/axisDragGizmo";
  47653. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47654. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47655. export * from "babylonjs/Gizmos/gizmo";
  47656. export * from "babylonjs/Gizmos/gizmoManager";
  47657. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47658. export * from "babylonjs/Gizmos/positionGizmo";
  47659. export * from "babylonjs/Gizmos/rotationGizmo";
  47660. export * from "babylonjs/Gizmos/scaleGizmo";
  47661. export * from "babylonjs/Gizmos/lightGizmo";
  47662. export * from "babylonjs/Gizmos/planeDragGizmo";
  47663. }
  47664. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47665. /** @hidden */
  47666. export var backgroundFragmentDeclaration: {
  47667. name: string;
  47668. shader: string;
  47669. };
  47670. }
  47671. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47672. /** @hidden */
  47673. export var backgroundUboDeclaration: {
  47674. name: string;
  47675. shader: string;
  47676. };
  47677. }
  47678. declare module "babylonjs/Shaders/background.fragment" {
  47679. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47680. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47681. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47682. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47683. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47684. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47685. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47686. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47687. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47688. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47689. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47690. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47691. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47692. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47693. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47694. /** @hidden */
  47695. export var backgroundPixelShader: {
  47696. name: string;
  47697. shader: string;
  47698. };
  47699. }
  47700. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47701. /** @hidden */
  47702. export var backgroundVertexDeclaration: {
  47703. name: string;
  47704. shader: string;
  47705. };
  47706. }
  47707. declare module "babylonjs/Shaders/background.vertex" {
  47708. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47709. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47710. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47711. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47712. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47713. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47714. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47715. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47716. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47717. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47718. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47719. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47720. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47721. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47722. /** @hidden */
  47723. export var backgroundVertexShader: {
  47724. name: string;
  47725. shader: string;
  47726. };
  47727. }
  47728. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47729. import { Nullable, int, float } from "babylonjs/types";
  47730. import { Scene } from "babylonjs/scene";
  47731. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47732. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47734. import { Mesh } from "babylonjs/Meshes/mesh";
  47735. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47736. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47737. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47739. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47740. import { Color3 } from "babylonjs/Maths/math.color";
  47741. import "babylonjs/Shaders/background.fragment";
  47742. import "babylonjs/Shaders/background.vertex";
  47743. /**
  47744. * Background material used to create an efficient environement around your scene.
  47745. */
  47746. export class BackgroundMaterial extends PushMaterial {
  47747. /**
  47748. * Standard reflectance value at parallel view angle.
  47749. */
  47750. static StandardReflectance0: number;
  47751. /**
  47752. * Standard reflectance value at grazing angle.
  47753. */
  47754. static StandardReflectance90: number;
  47755. protected _primaryColor: Color3;
  47756. /**
  47757. * Key light Color (multiply against the environement texture)
  47758. */
  47759. primaryColor: Color3;
  47760. protected __perceptualColor: Nullable<Color3>;
  47761. /**
  47762. * Experimental Internal Use Only.
  47763. *
  47764. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47765. * This acts as a helper to set the primary color to a more "human friendly" value.
  47766. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47767. * output color as close as possible from the chosen value.
  47768. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47769. * part of lighting setup.)
  47770. */
  47771. _perceptualColor: Nullable<Color3>;
  47772. protected _primaryColorShadowLevel: float;
  47773. /**
  47774. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47775. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47776. */
  47777. primaryColorShadowLevel: float;
  47778. protected _primaryColorHighlightLevel: float;
  47779. /**
  47780. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47781. * The primary color is used at the level chosen to define what the white area would look.
  47782. */
  47783. primaryColorHighlightLevel: float;
  47784. protected _reflectionTexture: Nullable<BaseTexture>;
  47785. /**
  47786. * Reflection Texture used in the material.
  47787. * Should be author in a specific way for the best result (refer to the documentation).
  47788. */
  47789. reflectionTexture: Nullable<BaseTexture>;
  47790. protected _reflectionBlur: float;
  47791. /**
  47792. * Reflection Texture level of blur.
  47793. *
  47794. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47795. * texture twice.
  47796. */
  47797. reflectionBlur: float;
  47798. protected _diffuseTexture: Nullable<BaseTexture>;
  47799. /**
  47800. * Diffuse Texture used in the material.
  47801. * Should be author in a specific way for the best result (refer to the documentation).
  47802. */
  47803. diffuseTexture: Nullable<BaseTexture>;
  47804. protected _shadowLights: Nullable<IShadowLight[]>;
  47805. /**
  47806. * Specify the list of lights casting shadow on the material.
  47807. * All scene shadow lights will be included if null.
  47808. */
  47809. shadowLights: Nullable<IShadowLight[]>;
  47810. protected _shadowLevel: float;
  47811. /**
  47812. * Helps adjusting the shadow to a softer level if required.
  47813. * 0 means black shadows and 1 means no shadows.
  47814. */
  47815. shadowLevel: float;
  47816. protected _sceneCenter: Vector3;
  47817. /**
  47818. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47819. * It is usually zero but might be interesting to modify according to your setup.
  47820. */
  47821. sceneCenter: Vector3;
  47822. protected _opacityFresnel: boolean;
  47823. /**
  47824. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47825. * This helps ensuring a nice transition when the camera goes under the ground.
  47826. */
  47827. opacityFresnel: boolean;
  47828. protected _reflectionFresnel: boolean;
  47829. /**
  47830. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47831. * This helps adding a mirror texture on the ground.
  47832. */
  47833. reflectionFresnel: boolean;
  47834. protected _reflectionFalloffDistance: number;
  47835. /**
  47836. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47837. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47838. */
  47839. reflectionFalloffDistance: number;
  47840. protected _reflectionAmount: number;
  47841. /**
  47842. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47843. */
  47844. reflectionAmount: number;
  47845. protected _reflectionReflectance0: number;
  47846. /**
  47847. * This specifies the weight of the reflection at grazing angle.
  47848. */
  47849. reflectionReflectance0: number;
  47850. protected _reflectionReflectance90: number;
  47851. /**
  47852. * This specifies the weight of the reflection at a perpendicular point of view.
  47853. */
  47854. reflectionReflectance90: number;
  47855. /**
  47856. * Sets the reflection reflectance fresnel values according to the default standard
  47857. * empirically know to work well :-)
  47858. */
  47859. reflectionStandardFresnelWeight: number;
  47860. protected _useRGBColor: boolean;
  47861. /**
  47862. * Helps to directly use the maps channels instead of their level.
  47863. */
  47864. useRGBColor: boolean;
  47865. protected _enableNoise: boolean;
  47866. /**
  47867. * This helps reducing the banding effect that could occur on the background.
  47868. */
  47869. enableNoise: boolean;
  47870. /**
  47871. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47872. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47873. * Recommended to be keep at 1.0 except for special cases.
  47874. */
  47875. fovMultiplier: number;
  47876. private _fovMultiplier;
  47877. /**
  47878. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47879. */
  47880. useEquirectangularFOV: boolean;
  47881. private _maxSimultaneousLights;
  47882. /**
  47883. * Number of Simultaneous lights allowed on the material.
  47884. */
  47885. maxSimultaneousLights: int;
  47886. /**
  47887. * Default configuration related to image processing available in the Background Material.
  47888. */
  47889. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47890. /**
  47891. * Keep track of the image processing observer to allow dispose and replace.
  47892. */
  47893. private _imageProcessingObserver;
  47894. /**
  47895. * Attaches a new image processing configuration to the PBR Material.
  47896. * @param configuration (if null the scene configuration will be use)
  47897. */
  47898. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47899. /**
  47900. * Gets the image processing configuration used either in this material.
  47901. */
  47902. /**
  47903. * Sets the Default image processing configuration used either in the this material.
  47904. *
  47905. * If sets to null, the scene one is in use.
  47906. */
  47907. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47908. /**
  47909. * Gets wether the color curves effect is enabled.
  47910. */
  47911. /**
  47912. * Sets wether the color curves effect is enabled.
  47913. */
  47914. cameraColorCurvesEnabled: boolean;
  47915. /**
  47916. * Gets wether the color grading effect is enabled.
  47917. */
  47918. /**
  47919. * Gets wether the color grading effect is enabled.
  47920. */
  47921. cameraColorGradingEnabled: boolean;
  47922. /**
  47923. * Gets wether tonemapping is enabled or not.
  47924. */
  47925. /**
  47926. * Sets wether tonemapping is enabled or not
  47927. */
  47928. cameraToneMappingEnabled: boolean;
  47929. /**
  47930. * The camera exposure used on this material.
  47931. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47932. * This corresponds to a photographic exposure.
  47933. */
  47934. /**
  47935. * The camera exposure used on this material.
  47936. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47937. * This corresponds to a photographic exposure.
  47938. */
  47939. cameraExposure: float;
  47940. /**
  47941. * Gets The camera contrast used on this material.
  47942. */
  47943. /**
  47944. * Sets The camera contrast used on this material.
  47945. */
  47946. cameraContrast: float;
  47947. /**
  47948. * Gets the Color Grading 2D Lookup Texture.
  47949. */
  47950. /**
  47951. * Sets the Color Grading 2D Lookup Texture.
  47952. */
  47953. cameraColorGradingTexture: Nullable<BaseTexture>;
  47954. /**
  47955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47957. * 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;
  47958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47959. */
  47960. /**
  47961. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47962. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47963. * 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;
  47964. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47965. */
  47966. cameraColorCurves: Nullable<ColorCurves>;
  47967. /**
  47968. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47969. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47970. */
  47971. switchToBGR: boolean;
  47972. private _renderTargets;
  47973. private _reflectionControls;
  47974. private _white;
  47975. private _primaryShadowColor;
  47976. private _primaryHighlightColor;
  47977. /**
  47978. * Instantiates a Background Material in the given scene
  47979. * @param name The friendly name of the material
  47980. * @param scene The scene to add the material to
  47981. */
  47982. constructor(name: string, scene: Scene);
  47983. /**
  47984. * Gets a boolean indicating that current material needs to register RTT
  47985. */
  47986. readonly hasRenderTargetTextures: boolean;
  47987. /**
  47988. * The entire material has been created in order to prevent overdraw.
  47989. * @returns false
  47990. */
  47991. needAlphaTesting(): boolean;
  47992. /**
  47993. * The entire material has been created in order to prevent overdraw.
  47994. * @returns true if blending is enable
  47995. */
  47996. needAlphaBlending(): boolean;
  47997. /**
  47998. * Checks wether the material is ready to be rendered for a given mesh.
  47999. * @param mesh The mesh to render
  48000. * @param subMesh The submesh to check against
  48001. * @param useInstances Specify wether or not the material is used with instances
  48002. * @returns true if all the dependencies are ready (Textures, Effects...)
  48003. */
  48004. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48005. /**
  48006. * Compute the primary color according to the chosen perceptual color.
  48007. */
  48008. private _computePrimaryColorFromPerceptualColor;
  48009. /**
  48010. * Compute the highlights and shadow colors according to their chosen levels.
  48011. */
  48012. private _computePrimaryColors;
  48013. /**
  48014. * Build the uniform buffer used in the material.
  48015. */
  48016. buildUniformLayout(): void;
  48017. /**
  48018. * Unbind the material.
  48019. */
  48020. unbind(): void;
  48021. /**
  48022. * Bind only the world matrix to the material.
  48023. * @param world The world matrix to bind.
  48024. */
  48025. bindOnlyWorldMatrix(world: Matrix): void;
  48026. /**
  48027. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48028. * @param world The world matrix to bind.
  48029. * @param subMesh The submesh to bind for.
  48030. */
  48031. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48032. /**
  48033. * Checks to see if a texture is used in the material.
  48034. * @param texture - Base texture to use.
  48035. * @returns - Boolean specifying if a texture is used in the material.
  48036. */
  48037. hasTexture(texture: BaseTexture): boolean;
  48038. /**
  48039. * Dispose the material.
  48040. * @param forceDisposeEffect Force disposal of the associated effect.
  48041. * @param forceDisposeTextures Force disposal of the associated textures.
  48042. */
  48043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48044. /**
  48045. * Clones the material.
  48046. * @param name The cloned name.
  48047. * @returns The cloned material.
  48048. */
  48049. clone(name: string): BackgroundMaterial;
  48050. /**
  48051. * Serializes the current material to its JSON representation.
  48052. * @returns The JSON representation.
  48053. */
  48054. serialize(): any;
  48055. /**
  48056. * Gets the class name of the material
  48057. * @returns "BackgroundMaterial"
  48058. */
  48059. getClassName(): string;
  48060. /**
  48061. * Parse a JSON input to create back a background material.
  48062. * @param source The JSON data to parse
  48063. * @param scene The scene to create the parsed material in
  48064. * @param rootUrl The root url of the assets the material depends upon
  48065. * @returns the instantiated BackgroundMaterial.
  48066. */
  48067. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48068. }
  48069. }
  48070. declare module "babylonjs/Helpers/environmentHelper" {
  48071. import { Observable } from "babylonjs/Misc/observable";
  48072. import { Nullable } from "babylonjs/types";
  48073. import { Scene } from "babylonjs/scene";
  48074. import { Vector3 } from "babylonjs/Maths/math.vector";
  48075. import { Color3 } from "babylonjs/Maths/math.color";
  48076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48077. import { Mesh } from "babylonjs/Meshes/mesh";
  48078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48079. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48080. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48081. import "babylonjs/Meshes/Builders/planeBuilder";
  48082. import "babylonjs/Meshes/Builders/boxBuilder";
  48083. /**
  48084. * Represents the different options available during the creation of
  48085. * a Environment helper.
  48086. *
  48087. * This can control the default ground, skybox and image processing setup of your scene.
  48088. */
  48089. export interface IEnvironmentHelperOptions {
  48090. /**
  48091. * Specifies wether or not to create a ground.
  48092. * True by default.
  48093. */
  48094. createGround: boolean;
  48095. /**
  48096. * Specifies the ground size.
  48097. * 15 by default.
  48098. */
  48099. groundSize: number;
  48100. /**
  48101. * The texture used on the ground for the main color.
  48102. * Comes from the BabylonJS CDN by default.
  48103. *
  48104. * Remarks: Can be either a texture or a url.
  48105. */
  48106. groundTexture: string | BaseTexture;
  48107. /**
  48108. * The color mixed in the ground texture by default.
  48109. * BabylonJS clearColor by default.
  48110. */
  48111. groundColor: Color3;
  48112. /**
  48113. * Specifies the ground opacity.
  48114. * 1 by default.
  48115. */
  48116. groundOpacity: number;
  48117. /**
  48118. * Enables the ground to receive shadows.
  48119. * True by default.
  48120. */
  48121. enableGroundShadow: boolean;
  48122. /**
  48123. * Helps preventing the shadow to be fully black on the ground.
  48124. * 0.5 by default.
  48125. */
  48126. groundShadowLevel: number;
  48127. /**
  48128. * Creates a mirror texture attach to the ground.
  48129. * false by default.
  48130. */
  48131. enableGroundMirror: boolean;
  48132. /**
  48133. * Specifies the ground mirror size ratio.
  48134. * 0.3 by default as the default kernel is 64.
  48135. */
  48136. groundMirrorSizeRatio: number;
  48137. /**
  48138. * Specifies the ground mirror blur kernel size.
  48139. * 64 by default.
  48140. */
  48141. groundMirrorBlurKernel: number;
  48142. /**
  48143. * Specifies the ground mirror visibility amount.
  48144. * 1 by default
  48145. */
  48146. groundMirrorAmount: number;
  48147. /**
  48148. * Specifies the ground mirror reflectance weight.
  48149. * This uses the standard weight of the background material to setup the fresnel effect
  48150. * of the mirror.
  48151. * 1 by default.
  48152. */
  48153. groundMirrorFresnelWeight: number;
  48154. /**
  48155. * Specifies the ground mirror Falloff distance.
  48156. * This can helps reducing the size of the reflection.
  48157. * 0 by Default.
  48158. */
  48159. groundMirrorFallOffDistance: number;
  48160. /**
  48161. * Specifies the ground mirror texture type.
  48162. * Unsigned Int by Default.
  48163. */
  48164. groundMirrorTextureType: number;
  48165. /**
  48166. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48167. * the shown objects.
  48168. */
  48169. groundYBias: number;
  48170. /**
  48171. * Specifies wether or not to create a skybox.
  48172. * True by default.
  48173. */
  48174. createSkybox: boolean;
  48175. /**
  48176. * Specifies the skybox size.
  48177. * 20 by default.
  48178. */
  48179. skyboxSize: number;
  48180. /**
  48181. * The texture used on the skybox for the main color.
  48182. * Comes from the BabylonJS CDN by default.
  48183. *
  48184. * Remarks: Can be either a texture or a url.
  48185. */
  48186. skyboxTexture: string | BaseTexture;
  48187. /**
  48188. * The color mixed in the skybox texture by default.
  48189. * BabylonJS clearColor by default.
  48190. */
  48191. skyboxColor: Color3;
  48192. /**
  48193. * The background rotation around the Y axis of the scene.
  48194. * This helps aligning the key lights of your scene with the background.
  48195. * 0 by default.
  48196. */
  48197. backgroundYRotation: number;
  48198. /**
  48199. * Compute automatically the size of the elements to best fit with the scene.
  48200. */
  48201. sizeAuto: boolean;
  48202. /**
  48203. * Default position of the rootMesh if autoSize is not true.
  48204. */
  48205. rootPosition: Vector3;
  48206. /**
  48207. * Sets up the image processing in the scene.
  48208. * true by default.
  48209. */
  48210. setupImageProcessing: boolean;
  48211. /**
  48212. * The texture used as your environment texture in the scene.
  48213. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48214. *
  48215. * Remarks: Can be either a texture or a url.
  48216. */
  48217. environmentTexture: string | BaseTexture;
  48218. /**
  48219. * The value of the exposure to apply to the scene.
  48220. * 0.6 by default if setupImageProcessing is true.
  48221. */
  48222. cameraExposure: number;
  48223. /**
  48224. * The value of the contrast to apply to the scene.
  48225. * 1.6 by default if setupImageProcessing is true.
  48226. */
  48227. cameraContrast: number;
  48228. /**
  48229. * Specifies wether or not tonemapping should be enabled in the scene.
  48230. * true by default if setupImageProcessing is true.
  48231. */
  48232. toneMappingEnabled: boolean;
  48233. }
  48234. /**
  48235. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48236. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48237. * It also helps with the default setup of your imageProcessing configuration.
  48238. */
  48239. export class EnvironmentHelper {
  48240. /**
  48241. * Default ground texture URL.
  48242. */
  48243. private static _groundTextureCDNUrl;
  48244. /**
  48245. * Default skybox texture URL.
  48246. */
  48247. private static _skyboxTextureCDNUrl;
  48248. /**
  48249. * Default environment texture URL.
  48250. */
  48251. private static _environmentTextureCDNUrl;
  48252. /**
  48253. * Creates the default options for the helper.
  48254. */
  48255. private static _getDefaultOptions;
  48256. private _rootMesh;
  48257. /**
  48258. * Gets the root mesh created by the helper.
  48259. */
  48260. readonly rootMesh: Mesh;
  48261. private _skybox;
  48262. /**
  48263. * Gets the skybox created by the helper.
  48264. */
  48265. readonly skybox: Nullable<Mesh>;
  48266. private _skyboxTexture;
  48267. /**
  48268. * Gets the skybox texture created by the helper.
  48269. */
  48270. readonly skyboxTexture: Nullable<BaseTexture>;
  48271. private _skyboxMaterial;
  48272. /**
  48273. * Gets the skybox material created by the helper.
  48274. */
  48275. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48276. private _ground;
  48277. /**
  48278. * Gets the ground mesh created by the helper.
  48279. */
  48280. readonly ground: Nullable<Mesh>;
  48281. private _groundTexture;
  48282. /**
  48283. * Gets the ground texture created by the helper.
  48284. */
  48285. readonly groundTexture: Nullable<BaseTexture>;
  48286. private _groundMirror;
  48287. /**
  48288. * Gets the ground mirror created by the helper.
  48289. */
  48290. readonly groundMirror: Nullable<MirrorTexture>;
  48291. /**
  48292. * Gets the ground mirror render list to helps pushing the meshes
  48293. * you wish in the ground reflection.
  48294. */
  48295. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48296. private _groundMaterial;
  48297. /**
  48298. * Gets the ground material created by the helper.
  48299. */
  48300. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48301. /**
  48302. * Stores the creation options.
  48303. */
  48304. private readonly _scene;
  48305. private _options;
  48306. /**
  48307. * This observable will be notified with any error during the creation of the environment,
  48308. * mainly texture creation errors.
  48309. */
  48310. onErrorObservable: Observable<{
  48311. message?: string;
  48312. exception?: any;
  48313. }>;
  48314. /**
  48315. * constructor
  48316. * @param options Defines the options we want to customize the helper
  48317. * @param scene The scene to add the material to
  48318. */
  48319. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48320. /**
  48321. * Updates the background according to the new options
  48322. * @param options
  48323. */
  48324. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48325. /**
  48326. * Sets the primary color of all the available elements.
  48327. * @param color the main color to affect to the ground and the background
  48328. */
  48329. setMainColor(color: Color3): void;
  48330. /**
  48331. * Setup the image processing according to the specified options.
  48332. */
  48333. private _setupImageProcessing;
  48334. /**
  48335. * Setup the environment texture according to the specified options.
  48336. */
  48337. private _setupEnvironmentTexture;
  48338. /**
  48339. * Setup the background according to the specified options.
  48340. */
  48341. private _setupBackground;
  48342. /**
  48343. * Get the scene sizes according to the setup.
  48344. */
  48345. private _getSceneSize;
  48346. /**
  48347. * Setup the ground according to the specified options.
  48348. */
  48349. private _setupGround;
  48350. /**
  48351. * Setup the ground material according to the specified options.
  48352. */
  48353. private _setupGroundMaterial;
  48354. /**
  48355. * Setup the ground diffuse texture according to the specified options.
  48356. */
  48357. private _setupGroundDiffuseTexture;
  48358. /**
  48359. * Setup the ground mirror texture according to the specified options.
  48360. */
  48361. private _setupGroundMirrorTexture;
  48362. /**
  48363. * Setup the ground to receive the mirror texture.
  48364. */
  48365. private _setupMirrorInGroundMaterial;
  48366. /**
  48367. * Setup the skybox according to the specified options.
  48368. */
  48369. private _setupSkybox;
  48370. /**
  48371. * Setup the skybox material according to the specified options.
  48372. */
  48373. private _setupSkyboxMaterial;
  48374. /**
  48375. * Setup the skybox reflection texture according to the specified options.
  48376. */
  48377. private _setupSkyboxReflectionTexture;
  48378. private _errorHandler;
  48379. /**
  48380. * Dispose all the elements created by the Helper.
  48381. */
  48382. dispose(): void;
  48383. }
  48384. }
  48385. declare module "babylonjs/Helpers/photoDome" {
  48386. import { Observable } from "babylonjs/Misc/observable";
  48387. import { Nullable } from "babylonjs/types";
  48388. import { Scene } from "babylonjs/scene";
  48389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48390. import { Mesh } from "babylonjs/Meshes/mesh";
  48391. import { Texture } from "babylonjs/Materials/Textures/texture";
  48392. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48393. import "babylonjs/Meshes/Builders/sphereBuilder";
  48394. /**
  48395. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48396. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48397. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48398. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48399. */
  48400. export class PhotoDome extends TransformNode {
  48401. /**
  48402. * Define the image as a Monoscopic panoramic 360 image.
  48403. */
  48404. static readonly MODE_MONOSCOPIC: number;
  48405. /**
  48406. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48407. */
  48408. static readonly MODE_TOPBOTTOM: number;
  48409. /**
  48410. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48411. */
  48412. static readonly MODE_SIDEBYSIDE: number;
  48413. private _useDirectMapping;
  48414. /**
  48415. * The texture being displayed on the sphere
  48416. */
  48417. protected _photoTexture: Texture;
  48418. /**
  48419. * Gets or sets the texture being displayed on the sphere
  48420. */
  48421. photoTexture: Texture;
  48422. /**
  48423. * Observable raised when an error occured while loading the 360 image
  48424. */
  48425. onLoadErrorObservable: Observable<string>;
  48426. /**
  48427. * The skybox material
  48428. */
  48429. protected _material: BackgroundMaterial;
  48430. /**
  48431. * The surface used for the skybox
  48432. */
  48433. protected _mesh: Mesh;
  48434. /**
  48435. * Gets the mesh used for the skybox.
  48436. */
  48437. readonly mesh: Mesh;
  48438. /**
  48439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48440. * Also see the options.resolution property.
  48441. */
  48442. fovMultiplier: number;
  48443. private _imageMode;
  48444. /**
  48445. * Gets or set the current video mode for the video. It can be:
  48446. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48447. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48448. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48449. */
  48450. imageMode: number;
  48451. /**
  48452. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48453. * @param name Element's name, child elements will append suffixes for their own names.
  48454. * @param urlsOfPhoto defines the url of the photo to display
  48455. * @param options defines an object containing optional or exposed sub element properties
  48456. * @param onError defines a callback called when an error occured while loading the texture
  48457. */
  48458. constructor(name: string, urlOfPhoto: string, options: {
  48459. resolution?: number;
  48460. size?: number;
  48461. useDirectMapping?: boolean;
  48462. faceForward?: boolean;
  48463. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48464. private _onBeforeCameraRenderObserver;
  48465. private _changeImageMode;
  48466. /**
  48467. * Releases resources associated with this node.
  48468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48470. */
  48471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48472. }
  48473. }
  48474. declare module "babylonjs/Misc/rgbdTextureTools" {
  48475. import "babylonjs/Shaders/rgbdDecode.fragment";
  48476. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48477. import { Texture } from "babylonjs/Materials/Textures/texture";
  48478. /**
  48479. * Class used to host RGBD texture specific utilities
  48480. */
  48481. export class RGBDTextureTools {
  48482. /**
  48483. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48484. * @param texture the texture to expand.
  48485. */
  48486. static ExpandRGBDTexture(texture: Texture): void;
  48487. }
  48488. }
  48489. declare module "babylonjs/Misc/brdfTextureTools" {
  48490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48491. import { Scene } from "babylonjs/scene";
  48492. /**
  48493. * Class used to host texture specific utilities
  48494. */
  48495. export class BRDFTextureTools {
  48496. /**
  48497. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48498. * @param scene defines the hosting scene
  48499. * @returns the environment BRDF texture
  48500. */
  48501. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48502. private static _environmentBRDFBase64Texture;
  48503. }
  48504. }
  48505. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48506. import { Nullable } from "babylonjs/types";
  48507. import { Color3 } from "babylonjs/Maths/math.color";
  48508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48510. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48511. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48512. import { Engine } from "babylonjs/Engines/engine";
  48513. import { Scene } from "babylonjs/scene";
  48514. /**
  48515. * @hidden
  48516. */
  48517. export interface IMaterialClearCoatDefines {
  48518. CLEARCOAT: boolean;
  48519. CLEARCOAT_DEFAULTIOR: boolean;
  48520. CLEARCOAT_TEXTURE: boolean;
  48521. CLEARCOAT_TEXTUREDIRECTUV: number;
  48522. CLEARCOAT_BUMP: boolean;
  48523. CLEARCOAT_BUMPDIRECTUV: number;
  48524. CLEARCOAT_TINT: boolean;
  48525. CLEARCOAT_TINT_TEXTURE: boolean;
  48526. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48527. /** @hidden */
  48528. _areTexturesDirty: boolean;
  48529. }
  48530. /**
  48531. * Define the code related to the clear coat parameters of the pbr material.
  48532. */
  48533. export class PBRClearCoatConfiguration {
  48534. /**
  48535. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48536. * The default fits with a polyurethane material.
  48537. */
  48538. private static readonly _DefaultIndexOfRefraction;
  48539. private _isEnabled;
  48540. /**
  48541. * Defines if the clear coat is enabled in the material.
  48542. */
  48543. isEnabled: boolean;
  48544. /**
  48545. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48546. */
  48547. intensity: number;
  48548. /**
  48549. * Defines the clear coat layer roughness.
  48550. */
  48551. roughness: number;
  48552. private _indexOfRefraction;
  48553. /**
  48554. * Defines the index of refraction of the clear coat.
  48555. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48556. * The default fits with a polyurethane material.
  48557. * Changing the default value is more performance intensive.
  48558. */
  48559. indexOfRefraction: number;
  48560. private _texture;
  48561. /**
  48562. * Stores the clear coat values in a texture.
  48563. */
  48564. texture: Nullable<BaseTexture>;
  48565. private _bumpTexture;
  48566. /**
  48567. * Define the clear coat specific bump texture.
  48568. */
  48569. bumpTexture: Nullable<BaseTexture>;
  48570. private _isTintEnabled;
  48571. /**
  48572. * Defines if the clear coat tint is enabled in the material.
  48573. */
  48574. isTintEnabled: boolean;
  48575. /**
  48576. * Defines the clear coat tint of the material.
  48577. * This is only use if tint is enabled
  48578. */
  48579. tintColor: Color3;
  48580. /**
  48581. * Defines the distance at which the tint color should be found in the
  48582. * clear coat media.
  48583. * This is only use if tint is enabled
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines the clear coat layer thickness.
  48588. * This is only use if tint is enabled
  48589. */
  48590. tintThickness: number;
  48591. private _tintTexture;
  48592. /**
  48593. * Stores the clear tint values in a texture.
  48594. * rgb is tint
  48595. * a is a thickness factor
  48596. */
  48597. tintTexture: Nullable<BaseTexture>;
  48598. /** @hidden */
  48599. private _internalMarkAllSubMeshesAsTexturesDirty;
  48600. /** @hidden */
  48601. _markAllSubMeshesAsTexturesDirty(): void;
  48602. /**
  48603. * Instantiate a new istance of clear coat configuration.
  48604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48605. */
  48606. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48607. /**
  48608. * Gets wehter the submesh is ready to be used or not.
  48609. * @param defines the list of "defines" to update.
  48610. * @param scene defines the scene the material belongs to.
  48611. * @param engine defines the engine the material belongs to.
  48612. * @param disableBumpMap defines wether the material disables bump or not.
  48613. * @returns - boolean indicating that the submesh is ready or not.
  48614. */
  48615. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48616. /**
  48617. * Checks to see if a texture is used in the material.
  48618. * @param defines the list of "defines" to update.
  48619. * @param scene defines the scene to the material belongs to.
  48620. */
  48621. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48622. /**
  48623. * Binds the material data.
  48624. * @param uniformBuffer defines the Uniform buffer to fill in.
  48625. * @param scene defines the scene the material belongs to.
  48626. * @param engine defines the engine the material belongs to.
  48627. * @param disableBumpMap defines wether the material disables bump or not.
  48628. * @param isFrozen defines wether the material is frozen or not.
  48629. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48630. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48631. */
  48632. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48633. /**
  48634. * Checks to see if a texture is used in the material.
  48635. * @param texture - Base texture to use.
  48636. * @returns - Boolean specifying if a texture is used in the material.
  48637. */
  48638. hasTexture(texture: BaseTexture): boolean;
  48639. /**
  48640. * Returns an array of the actively used textures.
  48641. * @param activeTextures Array of BaseTextures
  48642. */
  48643. getActiveTextures(activeTextures: BaseTexture[]): void;
  48644. /**
  48645. * Returns the animatable textures.
  48646. * @param animatables Array of animatable textures.
  48647. */
  48648. getAnimatables(animatables: IAnimatable[]): void;
  48649. /**
  48650. * Disposes the resources of the material.
  48651. * @param forceDisposeTextures - Forces the disposal of all textures.
  48652. */
  48653. dispose(forceDisposeTextures?: boolean): void;
  48654. /**
  48655. * Get the current class name of the texture useful for serialization or dynamic coding.
  48656. * @returns "PBRClearCoatConfiguration"
  48657. */
  48658. getClassName(): string;
  48659. /**
  48660. * Add fallbacks to the effect fallbacks list.
  48661. * @param defines defines the Base texture to use.
  48662. * @param fallbacks defines the current fallback list.
  48663. * @param currentRank defines the current fallback rank.
  48664. * @returns the new fallback rank.
  48665. */
  48666. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48667. /**
  48668. * Add the required uniforms to the current list.
  48669. * @param uniforms defines the current uniform list.
  48670. */
  48671. static AddUniforms(uniforms: string[]): void;
  48672. /**
  48673. * Add the required samplers to the current list.
  48674. * @param samplers defines the current sampler list.
  48675. */
  48676. static AddSamplers(samplers: string[]): void;
  48677. /**
  48678. * Add the required uniforms to the current buffer.
  48679. * @param uniformBuffer defines the current uniform buffer.
  48680. */
  48681. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48682. /**
  48683. * Makes a duplicate of the current configuration into another one.
  48684. * @param clearCoatConfiguration define the config where to copy the info
  48685. */
  48686. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48687. /**
  48688. * Serializes this clear coat configuration.
  48689. * @returns - An object with the serialized config.
  48690. */
  48691. serialize(): any;
  48692. /**
  48693. * Parses a anisotropy Configuration from a serialized object.
  48694. * @param source - Serialized object.
  48695. * @param scene Defines the scene we are parsing for
  48696. * @param rootUrl Defines the rootUrl to load from
  48697. */
  48698. parse(source: any, scene: Scene, rootUrl: string): void;
  48699. }
  48700. }
  48701. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48702. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48704. import { Vector2 } from "babylonjs/Maths/math.vector";
  48705. import { Scene } from "babylonjs/scene";
  48706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48707. import { Nullable } from "babylonjs/types";
  48708. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48709. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48710. /**
  48711. * @hidden
  48712. */
  48713. export interface IMaterialAnisotropicDefines {
  48714. ANISOTROPIC: boolean;
  48715. ANISOTROPIC_TEXTURE: boolean;
  48716. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48717. MAINUV1: boolean;
  48718. _areTexturesDirty: boolean;
  48719. _needUVs: boolean;
  48720. }
  48721. /**
  48722. * Define the code related to the anisotropic parameters of the pbr material.
  48723. */
  48724. export class PBRAnisotropicConfiguration {
  48725. private _isEnabled;
  48726. /**
  48727. * Defines if the anisotropy is enabled in the material.
  48728. */
  48729. isEnabled: boolean;
  48730. /**
  48731. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48732. */
  48733. intensity: number;
  48734. /**
  48735. * Defines if the effect is along the tangents, bitangents or in between.
  48736. * By default, the effect is "strectching" the highlights along the tangents.
  48737. */
  48738. direction: Vector2;
  48739. private _texture;
  48740. /**
  48741. * Stores the anisotropy values in a texture.
  48742. * rg is direction (like normal from -1 to 1)
  48743. * b is a intensity
  48744. */
  48745. texture: Nullable<BaseTexture>;
  48746. /** @hidden */
  48747. private _internalMarkAllSubMeshesAsTexturesDirty;
  48748. /** @hidden */
  48749. _markAllSubMeshesAsTexturesDirty(): void;
  48750. /**
  48751. * Instantiate a new istance of anisotropy configuration.
  48752. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48753. */
  48754. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48755. /**
  48756. * Specifies that the submesh is ready to be used.
  48757. * @param defines the list of "defines" to update.
  48758. * @param scene defines the scene the material belongs to.
  48759. * @returns - boolean indicating that the submesh is ready or not.
  48760. */
  48761. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48762. /**
  48763. * Checks to see if a texture is used in the material.
  48764. * @param defines the list of "defines" to update.
  48765. * @param mesh the mesh we are preparing the defines for.
  48766. * @param scene defines the scene the material belongs to.
  48767. */
  48768. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48769. /**
  48770. * Binds the material data.
  48771. * @param uniformBuffer defines the Uniform buffer to fill in.
  48772. * @param scene defines the scene the material belongs to.
  48773. * @param isFrozen defines wether the material is frozen or not.
  48774. */
  48775. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48776. /**
  48777. * Checks to see if a texture is used in the material.
  48778. * @param texture - Base texture to use.
  48779. * @returns - Boolean specifying if a texture is used in the material.
  48780. */
  48781. hasTexture(texture: BaseTexture): boolean;
  48782. /**
  48783. * Returns an array of the actively used textures.
  48784. * @param activeTextures Array of BaseTextures
  48785. */
  48786. getActiveTextures(activeTextures: BaseTexture[]): void;
  48787. /**
  48788. * Returns the animatable textures.
  48789. * @param animatables Array of animatable textures.
  48790. */
  48791. getAnimatables(animatables: IAnimatable[]): void;
  48792. /**
  48793. * Disposes the resources of the material.
  48794. * @param forceDisposeTextures - Forces the disposal of all textures.
  48795. */
  48796. dispose(forceDisposeTextures?: boolean): void;
  48797. /**
  48798. * Get the current class name of the texture useful for serialization or dynamic coding.
  48799. * @returns "PBRAnisotropicConfiguration"
  48800. */
  48801. getClassName(): string;
  48802. /**
  48803. * Add fallbacks to the effect fallbacks list.
  48804. * @param defines defines the Base texture to use.
  48805. * @param fallbacks defines the current fallback list.
  48806. * @param currentRank defines the current fallback rank.
  48807. * @returns the new fallback rank.
  48808. */
  48809. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48810. /**
  48811. * Add the required uniforms to the current list.
  48812. * @param uniforms defines the current uniform list.
  48813. */
  48814. static AddUniforms(uniforms: string[]): void;
  48815. /**
  48816. * Add the required uniforms to the current buffer.
  48817. * @param uniformBuffer defines the current uniform buffer.
  48818. */
  48819. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48820. /**
  48821. * Add the required samplers to the current list.
  48822. * @param samplers defines the current sampler list.
  48823. */
  48824. static AddSamplers(samplers: string[]): void;
  48825. /**
  48826. * Makes a duplicate of the current configuration into another one.
  48827. * @param anisotropicConfiguration define the config where to copy the info
  48828. */
  48829. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48830. /**
  48831. * Serializes this anisotropy configuration.
  48832. * @returns - An object with the serialized config.
  48833. */
  48834. serialize(): any;
  48835. /**
  48836. * Parses a anisotropy Configuration from a serialized object.
  48837. * @param source - Serialized object.
  48838. * @param scene Defines the scene we are parsing for
  48839. * @param rootUrl Defines the rootUrl to load from
  48840. */
  48841. parse(source: any, scene: Scene, rootUrl: string): void;
  48842. }
  48843. }
  48844. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48845. import { Scene } from "babylonjs/scene";
  48846. /**
  48847. * @hidden
  48848. */
  48849. export interface IMaterialBRDFDefines {
  48850. BRDF_V_HEIGHT_CORRELATED: boolean;
  48851. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48852. SPHERICAL_HARMONICS: boolean;
  48853. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48854. /** @hidden */
  48855. _areMiscDirty: boolean;
  48856. }
  48857. /**
  48858. * Define the code related to the BRDF parameters of the pbr material.
  48859. */
  48860. export class PBRBRDFConfiguration {
  48861. /**
  48862. * Default value used for the energy conservation.
  48863. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48864. */
  48865. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48866. /**
  48867. * Default value used for the Smith Visibility Height Correlated mode.
  48868. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48869. */
  48870. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48871. /**
  48872. * Default value used for the IBL diffuse part.
  48873. * This can help switching back to the polynomials mode globally which is a tiny bit
  48874. * less GPU intensive at the drawback of a lower quality.
  48875. */
  48876. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48877. /**
  48878. * Default value used for activating energy conservation for the specular workflow.
  48879. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48880. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48881. */
  48882. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48883. private _useEnergyConservation;
  48884. /**
  48885. * Defines if the material uses energy conservation.
  48886. */
  48887. useEnergyConservation: boolean;
  48888. private _useSmithVisibilityHeightCorrelated;
  48889. /**
  48890. * LEGACY Mode set to false
  48891. * Defines if the material uses height smith correlated visibility term.
  48892. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48893. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48894. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48895. * Not relying on height correlated will also disable energy conservation.
  48896. */
  48897. useSmithVisibilityHeightCorrelated: boolean;
  48898. private _useSphericalHarmonics;
  48899. /**
  48900. * LEGACY Mode set to false
  48901. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48902. * diffuse part of the IBL.
  48903. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48904. * to the ground truth.
  48905. */
  48906. useSphericalHarmonics: boolean;
  48907. private _useSpecularGlossinessInputEnergyConservation;
  48908. /**
  48909. * Defines if the material uses energy conservation, when the specular workflow is active.
  48910. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48911. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48912. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48913. */
  48914. useSpecularGlossinessInputEnergyConservation: boolean;
  48915. /** @hidden */
  48916. private _internalMarkAllSubMeshesAsMiscDirty;
  48917. /** @hidden */
  48918. _markAllSubMeshesAsMiscDirty(): void;
  48919. /**
  48920. * Instantiate a new istance of clear coat configuration.
  48921. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48922. */
  48923. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48924. /**
  48925. * Checks to see if a texture is used in the material.
  48926. * @param defines the list of "defines" to update.
  48927. */
  48928. prepareDefines(defines: IMaterialBRDFDefines): void;
  48929. /**
  48930. * Get the current class name of the texture useful for serialization or dynamic coding.
  48931. * @returns "PBRClearCoatConfiguration"
  48932. */
  48933. getClassName(): string;
  48934. /**
  48935. * Makes a duplicate of the current configuration into another one.
  48936. * @param brdfConfiguration define the config where to copy the info
  48937. */
  48938. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48939. /**
  48940. * Serializes this BRDF configuration.
  48941. * @returns - An object with the serialized config.
  48942. */
  48943. serialize(): any;
  48944. /**
  48945. * Parses a anisotropy Configuration from a serialized object.
  48946. * @param source - Serialized object.
  48947. * @param scene Defines the scene we are parsing for
  48948. * @param rootUrl Defines the rootUrl to load from
  48949. */
  48950. parse(source: any, scene: Scene, rootUrl: string): void;
  48951. }
  48952. }
  48953. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48954. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48955. import { Color3 } from "babylonjs/Maths/math.color";
  48956. import { Scene } from "babylonjs/scene";
  48957. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48958. import { Nullable } from "babylonjs/types";
  48959. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48960. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48961. /**
  48962. * @hidden
  48963. */
  48964. export interface IMaterialSheenDefines {
  48965. SHEEN: boolean;
  48966. SHEEN_TEXTURE: boolean;
  48967. SHEEN_TEXTUREDIRECTUV: number;
  48968. SHEEN_LINKWITHALBEDO: boolean;
  48969. /** @hidden */
  48970. _areTexturesDirty: boolean;
  48971. }
  48972. /**
  48973. * Define the code related to the Sheen parameters of the pbr material.
  48974. */
  48975. export class PBRSheenConfiguration {
  48976. private _isEnabled;
  48977. /**
  48978. * Defines if the material uses sheen.
  48979. */
  48980. isEnabled: boolean;
  48981. private _linkSheenWithAlbedo;
  48982. /**
  48983. * Defines if the sheen is linked to the sheen color.
  48984. */
  48985. linkSheenWithAlbedo: boolean;
  48986. /**
  48987. * Defines the sheen intensity.
  48988. */
  48989. intensity: number;
  48990. /**
  48991. * Defines the sheen color.
  48992. */
  48993. color: Color3;
  48994. private _texture;
  48995. /**
  48996. * Stores the sheen tint values in a texture.
  48997. * rgb is tint
  48998. * a is a intensity
  48999. */
  49000. texture: Nullable<BaseTexture>;
  49001. /** @hidden */
  49002. private _internalMarkAllSubMeshesAsTexturesDirty;
  49003. /** @hidden */
  49004. _markAllSubMeshesAsTexturesDirty(): void;
  49005. /**
  49006. * Instantiate a new istance of clear coat configuration.
  49007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49008. */
  49009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49010. /**
  49011. * Specifies that the submesh is ready to be used.
  49012. * @param defines the list of "defines" to update.
  49013. * @param scene defines the scene the material belongs to.
  49014. * @returns - boolean indicating that the submesh is ready or not.
  49015. */
  49016. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49017. /**
  49018. * Checks to see if a texture is used in the material.
  49019. * @param defines the list of "defines" to update.
  49020. * @param scene defines the scene the material belongs to.
  49021. */
  49022. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49023. /**
  49024. * Binds the material data.
  49025. * @param uniformBuffer defines the Uniform buffer to fill in.
  49026. * @param scene defines the scene the material belongs to.
  49027. * @param isFrozen defines wether the material is frozen or not.
  49028. */
  49029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49030. /**
  49031. * Checks to see if a texture is used in the material.
  49032. * @param texture - Base texture to use.
  49033. * @returns - Boolean specifying if a texture is used in the material.
  49034. */
  49035. hasTexture(texture: BaseTexture): boolean;
  49036. /**
  49037. * Returns an array of the actively used textures.
  49038. * @param activeTextures Array of BaseTextures
  49039. */
  49040. getActiveTextures(activeTextures: BaseTexture[]): void;
  49041. /**
  49042. * Returns the animatable textures.
  49043. * @param animatables Array of animatable textures.
  49044. */
  49045. getAnimatables(animatables: IAnimatable[]): void;
  49046. /**
  49047. * Disposes the resources of the material.
  49048. * @param forceDisposeTextures - Forces the disposal of all textures.
  49049. */
  49050. dispose(forceDisposeTextures?: boolean): void;
  49051. /**
  49052. * Get the current class name of the texture useful for serialization or dynamic coding.
  49053. * @returns "PBRSheenConfiguration"
  49054. */
  49055. getClassName(): string;
  49056. /**
  49057. * Add fallbacks to the effect fallbacks list.
  49058. * @param defines defines the Base texture to use.
  49059. * @param fallbacks defines the current fallback list.
  49060. * @param currentRank defines the current fallback rank.
  49061. * @returns the new fallback rank.
  49062. */
  49063. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49064. /**
  49065. * Add the required uniforms to the current list.
  49066. * @param uniforms defines the current uniform list.
  49067. */
  49068. static AddUniforms(uniforms: string[]): void;
  49069. /**
  49070. * Add the required uniforms to the current buffer.
  49071. * @param uniformBuffer defines the current uniform buffer.
  49072. */
  49073. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49074. /**
  49075. * Add the required samplers to the current list.
  49076. * @param samplers defines the current sampler list.
  49077. */
  49078. static AddSamplers(samplers: string[]): void;
  49079. /**
  49080. * Makes a duplicate of the current configuration into another one.
  49081. * @param sheenConfiguration define the config where to copy the info
  49082. */
  49083. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49084. /**
  49085. * Serializes this BRDF configuration.
  49086. * @returns - An object with the serialized config.
  49087. */
  49088. serialize(): any;
  49089. /**
  49090. * Parses a anisotropy Configuration from a serialized object.
  49091. * @param source - Serialized object.
  49092. * @param scene Defines the scene we are parsing for
  49093. * @param rootUrl Defines the rootUrl to load from
  49094. */
  49095. parse(source: any, scene: Scene, rootUrl: string): void;
  49096. }
  49097. }
  49098. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49099. import { Nullable } from "babylonjs/types";
  49100. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49101. import { Color3 } from "babylonjs/Maths/math.color";
  49102. import { SmartArray } from "babylonjs/Misc/smartArray";
  49103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49105. import { Effect } from "babylonjs/Materials/effect";
  49106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49107. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49108. import { Engine } from "babylonjs/Engines/engine";
  49109. import { Scene } from "babylonjs/scene";
  49110. /**
  49111. * @hidden
  49112. */
  49113. export interface IMaterialSubSurfaceDefines {
  49114. SUBSURFACE: boolean;
  49115. SS_REFRACTION: boolean;
  49116. SS_TRANSLUCENCY: boolean;
  49117. SS_SCATERRING: boolean;
  49118. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49119. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49120. SS_REFRACTIONMAP_3D: boolean;
  49121. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49122. SS_LODINREFRACTIONALPHA: boolean;
  49123. SS_GAMMAREFRACTION: boolean;
  49124. SS_RGBDREFRACTION: boolean;
  49125. SS_LINEARSPECULARREFRACTION: boolean;
  49126. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49127. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49128. /** @hidden */
  49129. _areTexturesDirty: boolean;
  49130. }
  49131. /**
  49132. * Define the code related to the sub surface parameters of the pbr material.
  49133. */
  49134. export class PBRSubSurfaceConfiguration {
  49135. private _isRefractionEnabled;
  49136. /**
  49137. * Defines if the refraction is enabled in the material.
  49138. */
  49139. isRefractionEnabled: boolean;
  49140. private _isTranslucencyEnabled;
  49141. /**
  49142. * Defines if the translucency is enabled in the material.
  49143. */
  49144. isTranslucencyEnabled: boolean;
  49145. private _isScatteringEnabled;
  49146. /**
  49147. * Defines the refraction intensity of the material.
  49148. * The refraction when enabled replaces the Diffuse part of the material.
  49149. * The intensity helps transitionning between diffuse and refraction.
  49150. */
  49151. refractionIntensity: number;
  49152. /**
  49153. * Defines the translucency intensity of the material.
  49154. * When translucency has been enabled, this defines how much of the "translucency"
  49155. * is addded to the diffuse part of the material.
  49156. */
  49157. translucencyIntensity: number;
  49158. /**
  49159. * Defines the scattering intensity of the material.
  49160. * When scattering has been enabled, this defines how much of the "scattered light"
  49161. * is addded to the diffuse part of the material.
  49162. */
  49163. scatteringIntensity: number;
  49164. private _thicknessTexture;
  49165. /**
  49166. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49167. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49168. * 0 would mean minimumThickness
  49169. * 1 would mean maximumThickness
  49170. * The other channels might be use as a mask to vary the different effects intensity.
  49171. */
  49172. thicknessTexture: Nullable<BaseTexture>;
  49173. private _refractionTexture;
  49174. /**
  49175. * Defines the texture to use for refraction.
  49176. */
  49177. refractionTexture: Nullable<BaseTexture>;
  49178. private _indexOfRefraction;
  49179. /**
  49180. * Defines the index of refraction used in the material.
  49181. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49182. */
  49183. indexOfRefraction: number;
  49184. private _invertRefractionY;
  49185. /**
  49186. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49187. */
  49188. invertRefractionY: boolean;
  49189. private _linkRefractionWithTransparency;
  49190. /**
  49191. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49192. * Materials half opaque for instance using refraction could benefit from this control.
  49193. */
  49194. linkRefractionWithTransparency: boolean;
  49195. /**
  49196. * Defines the minimum thickness stored in the thickness map.
  49197. * If no thickness map is defined, this value will be used to simulate thickness.
  49198. */
  49199. minimumThickness: number;
  49200. /**
  49201. * Defines the maximum thickness stored in the thickness map.
  49202. */
  49203. maximumThickness: number;
  49204. /**
  49205. * Defines the volume tint of the material.
  49206. * This is used for both translucency and scattering.
  49207. */
  49208. tintColor: Color3;
  49209. /**
  49210. * Defines the distance at which the tint color should be found in the media.
  49211. * This is used for refraction only.
  49212. */
  49213. tintColorAtDistance: number;
  49214. /**
  49215. * Defines how far each channel transmit through the media.
  49216. * It is defined as a color to simplify it selection.
  49217. */
  49218. diffusionDistance: Color3;
  49219. private _useMaskFromThicknessTexture;
  49220. /**
  49221. * Stores the intensity of the different subsurface effects in the thickness texture.
  49222. * * the green channel is the translucency intensity.
  49223. * * the blue channel is the scattering intensity.
  49224. * * the alpha channel is the refraction intensity.
  49225. */
  49226. useMaskFromThicknessTexture: boolean;
  49227. /** @hidden */
  49228. private _internalMarkAllSubMeshesAsTexturesDirty;
  49229. /** @hidden */
  49230. _markAllSubMeshesAsTexturesDirty(): void;
  49231. /**
  49232. * Instantiate a new istance of sub surface configuration.
  49233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49234. */
  49235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49236. /**
  49237. * Gets wehter the submesh is ready to be used or not.
  49238. * @param defines the list of "defines" to update.
  49239. * @param scene defines the scene the material belongs to.
  49240. * @returns - boolean indicating that the submesh is ready or not.
  49241. */
  49242. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49243. /**
  49244. * Checks to see if a texture is used in the material.
  49245. * @param defines the list of "defines" to update.
  49246. * @param scene defines the scene to the material belongs to.
  49247. */
  49248. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49249. /**
  49250. * Binds the material data.
  49251. * @param uniformBuffer defines the Uniform buffer to fill in.
  49252. * @param scene defines the scene the material belongs to.
  49253. * @param engine defines the engine the material belongs to.
  49254. * @param isFrozen defines wether the material is frozen or not.
  49255. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49256. */
  49257. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49258. /**
  49259. * Unbinds the material from the mesh.
  49260. * @param activeEffect defines the effect that should be unbound from.
  49261. * @returns true if unbound, otherwise false
  49262. */
  49263. unbind(activeEffect: Effect): boolean;
  49264. /**
  49265. * Returns the texture used for refraction or null if none is used.
  49266. * @param scene defines the scene the material belongs to.
  49267. * @returns - Refraction texture if present. If no refraction texture and refraction
  49268. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49269. */
  49270. private _getRefractionTexture;
  49271. /**
  49272. * Returns true if alpha blending should be disabled.
  49273. */
  49274. readonly disableAlphaBlending: boolean;
  49275. /**
  49276. * Fills the list of render target textures.
  49277. * @param renderTargets the list of render targets to update
  49278. */
  49279. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49280. /**
  49281. * Checks to see if a texture is used in the material.
  49282. * @param texture - Base texture to use.
  49283. * @returns - Boolean specifying if a texture is used in the material.
  49284. */
  49285. hasTexture(texture: BaseTexture): boolean;
  49286. /**
  49287. * Gets a boolean indicating that current material needs to register RTT
  49288. * @returns true if this uses a render target otherwise false.
  49289. */
  49290. hasRenderTargetTextures(): boolean;
  49291. /**
  49292. * Returns an array of the actively used textures.
  49293. * @param activeTextures Array of BaseTextures
  49294. */
  49295. getActiveTextures(activeTextures: BaseTexture[]): void;
  49296. /**
  49297. * Returns the animatable textures.
  49298. * @param animatables Array of animatable textures.
  49299. */
  49300. getAnimatables(animatables: IAnimatable[]): void;
  49301. /**
  49302. * Disposes the resources of the material.
  49303. * @param forceDisposeTextures - Forces the disposal of all textures.
  49304. */
  49305. dispose(forceDisposeTextures?: boolean): void;
  49306. /**
  49307. * Get the current class name of the texture useful for serialization or dynamic coding.
  49308. * @returns "PBRSubSurfaceConfiguration"
  49309. */
  49310. getClassName(): string;
  49311. /**
  49312. * Add fallbacks to the effect fallbacks list.
  49313. * @param defines defines the Base texture to use.
  49314. * @param fallbacks defines the current fallback list.
  49315. * @param currentRank defines the current fallback rank.
  49316. * @returns the new fallback rank.
  49317. */
  49318. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49319. /**
  49320. * Add the required uniforms to the current list.
  49321. * @param uniforms defines the current uniform list.
  49322. */
  49323. static AddUniforms(uniforms: string[]): void;
  49324. /**
  49325. * Add the required samplers to the current list.
  49326. * @param samplers defines the current sampler list.
  49327. */
  49328. static AddSamplers(samplers: string[]): void;
  49329. /**
  49330. * Add the required uniforms to the current buffer.
  49331. * @param uniformBuffer defines the current uniform buffer.
  49332. */
  49333. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49334. /**
  49335. * Makes a duplicate of the current configuration into another one.
  49336. * @param configuration define the config where to copy the info
  49337. */
  49338. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49339. /**
  49340. * Serializes this Sub Surface configuration.
  49341. * @returns - An object with the serialized config.
  49342. */
  49343. serialize(): any;
  49344. /**
  49345. * Parses a anisotropy Configuration from a serialized object.
  49346. * @param source - Serialized object.
  49347. * @param scene Defines the scene we are parsing for
  49348. * @param rootUrl Defines the rootUrl to load from
  49349. */
  49350. parse(source: any, scene: Scene, rootUrl: string): void;
  49351. }
  49352. }
  49353. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49354. /** @hidden */
  49355. export var pbrFragmentDeclaration: {
  49356. name: string;
  49357. shader: string;
  49358. };
  49359. }
  49360. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49361. /** @hidden */
  49362. export var pbrUboDeclaration: {
  49363. name: string;
  49364. shader: string;
  49365. };
  49366. }
  49367. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49368. /** @hidden */
  49369. export var pbrFragmentExtraDeclaration: {
  49370. name: string;
  49371. shader: string;
  49372. };
  49373. }
  49374. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49375. /** @hidden */
  49376. export var pbrFragmentSamplersDeclaration: {
  49377. name: string;
  49378. shader: string;
  49379. };
  49380. }
  49381. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49382. /** @hidden */
  49383. export var pbrHelperFunctions: {
  49384. name: string;
  49385. shader: string;
  49386. };
  49387. }
  49388. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49389. /** @hidden */
  49390. export var harmonicsFunctions: {
  49391. name: string;
  49392. shader: string;
  49393. };
  49394. }
  49395. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49396. /** @hidden */
  49397. export var pbrDirectLightingSetupFunctions: {
  49398. name: string;
  49399. shader: string;
  49400. };
  49401. }
  49402. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49403. /** @hidden */
  49404. export var pbrDirectLightingFalloffFunctions: {
  49405. name: string;
  49406. shader: string;
  49407. };
  49408. }
  49409. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49410. /** @hidden */
  49411. export var pbrBRDFFunctions: {
  49412. name: string;
  49413. shader: string;
  49414. };
  49415. }
  49416. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49417. /** @hidden */
  49418. export var pbrDirectLightingFunctions: {
  49419. name: string;
  49420. shader: string;
  49421. };
  49422. }
  49423. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49424. /** @hidden */
  49425. export var pbrIBLFunctions: {
  49426. name: string;
  49427. shader: string;
  49428. };
  49429. }
  49430. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49431. /** @hidden */
  49432. export var pbrDebug: {
  49433. name: string;
  49434. shader: string;
  49435. };
  49436. }
  49437. declare module "babylonjs/Shaders/pbr.fragment" {
  49438. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49439. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49440. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49441. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49442. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49443. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49444. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49445. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49446. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49447. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49448. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49449. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49450. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49451. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49452. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49453. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49454. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49455. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49456. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49457. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49458. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49459. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49460. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49461. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49462. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49463. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49464. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49465. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49466. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49467. /** @hidden */
  49468. export var pbrPixelShader: {
  49469. name: string;
  49470. shader: string;
  49471. };
  49472. }
  49473. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49474. /** @hidden */
  49475. export var pbrVertexDeclaration: {
  49476. name: string;
  49477. shader: string;
  49478. };
  49479. }
  49480. declare module "babylonjs/Shaders/pbr.vertex" {
  49481. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49482. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49484. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49485. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49486. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49487. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49488. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49489. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49494. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49496. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49497. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49498. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49499. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49500. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49501. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49502. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49503. /** @hidden */
  49504. export var pbrVertexShader: {
  49505. name: string;
  49506. shader: string;
  49507. };
  49508. }
  49509. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49510. import { Nullable } from "babylonjs/types";
  49511. import { Scene } from "babylonjs/scene";
  49512. import { Matrix } from "babylonjs/Maths/math.vector";
  49513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49515. import { Mesh } from "babylonjs/Meshes/mesh";
  49516. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49517. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49518. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49519. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49520. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49521. import { Color3 } from "babylonjs/Maths/math.color";
  49522. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49523. import { Material } from "babylonjs/Materials/material";
  49524. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49525. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49527. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49528. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49529. import "babylonjs/Shaders/pbr.fragment";
  49530. import "babylonjs/Shaders/pbr.vertex";
  49531. /**
  49532. * Manages the defines for the PBR Material.
  49533. * @hidden
  49534. */
  49535. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49536. PBR: boolean;
  49537. MAINUV1: boolean;
  49538. MAINUV2: boolean;
  49539. UV1: boolean;
  49540. UV2: boolean;
  49541. ALBEDO: boolean;
  49542. ALBEDODIRECTUV: number;
  49543. VERTEXCOLOR: boolean;
  49544. AMBIENT: boolean;
  49545. AMBIENTDIRECTUV: number;
  49546. AMBIENTINGRAYSCALE: boolean;
  49547. OPACITY: boolean;
  49548. VERTEXALPHA: boolean;
  49549. OPACITYDIRECTUV: number;
  49550. OPACITYRGB: boolean;
  49551. ALPHATEST: boolean;
  49552. DEPTHPREPASS: boolean;
  49553. ALPHABLEND: boolean;
  49554. ALPHAFROMALBEDO: boolean;
  49555. ALPHATESTVALUE: string;
  49556. SPECULAROVERALPHA: boolean;
  49557. RADIANCEOVERALPHA: boolean;
  49558. ALPHAFRESNEL: boolean;
  49559. LINEARALPHAFRESNEL: boolean;
  49560. PREMULTIPLYALPHA: boolean;
  49561. EMISSIVE: boolean;
  49562. EMISSIVEDIRECTUV: number;
  49563. REFLECTIVITY: boolean;
  49564. REFLECTIVITYDIRECTUV: number;
  49565. SPECULARTERM: boolean;
  49566. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49567. MICROSURFACEAUTOMATIC: boolean;
  49568. LODBASEDMICROSFURACE: boolean;
  49569. MICROSURFACEMAP: boolean;
  49570. MICROSURFACEMAPDIRECTUV: number;
  49571. METALLICWORKFLOW: boolean;
  49572. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49573. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49574. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49575. AOSTOREINMETALMAPRED: boolean;
  49576. ENVIRONMENTBRDF: boolean;
  49577. ENVIRONMENTBRDF_RGBD: boolean;
  49578. NORMAL: boolean;
  49579. TANGENT: boolean;
  49580. BUMP: boolean;
  49581. BUMPDIRECTUV: number;
  49582. OBJECTSPACE_NORMALMAP: boolean;
  49583. PARALLAX: boolean;
  49584. PARALLAXOCCLUSION: boolean;
  49585. NORMALXYSCALE: boolean;
  49586. LIGHTMAP: boolean;
  49587. LIGHTMAPDIRECTUV: number;
  49588. USELIGHTMAPASSHADOWMAP: boolean;
  49589. GAMMALIGHTMAP: boolean;
  49590. RGBDLIGHTMAP: boolean;
  49591. REFLECTION: boolean;
  49592. REFLECTIONMAP_3D: boolean;
  49593. REFLECTIONMAP_SPHERICAL: boolean;
  49594. REFLECTIONMAP_PLANAR: boolean;
  49595. REFLECTIONMAP_CUBIC: boolean;
  49596. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49597. REFLECTIONMAP_PROJECTION: boolean;
  49598. REFLECTIONMAP_SKYBOX: boolean;
  49599. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49600. REFLECTIONMAP_EXPLICIT: boolean;
  49601. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49602. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49603. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49604. INVERTCUBICMAP: boolean;
  49605. USESPHERICALFROMREFLECTIONMAP: boolean;
  49606. USEIRRADIANCEMAP: boolean;
  49607. SPHERICAL_HARMONICS: boolean;
  49608. USESPHERICALINVERTEX: boolean;
  49609. REFLECTIONMAP_OPPOSITEZ: boolean;
  49610. LODINREFLECTIONALPHA: boolean;
  49611. GAMMAREFLECTION: boolean;
  49612. RGBDREFLECTION: boolean;
  49613. LINEARSPECULARREFLECTION: boolean;
  49614. RADIANCEOCCLUSION: boolean;
  49615. HORIZONOCCLUSION: boolean;
  49616. INSTANCES: boolean;
  49617. NUM_BONE_INFLUENCERS: number;
  49618. BonesPerMesh: number;
  49619. BONETEXTURE: boolean;
  49620. NONUNIFORMSCALING: boolean;
  49621. MORPHTARGETS: boolean;
  49622. MORPHTARGETS_NORMAL: boolean;
  49623. MORPHTARGETS_TANGENT: boolean;
  49624. MORPHTARGETS_UV: boolean;
  49625. NUM_MORPH_INFLUENCERS: number;
  49626. IMAGEPROCESSING: boolean;
  49627. VIGNETTE: boolean;
  49628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49629. VIGNETTEBLENDMODEOPAQUE: boolean;
  49630. TONEMAPPING: boolean;
  49631. TONEMAPPING_ACES: boolean;
  49632. CONTRAST: boolean;
  49633. COLORCURVES: boolean;
  49634. COLORGRADING: boolean;
  49635. COLORGRADING3D: boolean;
  49636. SAMPLER3DGREENDEPTH: boolean;
  49637. SAMPLER3DBGRMAP: boolean;
  49638. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49639. EXPOSURE: boolean;
  49640. MULTIVIEW: boolean;
  49641. USEPHYSICALLIGHTFALLOFF: boolean;
  49642. USEGLTFLIGHTFALLOFF: boolean;
  49643. TWOSIDEDLIGHTING: boolean;
  49644. SHADOWFLOAT: boolean;
  49645. CLIPPLANE: boolean;
  49646. CLIPPLANE2: boolean;
  49647. CLIPPLANE3: boolean;
  49648. CLIPPLANE4: boolean;
  49649. POINTSIZE: boolean;
  49650. FOG: boolean;
  49651. LOGARITHMICDEPTH: boolean;
  49652. FORCENORMALFORWARD: boolean;
  49653. SPECULARAA: boolean;
  49654. CLEARCOAT: boolean;
  49655. CLEARCOAT_DEFAULTIOR: boolean;
  49656. CLEARCOAT_TEXTURE: boolean;
  49657. CLEARCOAT_TEXTUREDIRECTUV: number;
  49658. CLEARCOAT_BUMP: boolean;
  49659. CLEARCOAT_BUMPDIRECTUV: number;
  49660. CLEARCOAT_TINT: boolean;
  49661. CLEARCOAT_TINT_TEXTURE: boolean;
  49662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49663. ANISOTROPIC: boolean;
  49664. ANISOTROPIC_TEXTURE: boolean;
  49665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49666. BRDF_V_HEIGHT_CORRELATED: boolean;
  49667. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49668. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49669. SHEEN: boolean;
  49670. SHEEN_TEXTURE: boolean;
  49671. SHEEN_TEXTUREDIRECTUV: number;
  49672. SHEEN_LINKWITHALBEDO: boolean;
  49673. SUBSURFACE: boolean;
  49674. SS_REFRACTION: boolean;
  49675. SS_TRANSLUCENCY: boolean;
  49676. SS_SCATERRING: boolean;
  49677. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49678. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49679. SS_REFRACTIONMAP_3D: boolean;
  49680. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49681. SS_LODINREFRACTIONALPHA: boolean;
  49682. SS_GAMMAREFRACTION: boolean;
  49683. SS_RGBDREFRACTION: boolean;
  49684. SS_LINEARSPECULARREFRACTION: boolean;
  49685. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49686. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49687. UNLIT: boolean;
  49688. DEBUGMODE: number;
  49689. /**
  49690. * Initializes the PBR Material defines.
  49691. */
  49692. constructor();
  49693. /**
  49694. * Resets the PBR Material defines.
  49695. */
  49696. reset(): void;
  49697. }
  49698. /**
  49699. * The Physically based material base class of BJS.
  49700. *
  49701. * This offers the main features of a standard PBR material.
  49702. * For more information, please refer to the documentation :
  49703. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49704. */
  49705. export abstract class PBRBaseMaterial extends PushMaterial {
  49706. /**
  49707. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49708. */
  49709. static readonly PBRMATERIAL_OPAQUE: number;
  49710. /**
  49711. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49712. */
  49713. static readonly PBRMATERIAL_ALPHATEST: number;
  49714. /**
  49715. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49716. */
  49717. static readonly PBRMATERIAL_ALPHABLEND: number;
  49718. /**
  49719. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49720. * They are also discarded below the alpha cutoff threshold to improve performances.
  49721. */
  49722. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49723. /**
  49724. * Defines the default value of how much AO map is occluding the analytical lights
  49725. * (point spot...).
  49726. */
  49727. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49728. /**
  49729. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49730. */
  49731. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49732. /**
  49733. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49734. * to enhance interoperability with other engines.
  49735. */
  49736. static readonly LIGHTFALLOFF_GLTF: number;
  49737. /**
  49738. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49739. * to enhance interoperability with other materials.
  49740. */
  49741. static readonly LIGHTFALLOFF_STANDARD: number;
  49742. /**
  49743. * Intensity of the direct lights e.g. the four lights available in your scene.
  49744. * This impacts both the direct diffuse and specular highlights.
  49745. */
  49746. protected _directIntensity: number;
  49747. /**
  49748. * Intensity of the emissive part of the material.
  49749. * This helps controlling the emissive effect without modifying the emissive color.
  49750. */
  49751. protected _emissiveIntensity: number;
  49752. /**
  49753. * Intensity of the environment e.g. how much the environment will light the object
  49754. * either through harmonics for rough material or through the refelction for shiny ones.
  49755. */
  49756. protected _environmentIntensity: number;
  49757. /**
  49758. * This is a special control allowing the reduction of the specular highlights coming from the
  49759. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49760. */
  49761. protected _specularIntensity: number;
  49762. /**
  49763. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49764. */
  49765. private _lightingInfos;
  49766. /**
  49767. * Debug Control allowing disabling the bump map on this material.
  49768. */
  49769. protected _disableBumpMap: boolean;
  49770. /**
  49771. * AKA Diffuse Texture in standard nomenclature.
  49772. */
  49773. protected _albedoTexture: Nullable<BaseTexture>;
  49774. /**
  49775. * AKA Occlusion Texture in other nomenclature.
  49776. */
  49777. protected _ambientTexture: Nullable<BaseTexture>;
  49778. /**
  49779. * AKA Occlusion Texture Intensity in other nomenclature.
  49780. */
  49781. protected _ambientTextureStrength: number;
  49782. /**
  49783. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49784. * 1 means it completely occludes it
  49785. * 0 mean it has no impact
  49786. */
  49787. protected _ambientTextureImpactOnAnalyticalLights: number;
  49788. /**
  49789. * Stores the alpha values in a texture.
  49790. */
  49791. protected _opacityTexture: Nullable<BaseTexture>;
  49792. /**
  49793. * Stores the reflection values in a texture.
  49794. */
  49795. protected _reflectionTexture: Nullable<BaseTexture>;
  49796. /**
  49797. * Stores the emissive values in a texture.
  49798. */
  49799. protected _emissiveTexture: Nullable<BaseTexture>;
  49800. /**
  49801. * AKA Specular texture in other nomenclature.
  49802. */
  49803. protected _reflectivityTexture: Nullable<BaseTexture>;
  49804. /**
  49805. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49806. */
  49807. protected _metallicTexture: Nullable<BaseTexture>;
  49808. /**
  49809. * Specifies the metallic scalar of the metallic/roughness workflow.
  49810. * Can also be used to scale the metalness values of the metallic texture.
  49811. */
  49812. protected _metallic: Nullable<number>;
  49813. /**
  49814. * Specifies the roughness scalar of the metallic/roughness workflow.
  49815. * Can also be used to scale the roughness values of the metallic texture.
  49816. */
  49817. protected _roughness: Nullable<number>;
  49818. /**
  49819. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49820. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49821. */
  49822. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49823. /**
  49824. * Stores surface normal data used to displace a mesh in a texture.
  49825. */
  49826. protected _bumpTexture: Nullable<BaseTexture>;
  49827. /**
  49828. * Stores the pre-calculated light information of a mesh in a texture.
  49829. */
  49830. protected _lightmapTexture: Nullable<BaseTexture>;
  49831. /**
  49832. * The color of a material in ambient lighting.
  49833. */
  49834. protected _ambientColor: Color3;
  49835. /**
  49836. * AKA Diffuse Color in other nomenclature.
  49837. */
  49838. protected _albedoColor: Color3;
  49839. /**
  49840. * AKA Specular Color in other nomenclature.
  49841. */
  49842. protected _reflectivityColor: Color3;
  49843. /**
  49844. * The color applied when light is reflected from a material.
  49845. */
  49846. protected _reflectionColor: Color3;
  49847. /**
  49848. * The color applied when light is emitted from a material.
  49849. */
  49850. protected _emissiveColor: Color3;
  49851. /**
  49852. * AKA Glossiness in other nomenclature.
  49853. */
  49854. protected _microSurface: number;
  49855. /**
  49856. * Specifies that the material will use the light map as a show map.
  49857. */
  49858. protected _useLightmapAsShadowmap: boolean;
  49859. /**
  49860. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49861. * makes the reflect vector face the model (under horizon).
  49862. */
  49863. protected _useHorizonOcclusion: boolean;
  49864. /**
  49865. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49866. * too much the area relying on ambient texture to define their ambient occlusion.
  49867. */
  49868. protected _useRadianceOcclusion: boolean;
  49869. /**
  49870. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49871. */
  49872. protected _useAlphaFromAlbedoTexture: boolean;
  49873. /**
  49874. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49875. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49876. */
  49877. protected _useSpecularOverAlpha: boolean;
  49878. /**
  49879. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49880. */
  49881. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49882. /**
  49883. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49884. */
  49885. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49886. /**
  49887. * Specifies if the metallic texture contains the roughness information in its green channel.
  49888. */
  49889. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49890. /**
  49891. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49892. */
  49893. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49894. /**
  49895. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49896. */
  49897. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49898. /**
  49899. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49900. */
  49901. protected _useAmbientInGrayScale: boolean;
  49902. /**
  49903. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49904. * The material will try to infer what glossiness each pixel should be.
  49905. */
  49906. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49907. /**
  49908. * Defines the falloff type used in this material.
  49909. * It by default is Physical.
  49910. */
  49911. protected _lightFalloff: number;
  49912. /**
  49913. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49914. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49915. */
  49916. protected _useRadianceOverAlpha: boolean;
  49917. /**
  49918. * Allows using an object space normal map (instead of tangent space).
  49919. */
  49920. protected _useObjectSpaceNormalMap: boolean;
  49921. /**
  49922. * Allows using the bump map in parallax mode.
  49923. */
  49924. protected _useParallax: boolean;
  49925. /**
  49926. * Allows using the bump map in parallax occlusion mode.
  49927. */
  49928. protected _useParallaxOcclusion: boolean;
  49929. /**
  49930. * Controls the scale bias of the parallax mode.
  49931. */
  49932. protected _parallaxScaleBias: number;
  49933. /**
  49934. * If sets to true, disables all the lights affecting the material.
  49935. */
  49936. protected _disableLighting: boolean;
  49937. /**
  49938. * Number of Simultaneous lights allowed on the material.
  49939. */
  49940. protected _maxSimultaneousLights: number;
  49941. /**
  49942. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49943. */
  49944. protected _invertNormalMapX: boolean;
  49945. /**
  49946. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49947. */
  49948. protected _invertNormalMapY: boolean;
  49949. /**
  49950. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49951. */
  49952. protected _twoSidedLighting: boolean;
  49953. /**
  49954. * Defines the alpha limits in alpha test mode.
  49955. */
  49956. protected _alphaCutOff: number;
  49957. /**
  49958. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49959. */
  49960. protected _forceAlphaTest: boolean;
  49961. /**
  49962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49963. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49964. */
  49965. protected _useAlphaFresnel: boolean;
  49966. /**
  49967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49968. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49969. */
  49970. protected _useLinearAlphaFresnel: boolean;
  49971. /**
  49972. * The transparency mode of the material.
  49973. */
  49974. protected _transparencyMode: Nullable<number>;
  49975. /**
  49976. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49977. * from cos thetav and roughness:
  49978. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49979. */
  49980. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49981. /**
  49982. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49983. */
  49984. protected _forceIrradianceInFragment: boolean;
  49985. /**
  49986. * Force normal to face away from face.
  49987. */
  49988. protected _forceNormalForward: boolean;
  49989. /**
  49990. * Enables specular anti aliasing in the PBR shader.
  49991. * It will both interacts on the Geometry for analytical and IBL lighting.
  49992. * It also prefilter the roughness map based on the bump values.
  49993. */
  49994. protected _enableSpecularAntiAliasing: boolean;
  49995. /**
  49996. * Default configuration related to image processing available in the PBR Material.
  49997. */
  49998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49999. /**
  50000. * Keep track of the image processing observer to allow dispose and replace.
  50001. */
  50002. private _imageProcessingObserver;
  50003. /**
  50004. * Attaches a new image processing configuration to the PBR Material.
  50005. * @param configuration
  50006. */
  50007. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50008. /**
  50009. * Stores the available render targets.
  50010. */
  50011. private _renderTargets;
  50012. /**
  50013. * Sets the global ambient color for the material used in lighting calculations.
  50014. */
  50015. private _globalAmbientColor;
  50016. /**
  50017. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50018. */
  50019. private _useLogarithmicDepth;
  50020. /**
  50021. * If set to true, no lighting calculations will be applied.
  50022. */
  50023. private _unlit;
  50024. private _debugMode;
  50025. /**
  50026. * @hidden
  50027. * This is reserved for the inspector.
  50028. * Defines the material debug mode.
  50029. * It helps seeing only some components of the material while troubleshooting.
  50030. */
  50031. debugMode: number;
  50032. /**
  50033. * @hidden
  50034. * This is reserved for the inspector.
  50035. * Specify from where on screen the debug mode should start.
  50036. * The value goes from -1 (full screen) to 1 (not visible)
  50037. * It helps with side by side comparison against the final render
  50038. * This defaults to -1
  50039. */
  50040. private debugLimit;
  50041. /**
  50042. * @hidden
  50043. * This is reserved for the inspector.
  50044. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50045. * You can use the factor to better multiply the final value.
  50046. */
  50047. private debugFactor;
  50048. /**
  50049. * Defines the clear coat layer parameters for the material.
  50050. */
  50051. readonly clearCoat: PBRClearCoatConfiguration;
  50052. /**
  50053. * Defines the anisotropic parameters for the material.
  50054. */
  50055. readonly anisotropy: PBRAnisotropicConfiguration;
  50056. /**
  50057. * Defines the BRDF parameters for the material.
  50058. */
  50059. readonly brdf: PBRBRDFConfiguration;
  50060. /**
  50061. * Defines the Sheen parameters for the material.
  50062. */
  50063. readonly sheen: PBRSheenConfiguration;
  50064. /**
  50065. * Defines the SubSurface parameters for the material.
  50066. */
  50067. readonly subSurface: PBRSubSurfaceConfiguration;
  50068. /**
  50069. * Custom callback helping to override the default shader used in the material.
  50070. */
  50071. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50072. protected _rebuildInParallel: boolean;
  50073. /**
  50074. * Instantiates a new PBRMaterial instance.
  50075. *
  50076. * @param name The material name
  50077. * @param scene The scene the material will be use in.
  50078. */
  50079. constructor(name: string, scene: Scene);
  50080. /**
  50081. * Gets a boolean indicating that current material needs to register RTT
  50082. */
  50083. readonly hasRenderTargetTextures: boolean;
  50084. /**
  50085. * Gets the name of the material class.
  50086. */
  50087. getClassName(): string;
  50088. /**
  50089. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50090. */
  50091. /**
  50092. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50093. */
  50094. useLogarithmicDepth: boolean;
  50095. /**
  50096. * Gets the current transparency mode.
  50097. */
  50098. /**
  50099. * Sets the transparency mode of the material.
  50100. *
  50101. * | Value | Type | Description |
  50102. * | ----- | ----------------------------------- | ----------- |
  50103. * | 0 | OPAQUE | |
  50104. * | 1 | ALPHATEST | |
  50105. * | 2 | ALPHABLEND | |
  50106. * | 3 | ALPHATESTANDBLEND | |
  50107. *
  50108. */
  50109. transparencyMode: Nullable<number>;
  50110. /**
  50111. * Returns true if alpha blending should be disabled.
  50112. */
  50113. private readonly _disableAlphaBlending;
  50114. /**
  50115. * Specifies whether or not this material should be rendered in alpha blend mode.
  50116. */
  50117. needAlphaBlending(): boolean;
  50118. /**
  50119. * Specifies if the mesh will require alpha blending.
  50120. * @param mesh - BJS mesh.
  50121. */
  50122. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50123. /**
  50124. * Specifies whether or not this material should be rendered in alpha test mode.
  50125. */
  50126. needAlphaTesting(): boolean;
  50127. /**
  50128. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50129. */
  50130. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50131. /**
  50132. * Gets the texture used for the alpha test.
  50133. */
  50134. getAlphaTestTexture(): Nullable<BaseTexture>;
  50135. /**
  50136. * Specifies that the submesh is ready to be used.
  50137. * @param mesh - BJS mesh.
  50138. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50139. * @param useInstances - Specifies that instances should be used.
  50140. * @returns - boolean indicating that the submesh is ready or not.
  50141. */
  50142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50143. /**
  50144. * Specifies if the material uses metallic roughness workflow.
  50145. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50146. */
  50147. isMetallicWorkflow(): boolean;
  50148. private _prepareEffect;
  50149. private _prepareDefines;
  50150. /**
  50151. * Force shader compilation
  50152. */
  50153. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50154. clipPlane: boolean;
  50155. }>): void;
  50156. /**
  50157. * Initializes the uniform buffer layout for the shader.
  50158. */
  50159. buildUniformLayout(): void;
  50160. /**
  50161. * Unbinds the material from the mesh
  50162. */
  50163. unbind(): void;
  50164. /**
  50165. * Binds the submesh data.
  50166. * @param world - The world matrix.
  50167. * @param mesh - The BJS mesh.
  50168. * @param subMesh - A submesh of the BJS mesh.
  50169. */
  50170. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50171. /**
  50172. * Returns the animatable textures.
  50173. * @returns - Array of animatable textures.
  50174. */
  50175. getAnimatables(): IAnimatable[];
  50176. /**
  50177. * Returns the texture used for reflections.
  50178. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50179. */
  50180. private _getReflectionTexture;
  50181. /**
  50182. * Returns an array of the actively used textures.
  50183. * @returns - Array of BaseTextures
  50184. */
  50185. getActiveTextures(): BaseTexture[];
  50186. /**
  50187. * Checks to see if a texture is used in the material.
  50188. * @param texture - Base texture to use.
  50189. * @returns - Boolean specifying if a texture is used in the material.
  50190. */
  50191. hasTexture(texture: BaseTexture): boolean;
  50192. /**
  50193. * Disposes the resources of the material.
  50194. * @param forceDisposeEffect - Forces the disposal of effects.
  50195. * @param forceDisposeTextures - Forces the disposal of all textures.
  50196. */
  50197. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50198. }
  50199. }
  50200. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50201. import { Nullable } from "babylonjs/types";
  50202. import { Scene } from "babylonjs/scene";
  50203. import { Color3 } from "babylonjs/Maths/math.color";
  50204. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50205. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50207. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50208. /**
  50209. * The Physically based material of BJS.
  50210. *
  50211. * This offers the main features of a standard PBR material.
  50212. * For more information, please refer to the documentation :
  50213. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50214. */
  50215. export class PBRMaterial extends PBRBaseMaterial {
  50216. /**
  50217. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50218. */
  50219. static readonly PBRMATERIAL_OPAQUE: number;
  50220. /**
  50221. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50222. */
  50223. static readonly PBRMATERIAL_ALPHATEST: number;
  50224. /**
  50225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50226. */
  50227. static readonly PBRMATERIAL_ALPHABLEND: number;
  50228. /**
  50229. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50230. * They are also discarded below the alpha cutoff threshold to improve performances.
  50231. */
  50232. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50233. /**
  50234. * Defines the default value of how much AO map is occluding the analytical lights
  50235. * (point spot...).
  50236. */
  50237. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50238. /**
  50239. * Intensity of the direct lights e.g. the four lights available in your scene.
  50240. * This impacts both the direct diffuse and specular highlights.
  50241. */
  50242. directIntensity: number;
  50243. /**
  50244. * Intensity of the emissive part of the material.
  50245. * This helps controlling the emissive effect without modifying the emissive color.
  50246. */
  50247. emissiveIntensity: number;
  50248. /**
  50249. * Intensity of the environment e.g. how much the environment will light the object
  50250. * either through harmonics for rough material or through the refelction for shiny ones.
  50251. */
  50252. environmentIntensity: number;
  50253. /**
  50254. * This is a special control allowing the reduction of the specular highlights coming from the
  50255. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50256. */
  50257. specularIntensity: number;
  50258. /**
  50259. * Debug Control allowing disabling the bump map on this material.
  50260. */
  50261. disableBumpMap: boolean;
  50262. /**
  50263. * AKA Diffuse Texture in standard nomenclature.
  50264. */
  50265. albedoTexture: BaseTexture;
  50266. /**
  50267. * AKA Occlusion Texture in other nomenclature.
  50268. */
  50269. ambientTexture: BaseTexture;
  50270. /**
  50271. * AKA Occlusion Texture Intensity in other nomenclature.
  50272. */
  50273. ambientTextureStrength: number;
  50274. /**
  50275. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50276. * 1 means it completely occludes it
  50277. * 0 mean it has no impact
  50278. */
  50279. ambientTextureImpactOnAnalyticalLights: number;
  50280. /**
  50281. * Stores the alpha values in a texture.
  50282. */
  50283. opacityTexture: BaseTexture;
  50284. /**
  50285. * Stores the reflection values in a texture.
  50286. */
  50287. reflectionTexture: Nullable<BaseTexture>;
  50288. /**
  50289. * Stores the emissive values in a texture.
  50290. */
  50291. emissiveTexture: BaseTexture;
  50292. /**
  50293. * AKA Specular texture in other nomenclature.
  50294. */
  50295. reflectivityTexture: BaseTexture;
  50296. /**
  50297. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50298. */
  50299. metallicTexture: BaseTexture;
  50300. /**
  50301. * Specifies the metallic scalar of the metallic/roughness workflow.
  50302. * Can also be used to scale the metalness values of the metallic texture.
  50303. */
  50304. metallic: Nullable<number>;
  50305. /**
  50306. * Specifies the roughness scalar of the metallic/roughness workflow.
  50307. * Can also be used to scale the roughness values of the metallic texture.
  50308. */
  50309. roughness: Nullable<number>;
  50310. /**
  50311. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50312. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50313. */
  50314. microSurfaceTexture: BaseTexture;
  50315. /**
  50316. * Stores surface normal data used to displace a mesh in a texture.
  50317. */
  50318. bumpTexture: BaseTexture;
  50319. /**
  50320. * Stores the pre-calculated light information of a mesh in a texture.
  50321. */
  50322. lightmapTexture: BaseTexture;
  50323. /**
  50324. * Stores the refracted light information in a texture.
  50325. */
  50326. refractionTexture: Nullable<BaseTexture>;
  50327. /**
  50328. * The color of a material in ambient lighting.
  50329. */
  50330. ambientColor: Color3;
  50331. /**
  50332. * AKA Diffuse Color in other nomenclature.
  50333. */
  50334. albedoColor: Color3;
  50335. /**
  50336. * AKA Specular Color in other nomenclature.
  50337. */
  50338. reflectivityColor: Color3;
  50339. /**
  50340. * The color reflected from the material.
  50341. */
  50342. reflectionColor: Color3;
  50343. /**
  50344. * The color emitted from the material.
  50345. */
  50346. emissiveColor: Color3;
  50347. /**
  50348. * AKA Glossiness in other nomenclature.
  50349. */
  50350. microSurface: number;
  50351. /**
  50352. * source material index of refraction (IOR)' / 'destination material IOR.
  50353. */
  50354. indexOfRefraction: number;
  50355. /**
  50356. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50357. */
  50358. invertRefractionY: boolean;
  50359. /**
  50360. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50361. * Materials half opaque for instance using refraction could benefit from this control.
  50362. */
  50363. linkRefractionWithTransparency: boolean;
  50364. /**
  50365. * If true, the light map contains occlusion information instead of lighting info.
  50366. */
  50367. useLightmapAsShadowmap: boolean;
  50368. /**
  50369. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50370. */
  50371. useAlphaFromAlbedoTexture: boolean;
  50372. /**
  50373. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50374. */
  50375. forceAlphaTest: boolean;
  50376. /**
  50377. * Defines the alpha limits in alpha test mode.
  50378. */
  50379. alphaCutOff: number;
  50380. /**
  50381. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50382. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50383. */
  50384. useSpecularOverAlpha: boolean;
  50385. /**
  50386. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50387. */
  50388. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50389. /**
  50390. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50391. */
  50392. useRoughnessFromMetallicTextureAlpha: boolean;
  50393. /**
  50394. * Specifies if the metallic texture contains the roughness information in its green channel.
  50395. */
  50396. useRoughnessFromMetallicTextureGreen: boolean;
  50397. /**
  50398. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50399. */
  50400. useMetallnessFromMetallicTextureBlue: boolean;
  50401. /**
  50402. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50403. */
  50404. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50405. /**
  50406. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50407. */
  50408. useAmbientInGrayScale: boolean;
  50409. /**
  50410. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50411. * The material will try to infer what glossiness each pixel should be.
  50412. */
  50413. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50414. /**
  50415. * BJS is using an harcoded light falloff based on a manually sets up range.
  50416. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50417. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50418. */
  50419. /**
  50420. * BJS is using an harcoded light falloff based on a manually sets up range.
  50421. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50422. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50423. */
  50424. usePhysicalLightFalloff: boolean;
  50425. /**
  50426. * In order to support the falloff compatibility with gltf, a special mode has been added
  50427. * to reproduce the gltf light falloff.
  50428. */
  50429. /**
  50430. * In order to support the falloff compatibility with gltf, a special mode has been added
  50431. * to reproduce the gltf light falloff.
  50432. */
  50433. useGLTFLightFalloff: boolean;
  50434. /**
  50435. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50436. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50437. */
  50438. useRadianceOverAlpha: boolean;
  50439. /**
  50440. * Allows using an object space normal map (instead of tangent space).
  50441. */
  50442. useObjectSpaceNormalMap: boolean;
  50443. /**
  50444. * Allows using the bump map in parallax mode.
  50445. */
  50446. useParallax: boolean;
  50447. /**
  50448. * Allows using the bump map in parallax occlusion mode.
  50449. */
  50450. useParallaxOcclusion: boolean;
  50451. /**
  50452. * Controls the scale bias of the parallax mode.
  50453. */
  50454. parallaxScaleBias: number;
  50455. /**
  50456. * If sets to true, disables all the lights affecting the material.
  50457. */
  50458. disableLighting: boolean;
  50459. /**
  50460. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50461. */
  50462. forceIrradianceInFragment: boolean;
  50463. /**
  50464. * Number of Simultaneous lights allowed on the material.
  50465. */
  50466. maxSimultaneousLights: number;
  50467. /**
  50468. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50469. */
  50470. invertNormalMapX: boolean;
  50471. /**
  50472. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50473. */
  50474. invertNormalMapY: boolean;
  50475. /**
  50476. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50477. */
  50478. twoSidedLighting: boolean;
  50479. /**
  50480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50481. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50482. */
  50483. useAlphaFresnel: boolean;
  50484. /**
  50485. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50486. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50487. */
  50488. useLinearAlphaFresnel: boolean;
  50489. /**
  50490. * Let user defines the brdf lookup texture used for IBL.
  50491. * A default 8bit version is embedded but you could point at :
  50492. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50493. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50494. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50495. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50496. */
  50497. environmentBRDFTexture: Nullable<BaseTexture>;
  50498. /**
  50499. * Force normal to face away from face.
  50500. */
  50501. forceNormalForward: boolean;
  50502. /**
  50503. * Enables specular anti aliasing in the PBR shader.
  50504. * It will both interacts on the Geometry for analytical and IBL lighting.
  50505. * It also prefilter the roughness map based on the bump values.
  50506. */
  50507. enableSpecularAntiAliasing: boolean;
  50508. /**
  50509. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50510. * makes the reflect vector face the model (under horizon).
  50511. */
  50512. useHorizonOcclusion: boolean;
  50513. /**
  50514. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50515. * too much the area relying on ambient texture to define their ambient occlusion.
  50516. */
  50517. useRadianceOcclusion: boolean;
  50518. /**
  50519. * If set to true, no lighting calculations will be applied.
  50520. */
  50521. unlit: boolean;
  50522. /**
  50523. * Gets the image processing configuration used either in this material.
  50524. */
  50525. /**
  50526. * Sets the Default image processing configuration used either in the this material.
  50527. *
  50528. * If sets to null, the scene one is in use.
  50529. */
  50530. imageProcessingConfiguration: ImageProcessingConfiguration;
  50531. /**
  50532. * Gets wether the color curves effect is enabled.
  50533. */
  50534. /**
  50535. * Sets wether the color curves effect is enabled.
  50536. */
  50537. cameraColorCurvesEnabled: boolean;
  50538. /**
  50539. * Gets wether the color grading effect is enabled.
  50540. */
  50541. /**
  50542. * Gets wether the color grading effect is enabled.
  50543. */
  50544. cameraColorGradingEnabled: boolean;
  50545. /**
  50546. * Gets wether tonemapping is enabled or not.
  50547. */
  50548. /**
  50549. * Sets wether tonemapping is enabled or not
  50550. */
  50551. cameraToneMappingEnabled: boolean;
  50552. /**
  50553. * The camera exposure used on this material.
  50554. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50555. * This corresponds to a photographic exposure.
  50556. */
  50557. /**
  50558. * The camera exposure used on this material.
  50559. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50560. * This corresponds to a photographic exposure.
  50561. */
  50562. cameraExposure: number;
  50563. /**
  50564. * Gets The camera contrast used on this material.
  50565. */
  50566. /**
  50567. * Sets The camera contrast used on this material.
  50568. */
  50569. cameraContrast: number;
  50570. /**
  50571. * Gets the Color Grading 2D Lookup Texture.
  50572. */
  50573. /**
  50574. * Sets the Color Grading 2D Lookup Texture.
  50575. */
  50576. cameraColorGradingTexture: Nullable<BaseTexture>;
  50577. /**
  50578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50580. * 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;
  50581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50582. */
  50583. /**
  50584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50586. * 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;
  50587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50588. */
  50589. cameraColorCurves: Nullable<ColorCurves>;
  50590. /**
  50591. * Instantiates a new PBRMaterial instance.
  50592. *
  50593. * @param name The material name
  50594. * @param scene The scene the material will be use in.
  50595. */
  50596. constructor(name: string, scene: Scene);
  50597. /**
  50598. * Returns the name of this material class.
  50599. */
  50600. getClassName(): string;
  50601. /**
  50602. * Makes a duplicate of the current material.
  50603. * @param name - name to use for the new material.
  50604. */
  50605. clone(name: string): PBRMaterial;
  50606. /**
  50607. * Serializes this PBR Material.
  50608. * @returns - An object with the serialized material.
  50609. */
  50610. serialize(): any;
  50611. /**
  50612. * Parses a PBR Material from a serialized object.
  50613. * @param source - Serialized object.
  50614. * @param scene - BJS scene instance.
  50615. * @param rootUrl - url for the scene object
  50616. * @returns - PBRMaterial
  50617. */
  50618. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50619. }
  50620. }
  50621. declare module "babylonjs/Misc/dds" {
  50622. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50624. import { Nullable } from "babylonjs/types";
  50625. import { Scene } from "babylonjs/scene";
  50626. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50627. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50628. /**
  50629. * Direct draw surface info
  50630. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50631. */
  50632. export interface DDSInfo {
  50633. /**
  50634. * Width of the texture
  50635. */
  50636. width: number;
  50637. /**
  50638. * Width of the texture
  50639. */
  50640. height: number;
  50641. /**
  50642. * Number of Mipmaps for the texture
  50643. * @see https://en.wikipedia.org/wiki/Mipmap
  50644. */
  50645. mipmapCount: number;
  50646. /**
  50647. * If the textures format is a known fourCC format
  50648. * @see https://www.fourcc.org/
  50649. */
  50650. isFourCC: boolean;
  50651. /**
  50652. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50653. */
  50654. isRGB: boolean;
  50655. /**
  50656. * If the texture is a lumincance format
  50657. */
  50658. isLuminance: boolean;
  50659. /**
  50660. * If this is a cube texture
  50661. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50662. */
  50663. isCube: boolean;
  50664. /**
  50665. * If the texture is a compressed format eg. FOURCC_DXT1
  50666. */
  50667. isCompressed: boolean;
  50668. /**
  50669. * The dxgiFormat of the texture
  50670. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50671. */
  50672. dxgiFormat: number;
  50673. /**
  50674. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50675. */
  50676. textureType: number;
  50677. /**
  50678. * Sphericle polynomial created for the dds texture
  50679. */
  50680. sphericalPolynomial?: SphericalPolynomial;
  50681. }
  50682. /**
  50683. * Class used to provide DDS decompression tools
  50684. */
  50685. export class DDSTools {
  50686. /**
  50687. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50688. */
  50689. static StoreLODInAlphaChannel: boolean;
  50690. /**
  50691. * Gets DDS information from an array buffer
  50692. * @param arrayBuffer defines the array buffer to read data from
  50693. * @returns the DDS information
  50694. */
  50695. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50696. private static _FloatView;
  50697. private static _Int32View;
  50698. private static _ToHalfFloat;
  50699. private static _FromHalfFloat;
  50700. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50701. private static _GetHalfFloatRGBAArrayBuffer;
  50702. private static _GetFloatRGBAArrayBuffer;
  50703. private static _GetFloatAsUIntRGBAArrayBuffer;
  50704. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50705. private static _GetRGBAArrayBuffer;
  50706. private static _ExtractLongWordOrder;
  50707. private static _GetRGBArrayBuffer;
  50708. private static _GetLuminanceArrayBuffer;
  50709. /**
  50710. * Uploads DDS Levels to a Babylon Texture
  50711. * @hidden
  50712. */
  50713. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50714. }
  50715. module "babylonjs/Engines/thinEngine" {
  50716. interface ThinEngine {
  50717. /**
  50718. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50719. * @param rootUrl defines the url where the file to load is located
  50720. * @param scene defines the current scene
  50721. * @param lodScale defines scale to apply to the mip map selection
  50722. * @param lodOffset defines offset to apply to the mip map selection
  50723. * @param onLoad defines an optional callback raised when the texture is loaded
  50724. * @param onError defines an optional callback raised if there is an issue to load the texture
  50725. * @param format defines the format of the data
  50726. * @param forcedExtension defines the extension to use to pick the right loader
  50727. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50728. * @returns the cube texture as an InternalTexture
  50729. */
  50730. 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;
  50731. }
  50732. }
  50733. }
  50734. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50735. import { Nullable } from "babylonjs/types";
  50736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50738. /**
  50739. * Implementation of the DDS Texture Loader.
  50740. * @hidden
  50741. */
  50742. export class _DDSTextureLoader implements IInternalTextureLoader {
  50743. /**
  50744. * Defines wether the loader supports cascade loading the different faces.
  50745. */
  50746. readonly supportCascades: boolean;
  50747. /**
  50748. * This returns if the loader support the current file information.
  50749. * @param extension defines the file extension of the file being loaded
  50750. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50751. * @param fallback defines the fallback internal texture if any
  50752. * @param isBase64 defines whether the texture is encoded as a base64
  50753. * @param isBuffer defines whether the texture data are stored as a buffer
  50754. * @returns true if the loader can load the specified file
  50755. */
  50756. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50757. /**
  50758. * Transform the url before loading if required.
  50759. * @param rootUrl the url of the texture
  50760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50761. * @returns the transformed texture
  50762. */
  50763. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50764. /**
  50765. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50766. * @param rootUrl the url of the texture
  50767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50768. * @returns the fallback texture
  50769. */
  50770. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50771. /**
  50772. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50773. * @param data contains the texture data
  50774. * @param texture defines the BabylonJS internal texture
  50775. * @param createPolynomials will be true if polynomials have been requested
  50776. * @param onLoad defines the callback to trigger once the texture is ready
  50777. * @param onError defines the callback to trigger in case of error
  50778. */
  50779. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50780. /**
  50781. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50782. * @param data contains the texture data
  50783. * @param texture defines the BabylonJS internal texture
  50784. * @param callback defines the method to call once ready to upload
  50785. */
  50786. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50787. }
  50788. }
  50789. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50790. import { Nullable } from "babylonjs/types";
  50791. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50792. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50793. /**
  50794. * Implementation of the ENV Texture Loader.
  50795. * @hidden
  50796. */
  50797. export class _ENVTextureLoader implements IInternalTextureLoader {
  50798. /**
  50799. * Defines wether the loader supports cascade loading the different faces.
  50800. */
  50801. readonly supportCascades: boolean;
  50802. /**
  50803. * This returns if the loader support the current file information.
  50804. * @param extension defines the file extension of the file being loaded
  50805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50806. * @param fallback defines the fallback internal texture if any
  50807. * @param isBase64 defines whether the texture is encoded as a base64
  50808. * @param isBuffer defines whether the texture data are stored as a buffer
  50809. * @returns true if the loader can load the specified file
  50810. */
  50811. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50812. /**
  50813. * Transform the url before loading if required.
  50814. * @param rootUrl the url of the texture
  50815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50816. * @returns the transformed texture
  50817. */
  50818. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50819. /**
  50820. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50821. * @param rootUrl the url of the texture
  50822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50823. * @returns the fallback texture
  50824. */
  50825. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50826. /**
  50827. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50828. * @param data contains the texture data
  50829. * @param texture defines the BabylonJS internal texture
  50830. * @param createPolynomials will be true if polynomials have been requested
  50831. * @param onLoad defines the callback to trigger once the texture is ready
  50832. * @param onError defines the callback to trigger in case of error
  50833. */
  50834. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50835. /**
  50836. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50837. * @param data contains the texture data
  50838. * @param texture defines the BabylonJS internal texture
  50839. * @param callback defines the method to call once ready to upload
  50840. */
  50841. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50842. }
  50843. }
  50844. declare module "babylonjs/Misc/khronosTextureContainer" {
  50845. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50846. /**
  50847. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50848. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50849. */
  50850. export class KhronosTextureContainer {
  50851. /** contents of the KTX container file */
  50852. arrayBuffer: any;
  50853. private static HEADER_LEN;
  50854. private static COMPRESSED_2D;
  50855. private static COMPRESSED_3D;
  50856. private static TEX_2D;
  50857. private static TEX_3D;
  50858. /**
  50859. * Gets the openGL type
  50860. */
  50861. glType: number;
  50862. /**
  50863. * Gets the openGL type size
  50864. */
  50865. glTypeSize: number;
  50866. /**
  50867. * Gets the openGL format
  50868. */
  50869. glFormat: number;
  50870. /**
  50871. * Gets the openGL internal format
  50872. */
  50873. glInternalFormat: number;
  50874. /**
  50875. * Gets the base internal format
  50876. */
  50877. glBaseInternalFormat: number;
  50878. /**
  50879. * Gets image width in pixel
  50880. */
  50881. pixelWidth: number;
  50882. /**
  50883. * Gets image height in pixel
  50884. */
  50885. pixelHeight: number;
  50886. /**
  50887. * Gets image depth in pixels
  50888. */
  50889. pixelDepth: number;
  50890. /**
  50891. * Gets the number of array elements
  50892. */
  50893. numberOfArrayElements: number;
  50894. /**
  50895. * Gets the number of faces
  50896. */
  50897. numberOfFaces: number;
  50898. /**
  50899. * Gets the number of mipmap levels
  50900. */
  50901. numberOfMipmapLevels: number;
  50902. /**
  50903. * Gets the bytes of key value data
  50904. */
  50905. bytesOfKeyValueData: number;
  50906. /**
  50907. * Gets the load type
  50908. */
  50909. loadType: number;
  50910. /**
  50911. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50912. */
  50913. isInvalid: boolean;
  50914. /**
  50915. * Creates a new KhronosTextureContainer
  50916. * @param arrayBuffer contents of the KTX container file
  50917. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50918. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50919. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50920. */
  50921. constructor(
  50922. /** contents of the KTX container file */
  50923. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50924. /**
  50925. * Uploads KTX content to a Babylon Texture.
  50926. * It is assumed that the texture has already been created & is currently bound
  50927. * @hidden
  50928. */
  50929. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50930. private _upload2DCompressedLevels;
  50931. }
  50932. }
  50933. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50934. import { Nullable } from "babylonjs/types";
  50935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50936. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50937. /**
  50938. * Implementation of the KTX Texture Loader.
  50939. * @hidden
  50940. */
  50941. export class _KTXTextureLoader implements IInternalTextureLoader {
  50942. /**
  50943. * Defines wether the loader supports cascade loading the different faces.
  50944. */
  50945. readonly supportCascades: boolean;
  50946. /**
  50947. * This returns if the loader support the current file information.
  50948. * @param extension defines the file extension of the file being loaded
  50949. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50950. * @param fallback defines the fallback internal texture if any
  50951. * @param isBase64 defines whether the texture is encoded as a base64
  50952. * @param isBuffer defines whether the texture data are stored as a buffer
  50953. * @returns true if the loader can load the specified file
  50954. */
  50955. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50956. /**
  50957. * Transform the url before loading if required.
  50958. * @param rootUrl the url of the texture
  50959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50960. * @returns the transformed texture
  50961. */
  50962. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50963. /**
  50964. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50965. * @param rootUrl the url of the texture
  50966. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50967. * @returns the fallback texture
  50968. */
  50969. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50970. /**
  50971. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50972. * @param data contains the texture data
  50973. * @param texture defines the BabylonJS internal texture
  50974. * @param createPolynomials will be true if polynomials have been requested
  50975. * @param onLoad defines the callback to trigger once the texture is ready
  50976. * @param onError defines the callback to trigger in case of error
  50977. */
  50978. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50979. /**
  50980. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50981. * @param data contains the texture data
  50982. * @param texture defines the BabylonJS internal texture
  50983. * @param callback defines the method to call once ready to upload
  50984. */
  50985. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50986. }
  50987. }
  50988. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50989. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50990. import { Scene } from "babylonjs/scene";
  50991. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50992. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50993. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50994. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50995. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50996. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50998. /**
  50999. * Options for the default xr helper
  51000. */
  51001. export class WebXRDefaultExperienceOptions {
  51002. /**
  51003. * Floor meshes that should be used for teleporting
  51004. */
  51005. floorMeshes: Array<AbstractMesh>;
  51006. }
  51007. /**
  51008. * Default experience which provides a similar setup to the previous webVRExperience
  51009. */
  51010. export class WebXRDefaultExperience {
  51011. /**
  51012. * Base experience
  51013. */
  51014. baseExperience: WebXRExperienceHelper;
  51015. /**
  51016. * Input experience extension
  51017. */
  51018. input: WebXRInput;
  51019. /**
  51020. * Loads the controller models
  51021. */
  51022. controllerModelLoader: WebXRControllerModelLoader;
  51023. /**
  51024. * Enables laser pointer and selection
  51025. */
  51026. pointerSelection: WebXRControllerPointerSelection;
  51027. /**
  51028. * Enables teleportation
  51029. */
  51030. teleportation: WebXRControllerTeleportation;
  51031. /**
  51032. * Enables ui for enetering/exiting xr
  51033. */
  51034. enterExitUI: WebXREnterExitUI;
  51035. /**
  51036. * Default output canvas xr should render to
  51037. */
  51038. outputCanvas: WebXRManagedOutputCanvas;
  51039. /**
  51040. * Creates the default xr experience
  51041. * @param scene scene
  51042. * @param options options for basic configuration
  51043. * @returns resulting WebXRDefaultExperience
  51044. */
  51045. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51046. private constructor();
  51047. /**
  51048. * DIsposes of the experience helper
  51049. */
  51050. dispose(): void;
  51051. }
  51052. }
  51053. declare module "babylonjs/Helpers/sceneHelpers" {
  51054. import { Nullable } from "babylonjs/types";
  51055. import { Mesh } from "babylonjs/Meshes/mesh";
  51056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51057. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51058. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51059. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51060. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51061. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51062. import "babylonjs/Meshes/Builders/boxBuilder";
  51063. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51064. /** @hidden */
  51065. export var _forceSceneHelpersToBundle: boolean;
  51066. module "babylonjs/scene" {
  51067. interface Scene {
  51068. /**
  51069. * Creates a default light for the scene.
  51070. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51071. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51072. */
  51073. createDefaultLight(replace?: boolean): void;
  51074. /**
  51075. * Creates a default camera for the scene.
  51076. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51077. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51078. * @param replace has default false, when true replaces the active camera in the scene
  51079. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51080. */
  51081. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51082. /**
  51083. * Creates a default camera and a default light.
  51084. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51085. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51086. * @param replace has the default false, when true replaces the active camera/light in the scene
  51087. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51088. */
  51089. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51090. /**
  51091. * Creates a new sky box
  51092. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51093. * @param environmentTexture defines the texture to use as environment texture
  51094. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51095. * @param scale defines the overall scale of the skybox
  51096. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51097. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51098. * @returns a new mesh holding the sky box
  51099. */
  51100. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51101. /**
  51102. * Creates a new environment
  51103. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51104. * @param options defines the options you can use to configure the environment
  51105. * @returns the new EnvironmentHelper
  51106. */
  51107. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51108. /**
  51109. * Creates a new VREXperienceHelper
  51110. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51111. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51112. * @returns a new VREXperienceHelper
  51113. */
  51114. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51115. /**
  51116. * Creates a new WebXRDefaultExperience
  51117. * @see http://doc.babylonjs.com/how_to/webxr
  51118. * @param options experience options
  51119. * @returns a promise for a new WebXRDefaultExperience
  51120. */
  51121. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51122. }
  51123. }
  51124. }
  51125. declare module "babylonjs/Helpers/videoDome" {
  51126. import { Scene } from "babylonjs/scene";
  51127. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51128. import { Mesh } from "babylonjs/Meshes/mesh";
  51129. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51130. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51131. import "babylonjs/Meshes/Builders/sphereBuilder";
  51132. /**
  51133. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51134. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51135. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51136. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51137. */
  51138. export class VideoDome extends TransformNode {
  51139. /**
  51140. * Define the video source as a Monoscopic panoramic 360 video.
  51141. */
  51142. static readonly MODE_MONOSCOPIC: number;
  51143. /**
  51144. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51145. */
  51146. static readonly MODE_TOPBOTTOM: number;
  51147. /**
  51148. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51149. */
  51150. static readonly MODE_SIDEBYSIDE: number;
  51151. private _halfDome;
  51152. private _useDirectMapping;
  51153. /**
  51154. * The video texture being displayed on the sphere
  51155. */
  51156. protected _videoTexture: VideoTexture;
  51157. /**
  51158. * Gets the video texture being displayed on the sphere
  51159. */
  51160. readonly videoTexture: VideoTexture;
  51161. /**
  51162. * The skybox material
  51163. */
  51164. protected _material: BackgroundMaterial;
  51165. /**
  51166. * The surface used for the skybox
  51167. */
  51168. protected _mesh: Mesh;
  51169. /**
  51170. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51171. */
  51172. private _halfDomeMask;
  51173. /**
  51174. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51175. * Also see the options.resolution property.
  51176. */
  51177. fovMultiplier: number;
  51178. private _videoMode;
  51179. /**
  51180. * Gets or set the current video mode for the video. It can be:
  51181. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51182. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51183. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51184. */
  51185. videoMode: number;
  51186. /**
  51187. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51188. *
  51189. */
  51190. /**
  51191. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51192. */
  51193. halfDome: boolean;
  51194. /**
  51195. * Oberserver used in Stereoscopic VR Mode.
  51196. */
  51197. private _onBeforeCameraRenderObserver;
  51198. /**
  51199. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51200. * @param name Element's name, child elements will append suffixes for their own names.
  51201. * @param urlsOrVideo defines the url(s) or the video element to use
  51202. * @param options An object containing optional or exposed sub element properties
  51203. */
  51204. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51205. resolution?: number;
  51206. clickToPlay?: boolean;
  51207. autoPlay?: boolean;
  51208. loop?: boolean;
  51209. size?: number;
  51210. poster?: string;
  51211. faceForward?: boolean;
  51212. useDirectMapping?: boolean;
  51213. halfDomeMode?: boolean;
  51214. }, scene: Scene);
  51215. private _changeVideoMode;
  51216. /**
  51217. * Releases resources associated with this node.
  51218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51220. */
  51221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51222. }
  51223. }
  51224. declare module "babylonjs/Helpers/index" {
  51225. export * from "babylonjs/Helpers/environmentHelper";
  51226. export * from "babylonjs/Helpers/photoDome";
  51227. export * from "babylonjs/Helpers/sceneHelpers";
  51228. export * from "babylonjs/Helpers/videoDome";
  51229. }
  51230. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51231. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51232. import { IDisposable } from "babylonjs/scene";
  51233. import { Engine } from "babylonjs/Engines/engine";
  51234. /**
  51235. * This class can be used to get instrumentation data from a Babylon engine
  51236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51237. */
  51238. export class EngineInstrumentation implements IDisposable {
  51239. /**
  51240. * Define the instrumented engine.
  51241. */
  51242. engine: Engine;
  51243. private _captureGPUFrameTime;
  51244. private _gpuFrameTimeToken;
  51245. private _gpuFrameTime;
  51246. private _captureShaderCompilationTime;
  51247. private _shaderCompilationTime;
  51248. private _onBeginFrameObserver;
  51249. private _onEndFrameObserver;
  51250. private _onBeforeShaderCompilationObserver;
  51251. private _onAfterShaderCompilationObserver;
  51252. /**
  51253. * Gets the perf counter used for GPU frame time
  51254. */
  51255. readonly gpuFrameTimeCounter: PerfCounter;
  51256. /**
  51257. * Gets the GPU frame time capture status
  51258. */
  51259. /**
  51260. * Enable or disable the GPU frame time capture
  51261. */
  51262. captureGPUFrameTime: boolean;
  51263. /**
  51264. * Gets the perf counter used for shader compilation time
  51265. */
  51266. readonly shaderCompilationTimeCounter: PerfCounter;
  51267. /**
  51268. * Gets the shader compilation time capture status
  51269. */
  51270. /**
  51271. * Enable or disable the shader compilation time capture
  51272. */
  51273. captureShaderCompilationTime: boolean;
  51274. /**
  51275. * Instantiates a new engine instrumentation.
  51276. * This class can be used to get instrumentation data from a Babylon engine
  51277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51278. * @param engine Defines the engine to instrument
  51279. */
  51280. constructor(
  51281. /**
  51282. * Define the instrumented engine.
  51283. */
  51284. engine: Engine);
  51285. /**
  51286. * Dispose and release associated resources.
  51287. */
  51288. dispose(): void;
  51289. }
  51290. }
  51291. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51292. import { Scene, IDisposable } from "babylonjs/scene";
  51293. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51294. /**
  51295. * This class can be used to get instrumentation data from a Babylon engine
  51296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51297. */
  51298. export class SceneInstrumentation implements IDisposable {
  51299. /**
  51300. * Defines the scene to instrument
  51301. */
  51302. scene: Scene;
  51303. private _captureActiveMeshesEvaluationTime;
  51304. private _activeMeshesEvaluationTime;
  51305. private _captureRenderTargetsRenderTime;
  51306. private _renderTargetsRenderTime;
  51307. private _captureFrameTime;
  51308. private _frameTime;
  51309. private _captureRenderTime;
  51310. private _renderTime;
  51311. private _captureInterFrameTime;
  51312. private _interFrameTime;
  51313. private _captureParticlesRenderTime;
  51314. private _particlesRenderTime;
  51315. private _captureSpritesRenderTime;
  51316. private _spritesRenderTime;
  51317. private _capturePhysicsTime;
  51318. private _physicsTime;
  51319. private _captureAnimationsTime;
  51320. private _animationsTime;
  51321. private _captureCameraRenderTime;
  51322. private _cameraRenderTime;
  51323. private _onBeforeActiveMeshesEvaluationObserver;
  51324. private _onAfterActiveMeshesEvaluationObserver;
  51325. private _onBeforeRenderTargetsRenderObserver;
  51326. private _onAfterRenderTargetsRenderObserver;
  51327. private _onAfterRenderObserver;
  51328. private _onBeforeDrawPhaseObserver;
  51329. private _onAfterDrawPhaseObserver;
  51330. private _onBeforeAnimationsObserver;
  51331. private _onBeforeParticlesRenderingObserver;
  51332. private _onAfterParticlesRenderingObserver;
  51333. private _onBeforeSpritesRenderingObserver;
  51334. private _onAfterSpritesRenderingObserver;
  51335. private _onBeforePhysicsObserver;
  51336. private _onAfterPhysicsObserver;
  51337. private _onAfterAnimationsObserver;
  51338. private _onBeforeCameraRenderObserver;
  51339. private _onAfterCameraRenderObserver;
  51340. /**
  51341. * Gets the perf counter used for active meshes evaluation time
  51342. */
  51343. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51344. /**
  51345. * Gets the active meshes evaluation time capture status
  51346. */
  51347. /**
  51348. * Enable or disable the active meshes evaluation time capture
  51349. */
  51350. captureActiveMeshesEvaluationTime: boolean;
  51351. /**
  51352. * Gets the perf counter used for render targets render time
  51353. */
  51354. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51355. /**
  51356. * Gets the render targets render time capture status
  51357. */
  51358. /**
  51359. * Enable or disable the render targets render time capture
  51360. */
  51361. captureRenderTargetsRenderTime: boolean;
  51362. /**
  51363. * Gets the perf counter used for particles render time
  51364. */
  51365. readonly particlesRenderTimeCounter: PerfCounter;
  51366. /**
  51367. * Gets the particles render time capture status
  51368. */
  51369. /**
  51370. * Enable or disable the particles render time capture
  51371. */
  51372. captureParticlesRenderTime: boolean;
  51373. /**
  51374. * Gets the perf counter used for sprites render time
  51375. */
  51376. readonly spritesRenderTimeCounter: PerfCounter;
  51377. /**
  51378. * Gets the sprites render time capture status
  51379. */
  51380. /**
  51381. * Enable or disable the sprites render time capture
  51382. */
  51383. captureSpritesRenderTime: boolean;
  51384. /**
  51385. * Gets the perf counter used for physics time
  51386. */
  51387. readonly physicsTimeCounter: PerfCounter;
  51388. /**
  51389. * Gets the physics time capture status
  51390. */
  51391. /**
  51392. * Enable or disable the physics time capture
  51393. */
  51394. capturePhysicsTime: boolean;
  51395. /**
  51396. * Gets the perf counter used for animations time
  51397. */
  51398. readonly animationsTimeCounter: PerfCounter;
  51399. /**
  51400. * Gets the animations time capture status
  51401. */
  51402. /**
  51403. * Enable or disable the animations time capture
  51404. */
  51405. captureAnimationsTime: boolean;
  51406. /**
  51407. * Gets the perf counter used for frame time capture
  51408. */
  51409. readonly frameTimeCounter: PerfCounter;
  51410. /**
  51411. * Gets the frame time capture status
  51412. */
  51413. /**
  51414. * Enable or disable the frame time capture
  51415. */
  51416. captureFrameTime: boolean;
  51417. /**
  51418. * Gets the perf counter used for inter-frames time capture
  51419. */
  51420. readonly interFrameTimeCounter: PerfCounter;
  51421. /**
  51422. * Gets the inter-frames time capture status
  51423. */
  51424. /**
  51425. * Enable or disable the inter-frames time capture
  51426. */
  51427. captureInterFrameTime: boolean;
  51428. /**
  51429. * Gets the perf counter used for render time capture
  51430. */
  51431. readonly renderTimeCounter: PerfCounter;
  51432. /**
  51433. * Gets the render time capture status
  51434. */
  51435. /**
  51436. * Enable or disable the render time capture
  51437. */
  51438. captureRenderTime: boolean;
  51439. /**
  51440. * Gets the perf counter used for camera render time capture
  51441. */
  51442. readonly cameraRenderTimeCounter: PerfCounter;
  51443. /**
  51444. * Gets the camera render time capture status
  51445. */
  51446. /**
  51447. * Enable or disable the camera render time capture
  51448. */
  51449. captureCameraRenderTime: boolean;
  51450. /**
  51451. * Gets the perf counter used for draw calls
  51452. */
  51453. readonly drawCallsCounter: PerfCounter;
  51454. /**
  51455. * Instantiates a new scene instrumentation.
  51456. * This class can be used to get instrumentation data from a Babylon engine
  51457. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51458. * @param scene Defines the scene to instrument
  51459. */
  51460. constructor(
  51461. /**
  51462. * Defines the scene to instrument
  51463. */
  51464. scene: Scene);
  51465. /**
  51466. * Dispose and release associated resources.
  51467. */
  51468. dispose(): void;
  51469. }
  51470. }
  51471. declare module "babylonjs/Instrumentation/index" {
  51472. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51473. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51474. export * from "babylonjs/Instrumentation/timeToken";
  51475. }
  51476. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51477. /** @hidden */
  51478. export var glowMapGenerationPixelShader: {
  51479. name: string;
  51480. shader: string;
  51481. };
  51482. }
  51483. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51484. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51487. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51489. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51490. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51491. /** @hidden */
  51492. export var glowMapGenerationVertexShader: {
  51493. name: string;
  51494. shader: string;
  51495. };
  51496. }
  51497. declare module "babylonjs/Layers/effectLayer" {
  51498. import { Observable } from "babylonjs/Misc/observable";
  51499. import { Nullable } from "babylonjs/types";
  51500. import { Camera } from "babylonjs/Cameras/camera";
  51501. import { Scene } from "babylonjs/scene";
  51502. import { ISize } from "babylonjs/Maths/math.size";
  51503. import { Color4 } from "babylonjs/Maths/math.color";
  51504. import { Engine } from "babylonjs/Engines/engine";
  51505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51507. import { Mesh } from "babylonjs/Meshes/mesh";
  51508. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51511. import { Effect } from "babylonjs/Materials/effect";
  51512. import { Material } from "babylonjs/Materials/material";
  51513. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51514. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51515. /**
  51516. * Effect layer options. This helps customizing the behaviour
  51517. * of the effect layer.
  51518. */
  51519. export interface IEffectLayerOptions {
  51520. /**
  51521. * Multiplication factor apply to the canvas size to compute the render target size
  51522. * used to generated the objects (the smaller the faster).
  51523. */
  51524. mainTextureRatio: number;
  51525. /**
  51526. * Enforces a fixed size texture to ensure effect stability across devices.
  51527. */
  51528. mainTextureFixedSize?: number;
  51529. /**
  51530. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51531. */
  51532. alphaBlendingMode: number;
  51533. /**
  51534. * The camera attached to the layer.
  51535. */
  51536. camera: Nullable<Camera>;
  51537. /**
  51538. * The rendering group to draw the layer in.
  51539. */
  51540. renderingGroupId: number;
  51541. }
  51542. /**
  51543. * The effect layer Helps adding post process effect blended with the main pass.
  51544. *
  51545. * This can be for instance use to generate glow or higlight effects on the scene.
  51546. *
  51547. * The effect layer class can not be used directly and is intented to inherited from to be
  51548. * customized per effects.
  51549. */
  51550. export abstract class EffectLayer {
  51551. private _vertexBuffers;
  51552. private _indexBuffer;
  51553. private _cachedDefines;
  51554. private _effectLayerMapGenerationEffect;
  51555. private _effectLayerOptions;
  51556. private _mergeEffect;
  51557. protected _scene: Scene;
  51558. protected _engine: Engine;
  51559. protected _maxSize: number;
  51560. protected _mainTextureDesiredSize: ISize;
  51561. protected _mainTexture: RenderTargetTexture;
  51562. protected _shouldRender: boolean;
  51563. protected _postProcesses: PostProcess[];
  51564. protected _textures: BaseTexture[];
  51565. protected _emissiveTextureAndColor: {
  51566. texture: Nullable<BaseTexture>;
  51567. color: Color4;
  51568. };
  51569. /**
  51570. * The name of the layer
  51571. */
  51572. name: string;
  51573. /**
  51574. * The clear color of the texture used to generate the glow map.
  51575. */
  51576. neutralColor: Color4;
  51577. /**
  51578. * Specifies wether the highlight layer is enabled or not.
  51579. */
  51580. isEnabled: boolean;
  51581. /**
  51582. * Gets the camera attached to the layer.
  51583. */
  51584. readonly camera: Nullable<Camera>;
  51585. /**
  51586. * Gets the rendering group id the layer should render in.
  51587. */
  51588. renderingGroupId: number;
  51589. /**
  51590. * An event triggered when the effect layer has been disposed.
  51591. */
  51592. onDisposeObservable: Observable<EffectLayer>;
  51593. /**
  51594. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51595. */
  51596. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51597. /**
  51598. * An event triggered when the generated texture is being merged in the scene.
  51599. */
  51600. onBeforeComposeObservable: Observable<EffectLayer>;
  51601. /**
  51602. * An event triggered when the generated texture has been merged in the scene.
  51603. */
  51604. onAfterComposeObservable: Observable<EffectLayer>;
  51605. /**
  51606. * An event triggered when the efffect layer changes its size.
  51607. */
  51608. onSizeChangedObservable: Observable<EffectLayer>;
  51609. /** @hidden */
  51610. static _SceneComponentInitialization: (scene: Scene) => void;
  51611. /**
  51612. * Instantiates a new effect Layer and references it in the scene.
  51613. * @param name The name of the layer
  51614. * @param scene The scene to use the layer in
  51615. */
  51616. constructor(
  51617. /** The Friendly of the effect in the scene */
  51618. name: string, scene: Scene);
  51619. /**
  51620. * Get the effect name of the layer.
  51621. * @return The effect name
  51622. */
  51623. abstract getEffectName(): string;
  51624. /**
  51625. * Checks for the readiness of the element composing the layer.
  51626. * @param subMesh the mesh to check for
  51627. * @param useInstances specify wether or not to use instances to render the mesh
  51628. * @return true if ready otherwise, false
  51629. */
  51630. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51631. /**
  51632. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51633. * @returns true if the effect requires stencil during the main canvas render pass.
  51634. */
  51635. abstract needStencil(): boolean;
  51636. /**
  51637. * Create the merge effect. This is the shader use to blit the information back
  51638. * to the main canvas at the end of the scene rendering.
  51639. * @returns The effect containing the shader used to merge the effect on the main canvas
  51640. */
  51641. protected abstract _createMergeEffect(): Effect;
  51642. /**
  51643. * Creates the render target textures and post processes used in the effect layer.
  51644. */
  51645. protected abstract _createTextureAndPostProcesses(): void;
  51646. /**
  51647. * Implementation specific of rendering the generating effect on the main canvas.
  51648. * @param effect The effect used to render through
  51649. */
  51650. protected abstract _internalRender(effect: Effect): void;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Free any resources and references associated to a mesh.
  51657. * Internal use
  51658. * @param mesh The mesh to free.
  51659. */
  51660. abstract _disposeMesh(mesh: Mesh): void;
  51661. /**
  51662. * Serializes this layer (Glow or Highlight for example)
  51663. * @returns a serialized layer object
  51664. */
  51665. abstract serialize?(): any;
  51666. /**
  51667. * Initializes the effect layer with the required options.
  51668. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51669. */
  51670. protected _init(options: Partial<IEffectLayerOptions>): void;
  51671. /**
  51672. * Generates the index buffer of the full screen quad blending to the main canvas.
  51673. */
  51674. private _generateIndexBuffer;
  51675. /**
  51676. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51677. */
  51678. private _generateVertexBuffer;
  51679. /**
  51680. * Sets the main texture desired size which is the closest power of two
  51681. * of the engine canvas size.
  51682. */
  51683. private _setMainTextureSize;
  51684. /**
  51685. * Creates the main texture for the effect layer.
  51686. */
  51687. protected _createMainTexture(): void;
  51688. /**
  51689. * Adds specific effects defines.
  51690. * @param defines The defines to add specifics to.
  51691. */
  51692. protected _addCustomEffectDefines(defines: string[]): void;
  51693. /**
  51694. * Checks for the readiness of the element composing the layer.
  51695. * @param subMesh the mesh to check for
  51696. * @param useInstances specify wether or not to use instances to render the mesh
  51697. * @param emissiveTexture the associated emissive texture used to generate the glow
  51698. * @return true if ready otherwise, false
  51699. */
  51700. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51701. /**
  51702. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51703. */
  51704. render(): void;
  51705. /**
  51706. * Determine if a given mesh will be used in the current effect.
  51707. * @param mesh mesh to test
  51708. * @returns true if the mesh will be used
  51709. */
  51710. hasMesh(mesh: AbstractMesh): boolean;
  51711. /**
  51712. * Returns true if the layer contains information to display, otherwise false.
  51713. * @returns true if the glow layer should be rendered
  51714. */
  51715. shouldRender(): boolean;
  51716. /**
  51717. * Returns true if the mesh should render, otherwise false.
  51718. * @param mesh The mesh to render
  51719. * @returns true if it should render otherwise false
  51720. */
  51721. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51722. /**
  51723. * Returns true if the mesh can be rendered, otherwise false.
  51724. * @param mesh The mesh to render
  51725. * @param material The material used on the mesh
  51726. * @returns true if it can be rendered otherwise false
  51727. */
  51728. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51729. /**
  51730. * Returns true if the mesh should render, otherwise false.
  51731. * @param mesh The mesh to render
  51732. * @returns true if it should render otherwise false
  51733. */
  51734. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51735. /**
  51736. * Renders the submesh passed in parameter to the generation map.
  51737. */
  51738. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51739. /**
  51740. * Rebuild the required buffers.
  51741. * @hidden Internal use only.
  51742. */
  51743. _rebuild(): void;
  51744. /**
  51745. * Dispose only the render target textures and post process.
  51746. */
  51747. private _disposeTextureAndPostProcesses;
  51748. /**
  51749. * Dispose the highlight layer and free resources.
  51750. */
  51751. dispose(): void;
  51752. /**
  51753. * Gets the class name of the effect layer
  51754. * @returns the string with the class name of the effect layer
  51755. */
  51756. getClassName(): string;
  51757. /**
  51758. * Creates an effect layer from parsed effect layer data
  51759. * @param parsedEffectLayer defines effect layer data
  51760. * @param scene defines the current scene
  51761. * @param rootUrl defines the root URL containing the effect layer information
  51762. * @returns a parsed effect Layer
  51763. */
  51764. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51765. }
  51766. }
  51767. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51768. import { Scene } from "babylonjs/scene";
  51769. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51770. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51771. import { AbstractScene } from "babylonjs/abstractScene";
  51772. module "babylonjs/abstractScene" {
  51773. interface AbstractScene {
  51774. /**
  51775. * The list of effect layers (highlights/glow) added to the scene
  51776. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51777. * @see http://doc.babylonjs.com/how_to/glow_layer
  51778. */
  51779. effectLayers: Array<EffectLayer>;
  51780. /**
  51781. * Removes the given effect layer from this scene.
  51782. * @param toRemove defines the effect layer to remove
  51783. * @returns the index of the removed effect layer
  51784. */
  51785. removeEffectLayer(toRemove: EffectLayer): number;
  51786. /**
  51787. * Adds the given effect layer to this scene
  51788. * @param newEffectLayer defines the effect layer to add
  51789. */
  51790. addEffectLayer(newEffectLayer: EffectLayer): void;
  51791. }
  51792. }
  51793. /**
  51794. * Defines the layer scene component responsible to manage any effect layers
  51795. * in a given scene.
  51796. */
  51797. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51798. /**
  51799. * The component name helpfull to identify the component in the list of scene components.
  51800. */
  51801. readonly name: string;
  51802. /**
  51803. * The scene the component belongs to.
  51804. */
  51805. scene: Scene;
  51806. private _engine;
  51807. private _renderEffects;
  51808. private _needStencil;
  51809. private _previousStencilState;
  51810. /**
  51811. * Creates a new instance of the component for the given scene
  51812. * @param scene Defines the scene to register the component in
  51813. */
  51814. constructor(scene: Scene);
  51815. /**
  51816. * Registers the component in a given scene
  51817. */
  51818. register(): void;
  51819. /**
  51820. * Rebuilds the elements related to this component in case of
  51821. * context lost for instance.
  51822. */
  51823. rebuild(): void;
  51824. /**
  51825. * Serializes the component data to the specified json object
  51826. * @param serializationObject The object to serialize to
  51827. */
  51828. serialize(serializationObject: any): void;
  51829. /**
  51830. * Adds all the elements from the container to the scene
  51831. * @param container the container holding the elements
  51832. */
  51833. addFromContainer(container: AbstractScene): void;
  51834. /**
  51835. * Removes all the elements in the container from the scene
  51836. * @param container contains the elements to remove
  51837. * @param dispose if the removed element should be disposed (default: false)
  51838. */
  51839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51840. /**
  51841. * Disposes the component and the associated ressources.
  51842. */
  51843. dispose(): void;
  51844. private _isReadyForMesh;
  51845. private _renderMainTexture;
  51846. private _setStencil;
  51847. private _setStencilBack;
  51848. private _draw;
  51849. private _drawCamera;
  51850. private _drawRenderingGroup;
  51851. }
  51852. }
  51853. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51854. /** @hidden */
  51855. export var glowMapMergePixelShader: {
  51856. name: string;
  51857. shader: string;
  51858. };
  51859. }
  51860. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51861. /** @hidden */
  51862. export var glowMapMergeVertexShader: {
  51863. name: string;
  51864. shader: string;
  51865. };
  51866. }
  51867. declare module "babylonjs/Layers/glowLayer" {
  51868. import { Nullable } from "babylonjs/types";
  51869. import { Camera } from "babylonjs/Cameras/camera";
  51870. import { Scene } from "babylonjs/scene";
  51871. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51873. import { Mesh } from "babylonjs/Meshes/mesh";
  51874. import { Texture } from "babylonjs/Materials/Textures/texture";
  51875. import { Effect } from "babylonjs/Materials/effect";
  51876. import { Material } from "babylonjs/Materials/material";
  51877. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51878. import { Color4 } from "babylonjs/Maths/math.color";
  51879. import "babylonjs/Shaders/glowMapMerge.fragment";
  51880. import "babylonjs/Shaders/glowMapMerge.vertex";
  51881. import "babylonjs/Layers/effectLayerSceneComponent";
  51882. module "babylonjs/abstractScene" {
  51883. interface AbstractScene {
  51884. /**
  51885. * Return a the first highlight layer of the scene with a given name.
  51886. * @param name The name of the highlight layer to look for.
  51887. * @return The highlight layer if found otherwise null.
  51888. */
  51889. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51890. }
  51891. }
  51892. /**
  51893. * Glow layer options. This helps customizing the behaviour
  51894. * of the glow layer.
  51895. */
  51896. export interface IGlowLayerOptions {
  51897. /**
  51898. * Multiplication factor apply to the canvas size to compute the render target size
  51899. * used to generated the glowing objects (the smaller the faster).
  51900. */
  51901. mainTextureRatio: number;
  51902. /**
  51903. * Enforces a fixed size texture to ensure resize independant blur.
  51904. */
  51905. mainTextureFixedSize?: number;
  51906. /**
  51907. * How big is the kernel of the blur texture.
  51908. */
  51909. blurKernelSize: number;
  51910. /**
  51911. * The camera attached to the layer.
  51912. */
  51913. camera: Nullable<Camera>;
  51914. /**
  51915. * Enable MSAA by chosing the number of samples.
  51916. */
  51917. mainTextureSamples?: number;
  51918. /**
  51919. * The rendering group to draw the layer in.
  51920. */
  51921. renderingGroupId: number;
  51922. }
  51923. /**
  51924. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51925. *
  51926. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51927. * glowy meshes to your scene.
  51928. *
  51929. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51930. */
  51931. export class GlowLayer extends EffectLayer {
  51932. /**
  51933. * Effect Name of the layer.
  51934. */
  51935. static readonly EffectName: string;
  51936. /**
  51937. * The default blur kernel size used for the glow.
  51938. */
  51939. static DefaultBlurKernelSize: number;
  51940. /**
  51941. * The default texture size ratio used for the glow.
  51942. */
  51943. static DefaultTextureRatio: number;
  51944. /**
  51945. * Sets the kernel size of the blur.
  51946. */
  51947. /**
  51948. * Gets the kernel size of the blur.
  51949. */
  51950. blurKernelSize: number;
  51951. /**
  51952. * Sets the glow intensity.
  51953. */
  51954. /**
  51955. * Gets the glow intensity.
  51956. */
  51957. intensity: number;
  51958. private _options;
  51959. private _intensity;
  51960. private _horizontalBlurPostprocess1;
  51961. private _verticalBlurPostprocess1;
  51962. private _horizontalBlurPostprocess2;
  51963. private _verticalBlurPostprocess2;
  51964. private _blurTexture1;
  51965. private _blurTexture2;
  51966. private _postProcesses1;
  51967. private _postProcesses2;
  51968. private _includedOnlyMeshes;
  51969. private _excludedMeshes;
  51970. /**
  51971. * Callback used to let the user override the color selection on a per mesh basis
  51972. */
  51973. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51974. /**
  51975. * Callback used to let the user override the texture selection on a per mesh basis
  51976. */
  51977. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51978. /**
  51979. * Instantiates a new glow Layer and references it to the scene.
  51980. * @param name The name of the layer
  51981. * @param scene The scene to use the layer in
  51982. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51983. */
  51984. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51985. /**
  51986. * Get the effect name of the layer.
  51987. * @return The effect name
  51988. */
  51989. getEffectName(): string;
  51990. /**
  51991. * Create the merge effect. This is the shader use to blit the information back
  51992. * to the main canvas at the end of the scene rendering.
  51993. */
  51994. protected _createMergeEffect(): Effect;
  51995. /**
  51996. * Creates the render target textures and post processes used in the glow layer.
  51997. */
  51998. protected _createTextureAndPostProcesses(): void;
  51999. /**
  52000. * Checks for the readiness of the element composing the layer.
  52001. * @param subMesh the mesh to check for
  52002. * @param useInstances specify wether or not to use instances to render the mesh
  52003. * @param emissiveTexture the associated emissive texture used to generate the glow
  52004. * @return true if ready otherwise, false
  52005. */
  52006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52007. /**
  52008. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52009. */
  52010. needStencil(): boolean;
  52011. /**
  52012. * Returns true if the mesh can be rendered, otherwise false.
  52013. * @param mesh The mesh to render
  52014. * @param material The material used on the mesh
  52015. * @returns true if it can be rendered otherwise false
  52016. */
  52017. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52018. /**
  52019. * Implementation specific of rendering the generating effect on the main canvas.
  52020. * @param effect The effect used to render through
  52021. */
  52022. protected _internalRender(effect: Effect): void;
  52023. /**
  52024. * Sets the required values for both the emissive texture and and the main color.
  52025. */
  52026. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52027. /**
  52028. * Returns true if the mesh should render, otherwise false.
  52029. * @param mesh The mesh to render
  52030. * @returns true if it should render otherwise false
  52031. */
  52032. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52033. /**
  52034. * Adds specific effects defines.
  52035. * @param defines The defines to add specifics to.
  52036. */
  52037. protected _addCustomEffectDefines(defines: string[]): void;
  52038. /**
  52039. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52040. * @param mesh The mesh to exclude from the glow layer
  52041. */
  52042. addExcludedMesh(mesh: Mesh): void;
  52043. /**
  52044. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52045. * @param mesh The mesh to remove
  52046. */
  52047. removeExcludedMesh(mesh: Mesh): void;
  52048. /**
  52049. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52050. * @param mesh The mesh to include in the glow layer
  52051. */
  52052. addIncludedOnlyMesh(mesh: Mesh): void;
  52053. /**
  52054. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52055. * @param mesh The mesh to remove
  52056. */
  52057. removeIncludedOnlyMesh(mesh: Mesh): void;
  52058. /**
  52059. * Determine if a given mesh will be used in the glow layer
  52060. * @param mesh The mesh to test
  52061. * @returns true if the mesh will be highlighted by the current glow layer
  52062. */
  52063. hasMesh(mesh: AbstractMesh): boolean;
  52064. /**
  52065. * Free any resources and references associated to a mesh.
  52066. * Internal use
  52067. * @param mesh The mesh to free.
  52068. * @hidden
  52069. */
  52070. _disposeMesh(mesh: Mesh): void;
  52071. /**
  52072. * Gets the class name of the effect layer
  52073. * @returns the string with the class name of the effect layer
  52074. */
  52075. getClassName(): string;
  52076. /**
  52077. * Serializes this glow layer
  52078. * @returns a serialized glow layer object
  52079. */
  52080. serialize(): any;
  52081. /**
  52082. * Creates a Glow Layer from parsed glow layer data
  52083. * @param parsedGlowLayer defines glow layer data
  52084. * @param scene defines the current scene
  52085. * @param rootUrl defines the root URL containing the glow layer information
  52086. * @returns a parsed Glow Layer
  52087. */
  52088. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52089. }
  52090. }
  52091. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52092. /** @hidden */
  52093. export var glowBlurPostProcessPixelShader: {
  52094. name: string;
  52095. shader: string;
  52096. };
  52097. }
  52098. declare module "babylonjs/Layers/highlightLayer" {
  52099. import { Observable } from "babylonjs/Misc/observable";
  52100. import { Nullable } from "babylonjs/types";
  52101. import { Camera } from "babylonjs/Cameras/camera";
  52102. import { Scene } from "babylonjs/scene";
  52103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52105. import { Mesh } from "babylonjs/Meshes/mesh";
  52106. import { Effect } from "babylonjs/Materials/effect";
  52107. import { Material } from "babylonjs/Materials/material";
  52108. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52109. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52110. import "babylonjs/Shaders/glowMapMerge.fragment";
  52111. import "babylonjs/Shaders/glowMapMerge.vertex";
  52112. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52113. module "babylonjs/abstractScene" {
  52114. interface AbstractScene {
  52115. /**
  52116. * Return a the first highlight layer of the scene with a given name.
  52117. * @param name The name of the highlight layer to look for.
  52118. * @return The highlight layer if found otherwise null.
  52119. */
  52120. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52121. }
  52122. }
  52123. /**
  52124. * Highlight layer options. This helps customizing the behaviour
  52125. * of the highlight layer.
  52126. */
  52127. export interface IHighlightLayerOptions {
  52128. /**
  52129. * Multiplication factor apply to the canvas size to compute the render target size
  52130. * used to generated the glowing objects (the smaller the faster).
  52131. */
  52132. mainTextureRatio: number;
  52133. /**
  52134. * Enforces a fixed size texture to ensure resize independant blur.
  52135. */
  52136. mainTextureFixedSize?: number;
  52137. /**
  52138. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52139. * of the picture to blur (the smaller the faster).
  52140. */
  52141. blurTextureSizeRatio: number;
  52142. /**
  52143. * How big in texel of the blur texture is the vertical blur.
  52144. */
  52145. blurVerticalSize: number;
  52146. /**
  52147. * How big in texel of the blur texture is the horizontal blur.
  52148. */
  52149. blurHorizontalSize: number;
  52150. /**
  52151. * Alpha blending mode used to apply the blur. Default is combine.
  52152. */
  52153. alphaBlendingMode: number;
  52154. /**
  52155. * The camera attached to the layer.
  52156. */
  52157. camera: Nullable<Camera>;
  52158. /**
  52159. * Should we display highlight as a solid stroke?
  52160. */
  52161. isStroke?: boolean;
  52162. /**
  52163. * The rendering group to draw the layer in.
  52164. */
  52165. renderingGroupId: number;
  52166. }
  52167. /**
  52168. * The highlight layer Helps adding a glow effect around a mesh.
  52169. *
  52170. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52171. * glowy meshes to your scene.
  52172. *
  52173. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52174. */
  52175. export class HighlightLayer extends EffectLayer {
  52176. name: string;
  52177. /**
  52178. * Effect Name of the highlight layer.
  52179. */
  52180. static readonly EffectName: string;
  52181. /**
  52182. * The neutral color used during the preparation of the glow effect.
  52183. * This is black by default as the blend operation is a blend operation.
  52184. */
  52185. static NeutralColor: Color4;
  52186. /**
  52187. * Stencil value used for glowing meshes.
  52188. */
  52189. static GlowingMeshStencilReference: number;
  52190. /**
  52191. * Stencil value used for the other meshes in the scene.
  52192. */
  52193. static NormalMeshStencilReference: number;
  52194. /**
  52195. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52196. */
  52197. innerGlow: boolean;
  52198. /**
  52199. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52200. */
  52201. outerGlow: boolean;
  52202. /**
  52203. * Specifies the horizontal size of the blur.
  52204. */
  52205. /**
  52206. * Gets the horizontal size of the blur.
  52207. */
  52208. blurHorizontalSize: number;
  52209. /**
  52210. * Specifies the vertical size of the blur.
  52211. */
  52212. /**
  52213. * Gets the vertical size of the blur.
  52214. */
  52215. blurVerticalSize: number;
  52216. /**
  52217. * An event triggered when the highlight layer is being blurred.
  52218. */
  52219. onBeforeBlurObservable: Observable<HighlightLayer>;
  52220. /**
  52221. * An event triggered when the highlight layer has been blurred.
  52222. */
  52223. onAfterBlurObservable: Observable<HighlightLayer>;
  52224. private _instanceGlowingMeshStencilReference;
  52225. private _options;
  52226. private _downSamplePostprocess;
  52227. private _horizontalBlurPostprocess;
  52228. private _verticalBlurPostprocess;
  52229. private _blurTexture;
  52230. private _meshes;
  52231. private _excludedMeshes;
  52232. /**
  52233. * Instantiates a new highlight Layer and references it to the scene..
  52234. * @param name The name of the layer
  52235. * @param scene The scene to use the layer in
  52236. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52237. */
  52238. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52239. /**
  52240. * Get the effect name of the layer.
  52241. * @return The effect name
  52242. */
  52243. getEffectName(): string;
  52244. /**
  52245. * Create the merge effect. This is the shader use to blit the information back
  52246. * to the main canvas at the end of the scene rendering.
  52247. */
  52248. protected _createMergeEffect(): Effect;
  52249. /**
  52250. * Creates the render target textures and post processes used in the highlight layer.
  52251. */
  52252. protected _createTextureAndPostProcesses(): void;
  52253. /**
  52254. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52255. */
  52256. needStencil(): boolean;
  52257. /**
  52258. * Checks for the readiness of the element composing the layer.
  52259. * @param subMesh the mesh to check for
  52260. * @param useInstances specify wether or not to use instances to render the mesh
  52261. * @param emissiveTexture the associated emissive texture used to generate the glow
  52262. * @return true if ready otherwise, false
  52263. */
  52264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52265. /**
  52266. * Implementation specific of rendering the generating effect on the main canvas.
  52267. * @param effect The effect used to render through
  52268. */
  52269. protected _internalRender(effect: Effect): void;
  52270. /**
  52271. * Returns true if the layer contains information to display, otherwise false.
  52272. */
  52273. shouldRender(): boolean;
  52274. /**
  52275. * Returns true if the mesh should render, otherwise false.
  52276. * @param mesh The mesh to render
  52277. * @returns true if it should render otherwise false
  52278. */
  52279. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52280. /**
  52281. * Sets the required values for both the emissive texture and and the main color.
  52282. */
  52283. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52284. /**
  52285. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52286. * @param mesh The mesh to exclude from the highlight layer
  52287. */
  52288. addExcludedMesh(mesh: Mesh): void;
  52289. /**
  52290. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52291. * @param mesh The mesh to highlight
  52292. */
  52293. removeExcludedMesh(mesh: Mesh): void;
  52294. /**
  52295. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52296. * @param mesh mesh to test
  52297. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52298. */
  52299. hasMesh(mesh: AbstractMesh): boolean;
  52300. /**
  52301. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52302. * @param mesh The mesh to highlight
  52303. * @param color The color of the highlight
  52304. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52305. */
  52306. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52307. /**
  52308. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52309. * @param mesh The mesh to highlight
  52310. */
  52311. removeMesh(mesh: Mesh): void;
  52312. /**
  52313. * Force the stencil to the normal expected value for none glowing parts
  52314. */
  52315. private _defaultStencilReference;
  52316. /**
  52317. * Free any resources and references associated to a mesh.
  52318. * Internal use
  52319. * @param mesh The mesh to free.
  52320. * @hidden
  52321. */
  52322. _disposeMesh(mesh: Mesh): void;
  52323. /**
  52324. * Dispose the highlight layer and free resources.
  52325. */
  52326. dispose(): void;
  52327. /**
  52328. * Gets the class name of the effect layer
  52329. * @returns the string with the class name of the effect layer
  52330. */
  52331. getClassName(): string;
  52332. /**
  52333. * Serializes this Highlight layer
  52334. * @returns a serialized Highlight layer object
  52335. */
  52336. serialize(): any;
  52337. /**
  52338. * Creates a Highlight layer from parsed Highlight layer data
  52339. * @param parsedHightlightLayer defines the Highlight layer data
  52340. * @param scene defines the current scene
  52341. * @param rootUrl defines the root URL containing the Highlight layer information
  52342. * @returns a parsed Highlight layer
  52343. */
  52344. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52345. }
  52346. }
  52347. declare module "babylonjs/Layers/layerSceneComponent" {
  52348. import { Scene } from "babylonjs/scene";
  52349. import { ISceneComponent } from "babylonjs/sceneComponent";
  52350. import { Layer } from "babylonjs/Layers/layer";
  52351. import { AbstractScene } from "babylonjs/abstractScene";
  52352. module "babylonjs/abstractScene" {
  52353. interface AbstractScene {
  52354. /**
  52355. * The list of layers (background and foreground) of the scene
  52356. */
  52357. layers: Array<Layer>;
  52358. }
  52359. }
  52360. /**
  52361. * Defines the layer scene component responsible to manage any layers
  52362. * in a given scene.
  52363. */
  52364. export class LayerSceneComponent implements ISceneComponent {
  52365. /**
  52366. * The component name helpfull to identify the component in the list of scene components.
  52367. */
  52368. readonly name: string;
  52369. /**
  52370. * The scene the component belongs to.
  52371. */
  52372. scene: Scene;
  52373. private _engine;
  52374. /**
  52375. * Creates a new instance of the component for the given scene
  52376. * @param scene Defines the scene to register the component in
  52377. */
  52378. constructor(scene: Scene);
  52379. /**
  52380. * Registers the component in a given scene
  52381. */
  52382. register(): void;
  52383. /**
  52384. * Rebuilds the elements related to this component in case of
  52385. * context lost for instance.
  52386. */
  52387. rebuild(): void;
  52388. /**
  52389. * Disposes the component and the associated ressources.
  52390. */
  52391. dispose(): void;
  52392. private _draw;
  52393. private _drawCameraPredicate;
  52394. private _drawCameraBackground;
  52395. private _drawCameraForeground;
  52396. private _drawRenderTargetPredicate;
  52397. private _drawRenderTargetBackground;
  52398. private _drawRenderTargetForeground;
  52399. /**
  52400. * Adds all the elements from the container to the scene
  52401. * @param container the container holding the elements
  52402. */
  52403. addFromContainer(container: AbstractScene): void;
  52404. /**
  52405. * Removes all the elements in the container from the scene
  52406. * @param container contains the elements to remove
  52407. * @param dispose if the removed element should be disposed (default: false)
  52408. */
  52409. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52410. }
  52411. }
  52412. declare module "babylonjs/Shaders/layer.fragment" {
  52413. /** @hidden */
  52414. export var layerPixelShader: {
  52415. name: string;
  52416. shader: string;
  52417. };
  52418. }
  52419. declare module "babylonjs/Shaders/layer.vertex" {
  52420. /** @hidden */
  52421. export var layerVertexShader: {
  52422. name: string;
  52423. shader: string;
  52424. };
  52425. }
  52426. declare module "babylonjs/Layers/layer" {
  52427. import { Observable } from "babylonjs/Misc/observable";
  52428. import { Nullable } from "babylonjs/types";
  52429. import { Scene } from "babylonjs/scene";
  52430. import { Vector2 } from "babylonjs/Maths/math.vector";
  52431. import { Color4 } from "babylonjs/Maths/math.color";
  52432. import { Texture } from "babylonjs/Materials/Textures/texture";
  52433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52434. import "babylonjs/Shaders/layer.fragment";
  52435. import "babylonjs/Shaders/layer.vertex";
  52436. /**
  52437. * This represents a full screen 2d layer.
  52438. * This can be useful to display a picture in the background of your scene for instance.
  52439. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52440. */
  52441. export class Layer {
  52442. /**
  52443. * Define the name of the layer.
  52444. */
  52445. name: string;
  52446. /**
  52447. * Define the texture the layer should display.
  52448. */
  52449. texture: Nullable<Texture>;
  52450. /**
  52451. * Is the layer in background or foreground.
  52452. */
  52453. isBackground: boolean;
  52454. /**
  52455. * Define the color of the layer (instead of texture).
  52456. */
  52457. color: Color4;
  52458. /**
  52459. * Define the scale of the layer in order to zoom in out of the texture.
  52460. */
  52461. scale: Vector2;
  52462. /**
  52463. * Define an offset for the layer in order to shift the texture.
  52464. */
  52465. offset: Vector2;
  52466. /**
  52467. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52468. */
  52469. alphaBlendingMode: number;
  52470. /**
  52471. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52472. * Alpha test will not mix with the background color in case of transparency.
  52473. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52474. */
  52475. alphaTest: boolean;
  52476. /**
  52477. * Define a mask to restrict the layer to only some of the scene cameras.
  52478. */
  52479. layerMask: number;
  52480. /**
  52481. * Define the list of render target the layer is visible into.
  52482. */
  52483. renderTargetTextures: RenderTargetTexture[];
  52484. /**
  52485. * Define if the layer is only used in renderTarget or if it also
  52486. * renders in the main frame buffer of the canvas.
  52487. */
  52488. renderOnlyInRenderTargetTextures: boolean;
  52489. private _scene;
  52490. private _vertexBuffers;
  52491. private _indexBuffer;
  52492. private _effect;
  52493. private _alphaTestEffect;
  52494. /**
  52495. * An event triggered when the layer is disposed.
  52496. */
  52497. onDisposeObservable: Observable<Layer>;
  52498. private _onDisposeObserver;
  52499. /**
  52500. * Back compatibility with callback before the onDisposeObservable existed.
  52501. * The set callback will be triggered when the layer has been disposed.
  52502. */
  52503. onDispose: () => void;
  52504. /**
  52505. * An event triggered before rendering the scene
  52506. */
  52507. onBeforeRenderObservable: Observable<Layer>;
  52508. private _onBeforeRenderObserver;
  52509. /**
  52510. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52511. * The set callback will be triggered just before rendering the layer.
  52512. */
  52513. onBeforeRender: () => void;
  52514. /**
  52515. * An event triggered after rendering the scene
  52516. */
  52517. onAfterRenderObservable: Observable<Layer>;
  52518. private _onAfterRenderObserver;
  52519. /**
  52520. * Back compatibility with callback before the onAfterRenderObservable existed.
  52521. * The set callback will be triggered just after rendering the layer.
  52522. */
  52523. onAfterRender: () => void;
  52524. /**
  52525. * Instantiates a new layer.
  52526. * This represents a full screen 2d layer.
  52527. * This can be useful to display a picture in the background of your scene for instance.
  52528. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52529. * @param name Define the name of the layer in the scene
  52530. * @param imgUrl Define the url of the texture to display in the layer
  52531. * @param scene Define the scene the layer belongs to
  52532. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52533. * @param color Defines a color for the layer
  52534. */
  52535. constructor(
  52536. /**
  52537. * Define the name of the layer.
  52538. */
  52539. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52540. private _createIndexBuffer;
  52541. /** @hidden */
  52542. _rebuild(): void;
  52543. /**
  52544. * Renders the layer in the scene.
  52545. */
  52546. render(): void;
  52547. /**
  52548. * Disposes and releases the associated ressources.
  52549. */
  52550. dispose(): void;
  52551. }
  52552. }
  52553. declare module "babylonjs/Layers/index" {
  52554. export * from "babylonjs/Layers/effectLayer";
  52555. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52556. export * from "babylonjs/Layers/glowLayer";
  52557. export * from "babylonjs/Layers/highlightLayer";
  52558. export * from "babylonjs/Layers/layer";
  52559. export * from "babylonjs/Layers/layerSceneComponent";
  52560. }
  52561. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52562. /** @hidden */
  52563. export var lensFlarePixelShader: {
  52564. name: string;
  52565. shader: string;
  52566. };
  52567. }
  52568. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52569. /** @hidden */
  52570. export var lensFlareVertexShader: {
  52571. name: string;
  52572. shader: string;
  52573. };
  52574. }
  52575. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52576. import { Scene } from "babylonjs/scene";
  52577. import { Vector3 } from "babylonjs/Maths/math.vector";
  52578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52579. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52580. import "babylonjs/Shaders/lensFlare.fragment";
  52581. import "babylonjs/Shaders/lensFlare.vertex";
  52582. import { Viewport } from "babylonjs/Maths/math.viewport";
  52583. /**
  52584. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52585. * It is usually composed of several `lensFlare`.
  52586. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52587. */
  52588. export class LensFlareSystem {
  52589. /**
  52590. * Define the name of the lens flare system
  52591. */
  52592. name: string;
  52593. /**
  52594. * List of lens flares used in this system.
  52595. */
  52596. lensFlares: LensFlare[];
  52597. /**
  52598. * Define a limit from the border the lens flare can be visible.
  52599. */
  52600. borderLimit: number;
  52601. /**
  52602. * Define a viewport border we do not want to see the lens flare in.
  52603. */
  52604. viewportBorder: number;
  52605. /**
  52606. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52607. */
  52608. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52609. /**
  52610. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52611. */
  52612. layerMask: number;
  52613. /**
  52614. * Define the id of the lens flare system in the scene.
  52615. * (equal to name by default)
  52616. */
  52617. id: string;
  52618. private _scene;
  52619. private _emitter;
  52620. private _vertexBuffers;
  52621. private _indexBuffer;
  52622. private _effect;
  52623. private _positionX;
  52624. private _positionY;
  52625. private _isEnabled;
  52626. /** @hidden */
  52627. static _SceneComponentInitialization: (scene: Scene) => void;
  52628. /**
  52629. * Instantiates a lens flare system.
  52630. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52631. * It is usually composed of several `lensFlare`.
  52632. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52633. * @param name Define the name of the lens flare system in the scene
  52634. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52635. * @param scene Define the scene the lens flare system belongs to
  52636. */
  52637. constructor(
  52638. /**
  52639. * Define the name of the lens flare system
  52640. */
  52641. name: string, emitter: any, scene: Scene);
  52642. /**
  52643. * Define if the lens flare system is enabled.
  52644. */
  52645. isEnabled: boolean;
  52646. /**
  52647. * Get the scene the effects belongs to.
  52648. * @returns the scene holding the lens flare system
  52649. */
  52650. getScene(): Scene;
  52651. /**
  52652. * Get the emitter of the lens flare system.
  52653. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52654. * @returns the emitter of the lens flare system
  52655. */
  52656. getEmitter(): any;
  52657. /**
  52658. * Set the emitter of the lens flare system.
  52659. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52660. * @param newEmitter Define the new emitter of the system
  52661. */
  52662. setEmitter(newEmitter: any): void;
  52663. /**
  52664. * Get the lens flare system emitter position.
  52665. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52666. * @returns the position
  52667. */
  52668. getEmitterPosition(): Vector3;
  52669. /**
  52670. * @hidden
  52671. */
  52672. computeEffectivePosition(globalViewport: Viewport): boolean;
  52673. /** @hidden */
  52674. _isVisible(): boolean;
  52675. /**
  52676. * @hidden
  52677. */
  52678. render(): boolean;
  52679. /**
  52680. * Dispose and release the lens flare with its associated resources.
  52681. */
  52682. dispose(): void;
  52683. /**
  52684. * Parse a lens flare system from a JSON repressentation
  52685. * @param parsedLensFlareSystem Define the JSON to parse
  52686. * @param scene Define the scene the parsed system should be instantiated in
  52687. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52688. * @returns the parsed system
  52689. */
  52690. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52691. /**
  52692. * Serialize the current Lens Flare System into a JSON representation.
  52693. * @returns the serialized JSON
  52694. */
  52695. serialize(): any;
  52696. }
  52697. }
  52698. declare module "babylonjs/LensFlares/lensFlare" {
  52699. import { Nullable } from "babylonjs/types";
  52700. import { Color3 } from "babylonjs/Maths/math.color";
  52701. import { Texture } from "babylonjs/Materials/Textures/texture";
  52702. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52703. /**
  52704. * This represents one of the lens effect in a `lensFlareSystem`.
  52705. * It controls one of the indiviual texture used in the effect.
  52706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52707. */
  52708. export class LensFlare {
  52709. /**
  52710. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52711. */
  52712. size: number;
  52713. /**
  52714. * 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.
  52715. */
  52716. position: number;
  52717. /**
  52718. * Define the lens color.
  52719. */
  52720. color: Color3;
  52721. /**
  52722. * Define the lens texture.
  52723. */
  52724. texture: Nullable<Texture>;
  52725. /**
  52726. * Define the alpha mode to render this particular lens.
  52727. */
  52728. alphaMode: number;
  52729. private _system;
  52730. /**
  52731. * Creates a new Lens Flare.
  52732. * This represents one of the lens effect in a `lensFlareSystem`.
  52733. * It controls one of the indiviual texture used in the effect.
  52734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52735. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52736. * @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.
  52737. * @param color Define the lens color
  52738. * @param imgUrl Define the lens texture url
  52739. * @param system Define the `lensFlareSystem` this flare is part of
  52740. * @returns The newly created Lens Flare
  52741. */
  52742. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52743. /**
  52744. * Instantiates a new Lens Flare.
  52745. * This represents one of the lens effect in a `lensFlareSystem`.
  52746. * It controls one of the indiviual texture used in the effect.
  52747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52748. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52749. * @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.
  52750. * @param color Define the lens color
  52751. * @param imgUrl Define the lens texture url
  52752. * @param system Define the `lensFlareSystem` this flare is part of
  52753. */
  52754. constructor(
  52755. /**
  52756. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52757. */
  52758. size: number,
  52759. /**
  52760. * 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.
  52761. */
  52762. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52763. /**
  52764. * Dispose and release the lens flare with its associated resources.
  52765. */
  52766. dispose(): void;
  52767. }
  52768. }
  52769. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52770. import { Nullable } from "babylonjs/types";
  52771. import { Scene } from "babylonjs/scene";
  52772. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52773. import { AbstractScene } from "babylonjs/abstractScene";
  52774. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52775. module "babylonjs/abstractScene" {
  52776. interface AbstractScene {
  52777. /**
  52778. * The list of lens flare system added to the scene
  52779. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52780. */
  52781. lensFlareSystems: Array<LensFlareSystem>;
  52782. /**
  52783. * Removes the given lens flare system from this scene.
  52784. * @param toRemove The lens flare system to remove
  52785. * @returns The index of the removed lens flare system
  52786. */
  52787. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52788. /**
  52789. * Adds the given lens flare system to this scene
  52790. * @param newLensFlareSystem The lens flare system to add
  52791. */
  52792. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52793. /**
  52794. * Gets a lens flare system using its name
  52795. * @param name defines the name to look for
  52796. * @returns the lens flare system or null if not found
  52797. */
  52798. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52799. /**
  52800. * Gets a lens flare system using its id
  52801. * @param id defines the id to look for
  52802. * @returns the lens flare system or null if not found
  52803. */
  52804. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52805. }
  52806. }
  52807. /**
  52808. * Defines the lens flare scene component responsible to manage any lens flares
  52809. * in a given scene.
  52810. */
  52811. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52812. /**
  52813. * The component name helpfull to identify the component in the list of scene components.
  52814. */
  52815. readonly name: string;
  52816. /**
  52817. * The scene the component belongs to.
  52818. */
  52819. scene: Scene;
  52820. /**
  52821. * Creates a new instance of the component for the given scene
  52822. * @param scene Defines the scene to register the component in
  52823. */
  52824. constructor(scene: Scene);
  52825. /**
  52826. * Registers the component in a given scene
  52827. */
  52828. register(): void;
  52829. /**
  52830. * Rebuilds the elements related to this component in case of
  52831. * context lost for instance.
  52832. */
  52833. rebuild(): void;
  52834. /**
  52835. * Adds all the elements from the container to the scene
  52836. * @param container the container holding the elements
  52837. */
  52838. addFromContainer(container: AbstractScene): void;
  52839. /**
  52840. * Removes all the elements in the container from the scene
  52841. * @param container contains the elements to remove
  52842. * @param dispose if the removed element should be disposed (default: false)
  52843. */
  52844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52845. /**
  52846. * Serializes the component data to the specified json object
  52847. * @param serializationObject The object to serialize to
  52848. */
  52849. serialize(serializationObject: any): void;
  52850. /**
  52851. * Disposes the component and the associated ressources.
  52852. */
  52853. dispose(): void;
  52854. private _draw;
  52855. }
  52856. }
  52857. declare module "babylonjs/LensFlares/index" {
  52858. export * from "babylonjs/LensFlares/lensFlare";
  52859. export * from "babylonjs/LensFlares/lensFlareSystem";
  52860. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52861. }
  52862. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52863. import { Scene } from "babylonjs/scene";
  52864. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52865. import { AbstractScene } from "babylonjs/abstractScene";
  52866. /**
  52867. * Defines the shadow generator component responsible to manage any shadow generators
  52868. * in a given scene.
  52869. */
  52870. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52871. /**
  52872. * The component name helpfull to identify the component in the list of scene components.
  52873. */
  52874. readonly name: string;
  52875. /**
  52876. * The scene the component belongs to.
  52877. */
  52878. scene: Scene;
  52879. /**
  52880. * Creates a new instance of the component for the given scene
  52881. * @param scene Defines the scene to register the component in
  52882. */
  52883. constructor(scene: Scene);
  52884. /**
  52885. * Registers the component in a given scene
  52886. */
  52887. register(): void;
  52888. /**
  52889. * Rebuilds the elements related to this component in case of
  52890. * context lost for instance.
  52891. */
  52892. rebuild(): void;
  52893. /**
  52894. * Serializes the component data to the specified json object
  52895. * @param serializationObject The object to serialize to
  52896. */
  52897. serialize(serializationObject: any): void;
  52898. /**
  52899. * Adds all the elements from the container to the scene
  52900. * @param container the container holding the elements
  52901. */
  52902. addFromContainer(container: AbstractScene): void;
  52903. /**
  52904. * Removes all the elements in the container from the scene
  52905. * @param container contains the elements to remove
  52906. * @param dispose if the removed element should be disposed (default: false)
  52907. */
  52908. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52909. /**
  52910. * Rebuilds the elements related to this component in case of
  52911. * context lost for instance.
  52912. */
  52913. dispose(): void;
  52914. private _gatherRenderTargets;
  52915. }
  52916. }
  52917. declare module "babylonjs/Lights/Shadows/index" {
  52918. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52919. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52920. }
  52921. declare module "babylonjs/Lights/pointLight" {
  52922. import { Scene } from "babylonjs/scene";
  52923. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52925. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52926. import { Effect } from "babylonjs/Materials/effect";
  52927. /**
  52928. * A point light is a light defined by an unique point in world space.
  52929. * The light is emitted in every direction from this point.
  52930. * A good example of a point light is a standard light bulb.
  52931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52932. */
  52933. export class PointLight extends ShadowLight {
  52934. private _shadowAngle;
  52935. /**
  52936. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52937. * This specifies what angle the shadow will use to be created.
  52938. *
  52939. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52940. */
  52941. /**
  52942. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52943. * This specifies what angle the shadow will use to be created.
  52944. *
  52945. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52946. */
  52947. shadowAngle: number;
  52948. /**
  52949. * Gets the direction if it has been set.
  52950. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52951. */
  52952. /**
  52953. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52954. */
  52955. direction: Vector3;
  52956. /**
  52957. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52958. * A PointLight emits the light in every direction.
  52959. * It can cast shadows.
  52960. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52961. * ```javascript
  52962. * var pointLight = new PointLight("pl", camera.position, scene);
  52963. * ```
  52964. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52965. * @param name The light friendly name
  52966. * @param position The position of the point light in the scene
  52967. * @param scene The scene the lights belongs to
  52968. */
  52969. constructor(name: string, position: Vector3, scene: Scene);
  52970. /**
  52971. * Returns the string "PointLight"
  52972. * @returns the class name
  52973. */
  52974. getClassName(): string;
  52975. /**
  52976. * Returns the integer 0.
  52977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52978. */
  52979. getTypeID(): number;
  52980. /**
  52981. * Specifies wether or not the shadowmap should be a cube texture.
  52982. * @returns true if the shadowmap needs to be a cube texture.
  52983. */
  52984. needCube(): boolean;
  52985. /**
  52986. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52987. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52988. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52989. */
  52990. getShadowDirection(faceIndex?: number): Vector3;
  52991. /**
  52992. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52993. * - fov = PI / 2
  52994. * - aspect ratio : 1.0
  52995. * - z-near and far equal to the active camera minZ and maxZ.
  52996. * Returns the PointLight.
  52997. */
  52998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52999. protected _buildUniformLayout(): void;
  53000. /**
  53001. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53002. * @param effect The effect to update
  53003. * @param lightIndex The index of the light in the effect to update
  53004. * @returns The point light
  53005. */
  53006. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53007. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53008. /**
  53009. * Prepares the list of defines specific to the light type.
  53010. * @param defines the list of defines
  53011. * @param lightIndex defines the index of the light for the effect
  53012. */
  53013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53014. }
  53015. }
  53016. declare module "babylonjs/Lights/index" {
  53017. export * from "babylonjs/Lights/light";
  53018. export * from "babylonjs/Lights/shadowLight";
  53019. export * from "babylonjs/Lights/Shadows/index";
  53020. export * from "babylonjs/Lights/directionalLight";
  53021. export * from "babylonjs/Lights/hemisphericLight";
  53022. export * from "babylonjs/Lights/pointLight";
  53023. export * from "babylonjs/Lights/spotLight";
  53024. }
  53025. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53026. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53027. /**
  53028. * Header information of HDR texture files.
  53029. */
  53030. export interface HDRInfo {
  53031. /**
  53032. * The height of the texture in pixels.
  53033. */
  53034. height: number;
  53035. /**
  53036. * The width of the texture in pixels.
  53037. */
  53038. width: number;
  53039. /**
  53040. * The index of the beginning of the data in the binary file.
  53041. */
  53042. dataPosition: number;
  53043. }
  53044. /**
  53045. * This groups tools to convert HDR texture to native colors array.
  53046. */
  53047. export class HDRTools {
  53048. private static Ldexp;
  53049. private static Rgbe2float;
  53050. private static readStringLine;
  53051. /**
  53052. * Reads header information from an RGBE texture stored in a native array.
  53053. * More information on this format are available here:
  53054. * https://en.wikipedia.org/wiki/RGBE_image_format
  53055. *
  53056. * @param uint8array The binary file stored in native array.
  53057. * @return The header information.
  53058. */
  53059. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53060. /**
  53061. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53062. * This RGBE texture needs to store the information as a panorama.
  53063. *
  53064. * More information on this format are available here:
  53065. * https://en.wikipedia.org/wiki/RGBE_image_format
  53066. *
  53067. * @param buffer The binary file stored in an array buffer.
  53068. * @param size The expected size of the extracted cubemap.
  53069. * @return The Cube Map information.
  53070. */
  53071. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53072. /**
  53073. * Returns the pixels data extracted from an RGBE texture.
  53074. * This pixels will be stored left to right up to down in the R G B order in one array.
  53075. *
  53076. * More information on this format are available here:
  53077. * https://en.wikipedia.org/wiki/RGBE_image_format
  53078. *
  53079. * @param uint8array The binary file stored in an array buffer.
  53080. * @param hdrInfo The header information of the file.
  53081. * @return The pixels data in RGB right to left up to down order.
  53082. */
  53083. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53084. private static RGBE_ReadPixels_RLE;
  53085. }
  53086. }
  53087. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53088. import { Nullable } from "babylonjs/types";
  53089. import { Scene } from "babylonjs/scene";
  53090. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53092. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53093. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53094. /**
  53095. * This represents a texture coming from an HDR input.
  53096. *
  53097. * The only supported format is currently panorama picture stored in RGBE format.
  53098. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53099. */
  53100. export class HDRCubeTexture extends BaseTexture {
  53101. private static _facesMapping;
  53102. private _generateHarmonics;
  53103. private _noMipmap;
  53104. private _textureMatrix;
  53105. private _size;
  53106. private _onLoad;
  53107. private _onError;
  53108. /**
  53109. * The texture URL.
  53110. */
  53111. url: string;
  53112. /**
  53113. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53114. */
  53115. coordinatesMode: number;
  53116. protected _isBlocking: boolean;
  53117. /**
  53118. * Sets wether or not the texture is blocking during loading.
  53119. */
  53120. /**
  53121. * Gets wether or not the texture is blocking during loading.
  53122. */
  53123. isBlocking: boolean;
  53124. protected _rotationY: number;
  53125. /**
  53126. * Sets texture matrix rotation angle around Y axis in radians.
  53127. */
  53128. /**
  53129. * Gets texture matrix rotation angle around Y axis radians.
  53130. */
  53131. rotationY: number;
  53132. /**
  53133. * Gets or sets the center of the bounding box associated with the cube texture
  53134. * It must define where the camera used to render the texture was set
  53135. */
  53136. boundingBoxPosition: Vector3;
  53137. private _boundingBoxSize;
  53138. /**
  53139. * Gets or sets the size of the bounding box associated with the cube texture
  53140. * When defined, the cubemap will switch to local mode
  53141. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53142. * @example https://www.babylonjs-playground.com/#RNASML
  53143. */
  53144. boundingBoxSize: Vector3;
  53145. /**
  53146. * Instantiates an HDRTexture from the following parameters.
  53147. *
  53148. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53149. * @param scene The scene the texture will be used in
  53150. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53151. * @param noMipmap Forces to not generate the mipmap if true
  53152. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53153. * @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)
  53154. * @param reserved Reserved flag for internal use.
  53155. */
  53156. 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>);
  53157. /**
  53158. * Get the current class name of the texture useful for serialization or dynamic coding.
  53159. * @returns "HDRCubeTexture"
  53160. */
  53161. getClassName(): string;
  53162. /**
  53163. * Occurs when the file is raw .hdr file.
  53164. */
  53165. private loadTexture;
  53166. clone(): HDRCubeTexture;
  53167. delayLoad(): void;
  53168. /**
  53169. * Get the texture reflection matrix used to rotate/transform the reflection.
  53170. * @returns the reflection matrix
  53171. */
  53172. getReflectionTextureMatrix(): Matrix;
  53173. /**
  53174. * Set the texture reflection matrix used to rotate/transform the reflection.
  53175. * @param value Define the reflection matrix to set
  53176. */
  53177. setReflectionTextureMatrix(value: Matrix): void;
  53178. /**
  53179. * Parses a JSON representation of an HDR Texture in order to create the texture
  53180. * @param parsedTexture Define the JSON representation
  53181. * @param scene Define the scene the texture should be created in
  53182. * @param rootUrl Define the root url in case we need to load relative dependencies
  53183. * @returns the newly created texture after parsing
  53184. */
  53185. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53186. serialize(): any;
  53187. }
  53188. }
  53189. declare module "babylonjs/Physics/physicsEngine" {
  53190. import { Nullable } from "babylonjs/types";
  53191. import { Vector3 } from "babylonjs/Maths/math.vector";
  53192. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53193. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53194. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53195. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53196. /**
  53197. * Class used to control physics engine
  53198. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53199. */
  53200. export class PhysicsEngine implements IPhysicsEngine {
  53201. private _physicsPlugin;
  53202. /**
  53203. * Global value used to control the smallest number supported by the simulation
  53204. */
  53205. static Epsilon: number;
  53206. private _impostors;
  53207. private _joints;
  53208. /**
  53209. * Gets the gravity vector used by the simulation
  53210. */
  53211. gravity: Vector3;
  53212. /**
  53213. * Factory used to create the default physics plugin.
  53214. * @returns The default physics plugin
  53215. */
  53216. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53217. /**
  53218. * Creates a new Physics Engine
  53219. * @param gravity defines the gravity vector used by the simulation
  53220. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53221. */
  53222. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53223. /**
  53224. * Sets the gravity vector used by the simulation
  53225. * @param gravity defines the gravity vector to use
  53226. */
  53227. setGravity(gravity: Vector3): void;
  53228. /**
  53229. * Set the time step of the physics engine.
  53230. * Default is 1/60.
  53231. * To slow it down, enter 1/600 for example.
  53232. * To speed it up, 1/30
  53233. * @param newTimeStep defines the new timestep to apply to this world.
  53234. */
  53235. setTimeStep(newTimeStep?: number): void;
  53236. /**
  53237. * Get the time step of the physics engine.
  53238. * @returns the current time step
  53239. */
  53240. getTimeStep(): number;
  53241. /**
  53242. * Release all resources
  53243. */
  53244. dispose(): void;
  53245. /**
  53246. * Gets the name of the current physics plugin
  53247. * @returns the name of the plugin
  53248. */
  53249. getPhysicsPluginName(): string;
  53250. /**
  53251. * Adding a new impostor for the impostor tracking.
  53252. * This will be done by the impostor itself.
  53253. * @param impostor the impostor to add
  53254. */
  53255. addImpostor(impostor: PhysicsImpostor): void;
  53256. /**
  53257. * Remove an impostor from the engine.
  53258. * This impostor and its mesh will not longer be updated by the physics engine.
  53259. * @param impostor the impostor to remove
  53260. */
  53261. removeImpostor(impostor: PhysicsImpostor): void;
  53262. /**
  53263. * Add a joint to the physics engine
  53264. * @param mainImpostor defines the main impostor to which the joint is added.
  53265. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53266. * @param joint defines the joint that will connect both impostors.
  53267. */
  53268. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53269. /**
  53270. * Removes a joint from the simulation
  53271. * @param mainImpostor defines the impostor used with the joint
  53272. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53273. * @param joint defines the joint to remove
  53274. */
  53275. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53276. /**
  53277. * Called by the scene. No need to call it.
  53278. * @param delta defines the timespam between frames
  53279. */
  53280. _step(delta: number): void;
  53281. /**
  53282. * Gets the current plugin used to run the simulation
  53283. * @returns current plugin
  53284. */
  53285. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53286. /**
  53287. * Gets the list of physic impostors
  53288. * @returns an array of PhysicsImpostor
  53289. */
  53290. getImpostors(): Array<PhysicsImpostor>;
  53291. /**
  53292. * Gets the impostor for a physics enabled object
  53293. * @param object defines the object impersonated by the impostor
  53294. * @returns the PhysicsImpostor or null if not found
  53295. */
  53296. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53297. /**
  53298. * Gets the impostor for a physics body object
  53299. * @param body defines physics body used by the impostor
  53300. * @returns the PhysicsImpostor or null if not found
  53301. */
  53302. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53303. /**
  53304. * Does a raycast in the physics world
  53305. * @param from when should the ray start?
  53306. * @param to when should the ray end?
  53307. * @returns PhysicsRaycastResult
  53308. */
  53309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53310. }
  53311. }
  53312. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53313. import { Nullable } from "babylonjs/types";
  53314. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53316. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53317. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53318. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53319. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53320. /** @hidden */
  53321. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53322. private _useDeltaForWorldStep;
  53323. world: any;
  53324. name: string;
  53325. private _physicsMaterials;
  53326. private _fixedTimeStep;
  53327. private _cannonRaycastResult;
  53328. private _raycastResult;
  53329. private _physicsBodysToRemoveAfterStep;
  53330. BJSCANNON: any;
  53331. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53332. setGravity(gravity: Vector3): void;
  53333. setTimeStep(timeStep: number): void;
  53334. getTimeStep(): number;
  53335. executeStep(delta: number): void;
  53336. private _removeMarkedPhysicsBodiesFromWorld;
  53337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53340. private _processChildMeshes;
  53341. removePhysicsBody(impostor: PhysicsImpostor): void;
  53342. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53343. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53344. private _addMaterial;
  53345. private _checkWithEpsilon;
  53346. private _createShape;
  53347. private _createHeightmap;
  53348. private _minus90X;
  53349. private _plus90X;
  53350. private _tmpPosition;
  53351. private _tmpDeltaPosition;
  53352. private _tmpUnityRotation;
  53353. private _updatePhysicsBodyTransformation;
  53354. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53356. isSupported(): boolean;
  53357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53362. getBodyMass(impostor: PhysicsImpostor): number;
  53363. getBodyFriction(impostor: PhysicsImpostor): number;
  53364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53365. getBodyRestitution(impostor: PhysicsImpostor): number;
  53366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53367. sleepBody(impostor: PhysicsImpostor): void;
  53368. wakeUpBody(impostor: PhysicsImpostor): void;
  53369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53370. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53372. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53373. getRadius(impostor: PhysicsImpostor): number;
  53374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53375. dispose(): void;
  53376. private _extendNamespace;
  53377. /**
  53378. * Does a raycast in the physics world
  53379. * @param from when should the ray start?
  53380. * @param to when should the ray end?
  53381. * @returns PhysicsRaycastResult
  53382. */
  53383. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53384. }
  53385. }
  53386. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53387. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53388. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53389. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53391. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53392. import { Nullable } from "babylonjs/types";
  53393. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53394. /** @hidden */
  53395. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53396. world: any;
  53397. name: string;
  53398. BJSOIMO: any;
  53399. private _raycastResult;
  53400. constructor(iterations?: number, oimoInjection?: any);
  53401. setGravity(gravity: Vector3): void;
  53402. setTimeStep(timeStep: number): void;
  53403. getTimeStep(): number;
  53404. private _tmpImpostorsArray;
  53405. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53409. private _tmpPositionVector;
  53410. removePhysicsBody(impostor: PhysicsImpostor): void;
  53411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53413. isSupported(): boolean;
  53414. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53416. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53418. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53419. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53420. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53421. getBodyMass(impostor: PhysicsImpostor): number;
  53422. getBodyFriction(impostor: PhysicsImpostor): number;
  53423. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53424. getBodyRestitution(impostor: PhysicsImpostor): number;
  53425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53426. sleepBody(impostor: PhysicsImpostor): void;
  53427. wakeUpBody(impostor: PhysicsImpostor): void;
  53428. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53429. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53430. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53432. getRadius(impostor: PhysicsImpostor): number;
  53433. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53434. dispose(): void;
  53435. /**
  53436. * Does a raycast in the physics world
  53437. * @param from when should the ray start?
  53438. * @param to when should the ray end?
  53439. * @returns PhysicsRaycastResult
  53440. */
  53441. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53442. }
  53443. }
  53444. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53445. import { Nullable } from "babylonjs/types";
  53446. import { Scene } from "babylonjs/scene";
  53447. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53448. import { Color4 } from "babylonjs/Maths/math.color";
  53449. import { Mesh } from "babylonjs/Meshes/mesh";
  53450. /**
  53451. * Class containing static functions to help procedurally build meshes
  53452. */
  53453. export class RibbonBuilder {
  53454. /**
  53455. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53456. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53457. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53458. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53459. * * 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
  53460. * * 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
  53461. * * 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
  53462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53465. * * 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
  53466. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53467. * * 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
  53468. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53470. * @param name defines the name of the mesh
  53471. * @param options defines the options used to create the mesh
  53472. * @param scene defines the hosting scene
  53473. * @returns the ribbon mesh
  53474. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53476. */
  53477. static CreateRibbon(name: string, options: {
  53478. pathArray: Vector3[][];
  53479. closeArray?: boolean;
  53480. closePath?: boolean;
  53481. offset?: number;
  53482. updatable?: boolean;
  53483. sideOrientation?: number;
  53484. frontUVs?: Vector4;
  53485. backUVs?: Vector4;
  53486. instance?: Mesh;
  53487. invertUV?: boolean;
  53488. uvs?: Vector2[];
  53489. colors?: Color4[];
  53490. }, scene?: Nullable<Scene>): Mesh;
  53491. }
  53492. }
  53493. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53494. import { Nullable } from "babylonjs/types";
  53495. import { Scene } from "babylonjs/scene";
  53496. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53497. import { Mesh } from "babylonjs/Meshes/mesh";
  53498. /**
  53499. * Class containing static functions to help procedurally build meshes
  53500. */
  53501. export class ShapeBuilder {
  53502. /**
  53503. * 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.
  53504. * * 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.
  53505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53506. * * 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.
  53507. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53508. * * 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
  53509. * * 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
  53510. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53515. * @param name defines the name of the mesh
  53516. * @param options defines the options used to create the mesh
  53517. * @param scene defines the hosting scene
  53518. * @returns the extruded shape mesh
  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 ExtrudeShape(name: string, options: {
  53523. shape: Vector3[];
  53524. path: Vector3[];
  53525. scale?: number;
  53526. rotation?: number;
  53527. cap?: number;
  53528. updatable?: boolean;
  53529. sideOrientation?: number;
  53530. frontUVs?: Vector4;
  53531. backUVs?: Vector4;
  53532. instance?: Mesh;
  53533. invertUV?: boolean;
  53534. }, scene?: Nullable<Scene>): Mesh;
  53535. /**
  53536. * Creates an custom extruded shape mesh.
  53537. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53538. * * 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.
  53539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53540. * * 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
  53541. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53542. * * 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
  53543. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53544. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53545. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53546. * * 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
  53547. * * 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
  53548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53553. * @param name defines the name of the mesh
  53554. * @param options defines the options used to create the mesh
  53555. * @param scene defines the hosting scene
  53556. * @returns the custom extruded shape mesh
  53557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53560. */
  53561. static ExtrudeShapeCustom(name: string, options: {
  53562. shape: Vector3[];
  53563. path: Vector3[];
  53564. scaleFunction?: any;
  53565. rotationFunction?: any;
  53566. ribbonCloseArray?: boolean;
  53567. ribbonClosePath?: boolean;
  53568. cap?: number;
  53569. updatable?: boolean;
  53570. sideOrientation?: number;
  53571. frontUVs?: Vector4;
  53572. backUVs?: Vector4;
  53573. instance?: Mesh;
  53574. invertUV?: boolean;
  53575. }, scene?: Nullable<Scene>): Mesh;
  53576. private static _ExtrudeShapeGeneric;
  53577. }
  53578. }
  53579. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53580. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53581. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53582. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53583. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53584. import { Nullable } from "babylonjs/types";
  53585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53586. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53587. /**
  53588. * AmmoJS Physics plugin
  53589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53590. * @see https://github.com/kripken/ammo.js/
  53591. */
  53592. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53593. private _useDeltaForWorldStep;
  53594. /**
  53595. * Reference to the Ammo library
  53596. */
  53597. bjsAMMO: any;
  53598. /**
  53599. * Created ammoJS world which physics bodies are added to
  53600. */
  53601. world: any;
  53602. /**
  53603. * Name of the plugin
  53604. */
  53605. name: string;
  53606. private _timeStep;
  53607. private _fixedTimeStep;
  53608. private _maxSteps;
  53609. private _tmpQuaternion;
  53610. private _tmpAmmoTransform;
  53611. private _tmpAmmoQuaternion;
  53612. private _tmpAmmoConcreteContactResultCallback;
  53613. private _collisionConfiguration;
  53614. private _dispatcher;
  53615. private _overlappingPairCache;
  53616. private _solver;
  53617. private _softBodySolver;
  53618. private _tmpAmmoVectorA;
  53619. private _tmpAmmoVectorB;
  53620. private _tmpAmmoVectorC;
  53621. private _tmpAmmoVectorD;
  53622. private _tmpContactCallbackResult;
  53623. private _tmpAmmoVectorRCA;
  53624. private _tmpAmmoVectorRCB;
  53625. private _raycastResult;
  53626. private static readonly DISABLE_COLLISION_FLAG;
  53627. private static readonly KINEMATIC_FLAG;
  53628. private static readonly DISABLE_DEACTIVATION_FLAG;
  53629. /**
  53630. * Initializes the ammoJS plugin
  53631. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53632. * @param ammoInjection can be used to inject your own ammo reference
  53633. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53634. */
  53635. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53636. /**
  53637. * Sets the gravity of the physics world (m/(s^2))
  53638. * @param gravity Gravity to set
  53639. */
  53640. setGravity(gravity: Vector3): void;
  53641. /**
  53642. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53643. * @param timeStep timestep to use in seconds
  53644. */
  53645. setTimeStep(timeStep: number): void;
  53646. /**
  53647. * 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)
  53648. * @param fixedTimeStep fixedTimeStep to use in seconds
  53649. */
  53650. setFixedTimeStep(fixedTimeStep: number): void;
  53651. /**
  53652. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53653. * @param maxSteps the maximum number of steps by the physics engine per frame
  53654. */
  53655. setMaxSteps(maxSteps: number): void;
  53656. /**
  53657. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53658. * @returns the current timestep in seconds
  53659. */
  53660. getTimeStep(): number;
  53661. private _isImpostorInContact;
  53662. private _isImpostorPairInContact;
  53663. private _stepSimulation;
  53664. /**
  53665. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53666. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53667. * After the step the babylon meshes are set to the position of the physics imposters
  53668. * @param delta amount of time to step forward
  53669. * @param impostors array of imposters to update before/after the step
  53670. */
  53671. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53672. /**
  53673. * Update babylon mesh to match physics world object
  53674. * @param impostor imposter to match
  53675. */
  53676. private _afterSoftStep;
  53677. /**
  53678. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53679. * @param impostor imposter to match
  53680. */
  53681. private _ropeStep;
  53682. /**
  53683. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53684. * @param impostor imposter to match
  53685. */
  53686. private _softbodyOrClothStep;
  53687. private _tmpVector;
  53688. private _tmpMatrix;
  53689. /**
  53690. * Applies an impulse on the imposter
  53691. * @param impostor imposter to apply impulse to
  53692. * @param force amount of force to be applied to the imposter
  53693. * @param contactPoint the location to apply the impulse on the imposter
  53694. */
  53695. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53696. /**
  53697. * Applies a force on the imposter
  53698. * @param impostor imposter to apply force
  53699. * @param force amount of force to be applied to the imposter
  53700. * @param contactPoint the location to apply the force on the imposter
  53701. */
  53702. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53703. /**
  53704. * Creates a physics body using the plugin
  53705. * @param impostor the imposter to create the physics body on
  53706. */
  53707. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53708. /**
  53709. * Removes the physics body from the imposter and disposes of the body's memory
  53710. * @param impostor imposter to remove the physics body from
  53711. */
  53712. removePhysicsBody(impostor: PhysicsImpostor): void;
  53713. /**
  53714. * Generates a joint
  53715. * @param impostorJoint the imposter joint to create the joint with
  53716. */
  53717. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53718. /**
  53719. * Removes a joint
  53720. * @param impostorJoint the imposter joint to remove the joint from
  53721. */
  53722. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53723. private _addMeshVerts;
  53724. /**
  53725. * Initialise the soft body vertices to match its object's (mesh) vertices
  53726. * Softbody vertices (nodes) are in world space and to match this
  53727. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53728. * @param impostor to create the softbody for
  53729. */
  53730. private _softVertexData;
  53731. /**
  53732. * Create an impostor's soft body
  53733. * @param impostor to create the softbody for
  53734. */
  53735. private _createSoftbody;
  53736. /**
  53737. * Create cloth for an impostor
  53738. * @param impostor to create the softbody for
  53739. */
  53740. private _createCloth;
  53741. /**
  53742. * Create rope for an impostor
  53743. * @param impostor to create the softbody for
  53744. */
  53745. private _createRope;
  53746. private _addHullVerts;
  53747. private _createShape;
  53748. /**
  53749. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53750. * @param impostor imposter containing the physics body and babylon object
  53751. */
  53752. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53753. /**
  53754. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53755. * @param impostor imposter containing the physics body and babylon object
  53756. * @param newPosition new position
  53757. * @param newRotation new rotation
  53758. */
  53759. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53760. /**
  53761. * If this plugin is supported
  53762. * @returns true if its supported
  53763. */
  53764. isSupported(): boolean;
  53765. /**
  53766. * Sets the linear velocity of the physics body
  53767. * @param impostor imposter to set the velocity on
  53768. * @param velocity velocity to set
  53769. */
  53770. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53771. /**
  53772. * Sets the angular velocity of the physics body
  53773. * @param impostor imposter to set the velocity on
  53774. * @param velocity velocity to set
  53775. */
  53776. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53777. /**
  53778. * gets the linear velocity
  53779. * @param impostor imposter to get linear velocity from
  53780. * @returns linear velocity
  53781. */
  53782. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53783. /**
  53784. * gets the angular velocity
  53785. * @param impostor imposter to get angular velocity from
  53786. * @returns angular velocity
  53787. */
  53788. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53789. /**
  53790. * Sets the mass of physics body
  53791. * @param impostor imposter to set the mass on
  53792. * @param mass mass to set
  53793. */
  53794. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53795. /**
  53796. * Gets the mass of the physics body
  53797. * @param impostor imposter to get the mass from
  53798. * @returns mass
  53799. */
  53800. getBodyMass(impostor: PhysicsImpostor): number;
  53801. /**
  53802. * Gets friction of the impostor
  53803. * @param impostor impostor to get friction from
  53804. * @returns friction value
  53805. */
  53806. getBodyFriction(impostor: PhysicsImpostor): number;
  53807. /**
  53808. * Sets friction of the impostor
  53809. * @param impostor impostor to set friction on
  53810. * @param friction friction value
  53811. */
  53812. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53813. /**
  53814. * Gets restitution of the impostor
  53815. * @param impostor impostor to get restitution from
  53816. * @returns restitution value
  53817. */
  53818. getBodyRestitution(impostor: PhysicsImpostor): number;
  53819. /**
  53820. * Sets resitution of the impostor
  53821. * @param impostor impostor to set resitution on
  53822. * @param restitution resitution value
  53823. */
  53824. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53825. /**
  53826. * Gets pressure inside the impostor
  53827. * @param impostor impostor to get pressure from
  53828. * @returns pressure value
  53829. */
  53830. getBodyPressure(impostor: PhysicsImpostor): number;
  53831. /**
  53832. * Sets pressure inside a soft body impostor
  53833. * Cloth and rope must remain 0 pressure
  53834. * @param impostor impostor to set pressure on
  53835. * @param pressure pressure value
  53836. */
  53837. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53838. /**
  53839. * Gets stiffness of the impostor
  53840. * @param impostor impostor to get stiffness from
  53841. * @returns pressure value
  53842. */
  53843. getBodyStiffness(impostor: PhysicsImpostor): number;
  53844. /**
  53845. * Sets stiffness of the impostor
  53846. * @param impostor impostor to set stiffness on
  53847. * @param stiffness stiffness value from 0 to 1
  53848. */
  53849. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53850. /**
  53851. * Gets velocityIterations of the impostor
  53852. * @param impostor impostor to get velocity iterations from
  53853. * @returns velocityIterations value
  53854. */
  53855. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53856. /**
  53857. * Sets velocityIterations of the impostor
  53858. * @param impostor impostor to set velocity iterations on
  53859. * @param velocityIterations velocityIterations value
  53860. */
  53861. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53862. /**
  53863. * Gets positionIterations of the impostor
  53864. * @param impostor impostor to get position iterations from
  53865. * @returns positionIterations value
  53866. */
  53867. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53868. /**
  53869. * Sets positionIterations of the impostor
  53870. * @param impostor impostor to set position on
  53871. * @param positionIterations positionIterations value
  53872. */
  53873. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53874. /**
  53875. * Append an anchor to a cloth object
  53876. * @param impostor is the cloth impostor to add anchor to
  53877. * @param otherImpostor is the rigid impostor to anchor to
  53878. * @param width ratio across width from 0 to 1
  53879. * @param height ratio up height from 0 to 1
  53880. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53881. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53882. */
  53883. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53884. /**
  53885. * Append an hook to a rope object
  53886. * @param impostor is the rope impostor to add hook to
  53887. * @param otherImpostor is the rigid impostor to hook to
  53888. * @param length ratio along the rope from 0 to 1
  53889. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53890. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53891. */
  53892. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53893. /**
  53894. * Sleeps the physics body and stops it from being active
  53895. * @param impostor impostor to sleep
  53896. */
  53897. sleepBody(impostor: PhysicsImpostor): void;
  53898. /**
  53899. * Activates the physics body
  53900. * @param impostor impostor to activate
  53901. */
  53902. wakeUpBody(impostor: PhysicsImpostor): void;
  53903. /**
  53904. * Updates the distance parameters of the joint
  53905. * @param joint joint to update
  53906. * @param maxDistance maximum distance of the joint
  53907. * @param minDistance minimum distance of the joint
  53908. */
  53909. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53910. /**
  53911. * Sets a motor on the joint
  53912. * @param joint joint to set motor on
  53913. * @param speed speed of the motor
  53914. * @param maxForce maximum force of the motor
  53915. * @param motorIndex index of the motor
  53916. */
  53917. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53918. /**
  53919. * Sets the motors limit
  53920. * @param joint joint to set limit on
  53921. * @param upperLimit upper limit
  53922. * @param lowerLimit lower limit
  53923. */
  53924. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53925. /**
  53926. * Syncs the position and rotation of a mesh with the impostor
  53927. * @param mesh mesh to sync
  53928. * @param impostor impostor to update the mesh with
  53929. */
  53930. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53931. /**
  53932. * Gets the radius of the impostor
  53933. * @param impostor impostor to get radius from
  53934. * @returns the radius
  53935. */
  53936. getRadius(impostor: PhysicsImpostor): number;
  53937. /**
  53938. * Gets the box size of the impostor
  53939. * @param impostor impostor to get box size from
  53940. * @param result the resulting box size
  53941. */
  53942. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53943. /**
  53944. * Disposes of the impostor
  53945. */
  53946. dispose(): void;
  53947. /**
  53948. * Does a raycast in the physics world
  53949. * @param from when should the ray start?
  53950. * @param to when should the ray end?
  53951. * @returns PhysicsRaycastResult
  53952. */
  53953. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53954. }
  53955. }
  53956. declare module "babylonjs/Probes/reflectionProbe" {
  53957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53958. import { Vector3 } from "babylonjs/Maths/math.vector";
  53959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53960. import { Nullable } from "babylonjs/types";
  53961. import { Scene } from "babylonjs/scene";
  53962. module "babylonjs/abstractScene" {
  53963. interface AbstractScene {
  53964. /**
  53965. * The list of reflection probes added to the scene
  53966. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53967. */
  53968. reflectionProbes: Array<ReflectionProbe>;
  53969. /**
  53970. * Removes the given reflection probe from this scene.
  53971. * @param toRemove The reflection probe to remove
  53972. * @returns The index of the removed reflection probe
  53973. */
  53974. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53975. /**
  53976. * Adds the given reflection probe to this scene.
  53977. * @param newReflectionProbe The reflection probe to add
  53978. */
  53979. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53980. }
  53981. }
  53982. /**
  53983. * Class used to generate realtime reflection / refraction cube textures
  53984. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53985. */
  53986. export class ReflectionProbe {
  53987. /** defines the name of the probe */
  53988. name: string;
  53989. private _scene;
  53990. private _renderTargetTexture;
  53991. private _projectionMatrix;
  53992. private _viewMatrix;
  53993. private _target;
  53994. private _add;
  53995. private _attachedMesh;
  53996. private _invertYAxis;
  53997. /** Gets or sets probe position (center of the cube map) */
  53998. position: Vector3;
  53999. /**
  54000. * Creates a new reflection probe
  54001. * @param name defines the name of the probe
  54002. * @param size defines the texture resolution (for each face)
  54003. * @param scene defines the hosting scene
  54004. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54005. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54006. */
  54007. constructor(
  54008. /** defines the name of the probe */
  54009. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54010. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54011. samples: number;
  54012. /** Gets or sets the refresh rate to use (on every frame by default) */
  54013. refreshRate: number;
  54014. /**
  54015. * Gets the hosting scene
  54016. * @returns a Scene
  54017. */
  54018. getScene(): Scene;
  54019. /** Gets the internal CubeTexture used to render to */
  54020. readonly cubeTexture: RenderTargetTexture;
  54021. /** Gets the list of meshes to render */
  54022. readonly renderList: Nullable<AbstractMesh[]>;
  54023. /**
  54024. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54025. * @param mesh defines the mesh to attach to
  54026. */
  54027. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54028. /**
  54029. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54030. * @param renderingGroupId The rendering group id corresponding to its index
  54031. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54032. */
  54033. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54034. /**
  54035. * Clean all associated resources
  54036. */
  54037. dispose(): void;
  54038. /**
  54039. * Converts the reflection probe information to a readable string for debug purpose.
  54040. * @param fullDetails Supports for multiple levels of logging within scene loading
  54041. * @returns the human readable reflection probe info
  54042. */
  54043. toString(fullDetails?: boolean): string;
  54044. /**
  54045. * Get the class name of the relfection probe.
  54046. * @returns "ReflectionProbe"
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54051. * @returns The JSON representation of the texture
  54052. */
  54053. serialize(): any;
  54054. /**
  54055. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54056. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54057. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54058. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54059. * @returns The parsed reflection probe if successful
  54060. */
  54061. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54062. }
  54063. }
  54064. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54065. /** @hidden */
  54066. export var _BabylonLoaderRegistered: boolean;
  54067. }
  54068. declare module "babylonjs/Loading/Plugins/index" {
  54069. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54070. }
  54071. declare module "babylonjs/Loading/index" {
  54072. export * from "babylonjs/Loading/loadingScreen";
  54073. export * from "babylonjs/Loading/Plugins/index";
  54074. export * from "babylonjs/Loading/sceneLoader";
  54075. export * from "babylonjs/Loading/sceneLoaderFlags";
  54076. }
  54077. declare module "babylonjs/Materials/Background/index" {
  54078. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54079. }
  54080. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54081. import { Scene } from "babylonjs/scene";
  54082. import { Color3 } from "babylonjs/Maths/math.color";
  54083. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54085. /**
  54086. * The Physically based simple base material of BJS.
  54087. *
  54088. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54089. * It is used as the base class for both the specGloss and metalRough conventions.
  54090. */
  54091. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54092. /**
  54093. * Number of Simultaneous lights allowed on the material.
  54094. */
  54095. maxSimultaneousLights: number;
  54096. /**
  54097. * If sets to true, disables all the lights affecting the material.
  54098. */
  54099. disableLighting: boolean;
  54100. /**
  54101. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54102. */
  54103. environmentTexture: BaseTexture;
  54104. /**
  54105. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54106. */
  54107. invertNormalMapX: boolean;
  54108. /**
  54109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54110. */
  54111. invertNormalMapY: boolean;
  54112. /**
  54113. * Normal map used in the model.
  54114. */
  54115. normalTexture: BaseTexture;
  54116. /**
  54117. * Emissivie color used to self-illuminate the model.
  54118. */
  54119. emissiveColor: Color3;
  54120. /**
  54121. * Emissivie texture used to self-illuminate the model.
  54122. */
  54123. emissiveTexture: BaseTexture;
  54124. /**
  54125. * Occlusion Channel Strenght.
  54126. */
  54127. occlusionStrength: number;
  54128. /**
  54129. * Occlusion Texture of the material (adding extra occlusion effects).
  54130. */
  54131. occlusionTexture: BaseTexture;
  54132. /**
  54133. * Defines the alpha limits in alpha test mode.
  54134. */
  54135. alphaCutOff: number;
  54136. /**
  54137. * Gets the current double sided mode.
  54138. */
  54139. /**
  54140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54141. */
  54142. doubleSided: boolean;
  54143. /**
  54144. * Stores the pre-calculated light information of a mesh in a texture.
  54145. */
  54146. lightmapTexture: BaseTexture;
  54147. /**
  54148. * If true, the light map contains occlusion information instead of lighting info.
  54149. */
  54150. useLightmapAsShadowmap: boolean;
  54151. /**
  54152. * Instantiates a new PBRMaterial instance.
  54153. *
  54154. * @param name The material name
  54155. * @param scene The scene the material will be use in.
  54156. */
  54157. constructor(name: string, scene: Scene);
  54158. getClassName(): string;
  54159. }
  54160. }
  54161. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54162. import { Scene } from "babylonjs/scene";
  54163. import { Color3 } from "babylonjs/Maths/math.color";
  54164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54165. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54166. /**
  54167. * The PBR material of BJS following the metal roughness convention.
  54168. *
  54169. * This fits to the PBR convention in the GLTF definition:
  54170. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54171. */
  54172. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54173. /**
  54174. * The base color has two different interpretations depending on the value of metalness.
  54175. * When the material is a metal, the base color is the specific measured reflectance value
  54176. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54177. * of the material.
  54178. */
  54179. baseColor: Color3;
  54180. /**
  54181. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54182. * well as opacity information in the alpha channel.
  54183. */
  54184. baseTexture: BaseTexture;
  54185. /**
  54186. * Specifies the metallic scalar value of the material.
  54187. * Can also be used to scale the metalness values of the metallic texture.
  54188. */
  54189. metallic: number;
  54190. /**
  54191. * Specifies the roughness scalar value of the material.
  54192. * Can also be used to scale the roughness values of the metallic texture.
  54193. */
  54194. roughness: number;
  54195. /**
  54196. * Texture containing both the metallic value in the B channel and the
  54197. * roughness value in the G channel to keep better precision.
  54198. */
  54199. metallicRoughnessTexture: BaseTexture;
  54200. /**
  54201. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54202. *
  54203. * @param name The material name
  54204. * @param scene The scene the material will be use in.
  54205. */
  54206. constructor(name: string, scene: Scene);
  54207. /**
  54208. * Return the currrent class name of the material.
  54209. */
  54210. getClassName(): string;
  54211. /**
  54212. * Makes a duplicate of the current material.
  54213. * @param name - name to use for the new material.
  54214. */
  54215. clone(name: string): PBRMetallicRoughnessMaterial;
  54216. /**
  54217. * Serialize the material to a parsable JSON object.
  54218. */
  54219. serialize(): any;
  54220. /**
  54221. * Parses a JSON object correponding to the serialize function.
  54222. */
  54223. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54224. }
  54225. }
  54226. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54227. import { Scene } from "babylonjs/scene";
  54228. import { Color3 } from "babylonjs/Maths/math.color";
  54229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54230. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54231. /**
  54232. * The PBR material of BJS following the specular glossiness convention.
  54233. *
  54234. * This fits to the PBR convention in the GLTF definition:
  54235. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54236. */
  54237. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54238. /**
  54239. * Specifies the diffuse color of the material.
  54240. */
  54241. diffuseColor: Color3;
  54242. /**
  54243. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54244. * channel.
  54245. */
  54246. diffuseTexture: BaseTexture;
  54247. /**
  54248. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54249. */
  54250. specularColor: Color3;
  54251. /**
  54252. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54253. */
  54254. glossiness: number;
  54255. /**
  54256. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54257. */
  54258. specularGlossinessTexture: BaseTexture;
  54259. /**
  54260. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54261. *
  54262. * @param name The material name
  54263. * @param scene The scene the material will be use in.
  54264. */
  54265. constructor(name: string, scene: Scene);
  54266. /**
  54267. * Return the currrent class name of the material.
  54268. */
  54269. getClassName(): string;
  54270. /**
  54271. * Makes a duplicate of the current material.
  54272. * @param name - name to use for the new material.
  54273. */
  54274. clone(name: string): PBRSpecularGlossinessMaterial;
  54275. /**
  54276. * Serialize the material to a parsable JSON object.
  54277. */
  54278. serialize(): any;
  54279. /**
  54280. * Parses a JSON object correponding to the serialize function.
  54281. */
  54282. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54283. }
  54284. }
  54285. declare module "babylonjs/Materials/PBR/index" {
  54286. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54287. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54288. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54289. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54290. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54291. }
  54292. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54293. import { Nullable } from "babylonjs/types";
  54294. import { Scene } from "babylonjs/scene";
  54295. import { Matrix } from "babylonjs/Maths/math.vector";
  54296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54297. /**
  54298. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54299. * It can help converting any input color in a desired output one. This can then be used to create effects
  54300. * from sepia, black and white to sixties or futuristic rendering...
  54301. *
  54302. * The only supported format is currently 3dl.
  54303. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54304. */
  54305. export class ColorGradingTexture extends BaseTexture {
  54306. /**
  54307. * The current texture matrix. (will always be identity in color grading texture)
  54308. */
  54309. private _textureMatrix;
  54310. /**
  54311. * The texture URL.
  54312. */
  54313. url: string;
  54314. /**
  54315. * Empty line regex stored for GC.
  54316. */
  54317. private static _noneEmptyLineRegex;
  54318. private _engine;
  54319. /**
  54320. * Instantiates a ColorGradingTexture from the following parameters.
  54321. *
  54322. * @param url The location of the color gradind data (currently only supporting 3dl)
  54323. * @param scene The scene the texture will be used in
  54324. */
  54325. constructor(url: string, scene: Scene);
  54326. /**
  54327. * Returns the texture matrix used in most of the material.
  54328. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54329. */
  54330. getTextureMatrix(): Matrix;
  54331. /**
  54332. * Occurs when the file being loaded is a .3dl LUT file.
  54333. */
  54334. private load3dlTexture;
  54335. /**
  54336. * Starts the loading process of the texture.
  54337. */
  54338. private loadTexture;
  54339. /**
  54340. * Clones the color gradind texture.
  54341. */
  54342. clone(): ColorGradingTexture;
  54343. /**
  54344. * Called during delayed load for textures.
  54345. */
  54346. delayLoad(): void;
  54347. /**
  54348. * Parses a color grading texture serialized by Babylon.
  54349. * @param parsedTexture The texture information being parsedTexture
  54350. * @param scene The scene to load the texture in
  54351. * @param rootUrl The root url of the data assets to load
  54352. * @return A color gradind texture
  54353. */
  54354. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54355. /**
  54356. * Serializes the LUT texture to json format.
  54357. */
  54358. serialize(): any;
  54359. }
  54360. }
  54361. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54363. import { Scene } from "babylonjs/scene";
  54364. import { Nullable } from "babylonjs/types";
  54365. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54366. /**
  54367. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54368. */
  54369. export class EquiRectangularCubeTexture extends BaseTexture {
  54370. /** The six faces of the cube. */
  54371. private static _FacesMapping;
  54372. private _noMipmap;
  54373. private _onLoad;
  54374. private _onError;
  54375. /** The size of the cubemap. */
  54376. private _size;
  54377. /** The buffer of the image. */
  54378. private _buffer;
  54379. /** The width of the input image. */
  54380. private _width;
  54381. /** The height of the input image. */
  54382. private _height;
  54383. /** The URL to the image. */
  54384. url: string;
  54385. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54386. coordinatesMode: number;
  54387. /**
  54388. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54389. * @param url The location of the image
  54390. * @param scene The scene the texture will be used in
  54391. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54392. * @param noMipmap Forces to not generate the mipmap if true
  54393. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54394. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54395. * @param onLoad — defines a callback called when texture is loaded
  54396. * @param onError — defines a callback called if there is an error
  54397. */
  54398. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54399. /**
  54400. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54401. */
  54402. private loadImage;
  54403. /**
  54404. * Convert the image buffer into a cubemap and create a CubeTexture.
  54405. */
  54406. private loadTexture;
  54407. /**
  54408. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54409. * @param buffer The ArrayBuffer that should be converted.
  54410. * @returns The buffer as Float32Array.
  54411. */
  54412. private getFloat32ArrayFromArrayBuffer;
  54413. /**
  54414. * Get the current class name of the texture useful for serialization or dynamic coding.
  54415. * @returns "EquiRectangularCubeTexture"
  54416. */
  54417. getClassName(): string;
  54418. /**
  54419. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54420. * @returns A clone of the current EquiRectangularCubeTexture.
  54421. */
  54422. clone(): EquiRectangularCubeTexture;
  54423. }
  54424. }
  54425. declare module "babylonjs/Misc/tga" {
  54426. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54427. /**
  54428. * Based on jsTGALoader - Javascript loader for TGA file
  54429. * By Vincent Thibault
  54430. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54431. */
  54432. export class TGATools {
  54433. private static _TYPE_INDEXED;
  54434. private static _TYPE_RGB;
  54435. private static _TYPE_GREY;
  54436. private static _TYPE_RLE_INDEXED;
  54437. private static _TYPE_RLE_RGB;
  54438. private static _TYPE_RLE_GREY;
  54439. private static _ORIGIN_MASK;
  54440. private static _ORIGIN_SHIFT;
  54441. private static _ORIGIN_BL;
  54442. private static _ORIGIN_BR;
  54443. private static _ORIGIN_UL;
  54444. private static _ORIGIN_UR;
  54445. /**
  54446. * Gets the header of a TGA file
  54447. * @param data defines the TGA data
  54448. * @returns the header
  54449. */
  54450. static GetTGAHeader(data: Uint8Array): any;
  54451. /**
  54452. * Uploads TGA content to a Babylon Texture
  54453. * @hidden
  54454. */
  54455. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54456. /** @hidden */
  54457. 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;
  54458. /** @hidden */
  54459. 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;
  54460. /** @hidden */
  54461. 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;
  54462. /** @hidden */
  54463. 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;
  54464. /** @hidden */
  54465. 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;
  54466. /** @hidden */
  54467. 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;
  54468. }
  54469. }
  54470. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54471. import { Nullable } from "babylonjs/types";
  54472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54473. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54474. /**
  54475. * Implementation of the TGA Texture Loader.
  54476. * @hidden
  54477. */
  54478. export class _TGATextureLoader implements IInternalTextureLoader {
  54479. /**
  54480. * Defines wether the loader supports cascade loading the different faces.
  54481. */
  54482. readonly supportCascades: boolean;
  54483. /**
  54484. * This returns if the loader support the current file information.
  54485. * @param extension defines the file extension of the file being loaded
  54486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54487. * @param fallback defines the fallback internal texture if any
  54488. * @param isBase64 defines whether the texture is encoded as a base64
  54489. * @param isBuffer defines whether the texture data are stored as a buffer
  54490. * @returns true if the loader can load the specified file
  54491. */
  54492. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54493. /**
  54494. * Transform the url before loading if required.
  54495. * @param rootUrl the url of the texture
  54496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54497. * @returns the transformed texture
  54498. */
  54499. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54500. /**
  54501. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54502. * @param rootUrl the url of the texture
  54503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54504. * @returns the fallback texture
  54505. */
  54506. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54507. /**
  54508. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54509. * @param data contains the texture data
  54510. * @param texture defines the BabylonJS internal texture
  54511. * @param createPolynomials will be true if polynomials have been requested
  54512. * @param onLoad defines the callback to trigger once the texture is ready
  54513. * @param onError defines the callback to trigger in case of error
  54514. */
  54515. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54516. /**
  54517. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54518. * @param data contains the texture data
  54519. * @param texture defines the BabylonJS internal texture
  54520. * @param callback defines the method to call once ready to upload
  54521. */
  54522. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54523. }
  54524. }
  54525. declare module "babylonjs/Misc/basis" {
  54526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54527. /**
  54528. * Info about the .basis files
  54529. */
  54530. class BasisFileInfo {
  54531. /**
  54532. * If the file has alpha
  54533. */
  54534. hasAlpha: boolean;
  54535. /**
  54536. * Info about each image of the basis file
  54537. */
  54538. images: Array<{
  54539. levels: Array<{
  54540. width: number;
  54541. height: number;
  54542. transcodedPixels: ArrayBufferView;
  54543. }>;
  54544. }>;
  54545. }
  54546. /**
  54547. * Result of transcoding a basis file
  54548. */
  54549. class TranscodeResult {
  54550. /**
  54551. * Info about the .basis file
  54552. */
  54553. fileInfo: BasisFileInfo;
  54554. /**
  54555. * Format to use when loading the file
  54556. */
  54557. format: number;
  54558. }
  54559. /**
  54560. * Configuration options for the Basis transcoder
  54561. */
  54562. export class BasisTranscodeConfiguration {
  54563. /**
  54564. * Supported compression formats used to determine the supported output format of the transcoder
  54565. */
  54566. supportedCompressionFormats?: {
  54567. /**
  54568. * etc1 compression format
  54569. */
  54570. etc1?: boolean;
  54571. /**
  54572. * s3tc compression format
  54573. */
  54574. s3tc?: boolean;
  54575. /**
  54576. * pvrtc compression format
  54577. */
  54578. pvrtc?: boolean;
  54579. /**
  54580. * etc2 compression format
  54581. */
  54582. etc2?: boolean;
  54583. };
  54584. /**
  54585. * If mipmap levels should be loaded for transcoded images (Default: true)
  54586. */
  54587. loadMipmapLevels?: boolean;
  54588. /**
  54589. * Index of a single image to load (Default: all images)
  54590. */
  54591. loadSingleImage?: number;
  54592. }
  54593. /**
  54594. * Used to load .Basis files
  54595. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54596. */
  54597. export class BasisTools {
  54598. private static _IgnoreSupportedFormats;
  54599. /**
  54600. * URL to use when loading the basis transcoder
  54601. */
  54602. static JSModuleURL: string;
  54603. /**
  54604. * URL to use when loading the wasm module for the transcoder
  54605. */
  54606. static WasmModuleURL: string;
  54607. /**
  54608. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54609. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54610. * @returns internal format corresponding to the Basis format
  54611. */
  54612. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54613. private static _WorkerPromise;
  54614. private static _Worker;
  54615. private static _actionId;
  54616. private static _CreateWorkerAsync;
  54617. /**
  54618. * Transcodes a loaded image file to compressed pixel data
  54619. * @param imageData image data to transcode
  54620. * @param config configuration options for the transcoding
  54621. * @returns a promise resulting in the transcoded image
  54622. */
  54623. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54624. /**
  54625. * Loads a texture from the transcode result
  54626. * @param texture texture load to
  54627. * @param transcodeResult the result of transcoding the basis file to load from
  54628. */
  54629. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54630. }
  54631. }
  54632. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54633. import { Nullable } from "babylonjs/types";
  54634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54635. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54636. /**
  54637. * Loader for .basis file format
  54638. */
  54639. export class _BasisTextureLoader implements IInternalTextureLoader {
  54640. /**
  54641. * Defines whether the loader supports cascade loading the different faces.
  54642. */
  54643. readonly supportCascades: boolean;
  54644. /**
  54645. * This returns if the loader support the current file information.
  54646. * @param extension defines the file extension of the file being loaded
  54647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54648. * @param fallback defines the fallback internal texture if any
  54649. * @param isBase64 defines whether the texture is encoded as a base64
  54650. * @param isBuffer defines whether the texture data are stored as a buffer
  54651. * @returns true if the loader can load the specified file
  54652. */
  54653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54654. /**
  54655. * Transform the url before loading if required.
  54656. * @param rootUrl the url of the texture
  54657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54658. * @returns the transformed texture
  54659. */
  54660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54661. /**
  54662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54663. * @param rootUrl the url of the texture
  54664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54665. * @returns the fallback texture
  54666. */
  54667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54668. /**
  54669. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54670. * @param data contains the texture data
  54671. * @param texture defines the BabylonJS internal texture
  54672. * @param createPolynomials will be true if polynomials have been requested
  54673. * @param onLoad defines the callback to trigger once the texture is ready
  54674. * @param onError defines the callback to trigger in case of error
  54675. */
  54676. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54677. /**
  54678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54679. * @param data contains the texture data
  54680. * @param texture defines the BabylonJS internal texture
  54681. * @param callback defines the method to call once ready to upload
  54682. */
  54683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54684. }
  54685. }
  54686. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54687. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54688. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54689. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54690. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54691. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54692. }
  54693. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54694. import { Scene } from "babylonjs/scene";
  54695. import { Texture } from "babylonjs/Materials/Textures/texture";
  54696. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54697. /**
  54698. * 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.
  54699. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54700. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54701. */
  54702. export class CustomProceduralTexture extends ProceduralTexture {
  54703. private _animate;
  54704. private _time;
  54705. private _config;
  54706. private _texturePath;
  54707. /**
  54708. * Instantiates a new Custom Procedural Texture.
  54709. * 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.
  54710. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54711. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54712. * @param name Define the name of the texture
  54713. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54714. * @param size Define the size of the texture to create
  54715. * @param scene Define the scene the texture belongs to
  54716. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54717. * @param generateMipMaps Define if the texture should creates mip maps or not
  54718. */
  54719. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54720. private _loadJson;
  54721. /**
  54722. * Is the texture ready to be used ? (rendered at least once)
  54723. * @returns true if ready, otherwise, false.
  54724. */
  54725. isReady(): boolean;
  54726. /**
  54727. * Render the texture to its associated render target.
  54728. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54729. */
  54730. render(useCameraPostProcess?: boolean): void;
  54731. /**
  54732. * Update the list of dependant textures samplers in the shader.
  54733. */
  54734. updateTextures(): void;
  54735. /**
  54736. * Update the uniform values of the procedural texture in the shader.
  54737. */
  54738. updateShaderUniforms(): void;
  54739. /**
  54740. * Define if the texture animates or not.
  54741. */
  54742. animate: boolean;
  54743. }
  54744. }
  54745. declare module "babylonjs/Shaders/noise.fragment" {
  54746. /** @hidden */
  54747. export var noisePixelShader: {
  54748. name: string;
  54749. shader: string;
  54750. };
  54751. }
  54752. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54753. import { Nullable } from "babylonjs/types";
  54754. import { Scene } from "babylonjs/scene";
  54755. import { Texture } from "babylonjs/Materials/Textures/texture";
  54756. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54757. import "babylonjs/Shaders/noise.fragment";
  54758. /**
  54759. * Class used to generate noise procedural textures
  54760. */
  54761. export class NoiseProceduralTexture extends ProceduralTexture {
  54762. private _time;
  54763. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54764. brightness: number;
  54765. /** Defines the number of octaves to process */
  54766. octaves: number;
  54767. /** Defines the level of persistence (0.8 by default) */
  54768. persistence: number;
  54769. /** Gets or sets animation speed factor (default is 1) */
  54770. animationSpeedFactor: number;
  54771. /**
  54772. * Creates a new NoiseProceduralTexture
  54773. * @param name defines the name fo the texture
  54774. * @param size defines the size of the texture (default is 256)
  54775. * @param scene defines the hosting scene
  54776. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54777. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54778. */
  54779. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54780. private _updateShaderUniforms;
  54781. protected _getDefines(): string;
  54782. /** Generate the current state of the procedural texture */
  54783. render(useCameraPostProcess?: boolean): void;
  54784. /**
  54785. * Serializes this noise procedural texture
  54786. * @returns a serialized noise procedural texture object
  54787. */
  54788. serialize(): any;
  54789. /**
  54790. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54791. * @param parsedTexture defines parsed texture data
  54792. * @param scene defines the current scene
  54793. * @param rootUrl defines the root URL containing noise procedural texture information
  54794. * @returns a parsed NoiseProceduralTexture
  54795. */
  54796. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54797. }
  54798. }
  54799. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54800. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54801. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54802. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54803. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54804. }
  54805. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54806. import { Nullable } from "babylonjs/types";
  54807. import { Scene } from "babylonjs/scene";
  54808. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54810. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54811. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54812. /**
  54813. * Raw cube texture where the raw buffers are passed in
  54814. */
  54815. export class RawCubeTexture extends CubeTexture {
  54816. /**
  54817. * Creates a cube texture where the raw buffers are passed in.
  54818. * @param scene defines the scene the texture is attached to
  54819. * @param data defines the array of data to use to create each face
  54820. * @param size defines the size of the textures
  54821. * @param format defines the format of the data
  54822. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54823. * @param generateMipMaps defines if the engine should generate the mip levels
  54824. * @param invertY defines if data must be stored with Y axis inverted
  54825. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54826. * @param compression defines the compression used (null by default)
  54827. */
  54828. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54829. /**
  54830. * Updates the raw cube texture.
  54831. * @param data defines the data to store
  54832. * @param format defines the data format
  54833. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54834. * @param invertY defines if data must be stored with Y axis inverted
  54835. * @param compression defines the compression used (null by default)
  54836. * @param level defines which level of the texture to update
  54837. */
  54838. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54839. /**
  54840. * Updates a raw cube texture with RGBD encoded data.
  54841. * @param data defines the array of data [mipmap][face] to use to create each face
  54842. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54843. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54844. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54845. * @returns a promsie that resolves when the operation is complete
  54846. */
  54847. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54848. /**
  54849. * Clones the raw cube texture.
  54850. * @return a new cube texture
  54851. */
  54852. clone(): CubeTexture;
  54853. /** @hidden */
  54854. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54855. }
  54856. }
  54857. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54858. import { Scene } from "babylonjs/scene";
  54859. import { Texture } from "babylonjs/Materials/Textures/texture";
  54860. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54861. /**
  54862. * Class used to store 3D textures containing user data
  54863. */
  54864. export class RawTexture3D extends Texture {
  54865. /** Gets or sets the texture format to use */
  54866. format: number;
  54867. private _engine;
  54868. /**
  54869. * Create a new RawTexture3D
  54870. * @param data defines the data of the texture
  54871. * @param width defines the width of the texture
  54872. * @param height defines the height of the texture
  54873. * @param depth defines the depth of the texture
  54874. * @param format defines the texture format to use
  54875. * @param scene defines the hosting scene
  54876. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54877. * @param invertY defines if texture must be stored with Y axis inverted
  54878. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54879. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54880. */
  54881. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54882. /** Gets or sets the texture format to use */
  54883. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54884. /**
  54885. * Update the texture with new data
  54886. * @param data defines the data to store in the texture
  54887. */
  54888. update(data: ArrayBufferView): void;
  54889. }
  54890. }
  54891. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54892. import { Scene } from "babylonjs/scene";
  54893. import { Plane } from "babylonjs/Maths/math.plane";
  54894. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54895. /**
  54896. * Creates a refraction texture used by refraction channel of the standard material.
  54897. * It is like a mirror but to see through a material.
  54898. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54899. */
  54900. export class RefractionTexture extends RenderTargetTexture {
  54901. /**
  54902. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54903. * 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.
  54904. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54905. */
  54906. refractionPlane: Plane;
  54907. /**
  54908. * Define how deep under the surface we should see.
  54909. */
  54910. depth: number;
  54911. /**
  54912. * Creates a refraction texture used by refraction channel of the standard material.
  54913. * It is like a mirror but to see through a material.
  54914. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54915. * @param name Define the texture name
  54916. * @param size Define the size of the underlying texture
  54917. * @param scene Define the scene the refraction belongs to
  54918. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54919. */
  54920. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54921. /**
  54922. * Clone the refraction texture.
  54923. * @returns the cloned texture
  54924. */
  54925. clone(): RefractionTexture;
  54926. /**
  54927. * Serialize the texture to a JSON representation you could use in Parse later on
  54928. * @returns the serialized JSON representation
  54929. */
  54930. serialize(): any;
  54931. }
  54932. }
  54933. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54934. import { Nullable } from "babylonjs/types";
  54935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54936. import { Matrix } from "babylonjs/Maths/math.vector";
  54937. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54938. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54939. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54940. import { Scene } from "babylonjs/scene";
  54941. /**
  54942. * Defines the options related to the creation of an HtmlElementTexture
  54943. */
  54944. export interface IHtmlElementTextureOptions {
  54945. /**
  54946. * Defines wether mip maps should be created or not.
  54947. */
  54948. generateMipMaps?: boolean;
  54949. /**
  54950. * Defines the sampling mode of the texture.
  54951. */
  54952. samplingMode?: number;
  54953. /**
  54954. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54955. */
  54956. engine: Nullable<ThinEngine>;
  54957. /**
  54958. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54959. */
  54960. scene: Nullable<Scene>;
  54961. }
  54962. /**
  54963. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54964. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54965. * is automatically managed.
  54966. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54967. * in your application.
  54968. *
  54969. * As the update is not automatic, you need to call them manually.
  54970. */
  54971. export class HtmlElementTexture extends BaseTexture {
  54972. /**
  54973. * The texture URL.
  54974. */
  54975. element: HTMLVideoElement | HTMLCanvasElement;
  54976. private static readonly DefaultOptions;
  54977. private _textureMatrix;
  54978. private _engine;
  54979. private _isVideo;
  54980. private _generateMipMaps;
  54981. private _samplingMode;
  54982. /**
  54983. * Instantiates a HtmlElementTexture from the following parameters.
  54984. *
  54985. * @param name Defines the name of the texture
  54986. * @param element Defines the video or canvas the texture is filled with
  54987. * @param options Defines the other none mandatory texture creation options
  54988. */
  54989. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54990. private _createInternalTexture;
  54991. /**
  54992. * Returns the texture matrix used in most of the material.
  54993. */
  54994. getTextureMatrix(): Matrix;
  54995. /**
  54996. * Updates the content of the texture.
  54997. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54998. */
  54999. update(invertY?: Nullable<boolean>): void;
  55000. }
  55001. }
  55002. declare module "babylonjs/Materials/Textures/index" {
  55003. export * from "babylonjs/Materials/Textures/baseTexture";
  55004. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55005. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55006. export * from "babylonjs/Materials/Textures/cubeTexture";
  55007. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55008. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55009. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55010. export * from "babylonjs/Materials/Textures/internalTexture";
  55011. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55012. export * from "babylonjs/Materials/Textures/Loaders/index";
  55013. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55014. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55015. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55016. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55017. export * from "babylonjs/Materials/Textures/rawTexture";
  55018. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55019. export * from "babylonjs/Materials/Textures/refractionTexture";
  55020. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55021. export * from "babylonjs/Materials/Textures/texture";
  55022. export * from "babylonjs/Materials/Textures/videoTexture";
  55023. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55024. }
  55025. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55026. /**
  55027. * Enum used to define the target of a block
  55028. */
  55029. export enum NodeMaterialBlockTargets {
  55030. /** Vertex shader */
  55031. Vertex = 1,
  55032. /** Fragment shader */
  55033. Fragment = 2,
  55034. /** Neutral */
  55035. Neutral = 4,
  55036. /** Vertex and Fragment */
  55037. VertexAndFragment = 3
  55038. }
  55039. }
  55040. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55041. /**
  55042. * Defines the kind of connection point for node based material
  55043. */
  55044. export enum NodeMaterialBlockConnectionPointTypes {
  55045. /** Float */
  55046. Float = 1,
  55047. /** Int */
  55048. Int = 2,
  55049. /** Vector2 */
  55050. Vector2 = 4,
  55051. /** Vector3 */
  55052. Vector3 = 8,
  55053. /** Vector4 */
  55054. Vector4 = 16,
  55055. /** Color3 */
  55056. Color3 = 32,
  55057. /** Color4 */
  55058. Color4 = 64,
  55059. /** Matrix */
  55060. Matrix = 128,
  55061. /** Detect type based on connection */
  55062. AutoDetect = 1024,
  55063. /** Output type that will be defined by input type */
  55064. BasedOnInput = 2048
  55065. }
  55066. }
  55067. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55068. /**
  55069. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55070. */
  55071. export enum NodeMaterialBlockConnectionPointMode {
  55072. /** Value is an uniform */
  55073. Uniform = 0,
  55074. /** Value is a mesh attribute */
  55075. Attribute = 1,
  55076. /** Value is a varying between vertex and fragment shaders */
  55077. Varying = 2,
  55078. /** Mode is undefined */
  55079. Undefined = 3
  55080. }
  55081. }
  55082. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55083. /**
  55084. * Enum used to define system values e.g. values automatically provided by the system
  55085. */
  55086. export enum NodeMaterialSystemValues {
  55087. /** World */
  55088. World = 1,
  55089. /** View */
  55090. View = 2,
  55091. /** Projection */
  55092. Projection = 3,
  55093. /** ViewProjection */
  55094. ViewProjection = 4,
  55095. /** WorldView */
  55096. WorldView = 5,
  55097. /** WorldViewProjection */
  55098. WorldViewProjection = 6,
  55099. /** CameraPosition */
  55100. CameraPosition = 7,
  55101. /** Fog Color */
  55102. FogColor = 8,
  55103. /** Delta time */
  55104. DeltaTime = 9
  55105. }
  55106. }
  55107. declare module "babylonjs/Materials/Node/Enums/index" {
  55108. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55109. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55110. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55111. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55112. }
  55113. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55115. /**
  55116. * Root class for all node material optimizers
  55117. */
  55118. export class NodeMaterialOptimizer {
  55119. /**
  55120. * Function used to optimize a NodeMaterial graph
  55121. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55122. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55123. */
  55124. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55125. }
  55126. }
  55127. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55131. import { Scene } from "babylonjs/scene";
  55132. /**
  55133. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55134. */
  55135. export class TransformBlock extends NodeMaterialBlock {
  55136. /**
  55137. * Defines the value to use to complement W value to transform it to a Vector4
  55138. */
  55139. complementW: number;
  55140. /**
  55141. * Defines the value to use to complement z value to transform it to a Vector4
  55142. */
  55143. complementZ: number;
  55144. /**
  55145. * Creates a new TransformBlock
  55146. * @param name defines the block name
  55147. */
  55148. constructor(name: string);
  55149. /**
  55150. * Gets the current class name
  55151. * @returns the class name
  55152. */
  55153. getClassName(): string;
  55154. /**
  55155. * Gets the vector input
  55156. */
  55157. readonly vector: NodeMaterialConnectionPoint;
  55158. /**
  55159. * Gets the output component
  55160. */
  55161. readonly output: NodeMaterialConnectionPoint;
  55162. /**
  55163. * Gets the matrix transform input
  55164. */
  55165. readonly transform: NodeMaterialConnectionPoint;
  55166. protected _buildBlock(state: NodeMaterialBuildState): this;
  55167. serialize(): any;
  55168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55169. protected _dumpPropertiesCode(): string;
  55170. }
  55171. }
  55172. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55176. /**
  55177. * Block used to output the vertex position
  55178. */
  55179. export class VertexOutputBlock extends NodeMaterialBlock {
  55180. /**
  55181. * Creates a new VertexOutputBlock
  55182. * @param name defines the block name
  55183. */
  55184. constructor(name: string);
  55185. /**
  55186. * Gets the current class name
  55187. * @returns the class name
  55188. */
  55189. getClassName(): string;
  55190. /**
  55191. * Gets the vector input component
  55192. */
  55193. readonly vector: NodeMaterialConnectionPoint;
  55194. protected _buildBlock(state: NodeMaterialBuildState): this;
  55195. }
  55196. }
  55197. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55201. /**
  55202. * Block used to output the final color
  55203. */
  55204. export class FragmentOutputBlock extends NodeMaterialBlock {
  55205. /**
  55206. * Create a new FragmentOutputBlock
  55207. * @param name defines the block name
  55208. */
  55209. constructor(name: string);
  55210. /**
  55211. * Gets the current class name
  55212. * @returns the class name
  55213. */
  55214. getClassName(): string;
  55215. /**
  55216. * Gets the rgba input component
  55217. */
  55218. readonly rgba: NodeMaterialConnectionPoint;
  55219. /**
  55220. * Gets the rgb input component
  55221. */
  55222. readonly rgb: NodeMaterialConnectionPoint;
  55223. /**
  55224. * Gets the a input component
  55225. */
  55226. readonly a: NodeMaterialConnectionPoint;
  55227. protected _buildBlock(state: NodeMaterialBuildState): this;
  55228. }
  55229. }
  55230. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55234. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55236. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55237. import { Effect } from "babylonjs/Materials/effect";
  55238. import { Mesh } from "babylonjs/Meshes/mesh";
  55239. import { Nullable } from "babylonjs/types";
  55240. import { Scene } from "babylonjs/scene";
  55241. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55242. /**
  55243. * Block used to read a reflection texture from a sampler
  55244. */
  55245. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55246. private _define3DName;
  55247. private _defineCubicName;
  55248. private _defineExplicitName;
  55249. private _defineProjectionName;
  55250. private _defineLocalCubicName;
  55251. private _defineSphericalName;
  55252. private _definePlanarName;
  55253. private _defineEquirectangularName;
  55254. private _defineMirroredEquirectangularFixedName;
  55255. private _defineEquirectangularFixedName;
  55256. private _defineSkyboxName;
  55257. private _cubeSamplerName;
  55258. private _2DSamplerName;
  55259. private _positionUVWName;
  55260. private _directionWName;
  55261. private _reflectionCoordsName;
  55262. private _reflection2DCoordsName;
  55263. private _reflectionColorName;
  55264. private _reflectionMatrixName;
  55265. /**
  55266. * Gets or sets the texture associated with the node
  55267. */
  55268. texture: Nullable<BaseTexture>;
  55269. /**
  55270. * Create a new TextureBlock
  55271. * @param name defines the block name
  55272. */
  55273. constructor(name: string);
  55274. /**
  55275. * Gets the current class name
  55276. * @returns the class name
  55277. */
  55278. getClassName(): string;
  55279. /**
  55280. * Gets the world position input component
  55281. */
  55282. readonly position: NodeMaterialConnectionPoint;
  55283. /**
  55284. * Gets the world position input component
  55285. */
  55286. readonly worldPosition: NodeMaterialConnectionPoint;
  55287. /**
  55288. * Gets the world normal input component
  55289. */
  55290. readonly worldNormal: NodeMaterialConnectionPoint;
  55291. /**
  55292. * Gets the world input component
  55293. */
  55294. readonly world: NodeMaterialConnectionPoint;
  55295. /**
  55296. * Gets the camera (or eye) position component
  55297. */
  55298. readonly cameraPosition: NodeMaterialConnectionPoint;
  55299. /**
  55300. * Gets the view input component
  55301. */
  55302. readonly view: NodeMaterialConnectionPoint;
  55303. /**
  55304. * Gets the rgb output component
  55305. */
  55306. readonly rgb: NodeMaterialConnectionPoint;
  55307. /**
  55308. * Gets the r output component
  55309. */
  55310. readonly r: NodeMaterialConnectionPoint;
  55311. /**
  55312. * Gets the g output component
  55313. */
  55314. readonly g: NodeMaterialConnectionPoint;
  55315. /**
  55316. * Gets the b output component
  55317. */
  55318. readonly b: NodeMaterialConnectionPoint;
  55319. autoConfigure(material: NodeMaterial): void;
  55320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55321. isReady(): boolean;
  55322. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55323. private _injectVertexCode;
  55324. private _writeOutput;
  55325. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55326. serialize(): any;
  55327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55328. }
  55329. }
  55330. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55332. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55333. import { Scene } from "babylonjs/scene";
  55334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55335. import { Matrix } from "babylonjs/Maths/math.vector";
  55336. import { Mesh } from "babylonjs/Meshes/mesh";
  55337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55338. import { Observable } from "babylonjs/Misc/observable";
  55339. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55340. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55341. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55342. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55343. import { Nullable } from "babylonjs/types";
  55344. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55345. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55346. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55347. /**
  55348. * Interface used to configure the node material editor
  55349. */
  55350. export interface INodeMaterialEditorOptions {
  55351. /** Define the URl to load node editor script */
  55352. editorURL?: string;
  55353. }
  55354. /** @hidden */
  55355. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55356. /** BONES */
  55357. NUM_BONE_INFLUENCERS: number;
  55358. BonesPerMesh: number;
  55359. BONETEXTURE: boolean;
  55360. /** MORPH TARGETS */
  55361. MORPHTARGETS: boolean;
  55362. MORPHTARGETS_NORMAL: boolean;
  55363. MORPHTARGETS_TANGENT: boolean;
  55364. MORPHTARGETS_UV: boolean;
  55365. NUM_MORPH_INFLUENCERS: number;
  55366. /** IMAGE PROCESSING */
  55367. IMAGEPROCESSING: boolean;
  55368. VIGNETTE: boolean;
  55369. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55370. VIGNETTEBLENDMODEOPAQUE: boolean;
  55371. TONEMAPPING: boolean;
  55372. TONEMAPPING_ACES: boolean;
  55373. CONTRAST: boolean;
  55374. EXPOSURE: boolean;
  55375. COLORCURVES: boolean;
  55376. COLORGRADING: boolean;
  55377. COLORGRADING3D: boolean;
  55378. SAMPLER3DGREENDEPTH: boolean;
  55379. SAMPLER3DBGRMAP: boolean;
  55380. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55381. /** MISC. */
  55382. BUMPDIRECTUV: number;
  55383. constructor();
  55384. setValue(name: string, value: boolean): void;
  55385. }
  55386. /**
  55387. * Class used to configure NodeMaterial
  55388. */
  55389. export interface INodeMaterialOptions {
  55390. /**
  55391. * Defines if blocks should emit comments
  55392. */
  55393. emitComments: boolean;
  55394. }
  55395. /**
  55396. * Class used to create a node based material built by assembling shader blocks
  55397. */
  55398. export class NodeMaterial extends PushMaterial {
  55399. private static _BuildIdGenerator;
  55400. private _options;
  55401. private _vertexCompilationState;
  55402. private _fragmentCompilationState;
  55403. private _sharedData;
  55404. private _buildId;
  55405. private _buildWasSuccessful;
  55406. private _cachedWorldViewMatrix;
  55407. private _cachedWorldViewProjectionMatrix;
  55408. private _optimizers;
  55409. private _animationFrame;
  55410. /** Define the URl to load node editor script */
  55411. static EditorURL: string;
  55412. private BJSNODEMATERIALEDITOR;
  55413. /** Get the inspector from bundle or global */
  55414. private _getGlobalNodeMaterialEditor;
  55415. /**
  55416. * 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)
  55417. */
  55418. ignoreAlpha: boolean;
  55419. /**
  55420. * Defines the maximum number of lights that can be used in the material
  55421. */
  55422. maxSimultaneousLights: number;
  55423. /**
  55424. * Observable raised when the material is built
  55425. */
  55426. onBuildObservable: Observable<NodeMaterial>;
  55427. /**
  55428. * Gets or sets the root nodes of the material vertex shader
  55429. */
  55430. _vertexOutputNodes: NodeMaterialBlock[];
  55431. /**
  55432. * Gets or sets the root nodes of the material fragment (pixel) shader
  55433. */
  55434. _fragmentOutputNodes: NodeMaterialBlock[];
  55435. /** Gets or sets options to control the node material overall behavior */
  55436. options: INodeMaterialOptions;
  55437. /**
  55438. * Default configuration related to image processing available in the standard Material.
  55439. */
  55440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55441. /**
  55442. * Gets the image processing configuration used either in this material.
  55443. */
  55444. /**
  55445. * Sets the Default image processing configuration used either in the this material.
  55446. *
  55447. * If sets to null, the scene one is in use.
  55448. */
  55449. imageProcessingConfiguration: ImageProcessingConfiguration;
  55450. /**
  55451. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55452. */
  55453. attachedBlocks: NodeMaterialBlock[];
  55454. /**
  55455. * Create a new node based material
  55456. * @param name defines the material name
  55457. * @param scene defines the hosting scene
  55458. * @param options defines creation option
  55459. */
  55460. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55461. /**
  55462. * Gets the current class name of the material e.g. "NodeMaterial"
  55463. * @returns the class name
  55464. */
  55465. getClassName(): string;
  55466. /**
  55467. * Keep track of the image processing observer to allow dispose and replace.
  55468. */
  55469. private _imageProcessingObserver;
  55470. /**
  55471. * Attaches a new image processing configuration to the Standard Material.
  55472. * @param configuration
  55473. */
  55474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55475. /**
  55476. * Get a block by its name
  55477. * @param name defines the name of the block to retrieve
  55478. * @returns the required block or null if not found
  55479. */
  55480. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55481. /**
  55482. * Get a block by its name
  55483. * @param predicate defines the predicate used to find the good candidate
  55484. * @returns the required block or null if not found
  55485. */
  55486. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55487. /**
  55488. * Get an input block by its name
  55489. * @param predicate defines the predicate used to find the good candidate
  55490. * @returns the required input block or null if not found
  55491. */
  55492. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55493. /**
  55494. * Gets the list of input blocks attached to this material
  55495. * @returns an array of InputBlocks
  55496. */
  55497. getInputBlocks(): InputBlock[];
  55498. /**
  55499. * Adds a new optimizer to the list of optimizers
  55500. * @param optimizer defines the optimizers to add
  55501. * @returns the current material
  55502. */
  55503. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55504. /**
  55505. * Remove an optimizer from the list of optimizers
  55506. * @param optimizer defines the optimizers to remove
  55507. * @returns the current material
  55508. */
  55509. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55510. /**
  55511. * Add a new block to the list of output nodes
  55512. * @param node defines the node to add
  55513. * @returns the current material
  55514. */
  55515. addOutputNode(node: NodeMaterialBlock): this;
  55516. /**
  55517. * Remove a block from the list of root nodes
  55518. * @param node defines the node to remove
  55519. * @returns the current material
  55520. */
  55521. removeOutputNode(node: NodeMaterialBlock): this;
  55522. private _addVertexOutputNode;
  55523. private _removeVertexOutputNode;
  55524. private _addFragmentOutputNode;
  55525. private _removeFragmentOutputNode;
  55526. /**
  55527. * Specifies if the material will require alpha blending
  55528. * @returns a boolean specifying if alpha blending is needed
  55529. */
  55530. needAlphaBlending(): boolean;
  55531. /**
  55532. * Specifies if this material should be rendered in alpha test mode
  55533. * @returns a boolean specifying if an alpha test is needed.
  55534. */
  55535. needAlphaTesting(): boolean;
  55536. private _initializeBlock;
  55537. private _resetDualBlocks;
  55538. /**
  55539. * Build the material and generates the inner effect
  55540. * @param verbose defines if the build should log activity
  55541. */
  55542. build(verbose?: boolean): void;
  55543. /**
  55544. * Runs an otpimization phase to try to improve the shader code
  55545. */
  55546. optimize(): void;
  55547. private _prepareDefinesForAttributes;
  55548. /**
  55549. * Get if the submesh is ready to be used and all its information available.
  55550. * Child classes can use it to update shaders
  55551. * @param mesh defines the mesh to check
  55552. * @param subMesh defines which submesh to check
  55553. * @param useInstances specifies that instances should be used
  55554. * @returns a boolean indicating that the submesh is ready or not
  55555. */
  55556. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55557. /**
  55558. * Get a string representing the shaders built by the current node graph
  55559. */
  55560. readonly compiledShaders: string;
  55561. /**
  55562. * Binds the world matrix to the material
  55563. * @param world defines the world transformation matrix
  55564. */
  55565. bindOnlyWorldMatrix(world: Matrix): void;
  55566. /**
  55567. * Binds the submesh to this material by preparing the effect and shader to draw
  55568. * @param world defines the world transformation matrix
  55569. * @param mesh defines the mesh containing the submesh
  55570. * @param subMesh defines the submesh to bind the material to
  55571. */
  55572. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55573. /**
  55574. * Gets the active textures from the material
  55575. * @returns an array of textures
  55576. */
  55577. getActiveTextures(): BaseTexture[];
  55578. /**
  55579. * Gets the list of texture blocks
  55580. * @returns an array of texture blocks
  55581. */
  55582. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55583. /**
  55584. * Specifies if the material uses a texture
  55585. * @param texture defines the texture to check against the material
  55586. * @returns a boolean specifying if the material uses the texture
  55587. */
  55588. hasTexture(texture: BaseTexture): boolean;
  55589. /**
  55590. * Disposes the material
  55591. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55592. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55593. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55594. */
  55595. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55596. /** Creates the node editor window. */
  55597. private _createNodeEditor;
  55598. /**
  55599. * Launch the node material editor
  55600. * @param config Define the configuration of the editor
  55601. * @return a promise fulfilled when the node editor is visible
  55602. */
  55603. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55604. /**
  55605. * Clear the current material
  55606. */
  55607. clear(): void;
  55608. /**
  55609. * Clear the current material and set it to a default state
  55610. */
  55611. setToDefault(): void;
  55612. /**
  55613. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55614. * @param url defines the url to load from
  55615. * @returns a promise that will fullfil when the material is fully loaded
  55616. */
  55617. loadAsync(url: string): Promise<unknown>;
  55618. private _gatherBlocks;
  55619. /**
  55620. * Generate a string containing the code declaration required to create an equivalent of this material
  55621. * @returns a string
  55622. */
  55623. generateCode(): string;
  55624. /**
  55625. * Serializes this material in a JSON representation
  55626. * @returns the serialized material object
  55627. */
  55628. serialize(): any;
  55629. private _restoreConnections;
  55630. /**
  55631. * Clear the current graph and load a new one from a serialization object
  55632. * @param source defines the JSON representation of the material
  55633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55634. */
  55635. loadFromSerialization(source: any, rootUrl?: string): void;
  55636. /**
  55637. * Creates a node material from parsed material data
  55638. * @param source defines the JSON representation of the material
  55639. * @param scene defines the hosting scene
  55640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55641. * @returns a new node material
  55642. */
  55643. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55644. /**
  55645. * Creates a new node material set to default basic configuration
  55646. * @param name defines the name of the material
  55647. * @param scene defines the hosting scene
  55648. * @returns a new NodeMaterial
  55649. */
  55650. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55651. }
  55652. }
  55653. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55656. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55659. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55660. import { Effect } from "babylonjs/Materials/effect";
  55661. import { Mesh } from "babylonjs/Meshes/mesh";
  55662. import { Nullable } from "babylonjs/types";
  55663. import { Texture } from "babylonjs/Materials/Textures/texture";
  55664. import { Scene } from "babylonjs/scene";
  55665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55666. /**
  55667. * Block used to read a texture from a sampler
  55668. */
  55669. export class TextureBlock extends NodeMaterialBlock {
  55670. private _defineName;
  55671. private _linearDefineName;
  55672. private _samplerName;
  55673. private _transformedUVName;
  55674. private _textureTransformName;
  55675. private _textureInfoName;
  55676. private _mainUVName;
  55677. private _mainUVDefineName;
  55678. /**
  55679. * Gets or sets the texture associated with the node
  55680. */
  55681. texture: Nullable<Texture>;
  55682. /**
  55683. * Create a new TextureBlock
  55684. * @param name defines the block name
  55685. */
  55686. constructor(name: string);
  55687. /**
  55688. * Gets the current class name
  55689. * @returns the class name
  55690. */
  55691. getClassName(): string;
  55692. /**
  55693. * Gets the uv input component
  55694. */
  55695. readonly uv: NodeMaterialConnectionPoint;
  55696. /**
  55697. * Gets the rgba output component
  55698. */
  55699. readonly rgba: NodeMaterialConnectionPoint;
  55700. /**
  55701. * Gets the rgb output component
  55702. */
  55703. readonly rgb: NodeMaterialConnectionPoint;
  55704. /**
  55705. * Gets the r output component
  55706. */
  55707. readonly r: NodeMaterialConnectionPoint;
  55708. /**
  55709. * Gets the g output component
  55710. */
  55711. readonly g: NodeMaterialConnectionPoint;
  55712. /**
  55713. * Gets the b output component
  55714. */
  55715. readonly b: NodeMaterialConnectionPoint;
  55716. /**
  55717. * Gets the a output component
  55718. */
  55719. readonly a: NodeMaterialConnectionPoint;
  55720. readonly target: NodeMaterialBlockTargets;
  55721. autoConfigure(material: NodeMaterial): void;
  55722. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55724. isReady(): boolean;
  55725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55726. private readonly _isMixed;
  55727. private _injectVertexCode;
  55728. private _writeOutput;
  55729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55730. protected _dumpPropertiesCode(): string;
  55731. serialize(): any;
  55732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55733. }
  55734. }
  55735. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55738. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55739. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55740. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55741. import { Scene } from "babylonjs/scene";
  55742. /**
  55743. * Class used to store shared data between 2 NodeMaterialBuildState
  55744. */
  55745. export class NodeMaterialBuildStateSharedData {
  55746. /**
  55747. * Gets the list of emitted varyings
  55748. */
  55749. temps: string[];
  55750. /**
  55751. * Gets the list of emitted varyings
  55752. */
  55753. varyings: string[];
  55754. /**
  55755. * Gets the varying declaration string
  55756. */
  55757. varyingDeclaration: string;
  55758. /**
  55759. * Input blocks
  55760. */
  55761. inputBlocks: InputBlock[];
  55762. /**
  55763. * Input blocks
  55764. */
  55765. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55766. /**
  55767. * Bindable blocks (Blocks that need to set data to the effect)
  55768. */
  55769. bindableBlocks: NodeMaterialBlock[];
  55770. /**
  55771. * List of blocks that can provide a compilation fallback
  55772. */
  55773. blocksWithFallbacks: NodeMaterialBlock[];
  55774. /**
  55775. * List of blocks that can provide a define update
  55776. */
  55777. blocksWithDefines: NodeMaterialBlock[];
  55778. /**
  55779. * List of blocks that can provide a repeatable content
  55780. */
  55781. repeatableContentBlocks: NodeMaterialBlock[];
  55782. /**
  55783. * List of blocks that can provide a dynamic list of uniforms
  55784. */
  55785. dynamicUniformBlocks: NodeMaterialBlock[];
  55786. /**
  55787. * List of blocks that can block the isReady function for the material
  55788. */
  55789. blockingBlocks: NodeMaterialBlock[];
  55790. /**
  55791. * Gets the list of animated inputs
  55792. */
  55793. animatedInputs: InputBlock[];
  55794. /**
  55795. * Build Id used to avoid multiple recompilations
  55796. */
  55797. buildId: number;
  55798. /** List of emitted variables */
  55799. variableNames: {
  55800. [key: string]: number;
  55801. };
  55802. /** List of emitted defines */
  55803. defineNames: {
  55804. [key: string]: number;
  55805. };
  55806. /** Should emit comments? */
  55807. emitComments: boolean;
  55808. /** Emit build activity */
  55809. verbose: boolean;
  55810. /** Gets or sets the hosting scene */
  55811. scene: Scene;
  55812. /**
  55813. * Gets the compilation hints emitted at compilation time
  55814. */
  55815. hints: {
  55816. needWorldViewMatrix: boolean;
  55817. needWorldViewProjectionMatrix: boolean;
  55818. needAlphaBlending: boolean;
  55819. needAlphaTesting: boolean;
  55820. };
  55821. /**
  55822. * List of compilation checks
  55823. */
  55824. checks: {
  55825. emitVertex: boolean;
  55826. emitFragment: boolean;
  55827. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55828. };
  55829. /** Creates a new shared data */
  55830. constructor();
  55831. /**
  55832. * Emits console errors and exceptions if there is a failing check
  55833. */
  55834. emitErrors(): void;
  55835. }
  55836. }
  55837. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55838. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55839. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55840. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55841. /**
  55842. * Class used to store node based material build state
  55843. */
  55844. export class NodeMaterialBuildState {
  55845. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55846. supportUniformBuffers: boolean;
  55847. /**
  55848. * Gets the list of emitted attributes
  55849. */
  55850. attributes: string[];
  55851. /**
  55852. * Gets the list of emitted uniforms
  55853. */
  55854. uniforms: string[];
  55855. /**
  55856. * Gets the list of emitted constants
  55857. */
  55858. constants: string[];
  55859. /**
  55860. * Gets the list of emitted samplers
  55861. */
  55862. samplers: string[];
  55863. /**
  55864. * Gets the list of emitted functions
  55865. */
  55866. functions: {
  55867. [key: string]: string;
  55868. };
  55869. /**
  55870. * Gets the list of emitted extensions
  55871. */
  55872. extensions: {
  55873. [key: string]: string;
  55874. };
  55875. /**
  55876. * Gets the target of the compilation state
  55877. */
  55878. target: NodeMaterialBlockTargets;
  55879. /**
  55880. * Gets the list of emitted counters
  55881. */
  55882. counters: {
  55883. [key: string]: number;
  55884. };
  55885. /**
  55886. * Shared data between multiple NodeMaterialBuildState instances
  55887. */
  55888. sharedData: NodeMaterialBuildStateSharedData;
  55889. /** @hidden */
  55890. _vertexState: NodeMaterialBuildState;
  55891. /** @hidden */
  55892. _attributeDeclaration: string;
  55893. /** @hidden */
  55894. _uniformDeclaration: string;
  55895. /** @hidden */
  55896. _constantDeclaration: string;
  55897. /** @hidden */
  55898. _samplerDeclaration: string;
  55899. /** @hidden */
  55900. _varyingTransfer: string;
  55901. private _repeatableContentAnchorIndex;
  55902. /** @hidden */
  55903. _builtCompilationString: string;
  55904. /**
  55905. * Gets the emitted compilation strings
  55906. */
  55907. compilationString: string;
  55908. /**
  55909. * Finalize the compilation strings
  55910. * @param state defines the current compilation state
  55911. */
  55912. finalize(state: NodeMaterialBuildState): void;
  55913. /** @hidden */
  55914. readonly _repeatableContentAnchor: string;
  55915. /** @hidden */
  55916. _getFreeVariableName(prefix: string): string;
  55917. /** @hidden */
  55918. _getFreeDefineName(prefix: string): string;
  55919. /** @hidden */
  55920. _excludeVariableName(name: string): void;
  55921. /** @hidden */
  55922. _emit2DSampler(name: string): void;
  55923. /** @hidden */
  55924. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55925. /** @hidden */
  55926. _emitExtension(name: string, extension: string): void;
  55927. /** @hidden */
  55928. _emitFunction(name: string, code: string, comments: string): void;
  55929. /** @hidden */
  55930. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55931. replaceStrings?: {
  55932. search: RegExp;
  55933. replace: string;
  55934. }[];
  55935. repeatKey?: string;
  55936. }): string;
  55937. /** @hidden */
  55938. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55939. repeatKey?: string;
  55940. removeAttributes?: boolean;
  55941. removeUniforms?: boolean;
  55942. removeVaryings?: boolean;
  55943. removeIfDef?: boolean;
  55944. replaceStrings?: {
  55945. search: RegExp;
  55946. replace: string;
  55947. }[];
  55948. }, storeKey?: string): void;
  55949. /** @hidden */
  55950. _registerTempVariable(name: string): boolean;
  55951. /** @hidden */
  55952. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55953. /** @hidden */
  55954. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55955. /** @hidden */
  55956. _emitFloat(value: number): string;
  55957. }
  55958. }
  55959. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55960. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55962. import { Nullable } from "babylonjs/types";
  55963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55964. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55965. import { Effect } from "babylonjs/Materials/effect";
  55966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55967. import { Mesh } from "babylonjs/Meshes/mesh";
  55968. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55969. import { Scene } from "babylonjs/scene";
  55970. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55971. /**
  55972. * Defines a block that can be used inside a node based material
  55973. */
  55974. export class NodeMaterialBlock {
  55975. private _buildId;
  55976. private _buildTarget;
  55977. private _target;
  55978. private _isFinalMerger;
  55979. private _isInput;
  55980. /** @hidden */
  55981. _codeVariableName: string;
  55982. /** @hidden */
  55983. _inputs: NodeMaterialConnectionPoint[];
  55984. /** @hidden */
  55985. _outputs: NodeMaterialConnectionPoint[];
  55986. /** @hidden */
  55987. _preparationId: number;
  55988. /**
  55989. * Gets or sets the name of the block
  55990. */
  55991. name: string;
  55992. /**
  55993. * Gets or sets the unique id of the node
  55994. */
  55995. uniqueId: number;
  55996. /**
  55997. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55998. */
  55999. readonly isFinalMerger: boolean;
  56000. /**
  56001. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56002. */
  56003. readonly isInput: boolean;
  56004. /**
  56005. * Gets or sets the build Id
  56006. */
  56007. buildId: number;
  56008. /**
  56009. * Gets or sets the target of the block
  56010. */
  56011. target: NodeMaterialBlockTargets;
  56012. /**
  56013. * Gets the list of input points
  56014. */
  56015. readonly inputs: NodeMaterialConnectionPoint[];
  56016. /** Gets the list of output points */
  56017. readonly outputs: NodeMaterialConnectionPoint[];
  56018. /**
  56019. * Find an input by its name
  56020. * @param name defines the name of the input to look for
  56021. * @returns the input or null if not found
  56022. */
  56023. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56024. /**
  56025. * Find an output by its name
  56026. * @param name defines the name of the outputto look for
  56027. * @returns the output or null if not found
  56028. */
  56029. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56030. /**
  56031. * Creates a new NodeMaterialBlock
  56032. * @param name defines the block name
  56033. * @param target defines the target of that block (Vertex by default)
  56034. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56035. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56036. */
  56037. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56038. /**
  56039. * Initialize the block and prepare the context for build
  56040. * @param state defines the state that will be used for the build
  56041. */
  56042. initialize(state: NodeMaterialBuildState): void;
  56043. /**
  56044. * Bind data to effect. Will only be called for blocks with isBindable === true
  56045. * @param effect defines the effect to bind data to
  56046. * @param nodeMaterial defines the hosting NodeMaterial
  56047. * @param mesh defines the mesh that will be rendered
  56048. */
  56049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56050. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56051. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56052. protected _writeFloat(value: number): string;
  56053. /**
  56054. * Gets the current class name e.g. "NodeMaterialBlock"
  56055. * @returns the class name
  56056. */
  56057. getClassName(): string;
  56058. /**
  56059. * Register a new input. Must be called inside a block constructor
  56060. * @param name defines the connection point name
  56061. * @param type defines the connection point type
  56062. * @param isOptional defines a boolean indicating that this input can be omitted
  56063. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56064. * @returns the current block
  56065. */
  56066. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56067. /**
  56068. * Register a new output. Must be called inside a block constructor
  56069. * @param name defines the connection point name
  56070. * @param type defines the connection point type
  56071. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56072. * @returns the current block
  56073. */
  56074. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56075. /**
  56076. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56077. * @param forOutput defines an optional connection point to check compatibility with
  56078. * @returns the first available input or null
  56079. */
  56080. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56081. /**
  56082. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56083. * @param forBlock defines an optional block to check compatibility with
  56084. * @returns the first available input or null
  56085. */
  56086. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56087. /**
  56088. * Gets the sibling of the given output
  56089. * @param current defines the current output
  56090. * @returns the next output in the list or null
  56091. */
  56092. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56093. /**
  56094. * Connect current block with another block
  56095. * @param other defines the block to connect with
  56096. * @param options define the various options to help pick the right connections
  56097. * @returns the current block
  56098. */
  56099. connectTo(other: NodeMaterialBlock, options?: {
  56100. input?: string;
  56101. output?: string;
  56102. outputSwizzle?: string;
  56103. }): this | undefined;
  56104. protected _buildBlock(state: NodeMaterialBuildState): void;
  56105. /**
  56106. * Add uniforms, samplers and uniform buffers at compilation time
  56107. * @param state defines the state to update
  56108. * @param nodeMaterial defines the node material requesting the update
  56109. * @param defines defines the material defines to update
  56110. * @param uniformBuffers defines the list of uniform buffer names
  56111. */
  56112. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56113. /**
  56114. * Add potential fallbacks if shader compilation fails
  56115. * @param mesh defines the mesh to be rendered
  56116. * @param fallbacks defines the current prioritized list of fallbacks
  56117. */
  56118. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56119. /**
  56120. * Initialize defines for shader compilation
  56121. * @param mesh defines the mesh to be rendered
  56122. * @param nodeMaterial defines the node material requesting the update
  56123. * @param defines defines the material defines to update
  56124. * @param useInstances specifies that instances should be used
  56125. */
  56126. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56127. /**
  56128. * Update defines for shader compilation
  56129. * @param mesh defines the mesh to be rendered
  56130. * @param nodeMaterial defines the node material requesting the update
  56131. * @param defines defines the material defines to update
  56132. * @param useInstances specifies that instances should be used
  56133. */
  56134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56135. /**
  56136. * Lets the block try to connect some inputs automatically
  56137. * @param material defines the hosting NodeMaterial
  56138. */
  56139. autoConfigure(material: NodeMaterial): void;
  56140. /**
  56141. * Function called when a block is declared as repeatable content generator
  56142. * @param vertexShaderState defines the current compilation state for the vertex shader
  56143. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56144. * @param mesh defines the mesh to be rendered
  56145. * @param defines defines the material defines to update
  56146. */
  56147. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56148. /**
  56149. * Checks if the block is ready
  56150. * @param mesh defines the mesh to be rendered
  56151. * @param nodeMaterial defines the node material requesting the update
  56152. * @param defines defines the material defines to update
  56153. * @param useInstances specifies that instances should be used
  56154. * @returns true if the block is ready
  56155. */
  56156. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56157. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56158. private _processBuild;
  56159. /**
  56160. * Compile the current node and generate the shader code
  56161. * @param state defines the current compilation state (uniforms, samplers, current string)
  56162. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56163. * @returns true if already built
  56164. */
  56165. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56166. protected _inputRename(name: string): string;
  56167. protected _outputRename(name: string): string;
  56168. protected _dumpPropertiesCode(): string;
  56169. /** @hidden */
  56170. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56171. /**
  56172. * Clone the current block to a new identical block
  56173. * @param scene defines the hosting scene
  56174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56175. * @returns a copy of the current block
  56176. */
  56177. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56178. /**
  56179. * Serializes this block in a JSON representation
  56180. * @returns the serialized block object
  56181. */
  56182. serialize(): any;
  56183. /** @hidden */
  56184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56185. }
  56186. }
  56187. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56188. /**
  56189. * Enum defining the type of animations supported by InputBlock
  56190. */
  56191. export enum AnimatedInputBlockTypes {
  56192. /** No animation */
  56193. None = 0,
  56194. /** Time based animation. Will only work for floats */
  56195. Time = 1
  56196. }
  56197. }
  56198. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56200. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56201. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56202. import { Nullable } from "babylonjs/types";
  56203. import { Effect } from "babylonjs/Materials/effect";
  56204. import { Matrix } from "babylonjs/Maths/math.vector";
  56205. import { Scene } from "babylonjs/scene";
  56206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56208. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56209. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56210. /**
  56211. * Block used to expose an input value
  56212. */
  56213. export class InputBlock extends NodeMaterialBlock {
  56214. private _mode;
  56215. private _associatedVariableName;
  56216. private _storedValue;
  56217. private _valueCallback;
  56218. private _type;
  56219. private _animationType;
  56220. /** Gets or set a value used to limit the range of float values */
  56221. min: number;
  56222. /** Gets or set a value used to limit the range of float values */
  56223. max: number;
  56224. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56225. matrixMode: number;
  56226. /** @hidden */
  56227. _systemValue: Nullable<NodeMaterialSystemValues>;
  56228. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56229. visibleInInspector: boolean;
  56230. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56231. isConstant: boolean;
  56232. /**
  56233. * Gets or sets the connection point type (default is float)
  56234. */
  56235. readonly type: NodeMaterialBlockConnectionPointTypes;
  56236. /**
  56237. * Creates a new InputBlock
  56238. * @param name defines the block name
  56239. * @param target defines the target of that block (Vertex by default)
  56240. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56241. */
  56242. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56243. /**
  56244. * Gets the output component
  56245. */
  56246. readonly output: NodeMaterialConnectionPoint;
  56247. /**
  56248. * Set the source of this connection point to a vertex attribute
  56249. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56250. * @returns the current connection point
  56251. */
  56252. setAsAttribute(attributeName?: string): InputBlock;
  56253. /**
  56254. * Set the source of this connection point to a system value
  56255. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56256. * @returns the current connection point
  56257. */
  56258. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56259. /**
  56260. * Gets or sets the value of that point.
  56261. * Please note that this value will be ignored if valueCallback is defined
  56262. */
  56263. value: any;
  56264. /**
  56265. * Gets or sets a callback used to get the value of that point.
  56266. * Please note that setting this value will force the connection point to ignore the value property
  56267. */
  56268. valueCallback: () => any;
  56269. /**
  56270. * Gets or sets the associated variable name in the shader
  56271. */
  56272. associatedVariableName: string;
  56273. /** Gets or sets the type of animation applied to the input */
  56274. animationType: AnimatedInputBlockTypes;
  56275. /**
  56276. * Gets a boolean indicating that this connection point not defined yet
  56277. */
  56278. readonly isUndefined: boolean;
  56279. /**
  56280. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56281. * In this case the connection point name must be the name of the uniform to use.
  56282. * Can only be set on inputs
  56283. */
  56284. isUniform: boolean;
  56285. /**
  56286. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56287. * In this case the connection point name must be the name of the attribute to use
  56288. * Can only be set on inputs
  56289. */
  56290. isAttribute: boolean;
  56291. /**
  56292. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56293. * Can only be set on exit points
  56294. */
  56295. isVarying: boolean;
  56296. /**
  56297. * Gets a boolean indicating that the current connection point is a system value
  56298. */
  56299. readonly isSystemValue: boolean;
  56300. /**
  56301. * Gets or sets the current well known value or null if not defined as a system value
  56302. */
  56303. systemValue: Nullable<NodeMaterialSystemValues>;
  56304. /**
  56305. * Gets the current class name
  56306. * @returns the class name
  56307. */
  56308. getClassName(): string;
  56309. /**
  56310. * Animate the input if animationType !== None
  56311. * @param scene defines the rendering scene
  56312. */
  56313. animate(scene: Scene): void;
  56314. private _emitDefine;
  56315. initialize(state: NodeMaterialBuildState): void;
  56316. /**
  56317. * Set the input block to its default value (based on its type)
  56318. */
  56319. setDefaultValue(): void;
  56320. private _emitConstant;
  56321. private _emit;
  56322. /** @hidden */
  56323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56324. /** @hidden */
  56325. _transmit(effect: Effect, scene: Scene): void;
  56326. protected _buildBlock(state: NodeMaterialBuildState): void;
  56327. protected _dumpPropertiesCode(): string;
  56328. serialize(): any;
  56329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56330. }
  56331. }
  56332. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56333. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56334. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56335. import { Nullable } from "babylonjs/types";
  56336. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56338. /**
  56339. * Defines a connection point for a block
  56340. */
  56341. export class NodeMaterialConnectionPoint {
  56342. /** @hidden */
  56343. _ownerBlock: NodeMaterialBlock;
  56344. /** @hidden */
  56345. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56346. private _endpoints;
  56347. private _associatedVariableName;
  56348. /** @hidden */
  56349. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56350. /** @hidden */
  56351. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56352. private _type;
  56353. /** @hidden */
  56354. _enforceAssociatedVariableName: boolean;
  56355. /**
  56356. * Gets or sets the additional types supported by this connection point
  56357. */
  56358. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56359. /**
  56360. * Gets or sets the additional types excluded by this connection point
  56361. */
  56362. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56363. /**
  56364. * Gets or sets the associated variable name in the shader
  56365. */
  56366. associatedVariableName: string;
  56367. /**
  56368. * Gets or sets the connection point type (default is float)
  56369. */
  56370. type: NodeMaterialBlockConnectionPointTypes;
  56371. /**
  56372. * Gets or sets the connection point name
  56373. */
  56374. name: string;
  56375. /**
  56376. * Gets or sets a boolean indicating that this connection point can be omitted
  56377. */
  56378. isOptional: boolean;
  56379. /**
  56380. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56381. */
  56382. define: string;
  56383. /** Gets or sets the target of that connection point */
  56384. target: NodeMaterialBlockTargets;
  56385. /**
  56386. * Gets a boolean indicating that the current point is connected
  56387. */
  56388. readonly isConnected: boolean;
  56389. /**
  56390. * Gets a boolean indicating that the current point is connected to an input block
  56391. */
  56392. readonly isConnectedToInputBlock: boolean;
  56393. /**
  56394. * Gets a the connected input block (if any)
  56395. */
  56396. readonly connectInputBlock: Nullable<InputBlock>;
  56397. /** Get the other side of the connection (if any) */
  56398. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56399. /** Get the block that owns this connection point */
  56400. readonly ownerBlock: NodeMaterialBlock;
  56401. /** Get the block connected on the other side of this connection (if any) */
  56402. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56403. /** Get the block connected on the endpoints of this connection (if any) */
  56404. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56405. /** Gets the list of connected endpoints */
  56406. readonly endpoints: NodeMaterialConnectionPoint[];
  56407. /** Gets a boolean indicating if that output point is connected to at least one input */
  56408. readonly hasEndpoints: boolean;
  56409. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56410. readonly isConnectedInVertexShader: boolean;
  56411. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56412. readonly isConnectedInFragmentShader: boolean;
  56413. /**
  56414. * Creates a new connection point
  56415. * @param name defines the connection point name
  56416. * @param ownerBlock defines the block hosting this connection point
  56417. */
  56418. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56419. /**
  56420. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56421. * @returns the class name
  56422. */
  56423. getClassName(): string;
  56424. /**
  56425. * Gets an boolean indicating if the current point can be connected to another point
  56426. * @param connectionPoint defines the other connection point
  56427. * @returns true if the connection is possible
  56428. */
  56429. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56430. /**
  56431. * Connect this point to another connection point
  56432. * @param connectionPoint defines the other connection point
  56433. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56434. * @returns the current connection point
  56435. */
  56436. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56437. /**
  56438. * Disconnect this point from one of his endpoint
  56439. * @param endpoint defines the other connection point
  56440. * @returns the current connection point
  56441. */
  56442. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56443. /**
  56444. * Serializes this point in a JSON representation
  56445. * @returns the serialized point object
  56446. */
  56447. serialize(): any;
  56448. }
  56449. }
  56450. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56454. import { Mesh } from "babylonjs/Meshes/mesh";
  56455. import { Effect } from "babylonjs/Materials/effect";
  56456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56457. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56459. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56460. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56461. /**
  56462. * Block used to add support for vertex skinning (bones)
  56463. */
  56464. export class BonesBlock extends NodeMaterialBlock {
  56465. /**
  56466. * Creates a new BonesBlock
  56467. * @param name defines the block name
  56468. */
  56469. constructor(name: string);
  56470. /**
  56471. * Initialize the block and prepare the context for build
  56472. * @param state defines the state that will be used for the build
  56473. */
  56474. initialize(state: NodeMaterialBuildState): void;
  56475. /**
  56476. * Gets the current class name
  56477. * @returns the class name
  56478. */
  56479. getClassName(): string;
  56480. /**
  56481. * Gets the matrix indices input component
  56482. */
  56483. readonly matricesIndices: NodeMaterialConnectionPoint;
  56484. /**
  56485. * Gets the matrix weights input component
  56486. */
  56487. readonly matricesWeights: NodeMaterialConnectionPoint;
  56488. /**
  56489. * Gets the extra matrix indices input component
  56490. */
  56491. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the extra matrix weights input component
  56494. */
  56495. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56496. /**
  56497. * Gets the world input component
  56498. */
  56499. readonly world: NodeMaterialConnectionPoint;
  56500. /**
  56501. * Gets the output component
  56502. */
  56503. readonly output: NodeMaterialConnectionPoint;
  56504. autoConfigure(material: NodeMaterial): void;
  56505. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56508. protected _buildBlock(state: NodeMaterialBuildState): this;
  56509. }
  56510. }
  56511. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56516. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56517. /**
  56518. * Block used to add support for instances
  56519. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56520. */
  56521. export class InstancesBlock extends NodeMaterialBlock {
  56522. /**
  56523. * Creates a new InstancesBlock
  56524. * @param name defines the block name
  56525. */
  56526. constructor(name: string);
  56527. /**
  56528. * Gets the current class name
  56529. * @returns the class name
  56530. */
  56531. getClassName(): string;
  56532. /**
  56533. * Gets the first world row input component
  56534. */
  56535. readonly world0: NodeMaterialConnectionPoint;
  56536. /**
  56537. * Gets the second world row input component
  56538. */
  56539. readonly world1: NodeMaterialConnectionPoint;
  56540. /**
  56541. * Gets the third world row input component
  56542. */
  56543. readonly world2: NodeMaterialConnectionPoint;
  56544. /**
  56545. * Gets the forth world row input component
  56546. */
  56547. readonly world3: NodeMaterialConnectionPoint;
  56548. /**
  56549. * Gets the world input component
  56550. */
  56551. readonly world: NodeMaterialConnectionPoint;
  56552. /**
  56553. * Gets the output component
  56554. */
  56555. readonly output: NodeMaterialConnectionPoint;
  56556. autoConfigure(material: NodeMaterial): void;
  56557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56558. protected _buildBlock(state: NodeMaterialBuildState): this;
  56559. }
  56560. }
  56561. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56566. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56567. import { Effect } from "babylonjs/Materials/effect";
  56568. import { Mesh } from "babylonjs/Meshes/mesh";
  56569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56571. /**
  56572. * Block used to add morph targets support to vertex shader
  56573. */
  56574. export class MorphTargetsBlock extends NodeMaterialBlock {
  56575. private _repeatableContentAnchor;
  56576. private _repeatebleContentGenerated;
  56577. /**
  56578. * Create a new MorphTargetsBlock
  56579. * @param name defines the block name
  56580. */
  56581. constructor(name: string);
  56582. /**
  56583. * Gets the current class name
  56584. * @returns the class name
  56585. */
  56586. getClassName(): string;
  56587. /**
  56588. * Gets the position input component
  56589. */
  56590. readonly position: NodeMaterialConnectionPoint;
  56591. /**
  56592. * Gets the normal input component
  56593. */
  56594. readonly normal: NodeMaterialConnectionPoint;
  56595. /**
  56596. * Gets the tangent input component
  56597. */
  56598. readonly tangent: NodeMaterialConnectionPoint;
  56599. /**
  56600. * Gets the tangent input component
  56601. */
  56602. readonly uv: NodeMaterialConnectionPoint;
  56603. /**
  56604. * Gets the position output component
  56605. */
  56606. readonly positionOutput: NodeMaterialConnectionPoint;
  56607. /**
  56608. * Gets the normal output component
  56609. */
  56610. readonly normalOutput: NodeMaterialConnectionPoint;
  56611. /**
  56612. * Gets the tangent output component
  56613. */
  56614. readonly tangentOutput: NodeMaterialConnectionPoint;
  56615. /**
  56616. * Gets the tangent output component
  56617. */
  56618. readonly uvOutput: NodeMaterialConnectionPoint;
  56619. initialize(state: NodeMaterialBuildState): void;
  56620. autoConfigure(material: NodeMaterial): void;
  56621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56623. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56624. protected _buildBlock(state: NodeMaterialBuildState): this;
  56625. }
  56626. }
  56627. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56631. import { Nullable } from "babylonjs/types";
  56632. import { Scene } from "babylonjs/scene";
  56633. import { Effect } from "babylonjs/Materials/effect";
  56634. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56635. import { Mesh } from "babylonjs/Meshes/mesh";
  56636. import { Light } from "babylonjs/Lights/light";
  56637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56638. /**
  56639. * Block used to get data information from a light
  56640. */
  56641. export class LightInformationBlock extends NodeMaterialBlock {
  56642. private _lightDataUniformName;
  56643. private _lightColorUniformName;
  56644. private _lightTypeDefineName;
  56645. /**
  56646. * Gets or sets the light associated with this block
  56647. */
  56648. light: Nullable<Light>;
  56649. /**
  56650. * Creates a new LightInformationBlock
  56651. * @param name defines the block name
  56652. */
  56653. constructor(name: string);
  56654. /**
  56655. * Gets the current class name
  56656. * @returns the class name
  56657. */
  56658. getClassName(): string;
  56659. /**
  56660. * Gets the world position input component
  56661. */
  56662. readonly worldPosition: NodeMaterialConnectionPoint;
  56663. /**
  56664. * Gets the direction output component
  56665. */
  56666. readonly direction: NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the direction output component
  56669. */
  56670. readonly color: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the direction output component
  56673. */
  56674. readonly intensity: NodeMaterialConnectionPoint;
  56675. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56677. protected _buildBlock(state: NodeMaterialBuildState): this;
  56678. serialize(): any;
  56679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56680. }
  56681. }
  56682. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56683. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56684. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56685. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56686. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56687. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56688. }
  56689. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56695. import { Effect } from "babylonjs/Materials/effect";
  56696. import { Mesh } from "babylonjs/Meshes/mesh";
  56697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56698. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56699. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56700. /**
  56701. * Block used to add image processing support to fragment shader
  56702. */
  56703. export class ImageProcessingBlock extends NodeMaterialBlock {
  56704. /**
  56705. * Create a new ImageProcessingBlock
  56706. * @param name defines the block name
  56707. */
  56708. constructor(name: string);
  56709. /**
  56710. * Gets the current class name
  56711. * @returns the class name
  56712. */
  56713. getClassName(): string;
  56714. /**
  56715. * Gets the color input component
  56716. */
  56717. readonly color: NodeMaterialConnectionPoint;
  56718. /**
  56719. * Gets the output component
  56720. */
  56721. readonly output: NodeMaterialConnectionPoint;
  56722. /**
  56723. * Initialize the block and prepare the context for build
  56724. * @param state defines the state that will be used for the build
  56725. */
  56726. initialize(state: NodeMaterialBuildState): void;
  56727. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56730. protected _buildBlock(state: NodeMaterialBuildState): this;
  56731. }
  56732. }
  56733. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56739. import { Effect } from "babylonjs/Materials/effect";
  56740. import { Mesh } from "babylonjs/Meshes/mesh";
  56741. import { Scene } from "babylonjs/scene";
  56742. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56743. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56744. /**
  56745. * Block used to pertub normals based on a normal map
  56746. */
  56747. export class PerturbNormalBlock extends NodeMaterialBlock {
  56748. private _tangentSpaceParameterName;
  56749. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56750. invertX: boolean;
  56751. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56752. invertY: boolean;
  56753. /**
  56754. * Create a new PerturbNormalBlock
  56755. * @param name defines the block name
  56756. */
  56757. constructor(name: string);
  56758. /**
  56759. * Gets the current class name
  56760. * @returns the class name
  56761. */
  56762. getClassName(): string;
  56763. /**
  56764. * Gets the world position input component
  56765. */
  56766. readonly worldPosition: NodeMaterialConnectionPoint;
  56767. /**
  56768. * Gets the world normal input component
  56769. */
  56770. readonly worldNormal: NodeMaterialConnectionPoint;
  56771. /**
  56772. * Gets the uv input component
  56773. */
  56774. readonly uv: NodeMaterialConnectionPoint;
  56775. /**
  56776. * Gets the normal map color input component
  56777. */
  56778. readonly normalMapColor: NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the strength input component
  56781. */
  56782. readonly strength: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the output component
  56785. */
  56786. readonly output: NodeMaterialConnectionPoint;
  56787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56789. autoConfigure(material: NodeMaterial): void;
  56790. protected _buildBlock(state: NodeMaterialBuildState): this;
  56791. protected _dumpPropertiesCode(): string;
  56792. serialize(): any;
  56793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56794. }
  56795. }
  56796. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56797. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56798. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56799. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56800. /**
  56801. * Block used to discard a pixel if a value is smaller than a cutoff
  56802. */
  56803. export class DiscardBlock extends NodeMaterialBlock {
  56804. /**
  56805. * Create a new DiscardBlock
  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 color input component
  56816. */
  56817. readonly value: NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the cutoff input component
  56820. */
  56821. readonly cutoff: NodeMaterialConnectionPoint;
  56822. protected _buildBlock(state: NodeMaterialBuildState): this;
  56823. }
  56824. }
  56825. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56826. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56827. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56828. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56829. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56830. }
  56831. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56834. import { Mesh } from "babylonjs/Meshes/mesh";
  56835. import { Effect } from "babylonjs/Materials/effect";
  56836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56839. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56840. /**
  56841. * Block used to add support for scene fog
  56842. */
  56843. export class FogBlock extends NodeMaterialBlock {
  56844. private _fogDistanceName;
  56845. private _fogParameters;
  56846. /**
  56847. * Create a new FogBlock
  56848. * @param name defines the block name
  56849. */
  56850. constructor(name: string);
  56851. /**
  56852. * Gets the current class name
  56853. * @returns the class name
  56854. */
  56855. getClassName(): string;
  56856. /**
  56857. * Gets the world position input component
  56858. */
  56859. readonly worldPosition: NodeMaterialConnectionPoint;
  56860. /**
  56861. * Gets the view input component
  56862. */
  56863. readonly view: NodeMaterialConnectionPoint;
  56864. /**
  56865. * Gets the color input component
  56866. */
  56867. readonly input: NodeMaterialConnectionPoint;
  56868. /**
  56869. * Gets the fog color input component
  56870. */
  56871. readonly fogColor: NodeMaterialConnectionPoint;
  56872. /**
  56873. * Gets the output component
  56874. */
  56875. readonly output: NodeMaterialConnectionPoint;
  56876. autoConfigure(material: NodeMaterial): void;
  56877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56879. protected _buildBlock(state: NodeMaterialBuildState): this;
  56880. }
  56881. }
  56882. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56885. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56887. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56888. import { Effect } from "babylonjs/Materials/effect";
  56889. import { Mesh } from "babylonjs/Meshes/mesh";
  56890. import { Light } from "babylonjs/Lights/light";
  56891. import { Nullable } from "babylonjs/types";
  56892. import { Scene } from "babylonjs/scene";
  56893. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56894. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56895. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56896. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56897. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56898. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56899. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56900. /**
  56901. * Block used to add light in the fragment shader
  56902. */
  56903. export class LightBlock extends NodeMaterialBlock {
  56904. private _lightId;
  56905. /**
  56906. * Gets or sets the light associated with this block
  56907. */
  56908. light: Nullable<Light>;
  56909. /**
  56910. * Create a new LightBlock
  56911. * @param name defines the block name
  56912. */
  56913. constructor(name: string);
  56914. /**
  56915. * Gets the current class name
  56916. * @returns the class name
  56917. */
  56918. getClassName(): string;
  56919. /**
  56920. * Gets the world position input component
  56921. */
  56922. readonly worldPosition: NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the world normal input component
  56925. */
  56926. readonly worldNormal: NodeMaterialConnectionPoint;
  56927. /**
  56928. * Gets the camera (or eye) position component
  56929. */
  56930. readonly cameraPosition: NodeMaterialConnectionPoint;
  56931. /**
  56932. * Gets the glossiness component
  56933. */
  56934. readonly glossiness: NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the glossinness power component
  56937. */
  56938. readonly glossPower: NodeMaterialConnectionPoint;
  56939. /**
  56940. * Gets the diffuse color component
  56941. */
  56942. readonly diffuseColor: NodeMaterialConnectionPoint;
  56943. /**
  56944. * Gets the specular color component
  56945. */
  56946. readonly specularColor: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the diffuse output component
  56949. */
  56950. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the specular output component
  56953. */
  56954. readonly specularOutput: NodeMaterialConnectionPoint;
  56955. autoConfigure(material: NodeMaterial): void;
  56956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56957. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56959. private _injectVertexCode;
  56960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56961. serialize(): any;
  56962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56963. }
  56964. }
  56965. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56966. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56967. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56968. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56969. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56970. }
  56971. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56972. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56973. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56974. }
  56975. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56979. /**
  56980. * Block used to multiply 2 values
  56981. */
  56982. export class MultiplyBlock extends NodeMaterialBlock {
  56983. /**
  56984. * Creates a new MultiplyBlock
  56985. * @param name defines the block name
  56986. */
  56987. constructor(name: string);
  56988. /**
  56989. * Gets the current class name
  56990. * @returns the class name
  56991. */
  56992. getClassName(): string;
  56993. /**
  56994. * Gets the left operand input component
  56995. */
  56996. readonly left: NodeMaterialConnectionPoint;
  56997. /**
  56998. * Gets the right operand input component
  56999. */
  57000. readonly right: NodeMaterialConnectionPoint;
  57001. /**
  57002. * Gets the output component
  57003. */
  57004. readonly output: NodeMaterialConnectionPoint;
  57005. protected _buildBlock(state: NodeMaterialBuildState): this;
  57006. }
  57007. }
  57008. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57012. /**
  57013. * Block used to add 2 vectors
  57014. */
  57015. export class AddBlock extends NodeMaterialBlock {
  57016. /**
  57017. * Creates a new AddBlock
  57018. * @param name defines the block name
  57019. */
  57020. constructor(name: string);
  57021. /**
  57022. * Gets the current class name
  57023. * @returns the class name
  57024. */
  57025. getClassName(): string;
  57026. /**
  57027. * Gets the left operand input component
  57028. */
  57029. readonly left: NodeMaterialConnectionPoint;
  57030. /**
  57031. * Gets the right operand input component
  57032. */
  57033. readonly right: NodeMaterialConnectionPoint;
  57034. /**
  57035. * Gets the output component
  57036. */
  57037. readonly output: NodeMaterialConnectionPoint;
  57038. protected _buildBlock(state: NodeMaterialBuildState): this;
  57039. }
  57040. }
  57041. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57045. /**
  57046. * Block used to scale a vector by a float
  57047. */
  57048. export class ScaleBlock extends NodeMaterialBlock {
  57049. /**
  57050. * Creates a new ScaleBlock
  57051. * @param name defines the block name
  57052. */
  57053. constructor(name: string);
  57054. /**
  57055. * Gets the current class name
  57056. * @returns the class name
  57057. */
  57058. getClassName(): string;
  57059. /**
  57060. * Gets the input component
  57061. */
  57062. readonly input: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the factor input component
  57065. */
  57066. readonly factor: NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the output component
  57069. */
  57070. readonly output: NodeMaterialConnectionPoint;
  57071. protected _buildBlock(state: NodeMaterialBuildState): this;
  57072. }
  57073. }
  57074. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57078. import { Scene } from "babylonjs/scene";
  57079. /**
  57080. * Block used to clamp a float
  57081. */
  57082. export class ClampBlock extends NodeMaterialBlock {
  57083. /** Gets or sets the minimum range */
  57084. minimum: number;
  57085. /** Gets or sets the maximum range */
  57086. maximum: number;
  57087. /**
  57088. * Creates a new ClampBlock
  57089. * @param name defines the block name
  57090. */
  57091. constructor(name: string);
  57092. /**
  57093. * Gets the current class name
  57094. * @returns the class name
  57095. */
  57096. getClassName(): string;
  57097. /**
  57098. * Gets the value input component
  57099. */
  57100. readonly value: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the output component
  57103. */
  57104. readonly output: NodeMaterialConnectionPoint;
  57105. protected _buildBlock(state: NodeMaterialBuildState): this;
  57106. protected _dumpPropertiesCode(): string;
  57107. serialize(): any;
  57108. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57109. }
  57110. }
  57111. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57115. /**
  57116. * Block used to apply a cross product between 2 vectors
  57117. */
  57118. export class CrossBlock extends NodeMaterialBlock {
  57119. /**
  57120. * Creates a new CrossBlock
  57121. * @param name defines the block name
  57122. */
  57123. constructor(name: string);
  57124. /**
  57125. * Gets the current class name
  57126. * @returns the class name
  57127. */
  57128. getClassName(): string;
  57129. /**
  57130. * Gets the left operand input component
  57131. */
  57132. readonly left: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Gets the right operand input component
  57135. */
  57136. readonly right: NodeMaterialConnectionPoint;
  57137. /**
  57138. * Gets the output component
  57139. */
  57140. readonly output: NodeMaterialConnectionPoint;
  57141. protected _buildBlock(state: NodeMaterialBuildState): this;
  57142. }
  57143. }
  57144. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57148. /**
  57149. * Block used to apply a dot product between 2 vectors
  57150. */
  57151. export class DotBlock extends NodeMaterialBlock {
  57152. /**
  57153. * Creates a new DotBlock
  57154. * @param name defines the block name
  57155. */
  57156. constructor(name: string);
  57157. /**
  57158. * Gets the current class name
  57159. * @returns the class name
  57160. */
  57161. getClassName(): string;
  57162. /**
  57163. * Gets the left operand input component
  57164. */
  57165. readonly left: NodeMaterialConnectionPoint;
  57166. /**
  57167. * Gets the right operand input component
  57168. */
  57169. readonly right: NodeMaterialConnectionPoint;
  57170. /**
  57171. * Gets the output component
  57172. */
  57173. readonly output: NodeMaterialConnectionPoint;
  57174. protected _buildBlock(state: NodeMaterialBuildState): this;
  57175. }
  57176. }
  57177. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57181. import { Vector2 } from "babylonjs/Maths/math.vector";
  57182. import { Scene } from "babylonjs/scene";
  57183. /**
  57184. * Block used to remap a float from a range to a new one
  57185. */
  57186. export class RemapBlock extends NodeMaterialBlock {
  57187. /**
  57188. * Gets or sets the source range
  57189. */
  57190. sourceRange: Vector2;
  57191. /**
  57192. * Gets or sets the target range
  57193. */
  57194. targetRange: Vector2;
  57195. /**
  57196. * Creates a new RemapBlock
  57197. * @param name defines the block name
  57198. */
  57199. constructor(name: string);
  57200. /**
  57201. * Gets the current class name
  57202. * @returns the class name
  57203. */
  57204. getClassName(): string;
  57205. /**
  57206. * Gets the input component
  57207. */
  57208. readonly input: NodeMaterialConnectionPoint;
  57209. /**
  57210. * Gets the source min input component
  57211. */
  57212. readonly sourceMin: NodeMaterialConnectionPoint;
  57213. /**
  57214. * Gets the source max input component
  57215. */
  57216. readonly sourceMax: NodeMaterialConnectionPoint;
  57217. /**
  57218. * Gets the target min input component
  57219. */
  57220. readonly targetMin: NodeMaterialConnectionPoint;
  57221. /**
  57222. * Gets the target max input component
  57223. */
  57224. readonly targetMax: NodeMaterialConnectionPoint;
  57225. /**
  57226. * Gets the output component
  57227. */
  57228. readonly output: NodeMaterialConnectionPoint;
  57229. protected _buildBlock(state: NodeMaterialBuildState): this;
  57230. protected _dumpPropertiesCode(): string;
  57231. serialize(): any;
  57232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57233. }
  57234. }
  57235. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57239. /**
  57240. * Block used to normalize a vector
  57241. */
  57242. export class NormalizeBlock extends NodeMaterialBlock {
  57243. /**
  57244. * Creates a new NormalizeBlock
  57245. * @param name defines the block name
  57246. */
  57247. constructor(name: string);
  57248. /**
  57249. * Gets the current class name
  57250. * @returns the class name
  57251. */
  57252. getClassName(): string;
  57253. /**
  57254. * Gets the input component
  57255. */
  57256. readonly input: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the output component
  57259. */
  57260. readonly output: NodeMaterialConnectionPoint;
  57261. protected _buildBlock(state: NodeMaterialBuildState): this;
  57262. }
  57263. }
  57264. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57268. import { Scene } from "babylonjs/scene";
  57269. /**
  57270. * Operations supported by the Trigonometry block
  57271. */
  57272. export enum TrigonometryBlockOperations {
  57273. /** Cos */
  57274. Cos = 0,
  57275. /** Sin */
  57276. Sin = 1,
  57277. /** Abs */
  57278. Abs = 2,
  57279. /** Exp */
  57280. Exp = 3,
  57281. /** Exp2 */
  57282. Exp2 = 4,
  57283. /** Round */
  57284. Round = 5,
  57285. /** Floor */
  57286. Floor = 6,
  57287. /** Ceiling */
  57288. Ceiling = 7,
  57289. /** Square root */
  57290. Sqrt = 8,
  57291. /** Log */
  57292. Log = 9,
  57293. /** Tangent */
  57294. Tan = 10,
  57295. /** Arc tangent */
  57296. ArcTan = 11,
  57297. /** Arc cosinus */
  57298. ArcCos = 12,
  57299. /** Arc sinus */
  57300. ArcSin = 13,
  57301. /** Fraction */
  57302. Fract = 14,
  57303. /** Sign */
  57304. Sign = 15,
  57305. /** To radians (from degrees) */
  57306. Radians = 16,
  57307. /** To degrees (from radians) */
  57308. Degrees = 17
  57309. }
  57310. /**
  57311. * Block used to apply trigonometry operation to floats
  57312. */
  57313. export class TrigonometryBlock extends NodeMaterialBlock {
  57314. /**
  57315. * Gets or sets the operation applied by the block
  57316. */
  57317. operation: TrigonometryBlockOperations;
  57318. /**
  57319. * Creates a new TrigonometryBlock
  57320. * @param name defines the block name
  57321. */
  57322. constructor(name: string);
  57323. /**
  57324. * Gets the current class name
  57325. * @returns the class name
  57326. */
  57327. getClassName(): string;
  57328. /**
  57329. * Gets the input component
  57330. */
  57331. readonly input: NodeMaterialConnectionPoint;
  57332. /**
  57333. * Gets the output component
  57334. */
  57335. readonly output: NodeMaterialConnectionPoint;
  57336. protected _buildBlock(state: NodeMaterialBuildState): this;
  57337. serialize(): any;
  57338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57339. }
  57340. }
  57341. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57345. /**
  57346. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57347. */
  57348. export class ColorMergerBlock extends NodeMaterialBlock {
  57349. /**
  57350. * Create a new ColorMergerBlock
  57351. * @param name defines the block name
  57352. */
  57353. constructor(name: string);
  57354. /**
  57355. * Gets the current class name
  57356. * @returns the class name
  57357. */
  57358. getClassName(): string;
  57359. /**
  57360. * Gets the r component (input)
  57361. */
  57362. readonly r: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the g component (input)
  57365. */
  57366. readonly g: NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the b component (input)
  57369. */
  57370. readonly b: NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the a component (input)
  57373. */
  57374. readonly a: NodeMaterialConnectionPoint;
  57375. /**
  57376. * Gets the rgba component (output)
  57377. */
  57378. readonly rgba: NodeMaterialConnectionPoint;
  57379. /**
  57380. * Gets the rgb component (output)
  57381. */
  57382. readonly rgb: NodeMaterialConnectionPoint;
  57383. protected _buildBlock(state: NodeMaterialBuildState): this;
  57384. }
  57385. }
  57386. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57390. /**
  57391. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57392. */
  57393. export class VectorMergerBlock extends NodeMaterialBlock {
  57394. /**
  57395. * Create a new VectorMergerBlock
  57396. * @param name defines the block name
  57397. */
  57398. constructor(name: string);
  57399. /**
  57400. * Gets the current class name
  57401. * @returns the class name
  57402. */
  57403. getClassName(): string;
  57404. /**
  57405. * Gets the x component (input)
  57406. */
  57407. readonly x: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the y component (input)
  57410. */
  57411. readonly y: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the z component (input)
  57414. */
  57415. readonly z: NodeMaterialConnectionPoint;
  57416. /**
  57417. * Gets the w component (input)
  57418. */
  57419. readonly w: NodeMaterialConnectionPoint;
  57420. /**
  57421. * Gets the xyzw component (output)
  57422. */
  57423. readonly xyzw: NodeMaterialConnectionPoint;
  57424. /**
  57425. * Gets the xyz component (output)
  57426. */
  57427. readonly xyz: NodeMaterialConnectionPoint;
  57428. /**
  57429. * Gets the xy component (output)
  57430. */
  57431. readonly xy: NodeMaterialConnectionPoint;
  57432. protected _buildBlock(state: NodeMaterialBuildState): this;
  57433. }
  57434. }
  57435. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57439. /**
  57440. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57441. */
  57442. export class ColorSplitterBlock extends NodeMaterialBlock {
  57443. /**
  57444. * Create a new ColorSplitterBlock
  57445. * @param name defines the block name
  57446. */
  57447. constructor(name: string);
  57448. /**
  57449. * Gets the current class name
  57450. * @returns the class name
  57451. */
  57452. getClassName(): string;
  57453. /**
  57454. * Gets the rgba component (input)
  57455. */
  57456. readonly rgba: NodeMaterialConnectionPoint;
  57457. /**
  57458. * Gets the rgb component (input)
  57459. */
  57460. readonly rgbIn: NodeMaterialConnectionPoint;
  57461. /**
  57462. * Gets the rgb component (output)
  57463. */
  57464. readonly rgbOut: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the r component (output)
  57467. */
  57468. readonly r: NodeMaterialConnectionPoint;
  57469. /**
  57470. * Gets the g component (output)
  57471. */
  57472. readonly g: NodeMaterialConnectionPoint;
  57473. /**
  57474. * Gets the b component (output)
  57475. */
  57476. readonly b: NodeMaterialConnectionPoint;
  57477. /**
  57478. * Gets the a component (output)
  57479. */
  57480. readonly a: NodeMaterialConnectionPoint;
  57481. protected _inputRename(name: string): string;
  57482. protected _outputRename(name: string): string;
  57483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57484. }
  57485. }
  57486. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57490. /**
  57491. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57492. */
  57493. export class VectorSplitterBlock extends NodeMaterialBlock {
  57494. /**
  57495. * Create a new VectorSplitterBlock
  57496. * @param name defines the block name
  57497. */
  57498. constructor(name: string);
  57499. /**
  57500. * Gets the current class name
  57501. * @returns the class name
  57502. */
  57503. getClassName(): string;
  57504. /**
  57505. * Gets the xyzw component (input)
  57506. */
  57507. readonly xyzw: NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the xyz component (input)
  57510. */
  57511. readonly xyzIn: NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the xy component (input)
  57514. */
  57515. readonly xyIn: NodeMaterialConnectionPoint;
  57516. /**
  57517. * Gets the xyz component (output)
  57518. */
  57519. readonly xyzOut: NodeMaterialConnectionPoint;
  57520. /**
  57521. * Gets the xy component (output)
  57522. */
  57523. readonly xyOut: NodeMaterialConnectionPoint;
  57524. /**
  57525. * Gets the x component (output)
  57526. */
  57527. readonly x: NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the y component (output)
  57530. */
  57531. readonly y: NodeMaterialConnectionPoint;
  57532. /**
  57533. * Gets the z component (output)
  57534. */
  57535. readonly z: NodeMaterialConnectionPoint;
  57536. /**
  57537. * Gets the w component (output)
  57538. */
  57539. readonly w: NodeMaterialConnectionPoint;
  57540. protected _inputRename(name: string): string;
  57541. protected _outputRename(name: string): string;
  57542. protected _buildBlock(state: NodeMaterialBuildState): this;
  57543. }
  57544. }
  57545. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57549. /**
  57550. * Block used to lerp between 2 values
  57551. */
  57552. export class LerpBlock extends NodeMaterialBlock {
  57553. /**
  57554. * Creates a new LerpBlock
  57555. * @param name defines the block name
  57556. */
  57557. constructor(name: string);
  57558. /**
  57559. * Gets the current class name
  57560. * @returns the class name
  57561. */
  57562. getClassName(): string;
  57563. /**
  57564. * Gets the left operand input component
  57565. */
  57566. readonly left: NodeMaterialConnectionPoint;
  57567. /**
  57568. * Gets the right operand input component
  57569. */
  57570. readonly right: NodeMaterialConnectionPoint;
  57571. /**
  57572. * Gets the gradient operand input component
  57573. */
  57574. readonly gradient: NodeMaterialConnectionPoint;
  57575. /**
  57576. * Gets the output component
  57577. */
  57578. readonly output: NodeMaterialConnectionPoint;
  57579. protected _buildBlock(state: NodeMaterialBuildState): this;
  57580. }
  57581. }
  57582. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57586. /**
  57587. * Block used to divide 2 vectors
  57588. */
  57589. export class DivideBlock extends NodeMaterialBlock {
  57590. /**
  57591. * Creates a new DivideBlock
  57592. * @param name defines the block name
  57593. */
  57594. constructor(name: string);
  57595. /**
  57596. * Gets the current class name
  57597. * @returns the class name
  57598. */
  57599. getClassName(): string;
  57600. /**
  57601. * Gets the left operand input component
  57602. */
  57603. readonly left: NodeMaterialConnectionPoint;
  57604. /**
  57605. * Gets the right operand input component
  57606. */
  57607. readonly right: NodeMaterialConnectionPoint;
  57608. /**
  57609. * Gets the output component
  57610. */
  57611. readonly output: NodeMaterialConnectionPoint;
  57612. protected _buildBlock(state: NodeMaterialBuildState): this;
  57613. }
  57614. }
  57615. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57619. /**
  57620. * Block used to subtract 2 vectors
  57621. */
  57622. export class SubtractBlock extends NodeMaterialBlock {
  57623. /**
  57624. * Creates a new SubtractBlock
  57625. * @param name defines the block name
  57626. */
  57627. constructor(name: string);
  57628. /**
  57629. * Gets the current class name
  57630. * @returns the class name
  57631. */
  57632. getClassName(): string;
  57633. /**
  57634. * Gets the left operand input component
  57635. */
  57636. readonly left: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the right operand input component
  57639. */
  57640. readonly right: NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the output component
  57643. */
  57644. readonly output: NodeMaterialConnectionPoint;
  57645. protected _buildBlock(state: NodeMaterialBuildState): this;
  57646. }
  57647. }
  57648. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57652. /**
  57653. * Block used to step a value
  57654. */
  57655. export class StepBlock extends NodeMaterialBlock {
  57656. /**
  57657. * Creates a new StepBlock
  57658. * @param name defines the block name
  57659. */
  57660. constructor(name: string);
  57661. /**
  57662. * Gets the current class name
  57663. * @returns the class name
  57664. */
  57665. getClassName(): string;
  57666. /**
  57667. * Gets the value operand input component
  57668. */
  57669. readonly value: NodeMaterialConnectionPoint;
  57670. /**
  57671. * Gets the edge operand input component
  57672. */
  57673. readonly edge: NodeMaterialConnectionPoint;
  57674. /**
  57675. * Gets the output component
  57676. */
  57677. readonly output: NodeMaterialConnectionPoint;
  57678. protected _buildBlock(state: NodeMaterialBuildState): this;
  57679. }
  57680. }
  57681. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57685. /**
  57686. * Block used to get the opposite (1 - x) of a value
  57687. */
  57688. export class OneMinusBlock extends NodeMaterialBlock {
  57689. /**
  57690. * Creates a new OneMinusBlock
  57691. * @param name defines the block name
  57692. */
  57693. constructor(name: string);
  57694. /**
  57695. * Gets the current class name
  57696. * @returns the class name
  57697. */
  57698. getClassName(): string;
  57699. /**
  57700. * Gets the input component
  57701. */
  57702. readonly input: NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the output component
  57705. */
  57706. readonly output: NodeMaterialConnectionPoint;
  57707. protected _buildBlock(state: NodeMaterialBuildState): this;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57714. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57715. /**
  57716. * Block used to get the view direction
  57717. */
  57718. export class ViewDirectionBlock extends NodeMaterialBlock {
  57719. /**
  57720. * Creates a new ViewDirectionBlock
  57721. * @param name defines the block name
  57722. */
  57723. constructor(name: string);
  57724. /**
  57725. * Gets the current class name
  57726. * @returns the class name
  57727. */
  57728. getClassName(): string;
  57729. /**
  57730. * Gets the world position component
  57731. */
  57732. readonly worldPosition: NodeMaterialConnectionPoint;
  57733. /**
  57734. * Gets the camera position component
  57735. */
  57736. readonly cameraPosition: NodeMaterialConnectionPoint;
  57737. /**
  57738. * Gets the output component
  57739. */
  57740. readonly output: NodeMaterialConnectionPoint;
  57741. autoConfigure(material: NodeMaterial): void;
  57742. protected _buildBlock(state: NodeMaterialBuildState): this;
  57743. }
  57744. }
  57745. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57749. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57750. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57751. /**
  57752. * Block used to compute fresnel value
  57753. */
  57754. export class FresnelBlock extends NodeMaterialBlock {
  57755. /**
  57756. * Create a new FresnelBlock
  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 world normal input component
  57767. */
  57768. readonly worldNormal: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the view direction input component
  57771. */
  57772. readonly viewDirection: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the bias input component
  57775. */
  57776. readonly bias: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the camera (or eye) position component
  57779. */
  57780. readonly power: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the fresnel output component
  57783. */
  57784. readonly fresnel: NodeMaterialConnectionPoint;
  57785. autoConfigure(material: NodeMaterial): void;
  57786. protected _buildBlock(state: NodeMaterialBuildState): this;
  57787. }
  57788. }
  57789. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57793. /**
  57794. * Block used to get the max of 2 values
  57795. */
  57796. export class MaxBlock extends NodeMaterialBlock {
  57797. /**
  57798. * Creates a new MaxBlock
  57799. * @param name defines the block name
  57800. */
  57801. constructor(name: string);
  57802. /**
  57803. * Gets the current class name
  57804. * @returns the class name
  57805. */
  57806. getClassName(): string;
  57807. /**
  57808. * Gets the left operand input component
  57809. */
  57810. readonly left: NodeMaterialConnectionPoint;
  57811. /**
  57812. * Gets the right operand input component
  57813. */
  57814. readonly right: NodeMaterialConnectionPoint;
  57815. /**
  57816. * Gets the output component
  57817. */
  57818. readonly output: NodeMaterialConnectionPoint;
  57819. protected _buildBlock(state: NodeMaterialBuildState): this;
  57820. }
  57821. }
  57822. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57826. /**
  57827. * Block used to get the min of 2 values
  57828. */
  57829. export class MinBlock extends NodeMaterialBlock {
  57830. /**
  57831. * Creates a new MinBlock
  57832. * @param name defines the block name
  57833. */
  57834. constructor(name: string);
  57835. /**
  57836. * Gets the current class name
  57837. * @returns the class name
  57838. */
  57839. getClassName(): string;
  57840. /**
  57841. * Gets the left operand input component
  57842. */
  57843. readonly left: NodeMaterialConnectionPoint;
  57844. /**
  57845. * Gets the right operand input component
  57846. */
  57847. readonly right: NodeMaterialConnectionPoint;
  57848. /**
  57849. * Gets the output component
  57850. */
  57851. readonly output: NodeMaterialConnectionPoint;
  57852. protected _buildBlock(state: NodeMaterialBuildState): this;
  57853. }
  57854. }
  57855. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57859. /**
  57860. * Block used to get the distance between 2 values
  57861. */
  57862. export class DistanceBlock extends NodeMaterialBlock {
  57863. /**
  57864. * Creates a new DistanceBlock
  57865. * @param name defines the block name
  57866. */
  57867. constructor(name: string);
  57868. /**
  57869. * Gets the current class name
  57870. * @returns the class name
  57871. */
  57872. getClassName(): string;
  57873. /**
  57874. * Gets the left operand input component
  57875. */
  57876. readonly left: NodeMaterialConnectionPoint;
  57877. /**
  57878. * Gets the right operand input component
  57879. */
  57880. readonly right: NodeMaterialConnectionPoint;
  57881. /**
  57882. * Gets the output component
  57883. */
  57884. readonly output: NodeMaterialConnectionPoint;
  57885. protected _buildBlock(state: NodeMaterialBuildState): this;
  57886. }
  57887. }
  57888. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57892. /**
  57893. * Block used to get the length of a vector
  57894. */
  57895. export class LengthBlock extends NodeMaterialBlock {
  57896. /**
  57897. * Creates a new LengthBlock
  57898. * @param name defines the block name
  57899. */
  57900. constructor(name: string);
  57901. /**
  57902. * Gets the current class name
  57903. * @returns the class name
  57904. */
  57905. getClassName(): string;
  57906. /**
  57907. * Gets the value input component
  57908. */
  57909. readonly value: NodeMaterialConnectionPoint;
  57910. /**
  57911. * Gets the output component
  57912. */
  57913. readonly output: NodeMaterialConnectionPoint;
  57914. protected _buildBlock(state: NodeMaterialBuildState): this;
  57915. }
  57916. }
  57917. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57921. /**
  57922. * Block used to get negative version of a value (i.e. x * -1)
  57923. */
  57924. export class NegateBlock extends NodeMaterialBlock {
  57925. /**
  57926. * Creates a new NegateBlock
  57927. * @param name defines the block name
  57928. */
  57929. constructor(name: string);
  57930. /**
  57931. * Gets the current class name
  57932. * @returns the class name
  57933. */
  57934. getClassName(): string;
  57935. /**
  57936. * Gets the value input component
  57937. */
  57938. readonly value: NodeMaterialConnectionPoint;
  57939. /**
  57940. * Gets the output component
  57941. */
  57942. readonly output: NodeMaterialConnectionPoint;
  57943. protected _buildBlock(state: NodeMaterialBuildState): this;
  57944. }
  57945. }
  57946. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57950. /**
  57951. * Block used to get the value of the first parameter raised to the power of the second
  57952. */
  57953. export class PowBlock extends NodeMaterialBlock {
  57954. /**
  57955. * Creates a new PowBlock
  57956. * @param name defines the block name
  57957. */
  57958. constructor(name: string);
  57959. /**
  57960. * Gets the current class name
  57961. * @returns the class name
  57962. */
  57963. getClassName(): string;
  57964. /**
  57965. * Gets the value operand input component
  57966. */
  57967. readonly value: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the power operand input component
  57970. */
  57971. readonly power: NodeMaterialConnectionPoint;
  57972. /**
  57973. * Gets the output component
  57974. */
  57975. readonly output: NodeMaterialConnectionPoint;
  57976. protected _buildBlock(state: NodeMaterialBuildState): this;
  57977. }
  57978. }
  57979. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57984. /**
  57985. * Block used to get a random number
  57986. */
  57987. export class RandomNumberBlock extends NodeMaterialBlock {
  57988. /**
  57989. * Creates a new RandomNumberBlock
  57990. * @param name defines the block name
  57991. */
  57992. constructor(name: string);
  57993. /**
  57994. * Gets the current class name
  57995. * @returns the class name
  57996. */
  57997. getClassName(): string;
  57998. /**
  57999. * Gets the seed input component
  58000. */
  58001. readonly seed: NodeMaterialConnectionPoint;
  58002. /**
  58003. * Gets the output component
  58004. */
  58005. readonly output: NodeMaterialConnectionPoint;
  58006. protected _buildBlock(state: NodeMaterialBuildState): this;
  58007. }
  58008. }
  58009. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58013. /**
  58014. * Block used to compute arc tangent of 2 values
  58015. */
  58016. export class ArcTan2Block extends NodeMaterialBlock {
  58017. /**
  58018. * Creates a new ArcTan2Block
  58019. * @param name defines the block name
  58020. */
  58021. constructor(name: string);
  58022. /**
  58023. * Gets the current class name
  58024. * @returns the class name
  58025. */
  58026. getClassName(): string;
  58027. /**
  58028. * Gets the x operand input component
  58029. */
  58030. readonly x: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the y operand input component
  58033. */
  58034. readonly y: NodeMaterialConnectionPoint;
  58035. /**
  58036. * Gets the output component
  58037. */
  58038. readonly output: NodeMaterialConnectionPoint;
  58039. protected _buildBlock(state: NodeMaterialBuildState): this;
  58040. }
  58041. }
  58042. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58046. /**
  58047. * Block used to smooth step a value
  58048. */
  58049. export class SmoothStepBlock extends NodeMaterialBlock {
  58050. /**
  58051. * Creates a new SmoothStepBlock
  58052. * @param name defines the block name
  58053. */
  58054. constructor(name: string);
  58055. /**
  58056. * Gets the current class name
  58057. * @returns the class name
  58058. */
  58059. getClassName(): string;
  58060. /**
  58061. * Gets the value operand input component
  58062. */
  58063. readonly value: NodeMaterialConnectionPoint;
  58064. /**
  58065. * Gets the first edge operand input component
  58066. */
  58067. readonly edge0: NodeMaterialConnectionPoint;
  58068. /**
  58069. * Gets the second edge operand input component
  58070. */
  58071. readonly edge1: NodeMaterialConnectionPoint;
  58072. /**
  58073. * Gets the output component
  58074. */
  58075. readonly output: NodeMaterialConnectionPoint;
  58076. protected _buildBlock(state: NodeMaterialBuildState): this;
  58077. }
  58078. }
  58079. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58083. /**
  58084. * Block used to get the reciprocal (1 / x) of a value
  58085. */
  58086. export class ReciprocalBlock extends NodeMaterialBlock {
  58087. /**
  58088. * Creates a new ReciprocalBlock
  58089. * @param name defines the block name
  58090. */
  58091. constructor(name: string);
  58092. /**
  58093. * Gets the current class name
  58094. * @returns the class name
  58095. */
  58096. getClassName(): string;
  58097. /**
  58098. * Gets the input component
  58099. */
  58100. readonly input: NodeMaterialConnectionPoint;
  58101. /**
  58102. * Gets the output component
  58103. */
  58104. readonly output: NodeMaterialConnectionPoint;
  58105. protected _buildBlock(state: NodeMaterialBuildState): this;
  58106. }
  58107. }
  58108. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58112. /**
  58113. * Block used to replace a color by another one
  58114. */
  58115. export class ReplaceColorBlock extends NodeMaterialBlock {
  58116. /**
  58117. * Creates a new ReplaceColorBlock
  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 reference input component
  58132. */
  58133. readonly reference: NodeMaterialConnectionPoint;
  58134. /**
  58135. * Gets the distance input component
  58136. */
  58137. readonly distance: NodeMaterialConnectionPoint;
  58138. /**
  58139. * Gets the replacement input component
  58140. */
  58141. readonly replacement: NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the output component
  58144. */
  58145. readonly output: NodeMaterialConnectionPoint;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. }
  58148. }
  58149. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58153. /**
  58154. * Block used to posterize a value
  58155. * @see https://en.wikipedia.org/wiki/Posterization
  58156. */
  58157. export class PosterizeBlock extends NodeMaterialBlock {
  58158. /**
  58159. * Creates a new PosterizeBlock
  58160. * @param name defines the block name
  58161. */
  58162. constructor(name: string);
  58163. /**
  58164. * Gets the current class name
  58165. * @returns the class name
  58166. */
  58167. getClassName(): string;
  58168. /**
  58169. * Gets the value input component
  58170. */
  58171. readonly value: NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the steps input component
  58174. */
  58175. readonly steps: NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the output component
  58178. */
  58179. readonly output: NodeMaterialConnectionPoint;
  58180. protected _buildBlock(state: NodeMaterialBuildState): this;
  58181. }
  58182. }
  58183. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58187. import { Scene } from "babylonjs/scene";
  58188. /**
  58189. * Operations supported by the Wave block
  58190. */
  58191. export enum WaveBlockKind {
  58192. /** SawTooth */
  58193. SawTooth = 0,
  58194. /** Square */
  58195. Square = 1,
  58196. /** Triangle */
  58197. Triangle = 2
  58198. }
  58199. /**
  58200. * Block used to apply wave operation to floats
  58201. */
  58202. export class WaveBlock extends NodeMaterialBlock {
  58203. /**
  58204. * Gets or sets the kibnd of wave to be applied by the block
  58205. */
  58206. kind: WaveBlockKind;
  58207. /**
  58208. * Creates a new WaveBlock
  58209. * @param name defines the block name
  58210. */
  58211. constructor(name: string);
  58212. /**
  58213. * Gets the current class name
  58214. * @returns the class name
  58215. */
  58216. getClassName(): string;
  58217. /**
  58218. * Gets the input component
  58219. */
  58220. readonly input: NodeMaterialConnectionPoint;
  58221. /**
  58222. * Gets the output component
  58223. */
  58224. readonly output: NodeMaterialConnectionPoint;
  58225. protected _buildBlock(state: NodeMaterialBuildState): this;
  58226. serialize(): any;
  58227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58228. }
  58229. }
  58230. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58234. import { Color3 } from "babylonjs/Maths/math.color";
  58235. import { Scene } from "babylonjs/scene";
  58236. /**
  58237. * Class used to store a color step for the GradientBlock
  58238. */
  58239. export class GradientBlockColorStep {
  58240. /**
  58241. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58242. */
  58243. step: number;
  58244. /**
  58245. * Gets or sets the color associated with this step
  58246. */
  58247. color: Color3;
  58248. /**
  58249. * Creates a new GradientBlockColorStep
  58250. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58251. * @param color defines the color associated with this step
  58252. */
  58253. constructor(
  58254. /**
  58255. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58256. */
  58257. step: number,
  58258. /**
  58259. * Gets or sets the color associated with this step
  58260. */
  58261. color: Color3);
  58262. }
  58263. /**
  58264. * Block used to return a color from a gradient based on an input value between 0 and 1
  58265. */
  58266. export class GradientBlock extends NodeMaterialBlock {
  58267. /**
  58268. * Gets or sets the list of color steps
  58269. */
  58270. colorSteps: GradientBlockColorStep[];
  58271. /**
  58272. * Creates a new GradientBlock
  58273. * @param name defines the block name
  58274. */
  58275. constructor(name: string);
  58276. /**
  58277. * Gets the current class name
  58278. * @returns the class name
  58279. */
  58280. getClassName(): string;
  58281. /**
  58282. * Gets the gradient input component
  58283. */
  58284. readonly gradient: NodeMaterialConnectionPoint;
  58285. /**
  58286. * Gets the output component
  58287. */
  58288. readonly output: NodeMaterialConnectionPoint;
  58289. private _writeColorConstant;
  58290. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58291. serialize(): any;
  58292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58293. protected _dumpPropertiesCode(): string;
  58294. }
  58295. }
  58296. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58300. /**
  58301. * Block used to normalize lerp between 2 values
  58302. */
  58303. export class NLerpBlock extends NodeMaterialBlock {
  58304. /**
  58305. * Creates a new NLerpBlock
  58306. * @param name defines the block name
  58307. */
  58308. constructor(name: string);
  58309. /**
  58310. * Gets the current class name
  58311. * @returns the class name
  58312. */
  58313. getClassName(): string;
  58314. /**
  58315. * Gets the left operand input component
  58316. */
  58317. readonly left: NodeMaterialConnectionPoint;
  58318. /**
  58319. * Gets the right operand input component
  58320. */
  58321. readonly right: NodeMaterialConnectionPoint;
  58322. /**
  58323. * Gets the gradient operand input component
  58324. */
  58325. readonly gradient: NodeMaterialConnectionPoint;
  58326. /**
  58327. * Gets the output component
  58328. */
  58329. readonly output: NodeMaterialConnectionPoint;
  58330. protected _buildBlock(state: NodeMaterialBuildState): this;
  58331. }
  58332. }
  58333. declare module "babylonjs/Materials/Node/Blocks/index" {
  58334. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58335. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58336. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58337. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58338. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58342. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58343. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58344. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58345. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58346. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58347. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58348. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58349. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58350. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58351. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58352. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58353. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58354. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58355. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58356. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58357. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58358. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58359. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58360. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58361. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58362. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58363. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58364. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58365. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58366. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58367. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58368. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58369. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58370. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58371. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58372. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58373. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58374. }
  58375. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58376. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58377. }
  58378. declare module "babylonjs/Materials/Node/index" {
  58379. export * from "babylonjs/Materials/Node/Enums/index";
  58380. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58381. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58382. export * from "babylonjs/Materials/Node/nodeMaterial";
  58383. export * from "babylonjs/Materials/Node/Blocks/index";
  58384. export * from "babylonjs/Materials/Node/Optimizers/index";
  58385. }
  58386. declare module "babylonjs/Materials/effectRenderer" {
  58387. import { Nullable } from "babylonjs/types";
  58388. import { Texture } from "babylonjs/Materials/Textures/texture";
  58389. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58390. import { Viewport } from "babylonjs/Maths/math.viewport";
  58391. import { Observable } from "babylonjs/Misc/observable";
  58392. import { Effect } from "babylonjs/Materials/effect";
  58393. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58394. import "babylonjs/Shaders/postprocess.vertex";
  58395. /**
  58396. * Effect Render Options
  58397. */
  58398. export interface IEffectRendererOptions {
  58399. /**
  58400. * Defines the vertices positions.
  58401. */
  58402. positions?: number[];
  58403. /**
  58404. * Defines the indices.
  58405. */
  58406. indices?: number[];
  58407. }
  58408. /**
  58409. * Helper class to render one or more effects
  58410. */
  58411. export class EffectRenderer {
  58412. private engine;
  58413. private static _DefaultOptions;
  58414. private _vertexBuffers;
  58415. private _indexBuffer;
  58416. private _ringBufferIndex;
  58417. private _ringScreenBuffer;
  58418. private _fullscreenViewport;
  58419. private _getNextFrameBuffer;
  58420. /**
  58421. * Creates an effect renderer
  58422. * @param engine the engine to use for rendering
  58423. * @param options defines the options of the effect renderer
  58424. */
  58425. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58426. /**
  58427. * Sets the current viewport in normalized coordinates 0-1
  58428. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58429. */
  58430. setViewport(viewport?: Viewport): void;
  58431. /**
  58432. * Binds the embedded attributes buffer to the effect.
  58433. * @param effect Defines the effect to bind the attributes for
  58434. */
  58435. bindBuffers(effect: Effect): void;
  58436. /**
  58437. * Sets the current effect wrapper to use during draw.
  58438. * The effect needs to be ready before calling this api.
  58439. * This also sets the default full screen position attribute.
  58440. * @param effectWrapper Defines the effect to draw with
  58441. */
  58442. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58443. /**
  58444. * Draws a full screen quad.
  58445. */
  58446. draw(): void;
  58447. /**
  58448. * renders one or more effects to a specified texture
  58449. * @param effectWrappers list of effects to renderer
  58450. * @param outputTexture texture to draw to, if null it will render to the screen
  58451. */
  58452. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58453. /**
  58454. * Disposes of the effect renderer
  58455. */
  58456. dispose(): void;
  58457. }
  58458. /**
  58459. * Options to create an EffectWrapper
  58460. */
  58461. interface EffectWrapperCreationOptions {
  58462. /**
  58463. * Engine to use to create the effect
  58464. */
  58465. engine: ThinEngine;
  58466. /**
  58467. * Fragment shader for the effect
  58468. */
  58469. fragmentShader: string;
  58470. /**
  58471. * Vertex shader for the effect
  58472. */
  58473. vertexShader?: string;
  58474. /**
  58475. * Attributes to use in the shader
  58476. */
  58477. attributeNames?: Array<string>;
  58478. /**
  58479. * Uniforms to use in the shader
  58480. */
  58481. uniformNames?: Array<string>;
  58482. /**
  58483. * Texture sampler names to use in the shader
  58484. */
  58485. samplerNames?: Array<string>;
  58486. /**
  58487. * The friendly name of the effect displayed in Spector.
  58488. */
  58489. name?: string;
  58490. }
  58491. /**
  58492. * Wraps an effect to be used for rendering
  58493. */
  58494. export class EffectWrapper {
  58495. /**
  58496. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58497. */
  58498. onApplyObservable: Observable<{}>;
  58499. /**
  58500. * The underlying effect
  58501. */
  58502. effect: Effect;
  58503. /**
  58504. * Creates an effect to be renderer
  58505. * @param creationOptions options to create the effect
  58506. */
  58507. constructor(creationOptions: EffectWrapperCreationOptions);
  58508. /**
  58509. * Disposes of the effect wrapper
  58510. */
  58511. dispose(): void;
  58512. }
  58513. }
  58514. declare module "babylonjs/Materials/index" {
  58515. export * from "babylonjs/Materials/Background/index";
  58516. export * from "babylonjs/Materials/colorCurves";
  58517. export * from "babylonjs/Materials/iEffectFallbacks";
  58518. export * from "babylonjs/Materials/effectFallbacks";
  58519. export * from "babylonjs/Materials/effect";
  58520. export * from "babylonjs/Materials/fresnelParameters";
  58521. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58522. export * from "babylonjs/Materials/material";
  58523. export * from "babylonjs/Materials/materialDefines";
  58524. export * from "babylonjs/Materials/materialHelper";
  58525. export * from "babylonjs/Materials/multiMaterial";
  58526. export * from "babylonjs/Materials/PBR/index";
  58527. export * from "babylonjs/Materials/pushMaterial";
  58528. export * from "babylonjs/Materials/shaderMaterial";
  58529. export * from "babylonjs/Materials/standardMaterial";
  58530. export * from "babylonjs/Materials/Textures/index";
  58531. export * from "babylonjs/Materials/uniformBuffer";
  58532. export * from "babylonjs/Materials/materialFlags";
  58533. export * from "babylonjs/Materials/Node/index";
  58534. export * from "babylonjs/Materials/effectRenderer";
  58535. }
  58536. declare module "babylonjs/Maths/index" {
  58537. export * from "babylonjs/Maths/math.scalar";
  58538. export * from "babylonjs/Maths/math";
  58539. export * from "babylonjs/Maths/sphericalPolynomial";
  58540. }
  58541. declare module "babylonjs/Misc/workerPool" {
  58542. import { IDisposable } from "babylonjs/scene";
  58543. /**
  58544. * Helper class to push actions to a pool of workers.
  58545. */
  58546. export class WorkerPool implements IDisposable {
  58547. private _workerInfos;
  58548. private _pendingActions;
  58549. /**
  58550. * Constructor
  58551. * @param workers Array of workers to use for actions
  58552. */
  58553. constructor(workers: Array<Worker>);
  58554. /**
  58555. * Terminates all workers and clears any pending actions.
  58556. */
  58557. dispose(): void;
  58558. /**
  58559. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58560. * pended until a worker has completed its action.
  58561. * @param action The action to perform. Call onComplete when the action is complete.
  58562. */
  58563. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58564. private _execute;
  58565. }
  58566. }
  58567. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58568. import { IDisposable } from "babylonjs/scene";
  58569. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58570. /**
  58571. * Configuration for Draco compression
  58572. */
  58573. export interface IDracoCompressionConfiguration {
  58574. /**
  58575. * Configuration for the decoder.
  58576. */
  58577. decoder: {
  58578. /**
  58579. * The url to the WebAssembly module.
  58580. */
  58581. wasmUrl?: string;
  58582. /**
  58583. * The url to the WebAssembly binary.
  58584. */
  58585. wasmBinaryUrl?: string;
  58586. /**
  58587. * The url to the fallback JavaScript module.
  58588. */
  58589. fallbackUrl?: string;
  58590. };
  58591. }
  58592. /**
  58593. * Draco compression (https://google.github.io/draco/)
  58594. *
  58595. * This class wraps the Draco module.
  58596. *
  58597. * **Encoder**
  58598. *
  58599. * The encoder is not currently implemented.
  58600. *
  58601. * **Decoder**
  58602. *
  58603. * 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.
  58604. *
  58605. * To update the configuration, use the following code:
  58606. * ```javascript
  58607. * DracoCompression.Configuration = {
  58608. * decoder: {
  58609. * wasmUrl: "<url to the WebAssembly library>",
  58610. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58611. * fallbackUrl: "<url to the fallback JavaScript library>",
  58612. * }
  58613. * };
  58614. * ```
  58615. *
  58616. * 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.
  58617. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58618. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58619. *
  58620. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58621. * ```javascript
  58622. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58623. * ```
  58624. *
  58625. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58626. */
  58627. export class DracoCompression implements IDisposable {
  58628. private _workerPoolPromise?;
  58629. private _decoderModulePromise?;
  58630. /**
  58631. * The configuration. Defaults to the following urls:
  58632. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58633. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58634. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58635. */
  58636. static Configuration: IDracoCompressionConfiguration;
  58637. /**
  58638. * Returns true if the decoder configuration is available.
  58639. */
  58640. static readonly DecoderAvailable: boolean;
  58641. /**
  58642. * Default number of workers to create when creating the draco compression object.
  58643. */
  58644. static DefaultNumWorkers: number;
  58645. private static GetDefaultNumWorkers;
  58646. private static _Default;
  58647. /**
  58648. * Default instance for the draco compression object.
  58649. */
  58650. static readonly Default: DracoCompression;
  58651. /**
  58652. * Constructor
  58653. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58654. */
  58655. constructor(numWorkers?: number);
  58656. /**
  58657. * Stop all async operations and release resources.
  58658. */
  58659. dispose(): void;
  58660. /**
  58661. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58662. * @returns a promise that resolves when ready
  58663. */
  58664. whenReadyAsync(): Promise<void>;
  58665. /**
  58666. * Decode Draco compressed mesh data to vertex data.
  58667. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58668. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58669. * @returns A promise that resolves with the decoded vertex data
  58670. */
  58671. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58672. [kind: string]: number;
  58673. }): Promise<VertexData>;
  58674. }
  58675. }
  58676. declare module "babylonjs/Meshes/Compression/index" {
  58677. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58678. }
  58679. declare module "babylonjs/Meshes/csg" {
  58680. import { Nullable } from "babylonjs/types";
  58681. import { Scene } from "babylonjs/scene";
  58682. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58683. import { Mesh } from "babylonjs/Meshes/mesh";
  58684. import { Material } from "babylonjs/Materials/material";
  58685. /**
  58686. * Class for building Constructive Solid Geometry
  58687. */
  58688. export class CSG {
  58689. private polygons;
  58690. /**
  58691. * The world matrix
  58692. */
  58693. matrix: Matrix;
  58694. /**
  58695. * Stores the position
  58696. */
  58697. position: Vector3;
  58698. /**
  58699. * Stores the rotation
  58700. */
  58701. rotation: Vector3;
  58702. /**
  58703. * Stores the rotation quaternion
  58704. */
  58705. rotationQuaternion: Nullable<Quaternion>;
  58706. /**
  58707. * Stores the scaling vector
  58708. */
  58709. scaling: Vector3;
  58710. /**
  58711. * Convert the Mesh to CSG
  58712. * @param mesh The Mesh to convert to CSG
  58713. * @returns A new CSG from the Mesh
  58714. */
  58715. static FromMesh(mesh: Mesh): CSG;
  58716. /**
  58717. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58718. * @param polygons Polygons used to construct a CSG solid
  58719. */
  58720. private static FromPolygons;
  58721. /**
  58722. * Clones, or makes a deep copy, of the CSG
  58723. * @returns A new CSG
  58724. */
  58725. clone(): CSG;
  58726. /**
  58727. * Unions this CSG with another CSG
  58728. * @param csg The CSG to union against this CSG
  58729. * @returns The unioned CSG
  58730. */
  58731. union(csg: CSG): CSG;
  58732. /**
  58733. * Unions this CSG with another CSG in place
  58734. * @param csg The CSG to union against this CSG
  58735. */
  58736. unionInPlace(csg: CSG): void;
  58737. /**
  58738. * Subtracts this CSG with another CSG
  58739. * @param csg The CSG to subtract against this CSG
  58740. * @returns A new CSG
  58741. */
  58742. subtract(csg: CSG): CSG;
  58743. /**
  58744. * Subtracts this CSG with another CSG in place
  58745. * @param csg The CSG to subtact against this CSG
  58746. */
  58747. subtractInPlace(csg: CSG): void;
  58748. /**
  58749. * Intersect this CSG with another CSG
  58750. * @param csg The CSG to intersect against this CSG
  58751. * @returns A new CSG
  58752. */
  58753. intersect(csg: CSG): CSG;
  58754. /**
  58755. * Intersects this CSG with another CSG in place
  58756. * @param csg The CSG to intersect against this CSG
  58757. */
  58758. intersectInPlace(csg: CSG): void;
  58759. /**
  58760. * Return a new CSG solid with solid and empty space switched. This solid is
  58761. * not modified.
  58762. * @returns A new CSG solid with solid and empty space switched
  58763. */
  58764. inverse(): CSG;
  58765. /**
  58766. * Inverses the CSG in place
  58767. */
  58768. inverseInPlace(): void;
  58769. /**
  58770. * This is used to keep meshes transformations so they can be restored
  58771. * when we build back a Babylon Mesh
  58772. * NB : All CSG operations are performed in world coordinates
  58773. * @param csg The CSG to copy the transform attributes from
  58774. * @returns This CSG
  58775. */
  58776. copyTransformAttributes(csg: CSG): CSG;
  58777. /**
  58778. * Build Raw mesh from CSG
  58779. * Coordinates here are in world space
  58780. * @param name The name of the mesh geometry
  58781. * @param scene The Scene
  58782. * @param keepSubMeshes Specifies if the submeshes should be kept
  58783. * @returns A new Mesh
  58784. */
  58785. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58786. /**
  58787. * Build Mesh from CSG taking material and transforms into account
  58788. * @param name The name of the Mesh
  58789. * @param material The material of the Mesh
  58790. * @param scene The Scene
  58791. * @param keepSubMeshes Specifies if submeshes should be kept
  58792. * @returns The new Mesh
  58793. */
  58794. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58795. }
  58796. }
  58797. declare module "babylonjs/Meshes/trailMesh" {
  58798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58799. import { Mesh } from "babylonjs/Meshes/mesh";
  58800. import { Scene } from "babylonjs/scene";
  58801. /**
  58802. * Class used to create a trail following a mesh
  58803. */
  58804. export class TrailMesh extends Mesh {
  58805. private _generator;
  58806. private _autoStart;
  58807. private _running;
  58808. private _diameter;
  58809. private _length;
  58810. private _sectionPolygonPointsCount;
  58811. private _sectionVectors;
  58812. private _sectionNormalVectors;
  58813. private _beforeRenderObserver;
  58814. /**
  58815. * @constructor
  58816. * @param name The value used by scene.getMeshByName() to do a lookup.
  58817. * @param generator The mesh to generate a trail.
  58818. * @param scene The scene to add this mesh to.
  58819. * @param diameter Diameter of trailing mesh. Default is 1.
  58820. * @param length Length of trailing mesh. Default is 60.
  58821. * @param autoStart Automatically start trailing mesh. Default true.
  58822. */
  58823. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58824. /**
  58825. * "TrailMesh"
  58826. * @returns "TrailMesh"
  58827. */
  58828. getClassName(): string;
  58829. private _createMesh;
  58830. /**
  58831. * Start trailing mesh.
  58832. */
  58833. start(): void;
  58834. /**
  58835. * Stop trailing mesh.
  58836. */
  58837. stop(): void;
  58838. /**
  58839. * Update trailing mesh geometry.
  58840. */
  58841. update(): void;
  58842. /**
  58843. * Returns a new TrailMesh object.
  58844. * @param name is a string, the name given to the new mesh
  58845. * @param newGenerator use new generator object for cloned trail mesh
  58846. * @returns a new mesh
  58847. */
  58848. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58849. /**
  58850. * Serializes this trail mesh
  58851. * @param serializationObject object to write serialization to
  58852. */
  58853. serialize(serializationObject: any): void;
  58854. /**
  58855. * Parses a serialized trail mesh
  58856. * @param parsedMesh the serialized mesh
  58857. * @param scene the scene to create the trail mesh in
  58858. * @returns the created trail mesh
  58859. */
  58860. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58861. }
  58862. }
  58863. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58864. import { Nullable } from "babylonjs/types";
  58865. import { Scene } from "babylonjs/scene";
  58866. import { Vector4 } from "babylonjs/Maths/math.vector";
  58867. import { Color4 } from "babylonjs/Maths/math.color";
  58868. import { Mesh } from "babylonjs/Meshes/mesh";
  58869. /**
  58870. * Class containing static functions to help procedurally build meshes
  58871. */
  58872. export class TiledBoxBuilder {
  58873. /**
  58874. * Creates a box mesh
  58875. * 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)
  58876. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58880. * @param name defines the name of the mesh
  58881. * @param options defines the options used to create the mesh
  58882. * @param scene defines the hosting scene
  58883. * @returns the box mesh
  58884. */
  58885. static CreateTiledBox(name: string, options: {
  58886. pattern?: number;
  58887. width?: number;
  58888. height?: number;
  58889. depth?: number;
  58890. tileSize?: number;
  58891. tileWidth?: number;
  58892. tileHeight?: number;
  58893. alignHorizontal?: number;
  58894. alignVertical?: number;
  58895. faceUV?: Vector4[];
  58896. faceColors?: Color4[];
  58897. sideOrientation?: number;
  58898. updatable?: boolean;
  58899. }, scene?: Nullable<Scene>): Mesh;
  58900. }
  58901. }
  58902. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58903. import { Vector4 } from "babylonjs/Maths/math.vector";
  58904. import { Mesh } from "babylonjs/Meshes/mesh";
  58905. /**
  58906. * Class containing static functions to help procedurally build meshes
  58907. */
  58908. export class TorusKnotBuilder {
  58909. /**
  58910. * Creates a torus knot mesh
  58911. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58912. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58913. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58914. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58918. * @param name defines the name of the mesh
  58919. * @param options defines the options used to create the mesh
  58920. * @param scene defines the hosting scene
  58921. * @returns the torus knot mesh
  58922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58923. */
  58924. static CreateTorusKnot(name: string, options: {
  58925. radius?: number;
  58926. tube?: number;
  58927. radialSegments?: number;
  58928. tubularSegments?: number;
  58929. p?: number;
  58930. q?: number;
  58931. updatable?: boolean;
  58932. sideOrientation?: number;
  58933. frontUVs?: Vector4;
  58934. backUVs?: Vector4;
  58935. }, scene: any): Mesh;
  58936. }
  58937. }
  58938. declare module "babylonjs/Meshes/polygonMesh" {
  58939. import { Scene } from "babylonjs/scene";
  58940. import { Vector2 } from "babylonjs/Maths/math.vector";
  58941. import { Mesh } from "babylonjs/Meshes/mesh";
  58942. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58943. import { Path2 } from "babylonjs/Maths/math.path";
  58944. /**
  58945. * Polygon
  58946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58947. */
  58948. export class Polygon {
  58949. /**
  58950. * Creates a rectangle
  58951. * @param xmin bottom X coord
  58952. * @param ymin bottom Y coord
  58953. * @param xmax top X coord
  58954. * @param ymax top Y coord
  58955. * @returns points that make the resulting rectation
  58956. */
  58957. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58958. /**
  58959. * Creates a circle
  58960. * @param radius radius of circle
  58961. * @param cx scale in x
  58962. * @param cy scale in y
  58963. * @param numberOfSides number of sides that make up the circle
  58964. * @returns points that make the resulting circle
  58965. */
  58966. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58967. /**
  58968. * Creates a polygon from input string
  58969. * @param input Input polygon data
  58970. * @returns the parsed points
  58971. */
  58972. static Parse(input: string): Vector2[];
  58973. /**
  58974. * Starts building a polygon from x and y coordinates
  58975. * @param x x coordinate
  58976. * @param y y coordinate
  58977. * @returns the started path2
  58978. */
  58979. static StartingAt(x: number, y: number): Path2;
  58980. }
  58981. /**
  58982. * Builds a polygon
  58983. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58984. */
  58985. export class PolygonMeshBuilder {
  58986. private _points;
  58987. private _outlinepoints;
  58988. private _holes;
  58989. private _name;
  58990. private _scene;
  58991. private _epoints;
  58992. private _eholes;
  58993. private _addToepoint;
  58994. /**
  58995. * Babylon reference to the earcut plugin.
  58996. */
  58997. bjsEarcut: any;
  58998. /**
  58999. * Creates a PolygonMeshBuilder
  59000. * @param name name of the builder
  59001. * @param contours Path of the polygon
  59002. * @param scene scene to add to when creating the mesh
  59003. * @param earcutInjection can be used to inject your own earcut reference
  59004. */
  59005. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59006. /**
  59007. * Adds a whole within the polygon
  59008. * @param hole Array of points defining the hole
  59009. * @returns this
  59010. */
  59011. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59012. /**
  59013. * Creates the polygon
  59014. * @param updatable If the mesh should be updatable
  59015. * @param depth The depth of the mesh created
  59016. * @returns the created mesh
  59017. */
  59018. build(updatable?: boolean, depth?: number): Mesh;
  59019. /**
  59020. * Creates the polygon
  59021. * @param depth The depth of the mesh created
  59022. * @returns the created VertexData
  59023. */
  59024. buildVertexData(depth?: number): VertexData;
  59025. /**
  59026. * Adds a side to the polygon
  59027. * @param positions points that make the polygon
  59028. * @param normals normals of the polygon
  59029. * @param uvs uvs of the polygon
  59030. * @param indices indices of the polygon
  59031. * @param bounds bounds of the polygon
  59032. * @param points points of the polygon
  59033. * @param depth depth of the polygon
  59034. * @param flip flip of the polygon
  59035. */
  59036. private addSide;
  59037. }
  59038. }
  59039. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59040. import { Scene } from "babylonjs/scene";
  59041. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59042. import { Color4 } from "babylonjs/Maths/math.color";
  59043. import { Mesh } from "babylonjs/Meshes/mesh";
  59044. import { Nullable } from "babylonjs/types";
  59045. /**
  59046. * Class containing static functions to help procedurally build meshes
  59047. */
  59048. export class PolygonBuilder {
  59049. /**
  59050. * Creates a polygon mesh
  59051. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59052. * * 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
  59053. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59056. * * Remember you can only change the shape positions, not their number when updating a polygon
  59057. * @param name defines the name of the mesh
  59058. * @param options defines the options used to create the mesh
  59059. * @param scene defines the hosting scene
  59060. * @param earcutInjection can be used to inject your own earcut reference
  59061. * @returns the polygon mesh
  59062. */
  59063. static CreatePolygon(name: string, options: {
  59064. shape: Vector3[];
  59065. holes?: Vector3[][];
  59066. depth?: number;
  59067. faceUV?: Vector4[];
  59068. faceColors?: Color4[];
  59069. updatable?: boolean;
  59070. sideOrientation?: number;
  59071. frontUVs?: Vector4;
  59072. backUVs?: Vector4;
  59073. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59074. /**
  59075. * Creates an extruded polygon mesh, with depth in the Y direction.
  59076. * * 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)
  59077. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  59082. * @returns the polygon mesh
  59083. */
  59084. static ExtrudePolygon(name: string, options: {
  59085. shape: Vector3[];
  59086. holes?: Vector3[][];
  59087. depth?: number;
  59088. faceUV?: Vector4[];
  59089. faceColors?: Color4[];
  59090. updatable?: boolean;
  59091. sideOrientation?: number;
  59092. frontUVs?: Vector4;
  59093. backUVs?: Vector4;
  59094. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59095. }
  59096. }
  59097. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59098. import { Scene } from "babylonjs/scene";
  59099. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59100. import { Mesh } from "babylonjs/Meshes/mesh";
  59101. import { Nullable } from "babylonjs/types";
  59102. /**
  59103. * Class containing static functions to help procedurally build meshes
  59104. */
  59105. export class LatheBuilder {
  59106. /**
  59107. * Creates lathe mesh.
  59108. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59109. * * 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
  59110. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59111. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59112. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59113. * * 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
  59114. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59115. * * 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
  59116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59120. * @param name defines the name of the mesh
  59121. * @param options defines the options used to create the mesh
  59122. * @param scene defines the hosting scene
  59123. * @returns the lathe mesh
  59124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59125. */
  59126. static CreateLathe(name: string, options: {
  59127. shape: Vector3[];
  59128. radius?: number;
  59129. tessellation?: number;
  59130. clip?: number;
  59131. arc?: number;
  59132. closed?: boolean;
  59133. updatable?: boolean;
  59134. sideOrientation?: number;
  59135. frontUVs?: Vector4;
  59136. backUVs?: Vector4;
  59137. cap?: number;
  59138. invertUV?: boolean;
  59139. }, scene?: Nullable<Scene>): Mesh;
  59140. }
  59141. }
  59142. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59143. import { Nullable } from "babylonjs/types";
  59144. import { Scene } from "babylonjs/scene";
  59145. import { Vector4 } from "babylonjs/Maths/math.vector";
  59146. import { Mesh } from "babylonjs/Meshes/mesh";
  59147. /**
  59148. * Class containing static functions to help procedurally build meshes
  59149. */
  59150. export class TiledPlaneBuilder {
  59151. /**
  59152. * Creates a tiled plane mesh
  59153. * * The parameter `pattern` will, depending on value, do nothing or
  59154. * * * flip (reflect about central vertical) alternate tiles across and up
  59155. * * * flip every tile on alternate rows
  59156. * * * rotate (180 degs) alternate tiles across and up
  59157. * * * rotate every tile on alternate rows
  59158. * * * flip and rotate alternate tiles across and up
  59159. * * * flip and rotate every tile on alternate rows
  59160. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59161. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59164. * * 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)
  59165. * * 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)
  59166. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59167. * @param name defines the name of the mesh
  59168. * @param options defines the options used to create the mesh
  59169. * @param scene defines the hosting scene
  59170. * @returns the box mesh
  59171. */
  59172. static CreateTiledPlane(name: string, options: {
  59173. pattern?: number;
  59174. tileSize?: number;
  59175. tileWidth?: number;
  59176. tileHeight?: number;
  59177. size?: number;
  59178. width?: number;
  59179. height?: number;
  59180. alignHorizontal?: number;
  59181. alignVertical?: number;
  59182. sideOrientation?: number;
  59183. frontUVs?: Vector4;
  59184. backUVs?: Vector4;
  59185. updatable?: boolean;
  59186. }, scene?: Nullable<Scene>): Mesh;
  59187. }
  59188. }
  59189. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59190. import { Nullable } from "babylonjs/types";
  59191. import { Scene } from "babylonjs/scene";
  59192. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59193. import { Mesh } from "babylonjs/Meshes/mesh";
  59194. /**
  59195. * Class containing static functions to help procedurally build meshes
  59196. */
  59197. export class TubeBuilder {
  59198. /**
  59199. * Creates a tube mesh.
  59200. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59201. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59202. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59203. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59204. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59205. * * 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)
  59206. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59207. * * 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
  59208. * * 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
  59209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59211. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59213. * @param name defines the name of the mesh
  59214. * @param options defines the options used to create the mesh
  59215. * @param scene defines the hosting scene
  59216. * @returns the tube mesh
  59217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59218. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59219. */
  59220. static CreateTube(name: string, options: {
  59221. path: Vector3[];
  59222. radius?: number;
  59223. tessellation?: number;
  59224. radiusFunction?: {
  59225. (i: number, distance: number): number;
  59226. };
  59227. cap?: number;
  59228. arc?: number;
  59229. updatable?: boolean;
  59230. sideOrientation?: number;
  59231. frontUVs?: Vector4;
  59232. backUVs?: Vector4;
  59233. instance?: Mesh;
  59234. invertUV?: boolean;
  59235. }, scene?: Nullable<Scene>): Mesh;
  59236. }
  59237. }
  59238. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59239. import { Scene } from "babylonjs/scene";
  59240. import { Vector4 } from "babylonjs/Maths/math.vector";
  59241. import { Mesh } from "babylonjs/Meshes/mesh";
  59242. import { Nullable } from "babylonjs/types";
  59243. /**
  59244. * Class containing static functions to help procedurally build meshes
  59245. */
  59246. export class IcoSphereBuilder {
  59247. /**
  59248. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59249. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59250. * * 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`)
  59251. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59252. * * 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
  59253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59256. * @param name defines the name of the mesh
  59257. * @param options defines the options used to create the mesh
  59258. * @param scene defines the hosting scene
  59259. * @returns the icosahedron mesh
  59260. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59261. */
  59262. static CreateIcoSphere(name: string, options: {
  59263. radius?: number;
  59264. radiusX?: number;
  59265. radiusY?: number;
  59266. radiusZ?: number;
  59267. flat?: boolean;
  59268. subdivisions?: number;
  59269. sideOrientation?: number;
  59270. frontUVs?: Vector4;
  59271. backUVs?: Vector4;
  59272. updatable?: boolean;
  59273. }, scene?: Nullable<Scene>): Mesh;
  59274. }
  59275. }
  59276. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59277. import { Vector3 } from "babylonjs/Maths/math.vector";
  59278. import { Mesh } from "babylonjs/Meshes/mesh";
  59279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59280. /**
  59281. * Class containing static functions to help procedurally build meshes
  59282. */
  59283. export class DecalBuilder {
  59284. /**
  59285. * Creates a decal mesh.
  59286. * 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
  59287. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59288. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59289. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59290. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59291. * @param name defines the name of the mesh
  59292. * @param sourceMesh defines the mesh where the decal must be applied
  59293. * @param options defines the options used to create the mesh
  59294. * @param scene defines the hosting scene
  59295. * @returns the decal mesh
  59296. * @see https://doc.babylonjs.com/how_to/decals
  59297. */
  59298. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59299. position?: Vector3;
  59300. normal?: Vector3;
  59301. size?: Vector3;
  59302. angle?: number;
  59303. }): Mesh;
  59304. }
  59305. }
  59306. declare module "babylonjs/Meshes/meshBuilder" {
  59307. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59308. import { Nullable } from "babylonjs/types";
  59309. import { Scene } from "babylonjs/scene";
  59310. import { Mesh } from "babylonjs/Meshes/mesh";
  59311. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59312. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59314. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59315. import { Plane } from "babylonjs/Maths/math.plane";
  59316. /**
  59317. * Class containing static functions to help procedurally build meshes
  59318. */
  59319. export class MeshBuilder {
  59320. /**
  59321. * Creates a box mesh
  59322. * * The parameter `size` sets the size (float) of each box side (default 1)
  59323. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59324. * * 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)
  59325. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59329. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59330. * @param name defines the name of the mesh
  59331. * @param options defines the options used to create the mesh
  59332. * @param scene defines the hosting scene
  59333. * @returns the box mesh
  59334. */
  59335. static CreateBox(name: string, options: {
  59336. size?: number;
  59337. width?: number;
  59338. height?: number;
  59339. depth?: number;
  59340. faceUV?: Vector4[];
  59341. faceColors?: Color4[];
  59342. sideOrientation?: number;
  59343. frontUVs?: Vector4;
  59344. backUVs?: Vector4;
  59345. updatable?: boolean;
  59346. }, scene?: Nullable<Scene>): Mesh;
  59347. /**
  59348. * Creates a tiled box mesh
  59349. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59351. * @param name defines the name of the mesh
  59352. * @param options defines the options used to create the mesh
  59353. * @param scene defines the hosting scene
  59354. * @returns the tiled box mesh
  59355. */
  59356. static CreateTiledBox(name: string, options: {
  59357. pattern?: number;
  59358. size?: number;
  59359. width?: number;
  59360. height?: number;
  59361. depth: number;
  59362. tileSize?: number;
  59363. tileWidth?: number;
  59364. tileHeight?: number;
  59365. faceUV?: Vector4[];
  59366. faceColors?: Color4[];
  59367. alignHorizontal?: number;
  59368. alignVertical?: number;
  59369. sideOrientation?: number;
  59370. updatable?: boolean;
  59371. }, scene?: Nullable<Scene>): Mesh;
  59372. /**
  59373. * Creates a sphere mesh
  59374. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59375. * * 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`)
  59376. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59377. * * 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
  59378. * * 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)
  59379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59382. * @param name defines the name of the mesh
  59383. * @param options defines the options used to create the mesh
  59384. * @param scene defines the hosting scene
  59385. * @returns the sphere mesh
  59386. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59387. */
  59388. static CreateSphere(name: string, options: {
  59389. segments?: number;
  59390. diameter?: number;
  59391. diameterX?: number;
  59392. diameterY?: number;
  59393. diameterZ?: number;
  59394. arc?: number;
  59395. slice?: number;
  59396. sideOrientation?: number;
  59397. frontUVs?: Vector4;
  59398. backUVs?: Vector4;
  59399. updatable?: boolean;
  59400. }, scene?: Nullable<Scene>): Mesh;
  59401. /**
  59402. * Creates a plane polygonal mesh. By default, this is a disc
  59403. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59404. * * 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
  59405. * * 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
  59406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59409. * @param name defines the name of the mesh
  59410. * @param options defines the options used to create the mesh
  59411. * @param scene defines the hosting scene
  59412. * @returns the plane polygonal mesh
  59413. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59414. */
  59415. static CreateDisc(name: string, options: {
  59416. radius?: number;
  59417. tessellation?: number;
  59418. arc?: number;
  59419. updatable?: boolean;
  59420. sideOrientation?: number;
  59421. frontUVs?: Vector4;
  59422. backUVs?: Vector4;
  59423. }, scene?: Nullable<Scene>): Mesh;
  59424. /**
  59425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59427. * * 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`)
  59428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59429. * * 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
  59430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59433. * @param name defines the name of the mesh
  59434. * @param options defines the options used to create the mesh
  59435. * @param scene defines the hosting scene
  59436. * @returns the icosahedron mesh
  59437. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59438. */
  59439. static CreateIcoSphere(name: string, options: {
  59440. radius?: number;
  59441. radiusX?: number;
  59442. radiusY?: number;
  59443. radiusZ?: number;
  59444. flat?: boolean;
  59445. subdivisions?: number;
  59446. sideOrientation?: number;
  59447. frontUVs?: Vector4;
  59448. backUVs?: Vector4;
  59449. updatable?: boolean;
  59450. }, scene?: Nullable<Scene>): Mesh;
  59451. /**
  59452. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59453. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59454. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59455. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59456. * * 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
  59457. * * 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
  59458. * * 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
  59459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59462. * * 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
  59463. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59464. * * 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
  59465. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59467. * @param name defines the name of the mesh
  59468. * @param options defines the options used to create the mesh
  59469. * @param scene defines the hosting scene
  59470. * @returns the ribbon mesh
  59471. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59473. */
  59474. static CreateRibbon(name: string, options: {
  59475. pathArray: Vector3[][];
  59476. closeArray?: boolean;
  59477. closePath?: boolean;
  59478. offset?: number;
  59479. updatable?: boolean;
  59480. sideOrientation?: number;
  59481. frontUVs?: Vector4;
  59482. backUVs?: Vector4;
  59483. instance?: Mesh;
  59484. invertUV?: boolean;
  59485. uvs?: Vector2[];
  59486. colors?: Color4[];
  59487. }, scene?: Nullable<Scene>): Mesh;
  59488. /**
  59489. * Creates a cylinder or a cone mesh
  59490. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59491. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59492. * * 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.
  59493. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59494. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59495. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59496. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59497. * * 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).
  59498. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59499. * * 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).
  59500. * * 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
  59501. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59502. * * 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
  59503. * * 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.
  59504. * * If `enclose` is false, a ring surface is one element.
  59505. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59506. * * 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
  59507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59510. * @param name defines the name of the mesh
  59511. * @param options defines the options used to create the mesh
  59512. * @param scene defines the hosting scene
  59513. * @returns the cylinder mesh
  59514. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59515. */
  59516. static CreateCylinder(name: string, options: {
  59517. height?: number;
  59518. diameterTop?: number;
  59519. diameterBottom?: number;
  59520. diameter?: number;
  59521. tessellation?: number;
  59522. subdivisions?: number;
  59523. arc?: number;
  59524. faceColors?: Color4[];
  59525. faceUV?: Vector4[];
  59526. updatable?: boolean;
  59527. hasRings?: boolean;
  59528. enclose?: boolean;
  59529. cap?: number;
  59530. sideOrientation?: number;
  59531. frontUVs?: Vector4;
  59532. backUVs?: Vector4;
  59533. }, scene?: Nullable<Scene>): Mesh;
  59534. /**
  59535. * Creates a torus mesh
  59536. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59537. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59538. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59542. * @param name defines the name of the mesh
  59543. * @param options defines the options used to create the mesh
  59544. * @param scene defines the hosting scene
  59545. * @returns the torus mesh
  59546. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59547. */
  59548. static CreateTorus(name: string, options: {
  59549. diameter?: number;
  59550. thickness?: number;
  59551. tessellation?: number;
  59552. updatable?: boolean;
  59553. sideOrientation?: number;
  59554. frontUVs?: Vector4;
  59555. backUVs?: Vector4;
  59556. }, scene?: Nullable<Scene>): Mesh;
  59557. /**
  59558. * Creates a torus knot mesh
  59559. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59560. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59561. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59562. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59566. * @param name defines the name of the mesh
  59567. * @param options defines the options used to create the mesh
  59568. * @param scene defines the hosting scene
  59569. * @returns the torus knot mesh
  59570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59571. */
  59572. static CreateTorusKnot(name: string, options: {
  59573. radius?: number;
  59574. tube?: number;
  59575. radialSegments?: number;
  59576. tubularSegments?: number;
  59577. p?: number;
  59578. q?: number;
  59579. updatable?: boolean;
  59580. sideOrientation?: number;
  59581. frontUVs?: Vector4;
  59582. backUVs?: Vector4;
  59583. }, scene?: Nullable<Scene>): Mesh;
  59584. /**
  59585. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59586. * * 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
  59587. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59588. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59589. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59590. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59591. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59592. * * 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
  59593. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59596. * @param name defines the name of the new line system
  59597. * @param options defines the options used to create the line system
  59598. * @param scene defines the hosting scene
  59599. * @returns a new line system mesh
  59600. */
  59601. static CreateLineSystem(name: string, options: {
  59602. lines: Vector3[][];
  59603. updatable?: boolean;
  59604. instance?: Nullable<LinesMesh>;
  59605. colors?: Nullable<Color4[][]>;
  59606. useVertexAlpha?: boolean;
  59607. }, scene: Nullable<Scene>): LinesMesh;
  59608. /**
  59609. * Creates a line mesh
  59610. * 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
  59611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59612. * * The parameter `points` is an array successive Vector3
  59613. * * 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
  59614. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59616. * * When updating an instance, remember that only point positions can change, not the number of points
  59617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59619. * @param name defines the name of the new line system
  59620. * @param options defines the options used to create the line system
  59621. * @param scene defines the hosting scene
  59622. * @returns a new line mesh
  59623. */
  59624. static CreateLines(name: string, options: {
  59625. points: Vector3[];
  59626. updatable?: boolean;
  59627. instance?: Nullable<LinesMesh>;
  59628. colors?: Color4[];
  59629. useVertexAlpha?: boolean;
  59630. }, scene?: Nullable<Scene>): LinesMesh;
  59631. /**
  59632. * Creates a dashed line mesh
  59633. * * 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
  59634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59635. * * The parameter `points` is an array successive Vector3
  59636. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59637. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59638. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59639. * * 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
  59640. * * When updating an instance, remember that only point positions can change, not the number of points
  59641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59642. * @param name defines the name of the mesh
  59643. * @param options defines the options used to create the mesh
  59644. * @param scene defines the hosting scene
  59645. * @returns the dashed line mesh
  59646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59647. */
  59648. static CreateDashedLines(name: string, options: {
  59649. points: Vector3[];
  59650. dashSize?: number;
  59651. gapSize?: number;
  59652. dashNb?: number;
  59653. updatable?: boolean;
  59654. instance?: LinesMesh;
  59655. }, scene?: Nullable<Scene>): LinesMesh;
  59656. /**
  59657. * 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.
  59658. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  59659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59660. * * The parameter `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.
  59661. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59662. * * 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
  59663. * * 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
  59664. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59669. * @param name defines the name of the mesh
  59670. * @param options defines the options used to create the mesh
  59671. * @param scene defines the hosting scene
  59672. * @returns the extruded shape mesh
  59673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59675. */
  59676. static ExtrudeShape(name: string, options: {
  59677. shape: Vector3[];
  59678. path: Vector3[];
  59679. scale?: number;
  59680. rotation?: number;
  59681. cap?: number;
  59682. updatable?: boolean;
  59683. sideOrientation?: number;
  59684. frontUVs?: Vector4;
  59685. backUVs?: Vector4;
  59686. instance?: Mesh;
  59687. invertUV?: boolean;
  59688. }, scene?: Nullable<Scene>): Mesh;
  59689. /**
  59690. * Creates an custom extruded shape mesh.
  59691. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59692. * * 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.
  59693. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59694. * * 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
  59695. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59696. * * 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
  59697. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59698. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59699. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59700. * * 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
  59701. * * 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
  59702. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59707. * @param name defines the name of the mesh
  59708. * @param options defines the options used to create the mesh
  59709. * @param scene defines the hosting scene
  59710. * @returns the custom extruded shape mesh
  59711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59714. */
  59715. static ExtrudeShapeCustom(name: string, options: {
  59716. shape: Vector3[];
  59717. path: Vector3[];
  59718. scaleFunction?: any;
  59719. rotationFunction?: any;
  59720. ribbonCloseArray?: boolean;
  59721. ribbonClosePath?: boolean;
  59722. cap?: number;
  59723. updatable?: boolean;
  59724. sideOrientation?: number;
  59725. frontUVs?: Vector4;
  59726. backUVs?: Vector4;
  59727. instance?: Mesh;
  59728. invertUV?: boolean;
  59729. }, scene?: Nullable<Scene>): Mesh;
  59730. /**
  59731. * Creates lathe mesh.
  59732. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59733. * * 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
  59734. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59735. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59736. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59737. * * 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
  59738. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59739. * * 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
  59740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59744. * @param name defines the name of the mesh
  59745. * @param options defines the options used to create the mesh
  59746. * @param scene defines the hosting scene
  59747. * @returns the lathe mesh
  59748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59749. */
  59750. static CreateLathe(name: string, options: {
  59751. shape: Vector3[];
  59752. radius?: number;
  59753. tessellation?: number;
  59754. clip?: number;
  59755. arc?: number;
  59756. closed?: boolean;
  59757. updatable?: boolean;
  59758. sideOrientation?: number;
  59759. frontUVs?: Vector4;
  59760. backUVs?: Vector4;
  59761. cap?: number;
  59762. invertUV?: boolean;
  59763. }, scene?: Nullable<Scene>): Mesh;
  59764. /**
  59765. * Creates a tiled plane mesh
  59766. * * You can set a limited pattern arrangement with the tiles
  59767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59770. * @param name defines the name of the mesh
  59771. * @param options defines the options used to create the mesh
  59772. * @param scene defines the hosting scene
  59773. * @returns the plane mesh
  59774. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59775. */
  59776. static CreateTiledPlane(name: string, options: {
  59777. pattern?: number;
  59778. tileSize?: number;
  59779. tileWidth?: number;
  59780. tileHeight?: number;
  59781. size?: number;
  59782. width?: number;
  59783. height?: number;
  59784. alignHorizontal?: number;
  59785. alignVertical?: number;
  59786. sideOrientation?: number;
  59787. frontUVs?: Vector4;
  59788. backUVs?: Vector4;
  59789. updatable?: boolean;
  59790. }, scene?: Nullable<Scene>): Mesh;
  59791. /**
  59792. * Creates a plane mesh
  59793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  59803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59804. */
  59805. static CreatePlane(name: string, options: {
  59806. size?: number;
  59807. width?: number;
  59808. height?: number;
  59809. sideOrientation?: number;
  59810. frontUVs?: Vector4;
  59811. backUVs?: Vector4;
  59812. updatable?: boolean;
  59813. sourcePlane?: Plane;
  59814. }, scene?: Nullable<Scene>): Mesh;
  59815. /**
  59816. * Creates a ground mesh
  59817. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59818. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59820. * @param name defines the name of the mesh
  59821. * @param options defines the options used to create the mesh
  59822. * @param scene defines the hosting scene
  59823. * @returns the ground mesh
  59824. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59825. */
  59826. static CreateGround(name: string, options: {
  59827. width?: number;
  59828. height?: number;
  59829. subdivisions?: number;
  59830. subdivisionsX?: number;
  59831. subdivisionsY?: number;
  59832. updatable?: boolean;
  59833. }, scene?: Nullable<Scene>): Mesh;
  59834. /**
  59835. * Creates a tiled ground mesh
  59836. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59837. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59838. * * 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
  59839. * * 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
  59840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59841. * @param name defines the name of the mesh
  59842. * @param options defines the options used to create the mesh
  59843. * @param scene defines the hosting scene
  59844. * @returns the tiled ground mesh
  59845. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59846. */
  59847. static CreateTiledGround(name: string, options: {
  59848. xmin: number;
  59849. zmin: number;
  59850. xmax: number;
  59851. zmax: number;
  59852. subdivisions?: {
  59853. w: number;
  59854. h: number;
  59855. };
  59856. precision?: {
  59857. w: number;
  59858. h: number;
  59859. };
  59860. updatable?: boolean;
  59861. }, scene?: Nullable<Scene>): Mesh;
  59862. /**
  59863. * Creates a ground mesh from a height map
  59864. * * The parameter `url` sets the URL of the height map image resource.
  59865. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59866. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59867. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59868. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59869. * * 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.
  59870. * * 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).
  59871. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59873. * @param name defines the name of the mesh
  59874. * @param url defines the url to the height map
  59875. * @param options defines the options used to create the mesh
  59876. * @param scene defines the hosting scene
  59877. * @returns the ground mesh
  59878. * @see https://doc.babylonjs.com/babylon101/height_map
  59879. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59880. */
  59881. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59882. width?: number;
  59883. height?: number;
  59884. subdivisions?: number;
  59885. minHeight?: number;
  59886. maxHeight?: number;
  59887. colorFilter?: Color3;
  59888. alphaFilter?: number;
  59889. updatable?: boolean;
  59890. onReady?: (mesh: GroundMesh) => void;
  59891. }, scene?: Nullable<Scene>): GroundMesh;
  59892. /**
  59893. * Creates a polygon mesh
  59894. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59895. * * 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
  59896. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59899. * * Remember you can only change the shape positions, not their number when updating a polygon
  59900. * @param name defines the name of the mesh
  59901. * @param options defines the options used to create the mesh
  59902. * @param scene defines the hosting scene
  59903. * @param earcutInjection can be used to inject your own earcut reference
  59904. * @returns the polygon mesh
  59905. */
  59906. static CreatePolygon(name: string, options: {
  59907. shape: Vector3[];
  59908. holes?: Vector3[][];
  59909. depth?: number;
  59910. faceUV?: Vector4[];
  59911. faceColors?: Color4[];
  59912. updatable?: boolean;
  59913. sideOrientation?: number;
  59914. frontUVs?: Vector4;
  59915. backUVs?: Vector4;
  59916. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59917. /**
  59918. * Creates an extruded polygon mesh, with depth in the Y direction.
  59919. * * 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)
  59920. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59921. * @param name defines the name of the mesh
  59922. * @param options defines the options used to create the mesh
  59923. * @param scene defines the hosting scene
  59924. * @param earcutInjection can be used to inject your own earcut reference
  59925. * @returns the polygon mesh
  59926. */
  59927. static ExtrudePolygon(name: string, options: {
  59928. shape: Vector3[];
  59929. holes?: Vector3[][];
  59930. depth?: number;
  59931. faceUV?: Vector4[];
  59932. faceColors?: Color4[];
  59933. updatable?: boolean;
  59934. sideOrientation?: number;
  59935. frontUVs?: Vector4;
  59936. backUVs?: Vector4;
  59937. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59938. /**
  59939. * Creates a tube mesh.
  59940. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59941. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59942. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59943. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59944. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59945. * * 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)
  59946. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59947. * * 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
  59948. * * 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
  59949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59953. * @param name defines the name of the mesh
  59954. * @param options defines the options used to create the mesh
  59955. * @param scene defines the hosting scene
  59956. * @returns the tube mesh
  59957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59958. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59959. */
  59960. static CreateTube(name: string, options: {
  59961. path: Vector3[];
  59962. radius?: number;
  59963. tessellation?: number;
  59964. radiusFunction?: {
  59965. (i: number, distance: number): number;
  59966. };
  59967. cap?: number;
  59968. arc?: number;
  59969. updatable?: boolean;
  59970. sideOrientation?: number;
  59971. frontUVs?: Vector4;
  59972. backUVs?: Vector4;
  59973. instance?: Mesh;
  59974. invertUV?: boolean;
  59975. }, scene?: Nullable<Scene>): Mesh;
  59976. /**
  59977. * Creates a polyhedron mesh
  59978. * * 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
  59979. * * The parameter `size` (positive float, default 1) sets the polygon size
  59980. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59981. * * 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`
  59982. * * 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
  59983. * * 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)`)
  59984. * * 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
  59985. * * 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
  59986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59989. * @param name defines the name of the mesh
  59990. * @param options defines the options used to create the mesh
  59991. * @param scene defines the hosting scene
  59992. * @returns the polyhedron mesh
  59993. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59994. */
  59995. static CreatePolyhedron(name: string, options: {
  59996. type?: number;
  59997. size?: number;
  59998. sizeX?: number;
  59999. sizeY?: number;
  60000. sizeZ?: number;
  60001. custom?: any;
  60002. faceUV?: Vector4[];
  60003. faceColors?: Color4[];
  60004. flat?: boolean;
  60005. updatable?: boolean;
  60006. sideOrientation?: number;
  60007. frontUVs?: Vector4;
  60008. backUVs?: Vector4;
  60009. }, scene?: Nullable<Scene>): Mesh;
  60010. /**
  60011. * Creates a decal mesh.
  60012. * 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
  60013. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60014. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60015. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60016. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60017. * @param name defines the name of the mesh
  60018. * @param sourceMesh defines the mesh where the decal must be applied
  60019. * @param options defines the options used to create the mesh
  60020. * @param scene defines the hosting scene
  60021. * @returns the decal mesh
  60022. * @see https://doc.babylonjs.com/how_to/decals
  60023. */
  60024. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60025. position?: Vector3;
  60026. normal?: Vector3;
  60027. size?: Vector3;
  60028. angle?: number;
  60029. }): Mesh;
  60030. }
  60031. }
  60032. declare module "babylonjs/Meshes/meshSimplification" {
  60033. import { Mesh } from "babylonjs/Meshes/mesh";
  60034. /**
  60035. * A simplifier interface for future simplification implementations
  60036. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60037. */
  60038. export interface ISimplifier {
  60039. /**
  60040. * Simplification of a given mesh according to the given settings.
  60041. * Since this requires computation, it is assumed that the function runs async.
  60042. * @param settings The settings of the simplification, including quality and distance
  60043. * @param successCallback A callback that will be called after the mesh was simplified.
  60044. * @param errorCallback in case of an error, this callback will be called. optional.
  60045. */
  60046. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60047. }
  60048. /**
  60049. * Expected simplification settings.
  60050. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60051. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60052. */
  60053. export interface ISimplificationSettings {
  60054. /**
  60055. * Gets or sets the expected quality
  60056. */
  60057. quality: number;
  60058. /**
  60059. * Gets or sets the distance when this optimized version should be used
  60060. */
  60061. distance: number;
  60062. /**
  60063. * Gets an already optimized mesh
  60064. */
  60065. optimizeMesh?: boolean;
  60066. }
  60067. /**
  60068. * Class used to specify simplification options
  60069. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60070. */
  60071. export class SimplificationSettings implements ISimplificationSettings {
  60072. /** expected quality */
  60073. quality: number;
  60074. /** distance when this optimized version should be used */
  60075. distance: number;
  60076. /** already optimized mesh */
  60077. optimizeMesh?: boolean | undefined;
  60078. /**
  60079. * Creates a SimplificationSettings
  60080. * @param quality expected quality
  60081. * @param distance distance when this optimized version should be used
  60082. * @param optimizeMesh already optimized mesh
  60083. */
  60084. constructor(
  60085. /** expected quality */
  60086. quality: number,
  60087. /** distance when this optimized version should be used */
  60088. distance: number,
  60089. /** already optimized mesh */
  60090. optimizeMesh?: boolean | undefined);
  60091. }
  60092. /**
  60093. * Interface used to define a simplification task
  60094. */
  60095. export interface ISimplificationTask {
  60096. /**
  60097. * Array of settings
  60098. */
  60099. settings: Array<ISimplificationSettings>;
  60100. /**
  60101. * Simplification type
  60102. */
  60103. simplificationType: SimplificationType;
  60104. /**
  60105. * Mesh to simplify
  60106. */
  60107. mesh: Mesh;
  60108. /**
  60109. * Callback called on success
  60110. */
  60111. successCallback?: () => void;
  60112. /**
  60113. * Defines if parallel processing can be used
  60114. */
  60115. parallelProcessing: boolean;
  60116. }
  60117. /**
  60118. * Queue used to order the simplification tasks
  60119. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60120. */
  60121. export class SimplificationQueue {
  60122. private _simplificationArray;
  60123. /**
  60124. * Gets a boolean indicating that the process is still running
  60125. */
  60126. running: boolean;
  60127. /**
  60128. * Creates a new queue
  60129. */
  60130. constructor();
  60131. /**
  60132. * Adds a new simplification task
  60133. * @param task defines a task to add
  60134. */
  60135. addTask(task: ISimplificationTask): void;
  60136. /**
  60137. * Execute next task
  60138. */
  60139. executeNext(): void;
  60140. /**
  60141. * Execute a simplification task
  60142. * @param task defines the task to run
  60143. */
  60144. runSimplification(task: ISimplificationTask): void;
  60145. private getSimplifier;
  60146. }
  60147. /**
  60148. * The implemented types of simplification
  60149. * At the moment only Quadratic Error Decimation is implemented
  60150. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60151. */
  60152. export enum SimplificationType {
  60153. /** Quadratic error decimation */
  60154. QUADRATIC = 0
  60155. }
  60156. }
  60157. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60158. import { Scene } from "babylonjs/scene";
  60159. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60160. import { ISceneComponent } from "babylonjs/sceneComponent";
  60161. module "babylonjs/scene" {
  60162. interface Scene {
  60163. /** @hidden (Backing field) */
  60164. _simplificationQueue: SimplificationQueue;
  60165. /**
  60166. * Gets or sets the simplification queue attached to the scene
  60167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60168. */
  60169. simplificationQueue: SimplificationQueue;
  60170. }
  60171. }
  60172. module "babylonjs/Meshes/mesh" {
  60173. interface Mesh {
  60174. /**
  60175. * Simplify the mesh according to the given array of settings.
  60176. * Function will return immediately and will simplify async
  60177. * @param settings a collection of simplification settings
  60178. * @param parallelProcessing should all levels calculate parallel or one after the other
  60179. * @param simplificationType the type of simplification to run
  60180. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60181. * @returns the current mesh
  60182. */
  60183. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60184. }
  60185. }
  60186. /**
  60187. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60188. * created in a scene
  60189. */
  60190. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60191. /**
  60192. * The component name helpfull to identify the component in the list of scene components.
  60193. */
  60194. readonly name: string;
  60195. /**
  60196. * The scene the component belongs to.
  60197. */
  60198. scene: Scene;
  60199. /**
  60200. * Creates a new instance of the component for the given scene
  60201. * @param scene Defines the scene to register the component in
  60202. */
  60203. constructor(scene: Scene);
  60204. /**
  60205. * Registers the component in a given scene
  60206. */
  60207. register(): void;
  60208. /**
  60209. * Rebuilds the elements related to this component in case of
  60210. * context lost for instance.
  60211. */
  60212. rebuild(): void;
  60213. /**
  60214. * Disposes the component and the associated ressources
  60215. */
  60216. dispose(): void;
  60217. private _beforeCameraUpdate;
  60218. }
  60219. }
  60220. declare module "babylonjs/Meshes/Builders/index" {
  60221. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60222. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60223. export * from "babylonjs/Meshes/Builders/discBuilder";
  60224. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60225. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60226. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60227. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60228. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60229. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60230. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60231. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60232. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60233. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60234. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60235. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60236. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60237. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60238. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60239. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60240. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60241. }
  60242. declare module "babylonjs/Meshes/index" {
  60243. export * from "babylonjs/Meshes/abstractMesh";
  60244. export * from "babylonjs/Meshes/buffer";
  60245. export * from "babylonjs/Meshes/Compression/index";
  60246. export * from "babylonjs/Meshes/csg";
  60247. export * from "babylonjs/Meshes/geometry";
  60248. export * from "babylonjs/Meshes/groundMesh";
  60249. export * from "babylonjs/Meshes/trailMesh";
  60250. export * from "babylonjs/Meshes/instancedMesh";
  60251. export * from "babylonjs/Meshes/linesMesh";
  60252. export * from "babylonjs/Meshes/mesh";
  60253. export * from "babylonjs/Meshes/mesh.vertexData";
  60254. export * from "babylonjs/Meshes/meshBuilder";
  60255. export * from "babylonjs/Meshes/meshSimplification";
  60256. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60257. export * from "babylonjs/Meshes/polygonMesh";
  60258. export * from "babylonjs/Meshes/subMesh";
  60259. export * from "babylonjs/Meshes/meshLODLevel";
  60260. export * from "babylonjs/Meshes/transformNode";
  60261. export * from "babylonjs/Meshes/Builders/index";
  60262. export * from "babylonjs/Meshes/dataBuffer";
  60263. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60264. }
  60265. declare module "babylonjs/Morph/index" {
  60266. export * from "babylonjs/Morph/morphTarget";
  60267. export * from "babylonjs/Morph/morphTargetManager";
  60268. }
  60269. declare module "babylonjs/Navigation/INavigationEngine" {
  60270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60271. import { Vector3 } from "babylonjs/Maths/math";
  60272. import { Mesh } from "babylonjs/Meshes/mesh";
  60273. import { Scene } from "babylonjs/scene";
  60274. /**
  60275. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60276. */
  60277. export interface INavigationEnginePlugin {
  60278. /**
  60279. * plugin name
  60280. */
  60281. name: string;
  60282. /**
  60283. * Creates a navigation mesh
  60284. * @param meshes array of all the geometry used to compute the navigatio mesh
  60285. * @param parameters bunch of parameters used to filter geometry
  60286. */
  60287. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60288. /**
  60289. * Create a navigation mesh debug mesh
  60290. * @param scene is where the mesh will be added
  60291. * @returns debug display mesh
  60292. */
  60293. createDebugNavMesh(scene: Scene): Mesh;
  60294. /**
  60295. * Get a navigation mesh constrained position, closest to the parameter position
  60296. * @param position world position
  60297. * @returns the closest point to position constrained by the navigation mesh
  60298. */
  60299. getClosestPoint(position: Vector3): Vector3;
  60300. /**
  60301. * Get a navigation mesh constrained position, within a particular radius
  60302. * @param position world position
  60303. * @param maxRadius the maximum distance to the constrained world position
  60304. * @returns the closest point to position constrained by the navigation mesh
  60305. */
  60306. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60307. /**
  60308. * Compute the final position from a segment made of destination-position
  60309. * @param position world position
  60310. * @param destination world position
  60311. * @returns the resulting point along the navmesh
  60312. */
  60313. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60314. /**
  60315. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60316. * @param start world position
  60317. * @param end world position
  60318. * @returns array containing world position composing the path
  60319. */
  60320. computePath(start: Vector3, end: Vector3): Vector3[];
  60321. /**
  60322. * If this plugin is supported
  60323. * @returns true if plugin is supported
  60324. */
  60325. isSupported(): boolean;
  60326. /**
  60327. * Create a new Crowd so you can add agents
  60328. * @param maxAgents the maximum agent count in the crowd
  60329. * @param maxAgentRadius the maximum radius an agent can have
  60330. * @param scene to attach the crowd to
  60331. * @returns the crowd you can add agents to
  60332. */
  60333. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60334. /**
  60335. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60336. * The queries will try to find a solution within those bounds
  60337. * default is (1,1,1)
  60338. * @param extent x,y,z value that define the extent around the queries point of reference
  60339. */
  60340. setDefaultQueryExtent(extent: Vector3): void;
  60341. /**
  60342. * Get the Bounding box extent specified by setDefaultQueryExtent
  60343. * @returns the box extent values
  60344. */
  60345. getDefaultQueryExtent(): Vector3;
  60346. /**
  60347. * Release all resources
  60348. */
  60349. dispose(): void;
  60350. }
  60351. /**
  60352. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60353. */
  60354. export interface ICrowd {
  60355. /**
  60356. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60357. * You can attach anything to that node. The node position is updated in the scene update tick.
  60358. * @param pos world position that will be constrained by the navigation mesh
  60359. * @param parameters agent parameters
  60360. * @param transform hooked to the agent that will be update by the scene
  60361. * @returns agent index
  60362. */
  60363. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60364. /**
  60365. * Returns the agent position in world space
  60366. * @param index agent index returned by addAgent
  60367. * @returns world space position
  60368. */
  60369. getAgentPosition(index: number): Vector3;
  60370. /**
  60371. * Gets the agent velocity in world space
  60372. * @param index agent index returned by addAgent
  60373. * @returns world space velocity
  60374. */
  60375. getAgentVelocity(index: number): Vector3;
  60376. /**
  60377. * remove a particular agent previously created
  60378. * @param index agent index returned by addAgent
  60379. */
  60380. removeAgent(index: number): void;
  60381. /**
  60382. * get the list of all agents attached to this crowd
  60383. * @returns list of agent indices
  60384. */
  60385. getAgents(): number[];
  60386. /**
  60387. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60388. * @param deltaTime in seconds
  60389. */
  60390. update(deltaTime: number): void;
  60391. /**
  60392. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60393. * @param index agent index returned by addAgent
  60394. * @param destination targeted world position
  60395. */
  60396. agentGoto(index: number, destination: Vector3): void;
  60397. /**
  60398. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60399. * The queries will try to find a solution within those bounds
  60400. * default is (1,1,1)
  60401. * @param extent x,y,z value that define the extent around the queries point of reference
  60402. */
  60403. setDefaultQueryExtent(extent: Vector3): void;
  60404. /**
  60405. * Get the Bounding box extent specified by setDefaultQueryExtent
  60406. * @returns the box extent values
  60407. */
  60408. getDefaultQueryExtent(): Vector3;
  60409. /**
  60410. * Release all resources
  60411. */
  60412. dispose(): void;
  60413. }
  60414. /**
  60415. * Configures an agent
  60416. */
  60417. export interface IAgentParameters {
  60418. /**
  60419. * Agent radius. [Limit: >= 0]
  60420. */
  60421. radius: number;
  60422. /**
  60423. * Agent height. [Limit: > 0]
  60424. */
  60425. height: number;
  60426. /**
  60427. * Maximum allowed acceleration. [Limit: >= 0]
  60428. */
  60429. maxAcceleration: number;
  60430. /**
  60431. * Maximum allowed speed. [Limit: >= 0]
  60432. */
  60433. maxSpeed: number;
  60434. /**
  60435. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60436. */
  60437. collisionQueryRange: number;
  60438. /**
  60439. * The path visibility optimization range. [Limit: > 0]
  60440. */
  60441. pathOptimizationRange: number;
  60442. /**
  60443. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60444. */
  60445. separationWeight: number;
  60446. }
  60447. /**
  60448. * Configures the navigation mesh creation
  60449. */
  60450. export interface INavMeshParameters {
  60451. /**
  60452. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60453. */
  60454. cs: number;
  60455. /**
  60456. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60457. */
  60458. ch: number;
  60459. /**
  60460. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60461. */
  60462. walkableSlopeAngle: number;
  60463. /**
  60464. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60465. * be considered walkable. [Limit: >= 3] [Units: vx]
  60466. */
  60467. walkableHeight: number;
  60468. /**
  60469. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60470. */
  60471. walkableClimb: number;
  60472. /**
  60473. * The distance to erode/shrink the walkable area of the heightfield away from
  60474. * obstructions. [Limit: >=0] [Units: vx]
  60475. */
  60476. walkableRadius: number;
  60477. /**
  60478. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60479. */
  60480. maxEdgeLen: number;
  60481. /**
  60482. * The maximum distance a simplfied contour's border edges should deviate
  60483. * the original raw contour. [Limit: >=0] [Units: vx]
  60484. */
  60485. maxSimplificationError: number;
  60486. /**
  60487. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60488. */
  60489. minRegionArea: number;
  60490. /**
  60491. * Any regions with a span count smaller than this value will, if possible,
  60492. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60493. */
  60494. mergeRegionArea: number;
  60495. /**
  60496. * The maximum number of vertices allowed for polygons generated during the
  60497. * contour to polygon conversion process. [Limit: >= 3]
  60498. */
  60499. maxVertsPerPoly: number;
  60500. /**
  60501. * Sets the sampling distance to use when generating the detail mesh.
  60502. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60503. */
  60504. detailSampleDist: number;
  60505. /**
  60506. * The maximum distance the detail mesh surface should deviate from heightfield
  60507. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60508. */
  60509. detailSampleMaxError: number;
  60510. }
  60511. }
  60512. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60513. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60514. import { Mesh } from "babylonjs/Meshes/mesh";
  60515. import { Scene } from "babylonjs/scene";
  60516. import { Vector3 } from "babylonjs/Maths/math";
  60517. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60518. /**
  60519. * RecastJS navigation plugin
  60520. */
  60521. export class RecastJSPlugin implements INavigationEnginePlugin {
  60522. /**
  60523. * Reference to the Recast library
  60524. */
  60525. bjsRECAST: any;
  60526. /**
  60527. * plugin name
  60528. */
  60529. name: string;
  60530. /**
  60531. * the first navmesh created. We might extend this to support multiple navmeshes
  60532. */
  60533. navMesh: any;
  60534. /**
  60535. * Initializes the recastJS plugin
  60536. * @param recastInjection can be used to inject your own recast reference
  60537. */
  60538. constructor(recastInjection?: any);
  60539. /**
  60540. * Creates a navigation mesh
  60541. * @param meshes array of all the geometry used to compute the navigatio mesh
  60542. * @param parameters bunch of parameters used to filter geometry
  60543. */
  60544. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60545. /**
  60546. * Create a navigation mesh debug mesh
  60547. * @param scene is where the mesh will be added
  60548. * @returns debug display mesh
  60549. */
  60550. createDebugNavMesh(scene: Scene): Mesh;
  60551. /**
  60552. * Get a navigation mesh constrained position, closest to the parameter position
  60553. * @param position world position
  60554. * @returns the closest point to position constrained by the navigation mesh
  60555. */
  60556. getClosestPoint(position: Vector3): Vector3;
  60557. /**
  60558. * Get a navigation mesh constrained position, within a particular radius
  60559. * @param position world position
  60560. * @param maxRadius the maximum distance to the constrained world position
  60561. * @returns the closest point to position constrained by the navigation mesh
  60562. */
  60563. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60564. /**
  60565. * Compute the final position from a segment made of destination-position
  60566. * @param position world position
  60567. * @param destination world position
  60568. * @returns the resulting point along the navmesh
  60569. */
  60570. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60571. /**
  60572. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60573. * @param start world position
  60574. * @param end world position
  60575. * @returns array containing world position composing the path
  60576. */
  60577. computePath(start: Vector3, end: Vector3): Vector3[];
  60578. /**
  60579. * Create a new Crowd so you can add agents
  60580. * @param maxAgents the maximum agent count in the crowd
  60581. * @param maxAgentRadius the maximum radius an agent can have
  60582. * @param scene to attach the crowd to
  60583. * @returns the crowd you can add agents to
  60584. */
  60585. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60586. /**
  60587. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60588. * The queries will try to find a solution within those bounds
  60589. * default is (1,1,1)
  60590. * @param extent x,y,z value that define the extent around the queries point of reference
  60591. */
  60592. setDefaultQueryExtent(extent: Vector3): void;
  60593. /**
  60594. * Get the Bounding box extent specified by setDefaultQueryExtent
  60595. * @returns the box extent values
  60596. */
  60597. getDefaultQueryExtent(): Vector3;
  60598. /**
  60599. * Disposes
  60600. */
  60601. dispose(): void;
  60602. /**
  60603. * If this plugin is supported
  60604. * @returns true if plugin is supported
  60605. */
  60606. isSupported(): boolean;
  60607. }
  60608. /**
  60609. * Recast detour crowd implementation
  60610. */
  60611. export class RecastJSCrowd implements ICrowd {
  60612. /**
  60613. * Recast/detour plugin
  60614. */
  60615. bjsRECASTPlugin: RecastJSPlugin;
  60616. /**
  60617. * Link to the detour crowd
  60618. */
  60619. recastCrowd: any;
  60620. /**
  60621. * One transform per agent
  60622. */
  60623. transforms: TransformNode[];
  60624. /**
  60625. * All agents created
  60626. */
  60627. agents: number[];
  60628. /**
  60629. * Link to the scene is kept to unregister the crowd from the scene
  60630. */
  60631. private _scene;
  60632. /**
  60633. * Observer for crowd updates
  60634. */
  60635. private _onBeforeAnimationsObserver;
  60636. /**
  60637. * Constructor
  60638. * @param plugin recastJS plugin
  60639. * @param maxAgents the maximum agent count in the crowd
  60640. * @param maxAgentRadius the maximum radius an agent can have
  60641. * @param scene to attach the crowd to
  60642. * @returns the crowd you can add agents to
  60643. */
  60644. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60645. /**
  60646. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60647. * You can attach anything to that node. The node position is updated in the scene update tick.
  60648. * @param pos world position that will be constrained by the navigation mesh
  60649. * @param parameters agent parameters
  60650. * @param transform hooked to the agent that will be update by the scene
  60651. * @returns agent index
  60652. */
  60653. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60654. /**
  60655. * Returns the agent position in world space
  60656. * @param index agent index returned by addAgent
  60657. * @returns world space position
  60658. */
  60659. getAgentPosition(index: number): Vector3;
  60660. /**
  60661. * Returns the agent velocity in world space
  60662. * @param index agent index returned by addAgent
  60663. * @returns world space velocity
  60664. */
  60665. getAgentVelocity(index: number): Vector3;
  60666. /**
  60667. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60668. * @param index agent index returned by addAgent
  60669. * @param destination targeted world position
  60670. */
  60671. agentGoto(index: number, destination: Vector3): void;
  60672. /**
  60673. * remove a particular agent previously created
  60674. * @param index agent index returned by addAgent
  60675. */
  60676. removeAgent(index: number): void;
  60677. /**
  60678. * get the list of all agents attached to this crowd
  60679. * @returns list of agent indices
  60680. */
  60681. getAgents(): number[];
  60682. /**
  60683. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60684. * @param deltaTime in seconds
  60685. */
  60686. update(deltaTime: number): void;
  60687. /**
  60688. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60689. * The queries will try to find a solution within those bounds
  60690. * default is (1,1,1)
  60691. * @param extent x,y,z value that define the extent around the queries point of reference
  60692. */
  60693. setDefaultQueryExtent(extent: Vector3): void;
  60694. /**
  60695. * Get the Bounding box extent specified by setDefaultQueryExtent
  60696. * @returns the box extent values
  60697. */
  60698. getDefaultQueryExtent(): Vector3;
  60699. /**
  60700. * Release all resources
  60701. */
  60702. dispose(): void;
  60703. }
  60704. }
  60705. declare module "babylonjs/Navigation/Plugins/index" {
  60706. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60707. }
  60708. declare module "babylonjs/Navigation/index" {
  60709. export * from "babylonjs/Navigation/INavigationEngine";
  60710. export * from "babylonjs/Navigation/Plugins/index";
  60711. }
  60712. declare module "babylonjs/Offline/database" {
  60713. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60714. /**
  60715. * Class used to enable access to IndexedDB
  60716. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60717. */
  60718. export class Database implements IOfflineProvider {
  60719. private _callbackManifestChecked;
  60720. private _currentSceneUrl;
  60721. private _db;
  60722. private _enableSceneOffline;
  60723. private _enableTexturesOffline;
  60724. private _manifestVersionFound;
  60725. private _mustUpdateRessources;
  60726. private _hasReachedQuota;
  60727. private _isSupported;
  60728. private _idbFactory;
  60729. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60730. private static IsUASupportingBlobStorage;
  60731. /**
  60732. * Gets a boolean indicating if Database storate is enabled (off by default)
  60733. */
  60734. static IDBStorageEnabled: boolean;
  60735. /**
  60736. * Gets a boolean indicating if scene must be saved in the database
  60737. */
  60738. readonly enableSceneOffline: boolean;
  60739. /**
  60740. * Gets a boolean indicating if textures must be saved in the database
  60741. */
  60742. readonly enableTexturesOffline: boolean;
  60743. /**
  60744. * Creates a new Database
  60745. * @param urlToScene defines the url to load the scene
  60746. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60747. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60748. */
  60749. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60750. private static _ParseURL;
  60751. private static _ReturnFullUrlLocation;
  60752. private _checkManifestFile;
  60753. /**
  60754. * Open the database and make it available
  60755. * @param successCallback defines the callback to call on success
  60756. * @param errorCallback defines the callback to call on error
  60757. */
  60758. open(successCallback: () => void, errorCallback: () => void): void;
  60759. /**
  60760. * Loads an image from the database
  60761. * @param url defines the url to load from
  60762. * @param image defines the target DOM image
  60763. */
  60764. loadImage(url: string, image: HTMLImageElement): void;
  60765. private _loadImageFromDBAsync;
  60766. private _saveImageIntoDBAsync;
  60767. private _checkVersionFromDB;
  60768. private _loadVersionFromDBAsync;
  60769. private _saveVersionIntoDBAsync;
  60770. /**
  60771. * Loads a file from database
  60772. * @param url defines the URL to load from
  60773. * @param sceneLoaded defines a callback to call on success
  60774. * @param progressCallBack defines a callback to call when progress changed
  60775. * @param errorCallback defines a callback to call on error
  60776. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60777. */
  60778. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60779. private _loadFileAsync;
  60780. private _saveFileAsync;
  60781. /**
  60782. * Validates if xhr data is correct
  60783. * @param xhr defines the request to validate
  60784. * @param dataType defines the expected data type
  60785. * @returns true if data is correct
  60786. */
  60787. private static _ValidateXHRData;
  60788. }
  60789. }
  60790. declare module "babylonjs/Offline/index" {
  60791. export * from "babylonjs/Offline/database";
  60792. export * from "babylonjs/Offline/IOfflineProvider";
  60793. }
  60794. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60795. /** @hidden */
  60796. export var gpuUpdateParticlesPixelShader: {
  60797. name: string;
  60798. shader: string;
  60799. };
  60800. }
  60801. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60802. /** @hidden */
  60803. export var gpuUpdateParticlesVertexShader: {
  60804. name: string;
  60805. shader: string;
  60806. };
  60807. }
  60808. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60809. /** @hidden */
  60810. export var clipPlaneFragmentDeclaration2: {
  60811. name: string;
  60812. shader: string;
  60813. };
  60814. }
  60815. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60816. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60817. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60818. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60819. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60820. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60821. /** @hidden */
  60822. export var gpuRenderParticlesPixelShader: {
  60823. name: string;
  60824. shader: string;
  60825. };
  60826. }
  60827. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60828. /** @hidden */
  60829. export var clipPlaneVertexDeclaration2: {
  60830. name: string;
  60831. shader: string;
  60832. };
  60833. }
  60834. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60835. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60836. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60837. /** @hidden */
  60838. export var gpuRenderParticlesVertexShader: {
  60839. name: string;
  60840. shader: string;
  60841. };
  60842. }
  60843. declare module "babylonjs/Particles/gpuParticleSystem" {
  60844. import { Nullable } from "babylonjs/types";
  60845. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60846. import { Observable } from "babylonjs/Misc/observable";
  60847. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60849. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60850. import { Scene, IDisposable } from "babylonjs/scene";
  60851. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60852. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60853. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60854. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60855. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60856. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60857. /**
  60858. * This represents a GPU particle system in Babylon
  60859. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60860. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60861. */
  60862. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60863. /**
  60864. * The layer mask we are rendering the particles through.
  60865. */
  60866. layerMask: number;
  60867. private _capacity;
  60868. private _activeCount;
  60869. private _currentActiveCount;
  60870. private _accumulatedCount;
  60871. private _renderEffect;
  60872. private _updateEffect;
  60873. private _buffer0;
  60874. private _buffer1;
  60875. private _spriteBuffer;
  60876. private _updateVAO;
  60877. private _renderVAO;
  60878. private _targetIndex;
  60879. private _sourceBuffer;
  60880. private _targetBuffer;
  60881. private _engine;
  60882. private _currentRenderId;
  60883. private _started;
  60884. private _stopped;
  60885. private _timeDelta;
  60886. private _randomTexture;
  60887. private _randomTexture2;
  60888. private _attributesStrideSize;
  60889. private _updateEffectOptions;
  60890. private _randomTextureSize;
  60891. private _actualFrame;
  60892. private readonly _rawTextureWidth;
  60893. /**
  60894. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60895. */
  60896. static readonly IsSupported: boolean;
  60897. /**
  60898. * An event triggered when the system is disposed.
  60899. */
  60900. onDisposeObservable: Observable<GPUParticleSystem>;
  60901. /**
  60902. * Gets the maximum number of particles active at the same time.
  60903. * @returns The max number of active particles.
  60904. */
  60905. getCapacity(): number;
  60906. /**
  60907. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60908. * to override the particles.
  60909. */
  60910. forceDepthWrite: boolean;
  60911. /**
  60912. * Gets or set the number of active particles
  60913. */
  60914. activeParticleCount: number;
  60915. private _preWarmDone;
  60916. /**
  60917. * Is this system ready to be used/rendered
  60918. * @return true if the system is ready
  60919. */
  60920. isReady(): boolean;
  60921. /**
  60922. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60923. * @returns True if it has been started, otherwise false.
  60924. */
  60925. isStarted(): boolean;
  60926. /**
  60927. * Starts the particle system and begins to emit
  60928. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60929. */
  60930. start(delay?: number): void;
  60931. /**
  60932. * Stops the particle system.
  60933. */
  60934. stop(): void;
  60935. /**
  60936. * Remove all active particles
  60937. */
  60938. reset(): void;
  60939. /**
  60940. * Returns the string "GPUParticleSystem"
  60941. * @returns a string containing the class name
  60942. */
  60943. getClassName(): string;
  60944. private _colorGradientsTexture;
  60945. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60946. /**
  60947. * Adds a new color gradient
  60948. * @param gradient defines the gradient to use (between 0 and 1)
  60949. * @param color1 defines the color to affect to the specified gradient
  60950. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60951. * @returns the current particle system
  60952. */
  60953. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60954. /**
  60955. * Remove a specific color gradient
  60956. * @param gradient defines the gradient to remove
  60957. * @returns the current particle system
  60958. */
  60959. removeColorGradient(gradient: number): GPUParticleSystem;
  60960. private _angularSpeedGradientsTexture;
  60961. private _sizeGradientsTexture;
  60962. private _velocityGradientsTexture;
  60963. private _limitVelocityGradientsTexture;
  60964. private _dragGradientsTexture;
  60965. private _addFactorGradient;
  60966. /**
  60967. * Adds a new size gradient
  60968. * @param gradient defines the gradient to use (between 0 and 1)
  60969. * @param factor defines the size factor to affect to the specified gradient
  60970. * @returns the current particle system
  60971. */
  60972. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60973. /**
  60974. * Remove a specific size gradient
  60975. * @param gradient defines the gradient to remove
  60976. * @returns the current particle system
  60977. */
  60978. removeSizeGradient(gradient: number): GPUParticleSystem;
  60979. /**
  60980. * Adds a new angular speed gradient
  60981. * @param gradient defines the gradient to use (between 0 and 1)
  60982. * @param factor defines the angular speed to affect to the specified gradient
  60983. * @returns the current particle system
  60984. */
  60985. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60986. /**
  60987. * Remove a specific angular speed gradient
  60988. * @param gradient defines the gradient to remove
  60989. * @returns the current particle system
  60990. */
  60991. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60992. /**
  60993. * Adds a new velocity gradient
  60994. * @param gradient defines the gradient to use (between 0 and 1)
  60995. * @param factor defines the velocity to affect to the specified gradient
  60996. * @returns the current particle system
  60997. */
  60998. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60999. /**
  61000. * Remove a specific velocity gradient
  61001. * @param gradient defines the gradient to remove
  61002. * @returns the current particle system
  61003. */
  61004. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61005. /**
  61006. * Adds a new limit velocity gradient
  61007. * @param gradient defines the gradient to use (between 0 and 1)
  61008. * @param factor defines the limit velocity value to affect to the specified gradient
  61009. * @returns the current particle system
  61010. */
  61011. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61012. /**
  61013. * Remove a specific limit velocity gradient
  61014. * @param gradient defines the gradient to remove
  61015. * @returns the current particle system
  61016. */
  61017. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61018. /**
  61019. * Adds a new drag gradient
  61020. * @param gradient defines the gradient to use (between 0 and 1)
  61021. * @param factor defines the drag value to affect to the specified gradient
  61022. * @returns the current particle system
  61023. */
  61024. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61025. /**
  61026. * Remove a specific drag gradient
  61027. * @param gradient defines the gradient to remove
  61028. * @returns the current particle system
  61029. */
  61030. removeDragGradient(gradient: number): GPUParticleSystem;
  61031. /**
  61032. * Not supported by GPUParticleSystem
  61033. * @param gradient defines the gradient to use (between 0 and 1)
  61034. * @param factor defines the emit rate value to affect to the specified gradient
  61035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61036. * @returns the current particle system
  61037. */
  61038. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61039. /**
  61040. * Not supported by GPUParticleSystem
  61041. * @param gradient defines the gradient to remove
  61042. * @returns the current particle system
  61043. */
  61044. removeEmitRateGradient(gradient: number): IParticleSystem;
  61045. /**
  61046. * Not supported by GPUParticleSystem
  61047. * @param gradient defines the gradient to use (between 0 and 1)
  61048. * @param factor defines the start size value to affect to the specified gradient
  61049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61050. * @returns the current particle system
  61051. */
  61052. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61053. /**
  61054. * Not supported by GPUParticleSystem
  61055. * @param gradient defines the gradient to remove
  61056. * @returns the current particle system
  61057. */
  61058. removeStartSizeGradient(gradient: number): IParticleSystem;
  61059. /**
  61060. * Not supported by GPUParticleSystem
  61061. * @param gradient defines the gradient to use (between 0 and 1)
  61062. * @param min defines the color remap minimal range
  61063. * @param max defines the color remap maximal range
  61064. * @returns the current particle system
  61065. */
  61066. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61067. /**
  61068. * Not supported by GPUParticleSystem
  61069. * @param gradient defines the gradient to remove
  61070. * @returns the current particle system
  61071. */
  61072. removeColorRemapGradient(): IParticleSystem;
  61073. /**
  61074. * Not supported by GPUParticleSystem
  61075. * @param gradient defines the gradient to use (between 0 and 1)
  61076. * @param min defines the alpha remap minimal range
  61077. * @param max defines the alpha remap maximal range
  61078. * @returns the current particle system
  61079. */
  61080. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61081. /**
  61082. * Not supported by GPUParticleSystem
  61083. * @param gradient defines the gradient to remove
  61084. * @returns the current particle system
  61085. */
  61086. removeAlphaRemapGradient(): IParticleSystem;
  61087. /**
  61088. * Not supported by GPUParticleSystem
  61089. * @param gradient defines the gradient to use (between 0 and 1)
  61090. * @param color defines the color to affect to the specified gradient
  61091. * @returns the current particle system
  61092. */
  61093. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61094. /**
  61095. * Not supported by GPUParticleSystem
  61096. * @param gradient defines the gradient to remove
  61097. * @returns the current particle system
  61098. */
  61099. removeRampGradient(): IParticleSystem;
  61100. /**
  61101. * Not supported by GPUParticleSystem
  61102. * @returns the list of ramp gradients
  61103. */
  61104. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61105. /**
  61106. * Not supported by GPUParticleSystem
  61107. * Gets or sets a boolean indicating that ramp gradients must be used
  61108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61109. */
  61110. useRampGradients: boolean;
  61111. /**
  61112. * Not supported by GPUParticleSystem
  61113. * @param gradient defines the gradient to use (between 0 and 1)
  61114. * @param factor defines the life time factor to affect to the specified gradient
  61115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61116. * @returns the current particle system
  61117. */
  61118. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61119. /**
  61120. * Not supported by GPUParticleSystem
  61121. * @param gradient defines the gradient to remove
  61122. * @returns the current particle system
  61123. */
  61124. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61125. /**
  61126. * Instantiates a GPU particle system.
  61127. * 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.
  61128. * @param name The name of the particle system
  61129. * @param options The options used to create the system
  61130. * @param scene The scene the particle system belongs to
  61131. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61132. */
  61133. constructor(name: string, options: Partial<{
  61134. capacity: number;
  61135. randomTextureSize: number;
  61136. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61137. protected _reset(): void;
  61138. private _createUpdateVAO;
  61139. private _createRenderVAO;
  61140. private _initialize;
  61141. /** @hidden */
  61142. _recreateUpdateEffect(): void;
  61143. /** @hidden */
  61144. _recreateRenderEffect(): void;
  61145. /**
  61146. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61147. * @param preWarm defines if we are in the pre-warmimg phase
  61148. */
  61149. animate(preWarm?: boolean): void;
  61150. private _createFactorGradientTexture;
  61151. private _createSizeGradientTexture;
  61152. private _createAngularSpeedGradientTexture;
  61153. private _createVelocityGradientTexture;
  61154. private _createLimitVelocityGradientTexture;
  61155. private _createDragGradientTexture;
  61156. private _createColorGradientTexture;
  61157. /**
  61158. * Renders the particle system in its current state
  61159. * @param preWarm defines if the system should only update the particles but not render them
  61160. * @returns the current number of particles
  61161. */
  61162. render(preWarm?: boolean): number;
  61163. /**
  61164. * Rebuilds the particle system
  61165. */
  61166. rebuild(): void;
  61167. private _releaseBuffers;
  61168. private _releaseVAOs;
  61169. /**
  61170. * Disposes the particle system and free the associated resources
  61171. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61172. */
  61173. dispose(disposeTexture?: boolean): void;
  61174. /**
  61175. * Clones the particle system.
  61176. * @param name The name of the cloned object
  61177. * @param newEmitter The new emitter to use
  61178. * @returns the cloned particle system
  61179. */
  61180. clone(name: string, newEmitter: any): GPUParticleSystem;
  61181. /**
  61182. * Serializes the particle system to a JSON object.
  61183. * @returns the JSON object
  61184. */
  61185. serialize(): any;
  61186. /**
  61187. * Parses a JSON object to create a GPU particle system.
  61188. * @param parsedParticleSystem The JSON object to parse
  61189. * @param scene The scene to create the particle system in
  61190. * @param rootUrl The root url to use to load external dependencies like texture
  61191. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61192. * @returns the parsed GPU particle system
  61193. */
  61194. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61195. }
  61196. }
  61197. declare module "babylonjs/Particles/particleSystemSet" {
  61198. import { Nullable } from "babylonjs/types";
  61199. import { Color3 } from "babylonjs/Maths/math.color";
  61200. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61202. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61203. import { Scene, IDisposable } from "babylonjs/scene";
  61204. /**
  61205. * Represents a set of particle systems working together to create a specific effect
  61206. */
  61207. export class ParticleSystemSet implements IDisposable {
  61208. private _emitterCreationOptions;
  61209. private _emitterNode;
  61210. /**
  61211. * Gets the particle system list
  61212. */
  61213. systems: IParticleSystem[];
  61214. /**
  61215. * Gets the emitter node used with this set
  61216. */
  61217. readonly emitterNode: Nullable<TransformNode>;
  61218. /**
  61219. * Creates a new emitter mesh as a sphere
  61220. * @param options defines the options used to create the sphere
  61221. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61222. * @param scene defines the hosting scene
  61223. */
  61224. setEmitterAsSphere(options: {
  61225. diameter: number;
  61226. segments: number;
  61227. color: Color3;
  61228. }, renderingGroupId: number, scene: Scene): void;
  61229. /**
  61230. * Starts all particle systems of the set
  61231. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61232. */
  61233. start(emitter?: AbstractMesh): void;
  61234. /**
  61235. * Release all associated resources
  61236. */
  61237. dispose(): void;
  61238. /**
  61239. * Serialize the set into a JSON compatible object
  61240. * @returns a JSON compatible representation of the set
  61241. */
  61242. serialize(): any;
  61243. /**
  61244. * Parse a new ParticleSystemSet from a serialized source
  61245. * @param data defines a JSON compatible representation of the set
  61246. * @param scene defines the hosting scene
  61247. * @param gpu defines if we want GPU particles or CPU particles
  61248. * @returns a new ParticleSystemSet
  61249. */
  61250. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61251. }
  61252. }
  61253. declare module "babylonjs/Particles/particleHelper" {
  61254. import { Nullable } from "babylonjs/types";
  61255. import { Scene } from "babylonjs/scene";
  61256. import { Vector3 } from "babylonjs/Maths/math.vector";
  61257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61259. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61260. /**
  61261. * This class is made for on one-liner static method to help creating particle system set.
  61262. */
  61263. export class ParticleHelper {
  61264. /**
  61265. * Gets or sets base Assets URL
  61266. */
  61267. static BaseAssetsUrl: string;
  61268. /**
  61269. * Create a default particle system that you can tweak
  61270. * @param emitter defines the emitter to use
  61271. * @param capacity defines the system capacity (default is 500 particles)
  61272. * @param scene defines the hosting scene
  61273. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61274. * @returns the new Particle system
  61275. */
  61276. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61277. /**
  61278. * This is the main static method (one-liner) of this helper to create different particle systems
  61279. * @param type This string represents the type to the particle system to create
  61280. * @param scene The scene where the particle system should live
  61281. * @param gpu If the system will use gpu
  61282. * @returns the ParticleSystemSet created
  61283. */
  61284. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61285. /**
  61286. * Static function used to export a particle system to a ParticleSystemSet variable.
  61287. * Please note that the emitter shape is not exported
  61288. * @param systems defines the particle systems to export
  61289. * @returns the created particle system set
  61290. */
  61291. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61292. }
  61293. }
  61294. declare module "babylonjs/Particles/particleSystemComponent" {
  61295. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61296. import { Effect } from "babylonjs/Materials/effect";
  61297. import "babylonjs/Shaders/particles.vertex";
  61298. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61299. module "babylonjs/Engines/engine" {
  61300. interface Engine {
  61301. /**
  61302. * Create an effect to use with particle systems.
  61303. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61304. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61305. * @param uniformsNames defines a list of attribute names
  61306. * @param samplers defines an array of string used to represent textures
  61307. * @param defines defines the string containing the defines to use to compile the shaders
  61308. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61309. * @param onCompiled defines a function to call when the effect creation is successful
  61310. * @param onError defines a function to call when the effect creation has failed
  61311. * @returns the new Effect
  61312. */
  61313. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61314. }
  61315. }
  61316. module "babylonjs/Meshes/mesh" {
  61317. interface Mesh {
  61318. /**
  61319. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61320. * @returns an array of IParticleSystem
  61321. */
  61322. getEmittedParticleSystems(): IParticleSystem[];
  61323. /**
  61324. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61325. * @returns an array of IParticleSystem
  61326. */
  61327. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61328. }
  61329. }
  61330. /**
  61331. * @hidden
  61332. */
  61333. export var _IDoNeedToBeInTheBuild: number;
  61334. }
  61335. declare module "babylonjs/Particles/pointsCloudSystem" {
  61336. import { Color4 } from "babylonjs/Maths/math";
  61337. import { Mesh } from "babylonjs/Meshes/mesh";
  61338. import { Scene, IDisposable } from "babylonjs/scene";
  61339. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61340. /** Defines the 4 color options */
  61341. export enum PointColor {
  61342. /** color value */
  61343. Color = 2,
  61344. /** uv value */
  61345. UV = 1,
  61346. /** random value */
  61347. Random = 0,
  61348. /** stated value */
  61349. Stated = 3
  61350. }
  61351. /**
  61352. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61353. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61354. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61355. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61356. *
  61357. * Full documentation here : TO BE ENTERED
  61358. */
  61359. export class PointsCloudSystem implements IDisposable {
  61360. /**
  61361. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61362. * Example : var p = SPS.particles[i];
  61363. */
  61364. particles: CloudPoint[];
  61365. /**
  61366. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61367. */
  61368. nbParticles: number;
  61369. /**
  61370. * This a counter for your own usage. It's not set by any SPS functions.
  61371. */
  61372. counter: number;
  61373. /**
  61374. * The PCS name. This name is also given to the underlying mesh.
  61375. */
  61376. name: string;
  61377. /**
  61378. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61379. */
  61380. mesh: Mesh;
  61381. /**
  61382. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61383. * Please read :
  61384. */
  61385. vars: any;
  61386. /**
  61387. * @hidden
  61388. */
  61389. _size: number;
  61390. private _scene;
  61391. private _promises;
  61392. private _positions;
  61393. private _indices;
  61394. private _normals;
  61395. private _colors;
  61396. private _uvs;
  61397. private _indices32;
  61398. private _positions32;
  61399. private _colors32;
  61400. private _uvs32;
  61401. private _updatable;
  61402. private _isVisibilityBoxLocked;
  61403. private _alwaysVisible;
  61404. private _groups;
  61405. private _groupCounter;
  61406. private _computeParticleColor;
  61407. private _computeParticleTexture;
  61408. private _computeParticleRotation;
  61409. private _computeBoundingBox;
  61410. private _isReady;
  61411. /**
  61412. * Creates a PCS (Points Cloud System) object
  61413. * @param name (String) is the PCS name, this will be the underlying mesh name
  61414. * @param pointSize (number) is the size for each point
  61415. * @param scene (Scene) is the scene in which the PCS is added
  61416. * @param options defines the options of the PCS e.g.
  61417. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61418. */
  61419. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61420. updatable?: boolean;
  61421. });
  61422. /**
  61423. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61424. * If no points were added to the PCS, the returned mesh is just a single point.
  61425. * @returns a promise for the created mesh
  61426. */
  61427. buildMeshAsync(): Promise<Mesh>;
  61428. /**
  61429. * @hidden
  61430. */
  61431. private _buildMesh;
  61432. private _addParticle;
  61433. private _randomUnitVector;
  61434. private _getColorIndicesForCoord;
  61435. private _setPointsColorOrUV;
  61436. private _colorFromTexture;
  61437. private _calculateDensity;
  61438. /**
  61439. * Adds points to the PCS in random positions within a unit sphere
  61440. * @param nb (positive integer) the number of particles to be created from this model
  61441. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61442. * @returns the number of groups in the system
  61443. */
  61444. addPoints(nb: number, pointFunction?: any): number;
  61445. /**
  61446. * Adds points to the PCS from the surface of the model shape
  61447. * @param mesh is any Mesh object that will be used as a surface model for the points
  61448. * @param nb (positive integer) the number of particles to be created from this model
  61449. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61450. * @param color (color3) to be used when colorWith is stated
  61451. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61452. * @returns the number of groups in the system
  61453. */
  61454. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61455. /**
  61456. * Adds points to the PCS inside the model shape
  61457. * @param mesh is any Mesh object that will be used as a surface model for the points
  61458. * @param nb (positive integer) the number of particles to be created from this model
  61459. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61460. * @param color (color4) to be used when colorWith is stated
  61461. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61462. * @returns the number of groups in the system
  61463. */
  61464. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61465. /**
  61466. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61467. * This method calls `updateParticle()` for each particle of the SPS.
  61468. * For an animated SPS, it is usually called within the render loop.
  61469. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61470. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61471. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61472. * @returns the PCS.
  61473. */
  61474. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61475. /**
  61476. * Disposes the PCS.
  61477. */
  61478. dispose(): void;
  61479. /**
  61480. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61481. * doc :
  61482. * @returns the PCS.
  61483. */
  61484. refreshVisibleSize(): PointsCloudSystem;
  61485. /**
  61486. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61487. * @param size the size (float) of the visibility box
  61488. * note : this doesn't lock the PCS mesh bounding box.
  61489. * doc :
  61490. */
  61491. setVisibilityBox(size: number): void;
  61492. /**
  61493. * Gets whether the PCS is always visible or not
  61494. * doc :
  61495. */
  61496. /**
  61497. * Sets the PCS as always visible or not
  61498. * doc :
  61499. */
  61500. isAlwaysVisible: boolean;
  61501. /**
  61502. * Tells to `setParticles()` to compute the particle rotations or not
  61503. * Default value : false. The PCS is faster when it's set to false
  61504. * Note : particle rotations are only applied to parent particles
  61505. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61506. */
  61507. computeParticleRotation: boolean;
  61508. /**
  61509. * Tells to `setParticles()` to compute the particle colors or not.
  61510. * Default value : true. The PCS is faster when it's set to false.
  61511. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61512. */
  61513. /**
  61514. * Gets if `setParticles()` computes the particle colors or not.
  61515. * Default value : false. The PCS is faster when it's set to false.
  61516. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61517. */
  61518. computeParticleColor: boolean;
  61519. /**
  61520. * Gets if `setParticles()` computes the particle textures or not.
  61521. * Default value : false. The PCS is faster when it's set to false.
  61522. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61523. */
  61524. computeParticleTexture: boolean;
  61525. /**
  61526. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61527. */
  61528. /**
  61529. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61530. */
  61531. computeBoundingBox: boolean;
  61532. /**
  61533. * This function does nothing. It may be overwritten to set all the particle first values.
  61534. * The PCS doesn't call this function, you may have to call it by your own.
  61535. * doc :
  61536. */
  61537. initParticles(): void;
  61538. /**
  61539. * This function does nothing. It may be overwritten to recycle a particle
  61540. * The PCS doesn't call this function, you can to call it
  61541. * doc :
  61542. * @param particle The particle to recycle
  61543. * @returns the recycled particle
  61544. */
  61545. recycleParticle(particle: CloudPoint): CloudPoint;
  61546. /**
  61547. * Updates a particle : this function should be overwritten by the user.
  61548. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61549. * doc :
  61550. * @example : just set a particle position or velocity and recycle conditions
  61551. * @param particle The particle to update
  61552. * @returns the updated particle
  61553. */
  61554. updateParticle(particle: CloudPoint): CloudPoint;
  61555. /**
  61556. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61557. * This does nothing and may be overwritten by the user.
  61558. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61559. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61560. * @param update the boolean update value actually passed to setParticles()
  61561. */
  61562. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61563. /**
  61564. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61565. * This will be passed three parameters.
  61566. * This does nothing and may be overwritten by the user.
  61567. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61568. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61569. * @param update the boolean update value actually passed to setParticles()
  61570. */
  61571. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61572. }
  61573. }
  61574. declare module "babylonjs/Particles/cloudPoint" {
  61575. import { Nullable } from "babylonjs/types";
  61576. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61577. import { Mesh } from "babylonjs/Meshes/mesh";
  61578. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61579. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61580. /**
  61581. * Represents one particle of a points cloud system.
  61582. */
  61583. export class CloudPoint {
  61584. /**
  61585. * particle global index
  61586. */
  61587. idx: number;
  61588. /**
  61589. * The color of the particle
  61590. */
  61591. color: Nullable<Color4>;
  61592. /**
  61593. * The world space position of the particle.
  61594. */
  61595. position: Vector3;
  61596. /**
  61597. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61598. */
  61599. rotation: Vector3;
  61600. /**
  61601. * The world space rotation quaternion of the particle.
  61602. */
  61603. rotationQuaternion: Nullable<Quaternion>;
  61604. /**
  61605. * The uv of the particle.
  61606. */
  61607. uv: Nullable<Vector2>;
  61608. /**
  61609. * The current speed of the particle.
  61610. */
  61611. velocity: Vector3;
  61612. /**
  61613. * The pivot point in the particle local space.
  61614. */
  61615. pivot: Vector3;
  61616. /**
  61617. * Must the particle be translated from its pivot point in its local space ?
  61618. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61619. * Default : false
  61620. */
  61621. translateFromPivot: boolean;
  61622. /**
  61623. * Index of this particle in the global "positions" array (Internal use)
  61624. * @hidden
  61625. */
  61626. _pos: number;
  61627. /**
  61628. * @hidden Index of this particle in the global "indices" array (Internal use)
  61629. */
  61630. _ind: number;
  61631. /**
  61632. * Group this particle belongs to
  61633. */
  61634. _group: PointsGroup;
  61635. /**
  61636. * Group id of this particle
  61637. */
  61638. groupId: number;
  61639. /**
  61640. * Index of the particle in its group id (Internal use)
  61641. */
  61642. idxInGroup: number;
  61643. /**
  61644. * @hidden Particle BoundingInfo object (Internal use)
  61645. */
  61646. _boundingInfo: BoundingInfo;
  61647. /**
  61648. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61649. */
  61650. _pcs: PointsCloudSystem;
  61651. /**
  61652. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61653. */
  61654. _stillInvisible: boolean;
  61655. /**
  61656. * @hidden Last computed particle rotation matrix
  61657. */
  61658. _rotationMatrix: number[];
  61659. /**
  61660. * Parent particle Id, if any.
  61661. * Default null.
  61662. */
  61663. parentId: Nullable<number>;
  61664. /**
  61665. * @hidden Internal global position in the PCS.
  61666. */
  61667. _globalPosition: Vector3;
  61668. /**
  61669. * Creates a Point Cloud object.
  61670. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  61671. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  61672. * @param group (PointsGroup) is the group the particle belongs to
  61673. * @param groupId (integer) is the group identifier in the PCS.
  61674. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  61675. * @param pcs defines the PCS it is associated to
  61676. */
  61677. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  61678. /**
  61679. * get point size
  61680. */
  61681. /**
  61682. * Set point size
  61683. */
  61684. size: Vector3;
  61685. /**
  61686. * Legacy support, changed quaternion to rotationQuaternion
  61687. */
  61688. /**
  61689. * Legacy support, changed quaternion to rotationQuaternion
  61690. */
  61691. quaternion: Nullable<Quaternion>;
  61692. /**
  61693. * Returns a boolean. True if the particle intersects a mesh, else false
  61694. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  61695. * @param target is the object (point or mesh) what the intersection is computed against
  61696. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  61697. * @returns true if it intersects
  61698. */
  61699. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  61700. /**
  61701. * get the rotation matrix of the particle
  61702. * @hidden
  61703. */
  61704. getRotationMatrix(m: Matrix): void;
  61705. }
  61706. /**
  61707. * Represents a group of points in a points cloud system
  61708. * * PCS internal tool, don't use it manually.
  61709. */
  61710. export class PointsGroup {
  61711. /**
  61712. * The group id
  61713. * @hidden
  61714. */
  61715. groupID: number;
  61716. /**
  61717. * image data for group (internal use)
  61718. * @hidden
  61719. */
  61720. _groupImageData: Nullable<ArrayBufferView>;
  61721. /**
  61722. * Image Width (internal use)
  61723. * @hidden
  61724. */
  61725. _groupImgWidth: number;
  61726. /**
  61727. * Image Height (internal use)
  61728. * @hidden
  61729. */
  61730. _groupImgHeight: number;
  61731. /**
  61732. * Custom position function (internal use)
  61733. * @hidden
  61734. */
  61735. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  61736. /**
  61737. * density per facet for surface points
  61738. * @hidden
  61739. */
  61740. _groupDensity: number[];
  61741. /**
  61742. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  61743. * PCS internal tool, don't use it manually.
  61744. * @hidden
  61745. */
  61746. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  61747. }
  61748. }
  61749. declare module "babylonjs/Particles/index" {
  61750. export * from "babylonjs/Particles/baseParticleSystem";
  61751. export * from "babylonjs/Particles/EmitterTypes/index";
  61752. export * from "babylonjs/Particles/gpuParticleSystem";
  61753. export * from "babylonjs/Particles/IParticleSystem";
  61754. export * from "babylonjs/Particles/particle";
  61755. export * from "babylonjs/Particles/particleHelper";
  61756. export * from "babylonjs/Particles/particleSystem";
  61757. export * from "babylonjs/Particles/particleSystemComponent";
  61758. export * from "babylonjs/Particles/particleSystemSet";
  61759. export * from "babylonjs/Particles/solidParticle";
  61760. export * from "babylonjs/Particles/solidParticleSystem";
  61761. export * from "babylonjs/Particles/cloudPoint";
  61762. export * from "babylonjs/Particles/pointsCloudSystem";
  61763. export * from "babylonjs/Particles/subEmitter";
  61764. }
  61765. declare module "babylonjs/Physics/physicsEngineComponent" {
  61766. import { Nullable } from "babylonjs/types";
  61767. import { Observable, Observer } from "babylonjs/Misc/observable";
  61768. import { Vector3 } from "babylonjs/Maths/math.vector";
  61769. import { Mesh } from "babylonjs/Meshes/mesh";
  61770. import { ISceneComponent } from "babylonjs/sceneComponent";
  61771. import { Scene } from "babylonjs/scene";
  61772. import { Node } from "babylonjs/node";
  61773. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61774. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61775. module "babylonjs/scene" {
  61776. interface Scene {
  61777. /** @hidden (Backing field) */
  61778. _physicsEngine: Nullable<IPhysicsEngine>;
  61779. /**
  61780. * Gets the current physics engine
  61781. * @returns a IPhysicsEngine or null if none attached
  61782. */
  61783. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61784. /**
  61785. * Enables physics to the current scene
  61786. * @param gravity defines the scene's gravity for the physics engine
  61787. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61788. * @return a boolean indicating if the physics engine was initialized
  61789. */
  61790. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61791. /**
  61792. * Disables and disposes the physics engine associated with the scene
  61793. */
  61794. disablePhysicsEngine(): void;
  61795. /**
  61796. * Gets a boolean indicating if there is an active physics engine
  61797. * @returns a boolean indicating if there is an active physics engine
  61798. */
  61799. isPhysicsEnabled(): boolean;
  61800. /**
  61801. * Deletes a physics compound impostor
  61802. * @param compound defines the compound to delete
  61803. */
  61804. deleteCompoundImpostor(compound: any): void;
  61805. /**
  61806. * An event triggered when physic simulation is about to be run
  61807. */
  61808. onBeforePhysicsObservable: Observable<Scene>;
  61809. /**
  61810. * An event triggered when physic simulation has been done
  61811. */
  61812. onAfterPhysicsObservable: Observable<Scene>;
  61813. }
  61814. }
  61815. module "babylonjs/Meshes/abstractMesh" {
  61816. interface AbstractMesh {
  61817. /** @hidden */
  61818. _physicsImpostor: Nullable<PhysicsImpostor>;
  61819. /**
  61820. * Gets or sets impostor used for physic simulation
  61821. * @see http://doc.babylonjs.com/features/physics_engine
  61822. */
  61823. physicsImpostor: Nullable<PhysicsImpostor>;
  61824. /**
  61825. * Gets the current physics impostor
  61826. * @see http://doc.babylonjs.com/features/physics_engine
  61827. * @returns a physics impostor or null
  61828. */
  61829. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61830. /** Apply a physic impulse to the mesh
  61831. * @param force defines the force to apply
  61832. * @param contactPoint defines where to apply the force
  61833. * @returns the current mesh
  61834. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61835. */
  61836. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61837. /**
  61838. * Creates a physic joint between two meshes
  61839. * @param otherMesh defines the other mesh to use
  61840. * @param pivot1 defines the pivot to use on this mesh
  61841. * @param pivot2 defines the pivot to use on the other mesh
  61842. * @param options defines additional options (can be plugin dependent)
  61843. * @returns the current mesh
  61844. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61845. */
  61846. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61847. /** @hidden */
  61848. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61849. }
  61850. }
  61851. /**
  61852. * Defines the physics engine scene component responsible to manage a physics engine
  61853. */
  61854. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61855. /**
  61856. * The component name helpful to identify the component in the list of scene components.
  61857. */
  61858. readonly name: string;
  61859. /**
  61860. * The scene the component belongs to.
  61861. */
  61862. scene: Scene;
  61863. /**
  61864. * Creates a new instance of the component for the given scene
  61865. * @param scene Defines the scene to register the component in
  61866. */
  61867. constructor(scene: Scene);
  61868. /**
  61869. * Registers the component in a given scene
  61870. */
  61871. register(): void;
  61872. /**
  61873. * Rebuilds the elements related to this component in case of
  61874. * context lost for instance.
  61875. */
  61876. rebuild(): void;
  61877. /**
  61878. * Disposes the component and the associated ressources
  61879. */
  61880. dispose(): void;
  61881. }
  61882. }
  61883. declare module "babylonjs/Physics/physicsHelper" {
  61884. import { Nullable } from "babylonjs/types";
  61885. import { Vector3 } from "babylonjs/Maths/math.vector";
  61886. import { Mesh } from "babylonjs/Meshes/mesh";
  61887. import { Scene } from "babylonjs/scene";
  61888. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61889. /**
  61890. * A helper for physics simulations
  61891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61892. */
  61893. export class PhysicsHelper {
  61894. private _scene;
  61895. private _physicsEngine;
  61896. /**
  61897. * Initializes the Physics helper
  61898. * @param scene Babylon.js scene
  61899. */
  61900. constructor(scene: Scene);
  61901. /**
  61902. * Applies a radial explosion impulse
  61903. * @param origin the origin of the explosion
  61904. * @param radiusOrEventOptions the radius or the options of radial explosion
  61905. * @param strength the explosion strength
  61906. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61907. * @returns A physics radial explosion event, or null
  61908. */
  61909. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61910. /**
  61911. * Applies a radial explosion force
  61912. * @param origin the origin of the explosion
  61913. * @param radiusOrEventOptions the radius or the options of radial explosion
  61914. * @param strength the explosion strength
  61915. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61916. * @returns A physics radial explosion event, or null
  61917. */
  61918. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61919. /**
  61920. * Creates a gravitational field
  61921. * @param origin the origin of the explosion
  61922. * @param radiusOrEventOptions the radius or the options of radial explosion
  61923. * @param strength the explosion strength
  61924. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61925. * @returns A physics gravitational field event, or null
  61926. */
  61927. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61928. /**
  61929. * Creates a physics updraft event
  61930. * @param origin the origin of the updraft
  61931. * @param radiusOrEventOptions the radius or the options of the updraft
  61932. * @param strength the strength of the updraft
  61933. * @param height the height of the updraft
  61934. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61935. * @returns A physics updraft event, or null
  61936. */
  61937. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61938. /**
  61939. * Creates a physics vortex event
  61940. * @param origin the of the vortex
  61941. * @param radiusOrEventOptions the radius or the options of the vortex
  61942. * @param strength the strength of the vortex
  61943. * @param height the height of the vortex
  61944. * @returns a Physics vortex event, or null
  61945. * A physics vortex event or null
  61946. */
  61947. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61948. }
  61949. /**
  61950. * Represents a physics radial explosion event
  61951. */
  61952. class PhysicsRadialExplosionEvent {
  61953. private _scene;
  61954. private _options;
  61955. private _sphere;
  61956. private _dataFetched;
  61957. /**
  61958. * Initializes a radial explosioin event
  61959. * @param _scene BabylonJS scene
  61960. * @param _options The options for the vortex event
  61961. */
  61962. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61963. /**
  61964. * Returns the data related to the radial explosion event (sphere).
  61965. * @returns The radial explosion event data
  61966. */
  61967. getData(): PhysicsRadialExplosionEventData;
  61968. /**
  61969. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61970. * @param impostor A physics imposter
  61971. * @param origin the origin of the explosion
  61972. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61973. */
  61974. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61975. /**
  61976. * Triggers affecterd impostors callbacks
  61977. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61978. */
  61979. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61980. /**
  61981. * Disposes the sphere.
  61982. * @param force Specifies if the sphere should be disposed by force
  61983. */
  61984. dispose(force?: boolean): void;
  61985. /*** Helpers ***/
  61986. private _prepareSphere;
  61987. private _intersectsWithSphere;
  61988. }
  61989. /**
  61990. * Represents a gravitational field event
  61991. */
  61992. class PhysicsGravitationalFieldEvent {
  61993. private _physicsHelper;
  61994. private _scene;
  61995. private _origin;
  61996. private _options;
  61997. private _tickCallback;
  61998. private _sphere;
  61999. private _dataFetched;
  62000. /**
  62001. * Initializes the physics gravitational field event
  62002. * @param _physicsHelper A physics helper
  62003. * @param _scene BabylonJS scene
  62004. * @param _origin The origin position of the gravitational field event
  62005. * @param _options The options for the vortex event
  62006. */
  62007. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62008. /**
  62009. * Returns the data related to the gravitational field event (sphere).
  62010. * @returns A gravitational field event
  62011. */
  62012. getData(): PhysicsGravitationalFieldEventData;
  62013. /**
  62014. * Enables the gravitational field.
  62015. */
  62016. enable(): void;
  62017. /**
  62018. * Disables the gravitational field.
  62019. */
  62020. disable(): void;
  62021. /**
  62022. * Disposes the sphere.
  62023. * @param force The force to dispose from the gravitational field event
  62024. */
  62025. dispose(force?: boolean): void;
  62026. private _tick;
  62027. }
  62028. /**
  62029. * Represents a physics updraft event
  62030. */
  62031. class PhysicsUpdraftEvent {
  62032. private _scene;
  62033. private _origin;
  62034. private _options;
  62035. private _physicsEngine;
  62036. private _originTop;
  62037. private _originDirection;
  62038. private _tickCallback;
  62039. private _cylinder;
  62040. private _cylinderPosition;
  62041. private _dataFetched;
  62042. /**
  62043. * Initializes the physics updraft event
  62044. * @param _scene BabylonJS scene
  62045. * @param _origin The origin position of the updraft
  62046. * @param _options The options for the updraft event
  62047. */
  62048. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62049. /**
  62050. * Returns the data related to the updraft event (cylinder).
  62051. * @returns A physics updraft event
  62052. */
  62053. getData(): PhysicsUpdraftEventData;
  62054. /**
  62055. * Enables the updraft.
  62056. */
  62057. enable(): void;
  62058. /**
  62059. * Disables the updraft.
  62060. */
  62061. disable(): void;
  62062. /**
  62063. * Disposes the cylinder.
  62064. * @param force Specifies if the updraft should be disposed by force
  62065. */
  62066. dispose(force?: boolean): void;
  62067. private getImpostorHitData;
  62068. private _tick;
  62069. /*** Helpers ***/
  62070. private _prepareCylinder;
  62071. private _intersectsWithCylinder;
  62072. }
  62073. /**
  62074. * Represents a physics vortex event
  62075. */
  62076. class PhysicsVortexEvent {
  62077. private _scene;
  62078. private _origin;
  62079. private _options;
  62080. private _physicsEngine;
  62081. private _originTop;
  62082. private _tickCallback;
  62083. private _cylinder;
  62084. private _cylinderPosition;
  62085. private _dataFetched;
  62086. /**
  62087. * Initializes the physics vortex event
  62088. * @param _scene The BabylonJS scene
  62089. * @param _origin The origin position of the vortex
  62090. * @param _options The options for the vortex event
  62091. */
  62092. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62093. /**
  62094. * Returns the data related to the vortex event (cylinder).
  62095. * @returns The physics vortex event data
  62096. */
  62097. getData(): PhysicsVortexEventData;
  62098. /**
  62099. * Enables the vortex.
  62100. */
  62101. enable(): void;
  62102. /**
  62103. * Disables the cortex.
  62104. */
  62105. disable(): void;
  62106. /**
  62107. * Disposes the sphere.
  62108. * @param force
  62109. */
  62110. dispose(force?: boolean): void;
  62111. private getImpostorHitData;
  62112. private _tick;
  62113. /*** Helpers ***/
  62114. private _prepareCylinder;
  62115. private _intersectsWithCylinder;
  62116. }
  62117. /**
  62118. * Options fot the radial explosion event
  62119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62120. */
  62121. export class PhysicsRadialExplosionEventOptions {
  62122. /**
  62123. * The radius of the sphere for the radial explosion.
  62124. */
  62125. radius: number;
  62126. /**
  62127. * The strenth of the explosion.
  62128. */
  62129. strength: number;
  62130. /**
  62131. * The strenght of the force in correspondence to the distance of the affected object
  62132. */
  62133. falloff: PhysicsRadialImpulseFalloff;
  62134. /**
  62135. * Sphere options for the radial explosion.
  62136. */
  62137. sphere: {
  62138. segments: number;
  62139. diameter: number;
  62140. };
  62141. /**
  62142. * Sphere options for the radial explosion.
  62143. */
  62144. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62145. }
  62146. /**
  62147. * Options fot the updraft event
  62148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62149. */
  62150. export class PhysicsUpdraftEventOptions {
  62151. /**
  62152. * The radius of the cylinder for the vortex
  62153. */
  62154. radius: number;
  62155. /**
  62156. * The strenth of the updraft.
  62157. */
  62158. strength: number;
  62159. /**
  62160. * The height of the cylinder for the updraft.
  62161. */
  62162. height: number;
  62163. /**
  62164. * The mode for the the updraft.
  62165. */
  62166. updraftMode: PhysicsUpdraftMode;
  62167. }
  62168. /**
  62169. * Options fot the vortex event
  62170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62171. */
  62172. export class PhysicsVortexEventOptions {
  62173. /**
  62174. * The radius of the cylinder for the vortex
  62175. */
  62176. radius: number;
  62177. /**
  62178. * The strenth of the vortex.
  62179. */
  62180. strength: number;
  62181. /**
  62182. * The height of the cylinder for the vortex.
  62183. */
  62184. height: number;
  62185. /**
  62186. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62187. */
  62188. centripetalForceThreshold: number;
  62189. /**
  62190. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62191. */
  62192. centripetalForceMultiplier: number;
  62193. /**
  62194. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62195. */
  62196. centrifugalForceMultiplier: number;
  62197. /**
  62198. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62199. */
  62200. updraftForceMultiplier: number;
  62201. }
  62202. /**
  62203. * The strenght of the force in correspondence to the distance of the affected object
  62204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62205. */
  62206. export enum PhysicsRadialImpulseFalloff {
  62207. /** Defines that impulse is constant in strength across it's whole radius */
  62208. Constant = 0,
  62209. /** Defines that impulse gets weaker if it's further from the origin */
  62210. Linear = 1
  62211. }
  62212. /**
  62213. * The strength of the force in correspondence to the distance of the affected object
  62214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62215. */
  62216. export enum PhysicsUpdraftMode {
  62217. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62218. Center = 0,
  62219. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62220. Perpendicular = 1
  62221. }
  62222. /**
  62223. * Interface for a physics hit data
  62224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62225. */
  62226. export interface PhysicsHitData {
  62227. /**
  62228. * The force applied at the contact point
  62229. */
  62230. force: Vector3;
  62231. /**
  62232. * The contact point
  62233. */
  62234. contactPoint: Vector3;
  62235. /**
  62236. * The distance from the origin to the contact point
  62237. */
  62238. distanceFromOrigin: number;
  62239. }
  62240. /**
  62241. * Interface for radial explosion event data
  62242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62243. */
  62244. export interface PhysicsRadialExplosionEventData {
  62245. /**
  62246. * A sphere used for the radial explosion event
  62247. */
  62248. sphere: Mesh;
  62249. }
  62250. /**
  62251. * Interface for gravitational field event data
  62252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62253. */
  62254. export interface PhysicsGravitationalFieldEventData {
  62255. /**
  62256. * A sphere mesh used for the gravitational field event
  62257. */
  62258. sphere: Mesh;
  62259. }
  62260. /**
  62261. * Interface for updraft event data
  62262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62263. */
  62264. export interface PhysicsUpdraftEventData {
  62265. /**
  62266. * A cylinder used for the updraft event
  62267. */
  62268. cylinder: Mesh;
  62269. }
  62270. /**
  62271. * Interface for vortex event data
  62272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62273. */
  62274. export interface PhysicsVortexEventData {
  62275. /**
  62276. * A cylinder used for the vortex event
  62277. */
  62278. cylinder: Mesh;
  62279. }
  62280. /**
  62281. * Interface for an affected physics impostor
  62282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62283. */
  62284. export interface PhysicsAffectedImpostorWithData {
  62285. /**
  62286. * The impostor affected by the effect
  62287. */
  62288. impostor: PhysicsImpostor;
  62289. /**
  62290. * The data about the hit/horce from the explosion
  62291. */
  62292. hitData: PhysicsHitData;
  62293. }
  62294. }
  62295. declare module "babylonjs/Physics/Plugins/index" {
  62296. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62297. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62298. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62299. }
  62300. declare module "babylonjs/Physics/index" {
  62301. export * from "babylonjs/Physics/IPhysicsEngine";
  62302. export * from "babylonjs/Physics/physicsEngine";
  62303. export * from "babylonjs/Physics/physicsEngineComponent";
  62304. export * from "babylonjs/Physics/physicsHelper";
  62305. export * from "babylonjs/Physics/physicsImpostor";
  62306. export * from "babylonjs/Physics/physicsJoint";
  62307. export * from "babylonjs/Physics/Plugins/index";
  62308. }
  62309. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62310. /** @hidden */
  62311. export var blackAndWhitePixelShader: {
  62312. name: string;
  62313. shader: string;
  62314. };
  62315. }
  62316. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62318. import { Camera } from "babylonjs/Cameras/camera";
  62319. import { Engine } from "babylonjs/Engines/engine";
  62320. import "babylonjs/Shaders/blackAndWhite.fragment";
  62321. /**
  62322. * Post process used to render in black and white
  62323. */
  62324. export class BlackAndWhitePostProcess extends PostProcess {
  62325. /**
  62326. * Linear about to convert he result to black and white (default: 1)
  62327. */
  62328. degree: number;
  62329. /**
  62330. * Creates a black and white post process
  62331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62332. * @param name The name of the effect.
  62333. * @param options The required width/height ratio to downsize to before computing the render pass.
  62334. * @param camera The camera to apply the render pass to.
  62335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62336. * @param engine The engine which the post process will be applied. (default: current engine)
  62337. * @param reusable If the post process can be reused on the same frame. (default: false)
  62338. */
  62339. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62340. }
  62341. }
  62342. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62343. import { Nullable } from "babylonjs/types";
  62344. import { Camera } from "babylonjs/Cameras/camera";
  62345. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62346. import { Engine } from "babylonjs/Engines/engine";
  62347. /**
  62348. * This represents a set of one or more post processes in Babylon.
  62349. * A post process can be used to apply a shader to a texture after it is rendered.
  62350. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62351. */
  62352. export class PostProcessRenderEffect {
  62353. private _postProcesses;
  62354. private _getPostProcesses;
  62355. private _singleInstance;
  62356. private _cameras;
  62357. private _indicesForCamera;
  62358. /**
  62359. * Name of the effect
  62360. * @hidden
  62361. */
  62362. _name: string;
  62363. /**
  62364. * Instantiates a post process render effect.
  62365. * A post process can be used to apply a shader to a texture after it is rendered.
  62366. * @param engine The engine the effect is tied to
  62367. * @param name The name of the effect
  62368. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62369. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62370. */
  62371. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62372. /**
  62373. * Checks if all the post processes in the effect are supported.
  62374. */
  62375. readonly isSupported: boolean;
  62376. /**
  62377. * Updates the current state of the effect
  62378. * @hidden
  62379. */
  62380. _update(): void;
  62381. /**
  62382. * Attaches the effect on cameras
  62383. * @param cameras The camera to attach to.
  62384. * @hidden
  62385. */
  62386. _attachCameras(cameras: Camera): void;
  62387. /**
  62388. * Attaches the effect on cameras
  62389. * @param cameras The camera to attach to.
  62390. * @hidden
  62391. */
  62392. _attachCameras(cameras: Camera[]): void;
  62393. /**
  62394. * Detaches the effect on cameras
  62395. * @param cameras The camera to detatch from.
  62396. * @hidden
  62397. */
  62398. _detachCameras(cameras: Camera): void;
  62399. /**
  62400. * Detatches the effect on cameras
  62401. * @param cameras The camera to detatch from.
  62402. * @hidden
  62403. */
  62404. _detachCameras(cameras: Camera[]): void;
  62405. /**
  62406. * Enables the effect on given cameras
  62407. * @param cameras The camera to enable.
  62408. * @hidden
  62409. */
  62410. _enable(cameras: Camera): void;
  62411. /**
  62412. * Enables the effect on given cameras
  62413. * @param cameras The camera to enable.
  62414. * @hidden
  62415. */
  62416. _enable(cameras: Nullable<Camera[]>): void;
  62417. /**
  62418. * Disables the effect on the given cameras
  62419. * @param cameras The camera to disable.
  62420. * @hidden
  62421. */
  62422. _disable(cameras: Camera): void;
  62423. /**
  62424. * Disables the effect on the given cameras
  62425. * @param cameras The camera to disable.
  62426. * @hidden
  62427. */
  62428. _disable(cameras: Nullable<Camera[]>): void;
  62429. /**
  62430. * Gets a list of the post processes contained in the effect.
  62431. * @param camera The camera to get the post processes on.
  62432. * @returns The list of the post processes in the effect.
  62433. */
  62434. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62435. }
  62436. }
  62437. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62438. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62439. /** @hidden */
  62440. export var extractHighlightsPixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62446. import { Nullable } from "babylonjs/types";
  62447. import { Camera } from "babylonjs/Cameras/camera";
  62448. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62449. import { Engine } from "babylonjs/Engines/engine";
  62450. import "babylonjs/Shaders/extractHighlights.fragment";
  62451. /**
  62452. * 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.
  62453. */
  62454. export class ExtractHighlightsPostProcess extends PostProcess {
  62455. /**
  62456. * The luminance threshold, pixels below this value will be set to black.
  62457. */
  62458. threshold: number;
  62459. /** @hidden */
  62460. _exposure: number;
  62461. /**
  62462. * Post process which has the input texture to be used when performing highlight extraction
  62463. * @hidden
  62464. */
  62465. _inputPostProcess: Nullable<PostProcess>;
  62466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62467. }
  62468. }
  62469. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62470. /** @hidden */
  62471. export var bloomMergePixelShader: {
  62472. name: string;
  62473. shader: string;
  62474. };
  62475. }
  62476. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62478. import { Nullable } from "babylonjs/types";
  62479. import { Engine } from "babylonjs/Engines/engine";
  62480. import { Camera } from "babylonjs/Cameras/camera";
  62481. import "babylonjs/Shaders/bloomMerge.fragment";
  62482. /**
  62483. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62484. */
  62485. export class BloomMergePostProcess extends PostProcess {
  62486. /** Weight of the bloom to be added to the original input. */
  62487. weight: number;
  62488. /**
  62489. * Creates a new instance of @see BloomMergePostProcess
  62490. * @param name The name of the effect.
  62491. * @param originalFromInput Post process which's input will be used for the merge.
  62492. * @param blurred Blurred highlights post process which's output will be used.
  62493. * @param weight Weight of the bloom to be added to the original input.
  62494. * @param options The required width/height ratio to downsize to before computing the render pass.
  62495. * @param camera The camera to apply the render pass to.
  62496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62497. * @param engine The engine which the post process will be applied. (default: current engine)
  62498. * @param reusable If the post process can be reused on the same frame. (default: false)
  62499. * @param textureType Type of textures used when performing the post process. (default: 0)
  62500. * @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)
  62501. */
  62502. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62503. /** Weight of the bloom to be added to the original input. */
  62504. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62505. }
  62506. }
  62507. declare module "babylonjs/PostProcesses/bloomEffect" {
  62508. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62509. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62510. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62511. import { Camera } from "babylonjs/Cameras/camera";
  62512. import { Scene } from "babylonjs/scene";
  62513. /**
  62514. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62515. */
  62516. export class BloomEffect extends PostProcessRenderEffect {
  62517. private bloomScale;
  62518. /**
  62519. * @hidden Internal
  62520. */
  62521. _effects: Array<PostProcess>;
  62522. /**
  62523. * @hidden Internal
  62524. */
  62525. _downscale: ExtractHighlightsPostProcess;
  62526. private _blurX;
  62527. private _blurY;
  62528. private _merge;
  62529. /**
  62530. * The luminance threshold to find bright areas of the image to bloom.
  62531. */
  62532. threshold: number;
  62533. /**
  62534. * The strength of the bloom.
  62535. */
  62536. weight: number;
  62537. /**
  62538. * Specifies the size of the bloom blur kernel, relative to the final output size
  62539. */
  62540. kernel: number;
  62541. /**
  62542. * Creates a new instance of @see BloomEffect
  62543. * @param scene The scene the effect belongs to.
  62544. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62545. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62546. * @param bloomWeight The the strength of bloom.
  62547. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62548. * @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)
  62549. */
  62550. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62551. /**
  62552. * Disposes each of the internal effects for a given camera.
  62553. * @param camera The camera to dispose the effect on.
  62554. */
  62555. disposeEffects(camera: Camera): void;
  62556. /**
  62557. * @hidden Internal
  62558. */
  62559. _updateEffects(): void;
  62560. /**
  62561. * Internal
  62562. * @returns if all the contained post processes are ready.
  62563. * @hidden
  62564. */
  62565. _isReady(): boolean;
  62566. }
  62567. }
  62568. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62569. /** @hidden */
  62570. export var chromaticAberrationPixelShader: {
  62571. name: string;
  62572. shader: string;
  62573. };
  62574. }
  62575. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62576. import { Vector2 } from "babylonjs/Maths/math.vector";
  62577. import { Nullable } from "babylonjs/types";
  62578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62579. import { Camera } from "babylonjs/Cameras/camera";
  62580. import { Engine } from "babylonjs/Engines/engine";
  62581. import "babylonjs/Shaders/chromaticAberration.fragment";
  62582. /**
  62583. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62584. */
  62585. export class ChromaticAberrationPostProcess extends PostProcess {
  62586. /**
  62587. * The amount of seperation of rgb channels (default: 30)
  62588. */
  62589. aberrationAmount: number;
  62590. /**
  62591. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62592. */
  62593. radialIntensity: number;
  62594. /**
  62595. * 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))
  62596. */
  62597. direction: Vector2;
  62598. /**
  62599. * 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))
  62600. */
  62601. centerPosition: Vector2;
  62602. /**
  62603. * Creates a new instance ChromaticAberrationPostProcess
  62604. * @param name The name of the effect.
  62605. * @param screenWidth The width of the screen to apply the effect on.
  62606. * @param screenHeight The height of the screen to apply the effect on.
  62607. * @param options The required width/height ratio to downsize to before computing the render pass.
  62608. * @param camera The camera to apply the render pass to.
  62609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62610. * @param engine The engine which the post process will be applied. (default: current engine)
  62611. * @param reusable If the post process can be reused on the same frame. (default: false)
  62612. * @param textureType Type of textures used when performing the post process. (default: 0)
  62613. * @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)
  62614. */
  62615. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62616. }
  62617. }
  62618. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62619. /** @hidden */
  62620. export var circleOfConfusionPixelShader: {
  62621. name: string;
  62622. shader: string;
  62623. };
  62624. }
  62625. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62626. import { Nullable } from "babylonjs/types";
  62627. import { Engine } from "babylonjs/Engines/engine";
  62628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62630. import { Camera } from "babylonjs/Cameras/camera";
  62631. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62632. /**
  62633. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62634. */
  62635. export class CircleOfConfusionPostProcess extends PostProcess {
  62636. /**
  62637. * 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.
  62638. */
  62639. lensSize: number;
  62640. /**
  62641. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62642. */
  62643. fStop: number;
  62644. /**
  62645. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62646. */
  62647. focusDistance: number;
  62648. /**
  62649. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62650. */
  62651. focalLength: number;
  62652. private _depthTexture;
  62653. /**
  62654. * Creates a new instance CircleOfConfusionPostProcess
  62655. * @param name The name of the effect.
  62656. * @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.
  62657. * @param options The required width/height ratio to downsize to before computing the render pass.
  62658. * @param camera The camera to apply the render pass to.
  62659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62660. * @param engine The engine which the post process will be applied. (default: current engine)
  62661. * @param reusable If the post process can be reused on the same frame. (default: false)
  62662. * @param textureType Type of textures used when performing the post process. (default: 0)
  62663. * @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)
  62664. */
  62665. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62666. /**
  62667. * 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.
  62668. */
  62669. depthTexture: RenderTargetTexture;
  62670. }
  62671. }
  62672. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62673. /** @hidden */
  62674. export var colorCorrectionPixelShader: {
  62675. name: string;
  62676. shader: string;
  62677. };
  62678. }
  62679. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62680. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62681. import { Engine } from "babylonjs/Engines/engine";
  62682. import { Camera } from "babylonjs/Cameras/camera";
  62683. import "babylonjs/Shaders/colorCorrection.fragment";
  62684. /**
  62685. *
  62686. * This post-process allows the modification of rendered colors by using
  62687. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62688. *
  62689. * The object needs to be provided an url to a texture containing the color
  62690. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62691. * Use an image editing software to tweak the LUT to match your needs.
  62692. *
  62693. * For an example of a color LUT, see here:
  62694. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62695. * For explanations on color grading, see here:
  62696. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62697. *
  62698. */
  62699. export class ColorCorrectionPostProcess extends PostProcess {
  62700. private _colorTableTexture;
  62701. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62702. }
  62703. }
  62704. declare module "babylonjs/Shaders/convolution.fragment" {
  62705. /** @hidden */
  62706. export var convolutionPixelShader: {
  62707. name: string;
  62708. shader: string;
  62709. };
  62710. }
  62711. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62712. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62713. import { Nullable } from "babylonjs/types";
  62714. import { Camera } from "babylonjs/Cameras/camera";
  62715. import { Engine } from "babylonjs/Engines/engine";
  62716. import "babylonjs/Shaders/convolution.fragment";
  62717. /**
  62718. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62719. * input texture to perform effects such as edge detection or sharpening
  62720. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62721. */
  62722. export class ConvolutionPostProcess extends PostProcess {
  62723. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62724. kernel: number[];
  62725. /**
  62726. * Creates a new instance ConvolutionPostProcess
  62727. * @param name The name of the effect.
  62728. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62729. * @param options The required width/height ratio to downsize to before computing the render pass.
  62730. * @param camera The camera to apply the render pass to.
  62731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62732. * @param engine The engine which the post process will be applied. (default: current engine)
  62733. * @param reusable If the post process can be reused on the same frame. (default: false)
  62734. * @param textureType Type of textures used when performing the post process. (default: 0)
  62735. */
  62736. constructor(name: string,
  62737. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62738. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62739. /**
  62740. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62741. */
  62742. static EdgeDetect0Kernel: number[];
  62743. /**
  62744. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62745. */
  62746. static EdgeDetect1Kernel: number[];
  62747. /**
  62748. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62749. */
  62750. static EdgeDetect2Kernel: number[];
  62751. /**
  62752. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62753. */
  62754. static SharpenKernel: number[];
  62755. /**
  62756. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62757. */
  62758. static EmbossKernel: number[];
  62759. /**
  62760. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62761. */
  62762. static GaussianKernel: number[];
  62763. }
  62764. }
  62765. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62766. import { Nullable } from "babylonjs/types";
  62767. import { Vector2 } from "babylonjs/Maths/math.vector";
  62768. import { Camera } from "babylonjs/Cameras/camera";
  62769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62770. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62771. import { Engine } from "babylonjs/Engines/engine";
  62772. import { Scene } from "babylonjs/scene";
  62773. /**
  62774. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62775. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62776. * based on samples that have a large difference in distance than the center pixel.
  62777. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62778. */
  62779. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62780. direction: Vector2;
  62781. /**
  62782. * Creates a new instance CircleOfConfusionPostProcess
  62783. * @param name The name of the effect.
  62784. * @param scene The scene the effect belongs to.
  62785. * @param direction The direction the blur should be applied.
  62786. * @param kernel The size of the kernel used to blur.
  62787. * @param options The required width/height ratio to downsize to before computing the render pass.
  62788. * @param camera The camera to apply the render pass to.
  62789. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62790. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62792. * @param engine The engine which the post process will be applied. (default: current engine)
  62793. * @param reusable If the post process can be reused on the same frame. (default: false)
  62794. * @param textureType Type of textures used when performing the post process. (default: 0)
  62795. * @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)
  62796. */
  62797. 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);
  62798. }
  62799. }
  62800. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62801. /** @hidden */
  62802. export var depthOfFieldMergePixelShader: {
  62803. name: string;
  62804. shader: string;
  62805. };
  62806. }
  62807. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62808. import { Nullable } from "babylonjs/types";
  62809. import { Camera } from "babylonjs/Cameras/camera";
  62810. import { Effect } from "babylonjs/Materials/effect";
  62811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62812. import { Engine } from "babylonjs/Engines/engine";
  62813. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62814. /**
  62815. * Options to be set when merging outputs from the default pipeline.
  62816. */
  62817. export class DepthOfFieldMergePostProcessOptions {
  62818. /**
  62819. * The original image to merge on top of
  62820. */
  62821. originalFromInput: PostProcess;
  62822. /**
  62823. * Parameters to perform the merge of the depth of field effect
  62824. */
  62825. depthOfField?: {
  62826. circleOfConfusion: PostProcess;
  62827. blurSteps: Array<PostProcess>;
  62828. };
  62829. /**
  62830. * Parameters to perform the merge of bloom effect
  62831. */
  62832. bloom?: {
  62833. blurred: PostProcess;
  62834. weight: number;
  62835. };
  62836. }
  62837. /**
  62838. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62839. */
  62840. export class DepthOfFieldMergePostProcess extends PostProcess {
  62841. private blurSteps;
  62842. /**
  62843. * Creates a new instance of DepthOfFieldMergePostProcess
  62844. * @param name The name of the effect.
  62845. * @param originalFromInput Post process which's input will be used for the merge.
  62846. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62847. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62848. * @param options The required width/height ratio to downsize to before computing the render pass.
  62849. * @param camera The camera to apply the render pass to.
  62850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62851. * @param engine The engine which the post process will be applied. (default: current engine)
  62852. * @param reusable If the post process can be reused on the same frame. (default: false)
  62853. * @param textureType Type of textures used when performing the post process. (default: 0)
  62854. * @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)
  62855. */
  62856. 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);
  62857. /**
  62858. * Updates the effect with the current post process compile time values and recompiles the shader.
  62859. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62860. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62861. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62862. * @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
  62863. * @param onCompiled Called when the shader has been compiled.
  62864. * @param onError Called if there is an error when compiling a shader.
  62865. */
  62866. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62867. }
  62868. }
  62869. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62870. import { Nullable } from "babylonjs/types";
  62871. import { Camera } from "babylonjs/Cameras/camera";
  62872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62874. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62875. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62876. import { Scene } from "babylonjs/scene";
  62877. /**
  62878. * Specifies the level of max blur that should be applied when using the depth of field effect
  62879. */
  62880. export enum DepthOfFieldEffectBlurLevel {
  62881. /**
  62882. * Subtle blur
  62883. */
  62884. Low = 0,
  62885. /**
  62886. * Medium blur
  62887. */
  62888. Medium = 1,
  62889. /**
  62890. * Large blur
  62891. */
  62892. High = 2
  62893. }
  62894. /**
  62895. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62896. */
  62897. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62898. private _circleOfConfusion;
  62899. /**
  62900. * @hidden Internal, blurs from high to low
  62901. */
  62902. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62903. private _depthOfFieldBlurY;
  62904. private _dofMerge;
  62905. /**
  62906. * @hidden Internal post processes in depth of field effect
  62907. */
  62908. _effects: Array<PostProcess>;
  62909. /**
  62910. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62911. */
  62912. focalLength: number;
  62913. /**
  62914. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62915. */
  62916. fStop: number;
  62917. /**
  62918. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62919. */
  62920. focusDistance: number;
  62921. /**
  62922. * 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.
  62923. */
  62924. lensSize: number;
  62925. /**
  62926. * Creates a new instance DepthOfFieldEffect
  62927. * @param scene The scene the effect belongs to.
  62928. * @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.
  62929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62930. * @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)
  62931. */
  62932. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62933. /**
  62934. * Get the current class name of the current effet
  62935. * @returns "DepthOfFieldEffect"
  62936. */
  62937. getClassName(): string;
  62938. /**
  62939. * 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.
  62940. */
  62941. depthTexture: RenderTargetTexture;
  62942. /**
  62943. * Disposes each of the internal effects for a given camera.
  62944. * @param camera The camera to dispose the effect on.
  62945. */
  62946. disposeEffects(camera: Camera): void;
  62947. /**
  62948. * @hidden Internal
  62949. */
  62950. _updateEffects(): void;
  62951. /**
  62952. * Internal
  62953. * @returns if all the contained post processes are ready.
  62954. * @hidden
  62955. */
  62956. _isReady(): boolean;
  62957. }
  62958. }
  62959. declare module "babylonjs/Shaders/displayPass.fragment" {
  62960. /** @hidden */
  62961. export var displayPassPixelShader: {
  62962. name: string;
  62963. shader: string;
  62964. };
  62965. }
  62966. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62967. import { Nullable } from "babylonjs/types";
  62968. import { Camera } from "babylonjs/Cameras/camera";
  62969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62970. import { Engine } from "babylonjs/Engines/engine";
  62971. import "babylonjs/Shaders/displayPass.fragment";
  62972. /**
  62973. * DisplayPassPostProcess which produces an output the same as it's input
  62974. */
  62975. export class DisplayPassPostProcess extends PostProcess {
  62976. /**
  62977. * Creates the DisplayPassPostProcess
  62978. * @param name The name of the effect.
  62979. * @param options The required width/height ratio to downsize to before computing the render pass.
  62980. * @param camera The camera to apply the render pass to.
  62981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62982. * @param engine The engine which the post process will be applied. (default: current engine)
  62983. * @param reusable If the post process can be reused on the same frame. (default: false)
  62984. */
  62985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62986. }
  62987. }
  62988. declare module "babylonjs/Shaders/filter.fragment" {
  62989. /** @hidden */
  62990. export var filterPixelShader: {
  62991. name: string;
  62992. shader: string;
  62993. };
  62994. }
  62995. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62996. import { Nullable } from "babylonjs/types";
  62997. import { Matrix } from "babylonjs/Maths/math.vector";
  62998. import { Camera } from "babylonjs/Cameras/camera";
  62999. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63000. import { Engine } from "babylonjs/Engines/engine";
  63001. import "babylonjs/Shaders/filter.fragment";
  63002. /**
  63003. * Applies a kernel filter to the image
  63004. */
  63005. export class FilterPostProcess extends PostProcess {
  63006. /** The matrix to be applied to the image */
  63007. kernelMatrix: Matrix;
  63008. /**
  63009. *
  63010. * @param name The name of the effect.
  63011. * @param kernelMatrix The matrix to be applied to the image
  63012. * @param options The required width/height ratio to downsize to before computing the render pass.
  63013. * @param camera The camera to apply the render pass to.
  63014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63015. * @param engine The engine which the post process will be applied. (default: current engine)
  63016. * @param reusable If the post process can be reused on the same frame. (default: false)
  63017. */
  63018. constructor(name: string,
  63019. /** The matrix to be applied to the image */
  63020. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63021. }
  63022. }
  63023. declare module "babylonjs/Shaders/fxaa.fragment" {
  63024. /** @hidden */
  63025. export var fxaaPixelShader: {
  63026. name: string;
  63027. shader: string;
  63028. };
  63029. }
  63030. declare module "babylonjs/Shaders/fxaa.vertex" {
  63031. /** @hidden */
  63032. export var fxaaVertexShader: {
  63033. name: string;
  63034. shader: string;
  63035. };
  63036. }
  63037. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63038. import { Nullable } from "babylonjs/types";
  63039. import { Camera } from "babylonjs/Cameras/camera";
  63040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63041. import { Engine } from "babylonjs/Engines/engine";
  63042. import "babylonjs/Shaders/fxaa.fragment";
  63043. import "babylonjs/Shaders/fxaa.vertex";
  63044. /**
  63045. * Fxaa post process
  63046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63047. */
  63048. export class FxaaPostProcess extends PostProcess {
  63049. /** @hidden */
  63050. texelWidth: number;
  63051. /** @hidden */
  63052. texelHeight: number;
  63053. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63054. private _getDefines;
  63055. }
  63056. }
  63057. declare module "babylonjs/Shaders/grain.fragment" {
  63058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63059. /** @hidden */
  63060. export var grainPixelShader: {
  63061. name: string;
  63062. shader: string;
  63063. };
  63064. }
  63065. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63066. import { Nullable } from "babylonjs/types";
  63067. import { Camera } from "babylonjs/Cameras/camera";
  63068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63069. import { Engine } from "babylonjs/Engines/engine";
  63070. import "babylonjs/Shaders/grain.fragment";
  63071. /**
  63072. * The GrainPostProcess adds noise to the image at mid luminance levels
  63073. */
  63074. export class GrainPostProcess extends PostProcess {
  63075. /**
  63076. * The intensity of the grain added (default: 30)
  63077. */
  63078. intensity: number;
  63079. /**
  63080. * If the grain should be randomized on every frame
  63081. */
  63082. animated: boolean;
  63083. /**
  63084. * Creates a new instance of @see GrainPostProcess
  63085. * @param name The name of the effect.
  63086. * @param options The required width/height ratio to downsize to before computing the render pass.
  63087. * @param camera The camera to apply the render pass to.
  63088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63089. * @param engine The engine which the post process will be applied. (default: current engine)
  63090. * @param reusable If the post process can be reused on the same frame. (default: false)
  63091. * @param textureType Type of textures used when performing the post process. (default: 0)
  63092. * @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)
  63093. */
  63094. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63095. }
  63096. }
  63097. declare module "babylonjs/Shaders/highlights.fragment" {
  63098. /** @hidden */
  63099. export var highlightsPixelShader: {
  63100. name: string;
  63101. shader: string;
  63102. };
  63103. }
  63104. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63105. import { Nullable } from "babylonjs/types";
  63106. import { Camera } from "babylonjs/Cameras/camera";
  63107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63108. import { Engine } from "babylonjs/Engines/engine";
  63109. import "babylonjs/Shaders/highlights.fragment";
  63110. /**
  63111. * Extracts highlights from the image
  63112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63113. */
  63114. export class HighlightsPostProcess extends PostProcess {
  63115. /**
  63116. * Extracts highlights from the image
  63117. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63118. * @param name The name of the effect.
  63119. * @param options The required width/height ratio to downsize to before computing the render pass.
  63120. * @param camera The camera to apply the render pass to.
  63121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63122. * @param engine The engine which the post process will be applied. (default: current engine)
  63123. * @param reusable If the post process can be reused on the same frame. (default: false)
  63124. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63125. */
  63126. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63127. }
  63128. }
  63129. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63130. /** @hidden */
  63131. export var mrtFragmentDeclaration: {
  63132. name: string;
  63133. shader: string;
  63134. };
  63135. }
  63136. declare module "babylonjs/Shaders/geometry.fragment" {
  63137. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63138. /** @hidden */
  63139. export var geometryPixelShader: {
  63140. name: string;
  63141. shader: string;
  63142. };
  63143. }
  63144. declare module "babylonjs/Shaders/geometry.vertex" {
  63145. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63146. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63147. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63148. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63149. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63150. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63151. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63152. /** @hidden */
  63153. export var geometryVertexShader: {
  63154. name: string;
  63155. shader: string;
  63156. };
  63157. }
  63158. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63159. import { Matrix } from "babylonjs/Maths/math.vector";
  63160. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63161. import { Mesh } from "babylonjs/Meshes/mesh";
  63162. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63163. import { Effect } from "babylonjs/Materials/effect";
  63164. import { Scene } from "babylonjs/scene";
  63165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63166. import "babylonjs/Shaders/geometry.fragment";
  63167. import "babylonjs/Shaders/geometry.vertex";
  63168. /** @hidden */
  63169. interface ISavedTransformationMatrix {
  63170. world: Matrix;
  63171. viewProjection: Matrix;
  63172. }
  63173. /**
  63174. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63175. */
  63176. export class GeometryBufferRenderer {
  63177. /**
  63178. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63179. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63180. */
  63181. static readonly POSITION_TEXTURE_TYPE: number;
  63182. /**
  63183. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63184. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63185. */
  63186. static readonly VELOCITY_TEXTURE_TYPE: number;
  63187. /**
  63188. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63189. * in order to compute objects velocities when enableVelocity is set to "true"
  63190. * @hidden
  63191. */
  63192. _previousTransformationMatrices: {
  63193. [index: number]: ISavedTransformationMatrix;
  63194. };
  63195. /**
  63196. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63197. * in order to compute objects velocities when enableVelocity is set to "true"
  63198. * @hidden
  63199. */
  63200. _previousBonesTransformationMatrices: {
  63201. [index: number]: Float32Array;
  63202. };
  63203. /**
  63204. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63205. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63206. */
  63207. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63208. private _scene;
  63209. private _multiRenderTarget;
  63210. private _ratio;
  63211. private _enablePosition;
  63212. private _enableVelocity;
  63213. private _positionIndex;
  63214. private _velocityIndex;
  63215. protected _effect: Effect;
  63216. protected _cachedDefines: string;
  63217. /**
  63218. * Set the render list (meshes to be rendered) used in the G buffer.
  63219. */
  63220. renderList: Mesh[];
  63221. /**
  63222. * Gets wether or not G buffer are supported by the running hardware.
  63223. * This requires draw buffer supports
  63224. */
  63225. readonly isSupported: boolean;
  63226. /**
  63227. * Returns the index of the given texture type in the G-Buffer textures array
  63228. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63229. * @returns the index of the given texture type in the G-Buffer textures array
  63230. */
  63231. getTextureIndex(textureType: number): number;
  63232. /**
  63233. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63234. */
  63235. /**
  63236. * Sets whether or not objects positions are enabled for the G buffer.
  63237. */
  63238. enablePosition: boolean;
  63239. /**
  63240. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63241. */
  63242. /**
  63243. * Sets wether or not objects velocities are enabled for the G buffer.
  63244. */
  63245. enableVelocity: boolean;
  63246. /**
  63247. * Gets the scene associated with the buffer.
  63248. */
  63249. readonly scene: Scene;
  63250. /**
  63251. * Gets the ratio used by the buffer during its creation.
  63252. * How big is the buffer related to the main canvas.
  63253. */
  63254. readonly ratio: number;
  63255. /** @hidden */
  63256. static _SceneComponentInitialization: (scene: Scene) => void;
  63257. /**
  63258. * Creates a new G Buffer for the scene
  63259. * @param scene The scene the buffer belongs to
  63260. * @param ratio How big is the buffer related to the main canvas.
  63261. */
  63262. constructor(scene: Scene, ratio?: number);
  63263. /**
  63264. * Checks wether everything is ready to render a submesh to the G buffer.
  63265. * @param subMesh the submesh to check readiness for
  63266. * @param useInstances is the mesh drawn using instance or not
  63267. * @returns true if ready otherwise false
  63268. */
  63269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63270. /**
  63271. * Gets the current underlying G Buffer.
  63272. * @returns the buffer
  63273. */
  63274. getGBuffer(): MultiRenderTarget;
  63275. /**
  63276. * Gets the number of samples used to render the buffer (anti aliasing).
  63277. */
  63278. /**
  63279. * Sets the number of samples used to render the buffer (anti aliasing).
  63280. */
  63281. samples: number;
  63282. /**
  63283. * Disposes the renderer and frees up associated resources.
  63284. */
  63285. dispose(): void;
  63286. protected _createRenderTargets(): void;
  63287. private _copyBonesTransformationMatrices;
  63288. }
  63289. }
  63290. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63291. import { Nullable } from "babylonjs/types";
  63292. import { Scene } from "babylonjs/scene";
  63293. import { ISceneComponent } from "babylonjs/sceneComponent";
  63294. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63295. module "babylonjs/scene" {
  63296. interface Scene {
  63297. /** @hidden (Backing field) */
  63298. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63299. /**
  63300. * Gets or Sets the current geometry buffer associated to the scene.
  63301. */
  63302. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63303. /**
  63304. * Enables a GeometryBufferRender and associates it with the scene
  63305. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63306. * @returns the GeometryBufferRenderer
  63307. */
  63308. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63309. /**
  63310. * Disables the GeometryBufferRender associated with the scene
  63311. */
  63312. disableGeometryBufferRenderer(): void;
  63313. }
  63314. }
  63315. /**
  63316. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63317. * in several rendering techniques.
  63318. */
  63319. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63320. /**
  63321. * The component name helpful to identify the component in the list of scene components.
  63322. */
  63323. readonly name: string;
  63324. /**
  63325. * The scene the component belongs to.
  63326. */
  63327. scene: Scene;
  63328. /**
  63329. * Creates a new instance of the component for the given scene
  63330. * @param scene Defines the scene to register the component in
  63331. */
  63332. constructor(scene: Scene);
  63333. /**
  63334. * Registers the component in a given scene
  63335. */
  63336. register(): void;
  63337. /**
  63338. * Rebuilds the elements related to this component in case of
  63339. * context lost for instance.
  63340. */
  63341. rebuild(): void;
  63342. /**
  63343. * Disposes the component and the associated ressources
  63344. */
  63345. dispose(): void;
  63346. private _gatherRenderTargets;
  63347. }
  63348. }
  63349. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63350. /** @hidden */
  63351. export var motionBlurPixelShader: {
  63352. name: string;
  63353. shader: string;
  63354. };
  63355. }
  63356. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63357. import { Nullable } from "babylonjs/types";
  63358. import { Camera } from "babylonjs/Cameras/camera";
  63359. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63360. import { Scene } from "babylonjs/scene";
  63361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63362. import "babylonjs/Animations/animatable";
  63363. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63364. import "babylonjs/Shaders/motionBlur.fragment";
  63365. import { Engine } from "babylonjs/Engines/engine";
  63366. /**
  63367. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63368. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63369. * As an example, all you have to do is to create the post-process:
  63370. * var mb = new BABYLON.MotionBlurPostProcess(
  63371. * 'mb', // The name of the effect.
  63372. * scene, // The scene containing the objects to blur according to their velocity.
  63373. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63374. * camera // The camera to apply the render pass to.
  63375. * );
  63376. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63377. */
  63378. export class MotionBlurPostProcess extends PostProcess {
  63379. /**
  63380. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63381. */
  63382. motionStrength: number;
  63383. /**
  63384. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63385. */
  63386. /**
  63387. * Sets the number of iterations to be used for motion blur quality
  63388. */
  63389. motionBlurSamples: number;
  63390. private _motionBlurSamples;
  63391. private _geometryBufferRenderer;
  63392. /**
  63393. * Creates a new instance MotionBlurPostProcess
  63394. * @param name The name of the effect.
  63395. * @param scene The scene containing the objects to blur according to their velocity.
  63396. * @param options The required width/height ratio to downsize to before computing the render pass.
  63397. * @param camera The camera to apply the render pass to.
  63398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63399. * @param engine The engine which the post process will be applied. (default: current engine)
  63400. * @param reusable If the post process can be reused on the same frame. (default: false)
  63401. * @param textureType Type of textures used when performing the post process. (default: 0)
  63402. * @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)
  63403. */
  63404. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63405. /**
  63406. * Excludes the given skinned mesh from computing bones velocities.
  63407. * 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.
  63408. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63409. */
  63410. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63411. /**
  63412. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63413. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63414. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63415. */
  63416. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63417. /**
  63418. * Disposes the post process.
  63419. * @param camera The camera to dispose the post process on.
  63420. */
  63421. dispose(camera?: Camera): void;
  63422. }
  63423. }
  63424. declare module "babylonjs/Shaders/refraction.fragment" {
  63425. /** @hidden */
  63426. export var refractionPixelShader: {
  63427. name: string;
  63428. shader: string;
  63429. };
  63430. }
  63431. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63432. import { Color3 } from "babylonjs/Maths/math.color";
  63433. import { Camera } from "babylonjs/Cameras/camera";
  63434. import { Texture } from "babylonjs/Materials/Textures/texture";
  63435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63436. import { Engine } from "babylonjs/Engines/engine";
  63437. import "babylonjs/Shaders/refraction.fragment";
  63438. /**
  63439. * Post process which applies a refractin texture
  63440. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63441. */
  63442. export class RefractionPostProcess extends PostProcess {
  63443. /** the base color of the refraction (used to taint the rendering) */
  63444. color: Color3;
  63445. /** simulated refraction depth */
  63446. depth: number;
  63447. /** the coefficient of the base color (0 to remove base color tainting) */
  63448. colorLevel: number;
  63449. private _refTexture;
  63450. private _ownRefractionTexture;
  63451. /**
  63452. * Gets or sets the refraction texture
  63453. * Please note that you are responsible for disposing the texture if you set it manually
  63454. */
  63455. refractionTexture: Texture;
  63456. /**
  63457. * Initializes the RefractionPostProcess
  63458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63459. * @param name The name of the effect.
  63460. * @param refractionTextureUrl Url of the refraction texture to use
  63461. * @param color the base color of the refraction (used to taint the rendering)
  63462. * @param depth simulated refraction depth
  63463. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63464. * @param camera The camera to apply the render pass to.
  63465. * @param options The required width/height ratio to downsize to before computing the render pass.
  63466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63467. * @param engine The engine which the post process will be applied. (default: current engine)
  63468. * @param reusable If the post process can be reused on the same frame. (default: false)
  63469. */
  63470. constructor(name: string, refractionTextureUrl: string,
  63471. /** the base color of the refraction (used to taint the rendering) */
  63472. color: Color3,
  63473. /** simulated refraction depth */
  63474. depth: number,
  63475. /** the coefficient of the base color (0 to remove base color tainting) */
  63476. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63477. /**
  63478. * Disposes of the post process
  63479. * @param camera Camera to dispose post process on
  63480. */
  63481. dispose(camera: Camera): void;
  63482. }
  63483. }
  63484. declare module "babylonjs/Shaders/sharpen.fragment" {
  63485. /** @hidden */
  63486. export var sharpenPixelShader: {
  63487. name: string;
  63488. shader: string;
  63489. };
  63490. }
  63491. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63492. import { Nullable } from "babylonjs/types";
  63493. import { Camera } from "babylonjs/Cameras/camera";
  63494. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63495. import "babylonjs/Shaders/sharpen.fragment";
  63496. import { Engine } from "babylonjs/Engines/engine";
  63497. /**
  63498. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63499. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63500. */
  63501. export class SharpenPostProcess extends PostProcess {
  63502. /**
  63503. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63504. */
  63505. colorAmount: number;
  63506. /**
  63507. * How much sharpness should be applied (default: 0.3)
  63508. */
  63509. edgeAmount: number;
  63510. /**
  63511. * Creates a new instance ConvolutionPostProcess
  63512. * @param name The name of the effect.
  63513. * @param options The required width/height ratio to downsize to before computing the render pass.
  63514. * @param camera The camera to apply the render pass to.
  63515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63516. * @param engine The engine which the post process will be applied. (default: current engine)
  63517. * @param reusable If the post process can be reused on the same frame. (default: false)
  63518. * @param textureType Type of textures used when performing the post process. (default: 0)
  63519. * @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)
  63520. */
  63521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63522. }
  63523. }
  63524. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63525. import { Nullable } from "babylonjs/types";
  63526. import { Camera } from "babylonjs/Cameras/camera";
  63527. import { Engine } from "babylonjs/Engines/engine";
  63528. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63529. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63530. /**
  63531. * PostProcessRenderPipeline
  63532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63533. */
  63534. export class PostProcessRenderPipeline {
  63535. private engine;
  63536. private _renderEffects;
  63537. private _renderEffectsForIsolatedPass;
  63538. /**
  63539. * List of inspectable custom properties (used by the Inspector)
  63540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63541. */
  63542. inspectableCustomProperties: IInspectable[];
  63543. /**
  63544. * @hidden
  63545. */
  63546. protected _cameras: Camera[];
  63547. /** @hidden */
  63548. _name: string;
  63549. /**
  63550. * Gets pipeline name
  63551. */
  63552. readonly name: string;
  63553. /**
  63554. * Initializes a PostProcessRenderPipeline
  63555. * @param engine engine to add the pipeline to
  63556. * @param name name of the pipeline
  63557. */
  63558. constructor(engine: Engine, name: string);
  63559. /**
  63560. * Gets the class name
  63561. * @returns "PostProcessRenderPipeline"
  63562. */
  63563. getClassName(): string;
  63564. /**
  63565. * If all the render effects in the pipeline are supported
  63566. */
  63567. readonly isSupported: boolean;
  63568. /**
  63569. * Adds an effect to the pipeline
  63570. * @param renderEffect the effect to add
  63571. */
  63572. addEffect(renderEffect: PostProcessRenderEffect): void;
  63573. /** @hidden */
  63574. _rebuild(): void;
  63575. /** @hidden */
  63576. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63577. /** @hidden */
  63578. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63579. /** @hidden */
  63580. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63581. /** @hidden */
  63582. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63583. /** @hidden */
  63584. _attachCameras(cameras: Camera, unique: boolean): void;
  63585. /** @hidden */
  63586. _attachCameras(cameras: Camera[], unique: boolean): void;
  63587. /** @hidden */
  63588. _detachCameras(cameras: Camera): void;
  63589. /** @hidden */
  63590. _detachCameras(cameras: Nullable<Camera[]>): void;
  63591. /** @hidden */
  63592. _update(): void;
  63593. /** @hidden */
  63594. _reset(): void;
  63595. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63596. /**
  63597. * Disposes of the pipeline
  63598. */
  63599. dispose(): void;
  63600. }
  63601. }
  63602. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63603. import { Camera } from "babylonjs/Cameras/camera";
  63604. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63605. /**
  63606. * PostProcessRenderPipelineManager class
  63607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63608. */
  63609. export class PostProcessRenderPipelineManager {
  63610. private _renderPipelines;
  63611. /**
  63612. * Initializes a PostProcessRenderPipelineManager
  63613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63614. */
  63615. constructor();
  63616. /**
  63617. * Gets the list of supported render pipelines
  63618. */
  63619. readonly supportedPipelines: PostProcessRenderPipeline[];
  63620. /**
  63621. * Adds a pipeline to the manager
  63622. * @param renderPipeline The pipeline to add
  63623. */
  63624. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63625. /**
  63626. * Attaches a camera to the pipeline
  63627. * @param renderPipelineName The name of the pipeline to attach to
  63628. * @param cameras the camera to attach
  63629. * @param unique if the camera can be attached multiple times to the pipeline
  63630. */
  63631. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63632. /**
  63633. * Detaches a camera from the pipeline
  63634. * @param renderPipelineName The name of the pipeline to detach from
  63635. * @param cameras the camera to detach
  63636. */
  63637. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63638. /**
  63639. * Enables an effect by name on a pipeline
  63640. * @param renderPipelineName the name of the pipeline to enable the effect in
  63641. * @param renderEffectName the name of the effect to enable
  63642. * @param cameras the cameras that the effect should be enabled on
  63643. */
  63644. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63645. /**
  63646. * Disables an effect by name on a pipeline
  63647. * @param renderPipelineName the name of the pipeline to disable the effect in
  63648. * @param renderEffectName the name of the effect to disable
  63649. * @param cameras the cameras that the effect should be disabled on
  63650. */
  63651. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63652. /**
  63653. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63654. */
  63655. update(): void;
  63656. /** @hidden */
  63657. _rebuild(): void;
  63658. /**
  63659. * Disposes of the manager and pipelines
  63660. */
  63661. dispose(): void;
  63662. }
  63663. }
  63664. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63665. import { ISceneComponent } from "babylonjs/sceneComponent";
  63666. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63667. import { Scene } from "babylonjs/scene";
  63668. module "babylonjs/scene" {
  63669. interface Scene {
  63670. /** @hidden (Backing field) */
  63671. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63672. /**
  63673. * Gets the postprocess render pipeline manager
  63674. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63675. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63676. */
  63677. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63678. }
  63679. }
  63680. /**
  63681. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63682. */
  63683. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63684. /**
  63685. * The component name helpfull to identify the component in the list of scene components.
  63686. */
  63687. readonly name: string;
  63688. /**
  63689. * The scene the component belongs to.
  63690. */
  63691. scene: Scene;
  63692. /**
  63693. * Creates a new instance of the component for the given scene
  63694. * @param scene Defines the scene to register the component in
  63695. */
  63696. constructor(scene: Scene);
  63697. /**
  63698. * Registers the component in a given scene
  63699. */
  63700. register(): void;
  63701. /**
  63702. * Rebuilds the elements related to this component in case of
  63703. * context lost for instance.
  63704. */
  63705. rebuild(): void;
  63706. /**
  63707. * Disposes the component and the associated ressources
  63708. */
  63709. dispose(): void;
  63710. private _gatherRenderTargets;
  63711. }
  63712. }
  63713. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63714. import { Nullable } from "babylonjs/types";
  63715. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63716. import { Camera } from "babylonjs/Cameras/camera";
  63717. import { IDisposable } from "babylonjs/scene";
  63718. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63719. import { Scene } from "babylonjs/scene";
  63720. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63721. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63722. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63723. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63724. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63725. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63726. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63727. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63728. import { Animation } from "babylonjs/Animations/animation";
  63729. /**
  63730. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63731. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63732. */
  63733. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63734. private _scene;
  63735. private _camerasToBeAttached;
  63736. /**
  63737. * ID of the sharpen post process,
  63738. */
  63739. private readonly SharpenPostProcessId;
  63740. /**
  63741. * @ignore
  63742. * ID of the image processing post process;
  63743. */
  63744. readonly ImageProcessingPostProcessId: string;
  63745. /**
  63746. * @ignore
  63747. * ID of the Fast Approximate Anti-Aliasing post process;
  63748. */
  63749. readonly FxaaPostProcessId: string;
  63750. /**
  63751. * ID of the chromatic aberration post process,
  63752. */
  63753. private readonly ChromaticAberrationPostProcessId;
  63754. /**
  63755. * ID of the grain post process
  63756. */
  63757. private readonly GrainPostProcessId;
  63758. /**
  63759. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63760. */
  63761. sharpen: SharpenPostProcess;
  63762. private _sharpenEffect;
  63763. private bloom;
  63764. /**
  63765. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63766. */
  63767. depthOfField: DepthOfFieldEffect;
  63768. /**
  63769. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63770. */
  63771. fxaa: FxaaPostProcess;
  63772. /**
  63773. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63774. */
  63775. imageProcessing: ImageProcessingPostProcess;
  63776. /**
  63777. * Chromatic aberration post process which will shift rgb colors in the image
  63778. */
  63779. chromaticAberration: ChromaticAberrationPostProcess;
  63780. private _chromaticAberrationEffect;
  63781. /**
  63782. * Grain post process which add noise to the image
  63783. */
  63784. grain: GrainPostProcess;
  63785. private _grainEffect;
  63786. /**
  63787. * Glow post process which adds a glow to emissive areas of the image
  63788. */
  63789. private _glowLayer;
  63790. /**
  63791. * Animations which can be used to tweak settings over a period of time
  63792. */
  63793. animations: Animation[];
  63794. private _imageProcessingConfigurationObserver;
  63795. private _sharpenEnabled;
  63796. private _bloomEnabled;
  63797. private _depthOfFieldEnabled;
  63798. private _depthOfFieldBlurLevel;
  63799. private _fxaaEnabled;
  63800. private _imageProcessingEnabled;
  63801. private _defaultPipelineTextureType;
  63802. private _bloomScale;
  63803. private _chromaticAberrationEnabled;
  63804. private _grainEnabled;
  63805. private _buildAllowed;
  63806. /**
  63807. * Gets active scene
  63808. */
  63809. readonly scene: Scene;
  63810. /**
  63811. * Enable or disable the sharpen process from the pipeline
  63812. */
  63813. sharpenEnabled: boolean;
  63814. private _resizeObserver;
  63815. private _hardwareScaleLevel;
  63816. private _bloomKernel;
  63817. /**
  63818. * Specifies the size of the bloom blur kernel, relative to the final output size
  63819. */
  63820. bloomKernel: number;
  63821. /**
  63822. * Specifies the weight of the bloom in the final rendering
  63823. */
  63824. private _bloomWeight;
  63825. /**
  63826. * Specifies the luma threshold for the area that will be blurred by the bloom
  63827. */
  63828. private _bloomThreshold;
  63829. private _hdr;
  63830. /**
  63831. * The strength of the bloom.
  63832. */
  63833. bloomWeight: number;
  63834. /**
  63835. * The strength of the bloom.
  63836. */
  63837. bloomThreshold: number;
  63838. /**
  63839. * The scale of the bloom, lower value will provide better performance.
  63840. */
  63841. bloomScale: number;
  63842. /**
  63843. * Enable or disable the bloom from the pipeline
  63844. */
  63845. bloomEnabled: boolean;
  63846. private _rebuildBloom;
  63847. /**
  63848. * If the depth of field is enabled.
  63849. */
  63850. depthOfFieldEnabled: boolean;
  63851. /**
  63852. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63853. */
  63854. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63855. /**
  63856. * If the anti aliasing is enabled.
  63857. */
  63858. fxaaEnabled: boolean;
  63859. private _samples;
  63860. /**
  63861. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63862. */
  63863. samples: number;
  63864. /**
  63865. * If image processing is enabled.
  63866. */
  63867. imageProcessingEnabled: boolean;
  63868. /**
  63869. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63870. */
  63871. glowLayerEnabled: boolean;
  63872. /**
  63873. * Gets the glow layer (or null if not defined)
  63874. */
  63875. readonly glowLayer: Nullable<GlowLayer>;
  63876. /**
  63877. * Enable or disable the chromaticAberration process from the pipeline
  63878. */
  63879. chromaticAberrationEnabled: boolean;
  63880. /**
  63881. * Enable or disable the grain process from the pipeline
  63882. */
  63883. grainEnabled: boolean;
  63884. /**
  63885. * @constructor
  63886. * @param name - The rendering pipeline name (default: "")
  63887. * @param hdr - If high dynamic range textures should be used (default: true)
  63888. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63889. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63890. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63891. */
  63892. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63893. /**
  63894. * Get the class name
  63895. * @returns "DefaultRenderingPipeline"
  63896. */
  63897. getClassName(): string;
  63898. /**
  63899. * Force the compilation of the entire pipeline.
  63900. */
  63901. prepare(): void;
  63902. private _hasCleared;
  63903. private _prevPostProcess;
  63904. private _prevPrevPostProcess;
  63905. private _setAutoClearAndTextureSharing;
  63906. private _depthOfFieldSceneObserver;
  63907. private _buildPipeline;
  63908. private _disposePostProcesses;
  63909. /**
  63910. * Adds a camera to the pipeline
  63911. * @param camera the camera to be added
  63912. */
  63913. addCamera(camera: Camera): void;
  63914. /**
  63915. * Removes a camera from the pipeline
  63916. * @param camera the camera to remove
  63917. */
  63918. removeCamera(camera: Camera): void;
  63919. /**
  63920. * Dispose of the pipeline and stop all post processes
  63921. */
  63922. dispose(): void;
  63923. /**
  63924. * Serialize the rendering pipeline (Used when exporting)
  63925. * @returns the serialized object
  63926. */
  63927. serialize(): any;
  63928. /**
  63929. * Parse the serialized pipeline
  63930. * @param source Source pipeline.
  63931. * @param scene The scene to load the pipeline to.
  63932. * @param rootUrl The URL of the serialized pipeline.
  63933. * @returns An instantiated pipeline from the serialized object.
  63934. */
  63935. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63936. }
  63937. }
  63938. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63939. /** @hidden */
  63940. export var lensHighlightsPixelShader: {
  63941. name: string;
  63942. shader: string;
  63943. };
  63944. }
  63945. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63946. /** @hidden */
  63947. export var depthOfFieldPixelShader: {
  63948. name: string;
  63949. shader: string;
  63950. };
  63951. }
  63952. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63953. import { Camera } from "babylonjs/Cameras/camera";
  63954. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63955. import { Scene } from "babylonjs/scene";
  63956. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63957. import "babylonjs/Shaders/chromaticAberration.fragment";
  63958. import "babylonjs/Shaders/lensHighlights.fragment";
  63959. import "babylonjs/Shaders/depthOfField.fragment";
  63960. /**
  63961. * BABYLON.JS Chromatic Aberration GLSL Shader
  63962. * Author: Olivier Guyot
  63963. * Separates very slightly R, G and B colors on the edges of the screen
  63964. * Inspired by Francois Tarlier & Martins Upitis
  63965. */
  63966. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63967. /**
  63968. * @ignore
  63969. * The chromatic aberration PostProcess id in the pipeline
  63970. */
  63971. LensChromaticAberrationEffect: string;
  63972. /**
  63973. * @ignore
  63974. * The highlights enhancing PostProcess id in the pipeline
  63975. */
  63976. HighlightsEnhancingEffect: string;
  63977. /**
  63978. * @ignore
  63979. * The depth-of-field PostProcess id in the pipeline
  63980. */
  63981. LensDepthOfFieldEffect: string;
  63982. private _scene;
  63983. private _depthTexture;
  63984. private _grainTexture;
  63985. private _chromaticAberrationPostProcess;
  63986. private _highlightsPostProcess;
  63987. private _depthOfFieldPostProcess;
  63988. private _edgeBlur;
  63989. private _grainAmount;
  63990. private _chromaticAberration;
  63991. private _distortion;
  63992. private _highlightsGain;
  63993. private _highlightsThreshold;
  63994. private _dofDistance;
  63995. private _dofAperture;
  63996. private _dofDarken;
  63997. private _dofPentagon;
  63998. private _blurNoise;
  63999. /**
  64000. * @constructor
  64001. *
  64002. * Effect parameters are as follow:
  64003. * {
  64004. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64005. * edge_blur: number; // from 0 to x (1 for realism)
  64006. * distortion: number; // from 0 to x (1 for realism)
  64007. * grain_amount: number; // from 0 to 1
  64008. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64009. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64010. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64011. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64012. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64013. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64014. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64015. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64016. * }
  64017. * Note: if an effect parameter is unset, effect is disabled
  64018. *
  64019. * @param name The rendering pipeline name
  64020. * @param parameters - An object containing all parameters (see above)
  64021. * @param scene The scene linked to this pipeline
  64022. * @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)
  64023. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64024. */
  64025. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64026. /**
  64027. * Get the class name
  64028. * @returns "LensRenderingPipeline"
  64029. */
  64030. getClassName(): string;
  64031. /**
  64032. * Gets associated scene
  64033. */
  64034. readonly scene: Scene;
  64035. /**
  64036. * Gets or sets the edge blur
  64037. */
  64038. edgeBlur: number;
  64039. /**
  64040. * Gets or sets the grain amount
  64041. */
  64042. grainAmount: number;
  64043. /**
  64044. * Gets or sets the chromatic aberration amount
  64045. */
  64046. chromaticAberration: number;
  64047. /**
  64048. * Gets or sets the depth of field aperture
  64049. */
  64050. dofAperture: number;
  64051. /**
  64052. * Gets or sets the edge distortion
  64053. */
  64054. edgeDistortion: number;
  64055. /**
  64056. * Gets or sets the depth of field distortion
  64057. */
  64058. dofDistortion: number;
  64059. /**
  64060. * Gets or sets the darken out of focus amount
  64061. */
  64062. darkenOutOfFocus: number;
  64063. /**
  64064. * Gets or sets a boolean indicating if blur noise is enabled
  64065. */
  64066. blurNoise: boolean;
  64067. /**
  64068. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64069. */
  64070. pentagonBokeh: boolean;
  64071. /**
  64072. * Gets or sets the highlight grain amount
  64073. */
  64074. highlightsGain: number;
  64075. /**
  64076. * Gets or sets the highlight threshold
  64077. */
  64078. highlightsThreshold: number;
  64079. /**
  64080. * Sets the amount of blur at the edges
  64081. * @param amount blur amount
  64082. */
  64083. setEdgeBlur(amount: number): void;
  64084. /**
  64085. * Sets edge blur to 0
  64086. */
  64087. disableEdgeBlur(): void;
  64088. /**
  64089. * Sets the amout of grain
  64090. * @param amount Amount of grain
  64091. */
  64092. setGrainAmount(amount: number): void;
  64093. /**
  64094. * Set grain amount to 0
  64095. */
  64096. disableGrain(): void;
  64097. /**
  64098. * Sets the chromatic aberration amount
  64099. * @param amount amount of chromatic aberration
  64100. */
  64101. setChromaticAberration(amount: number): void;
  64102. /**
  64103. * Sets chromatic aberration amount to 0
  64104. */
  64105. disableChromaticAberration(): void;
  64106. /**
  64107. * Sets the EdgeDistortion amount
  64108. * @param amount amount of EdgeDistortion
  64109. */
  64110. setEdgeDistortion(amount: number): void;
  64111. /**
  64112. * Sets edge distortion to 0
  64113. */
  64114. disableEdgeDistortion(): void;
  64115. /**
  64116. * Sets the FocusDistance amount
  64117. * @param amount amount of FocusDistance
  64118. */
  64119. setFocusDistance(amount: number): void;
  64120. /**
  64121. * Disables depth of field
  64122. */
  64123. disableDepthOfField(): void;
  64124. /**
  64125. * Sets the Aperture amount
  64126. * @param amount amount of Aperture
  64127. */
  64128. setAperture(amount: number): void;
  64129. /**
  64130. * Sets the DarkenOutOfFocus amount
  64131. * @param amount amount of DarkenOutOfFocus
  64132. */
  64133. setDarkenOutOfFocus(amount: number): void;
  64134. private _pentagonBokehIsEnabled;
  64135. /**
  64136. * Creates a pentagon bokeh effect
  64137. */
  64138. enablePentagonBokeh(): void;
  64139. /**
  64140. * Disables the pentagon bokeh effect
  64141. */
  64142. disablePentagonBokeh(): void;
  64143. /**
  64144. * Enables noise blur
  64145. */
  64146. enableNoiseBlur(): void;
  64147. /**
  64148. * Disables noise blur
  64149. */
  64150. disableNoiseBlur(): void;
  64151. /**
  64152. * Sets the HighlightsGain amount
  64153. * @param amount amount of HighlightsGain
  64154. */
  64155. setHighlightsGain(amount: number): void;
  64156. /**
  64157. * Sets the HighlightsThreshold amount
  64158. * @param amount amount of HighlightsThreshold
  64159. */
  64160. setHighlightsThreshold(amount: number): void;
  64161. /**
  64162. * Disables highlights
  64163. */
  64164. disableHighlights(): void;
  64165. /**
  64166. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64167. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64168. */
  64169. dispose(disableDepthRender?: boolean): void;
  64170. private _createChromaticAberrationPostProcess;
  64171. private _createHighlightsPostProcess;
  64172. private _createDepthOfFieldPostProcess;
  64173. private _createGrainTexture;
  64174. }
  64175. }
  64176. declare module "babylonjs/Shaders/ssao2.fragment" {
  64177. /** @hidden */
  64178. export var ssao2PixelShader: {
  64179. name: string;
  64180. shader: string;
  64181. };
  64182. }
  64183. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64184. /** @hidden */
  64185. export var ssaoCombinePixelShader: {
  64186. name: string;
  64187. shader: string;
  64188. };
  64189. }
  64190. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64191. import { Camera } from "babylonjs/Cameras/camera";
  64192. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64193. import { Scene } from "babylonjs/scene";
  64194. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64195. import "babylonjs/Shaders/ssao2.fragment";
  64196. import "babylonjs/Shaders/ssaoCombine.fragment";
  64197. /**
  64198. * Render pipeline to produce ssao effect
  64199. */
  64200. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64201. /**
  64202. * @ignore
  64203. * The PassPostProcess id in the pipeline that contains the original scene color
  64204. */
  64205. SSAOOriginalSceneColorEffect: string;
  64206. /**
  64207. * @ignore
  64208. * The SSAO PostProcess id in the pipeline
  64209. */
  64210. SSAORenderEffect: string;
  64211. /**
  64212. * @ignore
  64213. * The horizontal blur PostProcess id in the pipeline
  64214. */
  64215. SSAOBlurHRenderEffect: string;
  64216. /**
  64217. * @ignore
  64218. * The vertical blur PostProcess id in the pipeline
  64219. */
  64220. SSAOBlurVRenderEffect: string;
  64221. /**
  64222. * @ignore
  64223. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64224. */
  64225. SSAOCombineRenderEffect: string;
  64226. /**
  64227. * The output strength of the SSAO post-process. Default value is 1.0.
  64228. */
  64229. totalStrength: number;
  64230. /**
  64231. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64232. */
  64233. maxZ: number;
  64234. /**
  64235. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64236. */
  64237. minZAspect: number;
  64238. private _samples;
  64239. /**
  64240. * Number of samples used for the SSAO calculations. Default value is 8
  64241. */
  64242. samples: number;
  64243. private _textureSamples;
  64244. /**
  64245. * Number of samples to use for antialiasing
  64246. */
  64247. textureSamples: number;
  64248. /**
  64249. * Ratio object used for SSAO ratio and blur ratio
  64250. */
  64251. private _ratio;
  64252. /**
  64253. * Dynamically generated sphere sampler.
  64254. */
  64255. private _sampleSphere;
  64256. /**
  64257. * Blur filter offsets
  64258. */
  64259. private _samplerOffsets;
  64260. private _expensiveBlur;
  64261. /**
  64262. * If bilateral blur should be used
  64263. */
  64264. expensiveBlur: boolean;
  64265. /**
  64266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64267. */
  64268. radius: number;
  64269. /**
  64270. * The base color of the SSAO post-process
  64271. * The final result is "base + ssao" between [0, 1]
  64272. */
  64273. base: number;
  64274. /**
  64275. * Support test.
  64276. */
  64277. static readonly IsSupported: boolean;
  64278. private _scene;
  64279. private _depthTexture;
  64280. private _normalTexture;
  64281. private _randomTexture;
  64282. private _originalColorPostProcess;
  64283. private _ssaoPostProcess;
  64284. private _blurHPostProcess;
  64285. private _blurVPostProcess;
  64286. private _ssaoCombinePostProcess;
  64287. private _firstUpdate;
  64288. /**
  64289. * Gets active scene
  64290. */
  64291. readonly scene: Scene;
  64292. /**
  64293. * @constructor
  64294. * @param name The rendering pipeline name
  64295. * @param scene The scene linked to this pipeline
  64296. * @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 }
  64297. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64298. */
  64299. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64300. /**
  64301. * Get the class name
  64302. * @returns "SSAO2RenderingPipeline"
  64303. */
  64304. getClassName(): string;
  64305. /**
  64306. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64307. */
  64308. dispose(disableGeometryBufferRenderer?: boolean): void;
  64309. private _createBlurPostProcess;
  64310. /** @hidden */
  64311. _rebuild(): void;
  64312. private _bits;
  64313. private _radicalInverse_VdC;
  64314. private _hammersley;
  64315. private _hemisphereSample_uniform;
  64316. private _generateHemisphere;
  64317. private _createSSAOPostProcess;
  64318. private _createSSAOCombinePostProcess;
  64319. private _createRandomTexture;
  64320. /**
  64321. * Serialize the rendering pipeline (Used when exporting)
  64322. * @returns the serialized object
  64323. */
  64324. serialize(): any;
  64325. /**
  64326. * Parse the serialized pipeline
  64327. * @param source Source pipeline.
  64328. * @param scene The scene to load the pipeline to.
  64329. * @param rootUrl The URL of the serialized pipeline.
  64330. * @returns An instantiated pipeline from the serialized object.
  64331. */
  64332. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64333. }
  64334. }
  64335. declare module "babylonjs/Shaders/ssao.fragment" {
  64336. /** @hidden */
  64337. export var ssaoPixelShader: {
  64338. name: string;
  64339. shader: string;
  64340. };
  64341. }
  64342. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64343. import { Camera } from "babylonjs/Cameras/camera";
  64344. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64345. import { Scene } from "babylonjs/scene";
  64346. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64347. import "babylonjs/Shaders/ssao.fragment";
  64348. import "babylonjs/Shaders/ssaoCombine.fragment";
  64349. /**
  64350. * Render pipeline to produce ssao effect
  64351. */
  64352. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64353. /**
  64354. * @ignore
  64355. * The PassPostProcess id in the pipeline that contains the original scene color
  64356. */
  64357. SSAOOriginalSceneColorEffect: string;
  64358. /**
  64359. * @ignore
  64360. * The SSAO PostProcess id in the pipeline
  64361. */
  64362. SSAORenderEffect: string;
  64363. /**
  64364. * @ignore
  64365. * The horizontal blur PostProcess id in the pipeline
  64366. */
  64367. SSAOBlurHRenderEffect: string;
  64368. /**
  64369. * @ignore
  64370. * The vertical blur PostProcess id in the pipeline
  64371. */
  64372. SSAOBlurVRenderEffect: string;
  64373. /**
  64374. * @ignore
  64375. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64376. */
  64377. SSAOCombineRenderEffect: string;
  64378. /**
  64379. * The output strength of the SSAO post-process. Default value is 1.0.
  64380. */
  64381. totalStrength: number;
  64382. /**
  64383. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64384. */
  64385. radius: number;
  64386. /**
  64387. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64388. * Must not be equal to fallOff and superior to fallOff.
  64389. * Default value is 0.0075
  64390. */
  64391. area: number;
  64392. /**
  64393. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64394. * Must not be equal to area and inferior to area.
  64395. * Default value is 0.000001
  64396. */
  64397. fallOff: number;
  64398. /**
  64399. * The base color of the SSAO post-process
  64400. * The final result is "base + ssao" between [0, 1]
  64401. */
  64402. base: number;
  64403. private _scene;
  64404. private _depthTexture;
  64405. private _randomTexture;
  64406. private _originalColorPostProcess;
  64407. private _ssaoPostProcess;
  64408. private _blurHPostProcess;
  64409. private _blurVPostProcess;
  64410. private _ssaoCombinePostProcess;
  64411. private _firstUpdate;
  64412. /**
  64413. * Gets active scene
  64414. */
  64415. readonly scene: Scene;
  64416. /**
  64417. * @constructor
  64418. * @param name - The rendering pipeline name
  64419. * @param scene - The scene linked to this pipeline
  64420. * @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 }
  64421. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64422. */
  64423. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64424. /**
  64425. * Get the class name
  64426. * @returns "SSAORenderingPipeline"
  64427. */
  64428. getClassName(): string;
  64429. /**
  64430. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64431. */
  64432. dispose(disableDepthRender?: boolean): void;
  64433. private _createBlurPostProcess;
  64434. /** @hidden */
  64435. _rebuild(): void;
  64436. private _createSSAOPostProcess;
  64437. private _createSSAOCombinePostProcess;
  64438. private _createRandomTexture;
  64439. }
  64440. }
  64441. declare module "babylonjs/Shaders/standard.fragment" {
  64442. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64443. /** @hidden */
  64444. export var standardPixelShader: {
  64445. name: string;
  64446. shader: string;
  64447. };
  64448. }
  64449. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64450. import { Nullable } from "babylonjs/types";
  64451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64452. import { Camera } from "babylonjs/Cameras/camera";
  64453. import { Texture } from "babylonjs/Materials/Textures/texture";
  64454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64455. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64456. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64457. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64458. import { IDisposable } from "babylonjs/scene";
  64459. import { SpotLight } from "babylonjs/Lights/spotLight";
  64460. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64461. import { Scene } from "babylonjs/scene";
  64462. import { Animation } from "babylonjs/Animations/animation";
  64463. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64464. import "babylonjs/Shaders/standard.fragment";
  64465. /**
  64466. * Standard rendering pipeline
  64467. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64468. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64469. */
  64470. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64471. /**
  64472. * Public members
  64473. */
  64474. /**
  64475. * Post-process which contains the original scene color before the pipeline applies all the effects
  64476. */
  64477. originalPostProcess: Nullable<PostProcess>;
  64478. /**
  64479. * Post-process used to down scale an image x4
  64480. */
  64481. downSampleX4PostProcess: Nullable<PostProcess>;
  64482. /**
  64483. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64484. */
  64485. brightPassPostProcess: Nullable<PostProcess>;
  64486. /**
  64487. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64488. */
  64489. blurHPostProcesses: PostProcess[];
  64490. /**
  64491. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64492. */
  64493. blurVPostProcesses: PostProcess[];
  64494. /**
  64495. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64496. */
  64497. textureAdderPostProcess: Nullable<PostProcess>;
  64498. /**
  64499. * Post-process used to create volumetric lighting effect
  64500. */
  64501. volumetricLightPostProcess: Nullable<PostProcess>;
  64502. /**
  64503. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64504. */
  64505. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64506. /**
  64507. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64508. */
  64509. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64510. /**
  64511. * Post-process used to merge the volumetric light effect and the real scene color
  64512. */
  64513. volumetricLightMergePostProces: Nullable<PostProcess>;
  64514. /**
  64515. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64516. */
  64517. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64518. /**
  64519. * Base post-process used to calculate the average luminance of the final image for HDR
  64520. */
  64521. luminancePostProcess: Nullable<PostProcess>;
  64522. /**
  64523. * Post-processes used to create down sample post-processes in order to get
  64524. * the average luminance of the final image for HDR
  64525. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64526. */
  64527. luminanceDownSamplePostProcesses: PostProcess[];
  64528. /**
  64529. * Post-process used to create a HDR effect (light adaptation)
  64530. */
  64531. hdrPostProcess: Nullable<PostProcess>;
  64532. /**
  64533. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64534. */
  64535. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64536. /**
  64537. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64538. */
  64539. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64540. /**
  64541. * Post-process used to merge the final HDR post-process and the real scene color
  64542. */
  64543. hdrFinalPostProcess: Nullable<PostProcess>;
  64544. /**
  64545. * Post-process used to create a lens flare effect
  64546. */
  64547. lensFlarePostProcess: Nullable<PostProcess>;
  64548. /**
  64549. * Post-process that merges the result of the lens flare post-process and the real scene color
  64550. */
  64551. lensFlareComposePostProcess: Nullable<PostProcess>;
  64552. /**
  64553. * Post-process used to create a motion blur effect
  64554. */
  64555. motionBlurPostProcess: Nullable<PostProcess>;
  64556. /**
  64557. * Post-process used to create a depth of field effect
  64558. */
  64559. depthOfFieldPostProcess: Nullable<PostProcess>;
  64560. /**
  64561. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64562. */
  64563. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64564. /**
  64565. * Represents the brightness threshold in order to configure the illuminated surfaces
  64566. */
  64567. brightThreshold: number;
  64568. /**
  64569. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64570. */
  64571. blurWidth: number;
  64572. /**
  64573. * Sets if the blur for highlighted surfaces must be only horizontal
  64574. */
  64575. horizontalBlur: boolean;
  64576. /**
  64577. * Gets the overall exposure used by the pipeline
  64578. */
  64579. /**
  64580. * Sets the overall exposure used by the pipeline
  64581. */
  64582. exposure: number;
  64583. /**
  64584. * Texture used typically to simulate "dirty" on camera lens
  64585. */
  64586. lensTexture: Nullable<Texture>;
  64587. /**
  64588. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64589. */
  64590. volumetricLightCoefficient: number;
  64591. /**
  64592. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64593. */
  64594. volumetricLightPower: number;
  64595. /**
  64596. * Used the set the blur intensity to smooth the volumetric lights
  64597. */
  64598. volumetricLightBlurScale: number;
  64599. /**
  64600. * Light (spot or directional) used to generate the volumetric lights rays
  64601. * The source light must have a shadow generate so the pipeline can get its
  64602. * depth map
  64603. */
  64604. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64605. /**
  64606. * For eye adaptation, represents the minimum luminance the eye can see
  64607. */
  64608. hdrMinimumLuminance: number;
  64609. /**
  64610. * For eye adaptation, represents the decrease luminance speed
  64611. */
  64612. hdrDecreaseRate: number;
  64613. /**
  64614. * For eye adaptation, represents the increase luminance speed
  64615. */
  64616. hdrIncreaseRate: number;
  64617. /**
  64618. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64619. */
  64620. /**
  64621. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64622. */
  64623. hdrAutoExposure: boolean;
  64624. /**
  64625. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64626. */
  64627. lensColorTexture: Nullable<Texture>;
  64628. /**
  64629. * The overall strengh for the lens flare effect
  64630. */
  64631. lensFlareStrength: number;
  64632. /**
  64633. * Dispersion coefficient for lens flare ghosts
  64634. */
  64635. lensFlareGhostDispersal: number;
  64636. /**
  64637. * Main lens flare halo width
  64638. */
  64639. lensFlareHaloWidth: number;
  64640. /**
  64641. * Based on the lens distortion effect, defines how much the lens flare result
  64642. * is distorted
  64643. */
  64644. lensFlareDistortionStrength: number;
  64645. /**
  64646. * Configures the blur intensity used for for lens flare (halo)
  64647. */
  64648. lensFlareBlurWidth: number;
  64649. /**
  64650. * Lens star texture must be used to simulate rays on the flares and is available
  64651. * in the documentation
  64652. */
  64653. lensStarTexture: Nullable<Texture>;
  64654. /**
  64655. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64656. * flare effect by taking account of the dirt texture
  64657. */
  64658. lensFlareDirtTexture: Nullable<Texture>;
  64659. /**
  64660. * Represents the focal length for the depth of field effect
  64661. */
  64662. depthOfFieldDistance: number;
  64663. /**
  64664. * Represents the blur intensity for the blurred part of the depth of field effect
  64665. */
  64666. depthOfFieldBlurWidth: number;
  64667. /**
  64668. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64669. */
  64670. /**
  64671. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64672. */
  64673. motionStrength: number;
  64674. /**
  64675. * Gets wether or not the motion blur post-process is object based or screen based.
  64676. */
  64677. /**
  64678. * Sets wether or not the motion blur post-process should be object based or screen based
  64679. */
  64680. objectBasedMotionBlur: boolean;
  64681. /**
  64682. * List of animations for the pipeline (IAnimatable implementation)
  64683. */
  64684. animations: Animation[];
  64685. /**
  64686. * Private members
  64687. */
  64688. private _scene;
  64689. private _currentDepthOfFieldSource;
  64690. private _basePostProcess;
  64691. private _fixedExposure;
  64692. private _currentExposure;
  64693. private _hdrAutoExposure;
  64694. private _hdrCurrentLuminance;
  64695. private _motionStrength;
  64696. private _isObjectBasedMotionBlur;
  64697. private _floatTextureType;
  64698. private _camerasToBeAttached;
  64699. private _ratio;
  64700. private _bloomEnabled;
  64701. private _depthOfFieldEnabled;
  64702. private _vlsEnabled;
  64703. private _lensFlareEnabled;
  64704. private _hdrEnabled;
  64705. private _motionBlurEnabled;
  64706. private _fxaaEnabled;
  64707. private _motionBlurSamples;
  64708. private _volumetricLightStepsCount;
  64709. private _samples;
  64710. /**
  64711. * @ignore
  64712. * Specifies if the bloom pipeline is enabled
  64713. */
  64714. BloomEnabled: boolean;
  64715. /**
  64716. * @ignore
  64717. * Specifies if the depth of field pipeline is enabed
  64718. */
  64719. DepthOfFieldEnabled: boolean;
  64720. /**
  64721. * @ignore
  64722. * Specifies if the lens flare pipeline is enabed
  64723. */
  64724. LensFlareEnabled: boolean;
  64725. /**
  64726. * @ignore
  64727. * Specifies if the HDR pipeline is enabled
  64728. */
  64729. HDREnabled: boolean;
  64730. /**
  64731. * @ignore
  64732. * Specifies if the volumetric lights scattering effect is enabled
  64733. */
  64734. VLSEnabled: boolean;
  64735. /**
  64736. * @ignore
  64737. * Specifies if the motion blur effect is enabled
  64738. */
  64739. MotionBlurEnabled: boolean;
  64740. /**
  64741. * Specifies if anti-aliasing is enabled
  64742. */
  64743. fxaaEnabled: boolean;
  64744. /**
  64745. * Specifies the number of steps used to calculate the volumetric lights
  64746. * Typically in interval [50, 200]
  64747. */
  64748. volumetricLightStepsCount: number;
  64749. /**
  64750. * Specifies the number of samples used for the motion blur effect
  64751. * Typically in interval [16, 64]
  64752. */
  64753. motionBlurSamples: number;
  64754. /**
  64755. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64756. */
  64757. samples: number;
  64758. /**
  64759. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64760. * @constructor
  64761. * @param name The rendering pipeline name
  64762. * @param scene The scene linked to this pipeline
  64763. * @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)
  64764. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64765. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64766. */
  64767. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64768. private _buildPipeline;
  64769. private _createDownSampleX4PostProcess;
  64770. private _createBrightPassPostProcess;
  64771. private _createBlurPostProcesses;
  64772. private _createTextureAdderPostProcess;
  64773. private _createVolumetricLightPostProcess;
  64774. private _createLuminancePostProcesses;
  64775. private _createHdrPostProcess;
  64776. private _createLensFlarePostProcess;
  64777. private _createDepthOfFieldPostProcess;
  64778. private _createMotionBlurPostProcess;
  64779. private _getDepthTexture;
  64780. private _disposePostProcesses;
  64781. /**
  64782. * Dispose of the pipeline and stop all post processes
  64783. */
  64784. dispose(): void;
  64785. /**
  64786. * Serialize the rendering pipeline (Used when exporting)
  64787. * @returns the serialized object
  64788. */
  64789. serialize(): any;
  64790. /**
  64791. * Parse the serialized pipeline
  64792. * @param source Source pipeline.
  64793. * @param scene The scene to load the pipeline to.
  64794. * @param rootUrl The URL of the serialized pipeline.
  64795. * @returns An instantiated pipeline from the serialized object.
  64796. */
  64797. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64798. /**
  64799. * Luminance steps
  64800. */
  64801. static LuminanceSteps: number;
  64802. }
  64803. }
  64804. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64805. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64806. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64807. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64808. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64809. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64810. }
  64811. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64812. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64813. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64814. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64815. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64816. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64817. }
  64818. declare module "babylonjs/Shaders/tonemap.fragment" {
  64819. /** @hidden */
  64820. export var tonemapPixelShader: {
  64821. name: string;
  64822. shader: string;
  64823. };
  64824. }
  64825. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64826. import { Camera } from "babylonjs/Cameras/camera";
  64827. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64828. import "babylonjs/Shaders/tonemap.fragment";
  64829. import { Engine } from "babylonjs/Engines/engine";
  64830. /** Defines operator used for tonemapping */
  64831. export enum TonemappingOperator {
  64832. /** Hable */
  64833. Hable = 0,
  64834. /** Reinhard */
  64835. Reinhard = 1,
  64836. /** HejiDawson */
  64837. HejiDawson = 2,
  64838. /** Photographic */
  64839. Photographic = 3
  64840. }
  64841. /**
  64842. * Defines a post process to apply tone mapping
  64843. */
  64844. export class TonemapPostProcess extends PostProcess {
  64845. private _operator;
  64846. /** Defines the required exposure adjustement */
  64847. exposureAdjustment: number;
  64848. /**
  64849. * Creates a new TonemapPostProcess
  64850. * @param name defines the name of the postprocess
  64851. * @param _operator defines the operator to use
  64852. * @param exposureAdjustment defines the required exposure adjustement
  64853. * @param camera defines the camera to use (can be null)
  64854. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64855. * @param engine defines the hosting engine (can be ignore if camera is set)
  64856. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64857. */
  64858. constructor(name: string, _operator: TonemappingOperator,
  64859. /** Defines the required exposure adjustement */
  64860. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64861. }
  64862. }
  64863. declare module "babylonjs/Shaders/depth.vertex" {
  64864. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64867. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64868. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64869. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64871. /** @hidden */
  64872. export var depthVertexShader: {
  64873. name: string;
  64874. shader: string;
  64875. };
  64876. }
  64877. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64878. /** @hidden */
  64879. export var volumetricLightScatteringPixelShader: {
  64880. name: string;
  64881. shader: string;
  64882. };
  64883. }
  64884. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64885. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64886. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64887. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64888. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64890. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64891. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64892. /** @hidden */
  64893. export var volumetricLightScatteringPassVertexShader: {
  64894. name: string;
  64895. shader: string;
  64896. };
  64897. }
  64898. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64899. /** @hidden */
  64900. export var volumetricLightScatteringPassPixelShader: {
  64901. name: string;
  64902. shader: string;
  64903. };
  64904. }
  64905. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64906. import { Vector3 } from "babylonjs/Maths/math.vector";
  64907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64908. import { Mesh } from "babylonjs/Meshes/mesh";
  64909. import { Camera } from "babylonjs/Cameras/camera";
  64910. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64911. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64912. import { Scene } from "babylonjs/scene";
  64913. import "babylonjs/Meshes/Builders/planeBuilder";
  64914. import "babylonjs/Shaders/depth.vertex";
  64915. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64916. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64917. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64918. import { Engine } from "babylonjs/Engines/engine";
  64919. /**
  64920. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64921. */
  64922. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64923. private _volumetricLightScatteringPass;
  64924. private _volumetricLightScatteringRTT;
  64925. private _viewPort;
  64926. private _screenCoordinates;
  64927. private _cachedDefines;
  64928. /**
  64929. * If not undefined, the mesh position is computed from the attached node position
  64930. */
  64931. attachedNode: {
  64932. position: Vector3;
  64933. };
  64934. /**
  64935. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64936. */
  64937. customMeshPosition: Vector3;
  64938. /**
  64939. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64940. */
  64941. useCustomMeshPosition: boolean;
  64942. /**
  64943. * If the post-process should inverse the light scattering direction
  64944. */
  64945. invert: boolean;
  64946. /**
  64947. * The internal mesh used by the post-process
  64948. */
  64949. mesh: Mesh;
  64950. /**
  64951. * @hidden
  64952. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64953. */
  64954. useDiffuseColor: boolean;
  64955. /**
  64956. * Array containing the excluded meshes not rendered in the internal pass
  64957. */
  64958. excludedMeshes: AbstractMesh[];
  64959. /**
  64960. * Controls the overall intensity of the post-process
  64961. */
  64962. exposure: number;
  64963. /**
  64964. * Dissipates each sample's contribution in range [0, 1]
  64965. */
  64966. decay: number;
  64967. /**
  64968. * Controls the overall intensity of each sample
  64969. */
  64970. weight: number;
  64971. /**
  64972. * Controls the density of each sample
  64973. */
  64974. density: number;
  64975. /**
  64976. * @constructor
  64977. * @param name The post-process name
  64978. * @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)
  64979. * @param camera The camera that the post-process will be attached to
  64980. * @param mesh The mesh used to create the light scattering
  64981. * @param samples The post-process quality, default 100
  64982. * @param samplingModeThe post-process filtering mode
  64983. * @param engine The babylon engine
  64984. * @param reusable If the post-process is reusable
  64985. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64986. */
  64987. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64988. /**
  64989. * Returns the string "VolumetricLightScatteringPostProcess"
  64990. * @returns "VolumetricLightScatteringPostProcess"
  64991. */
  64992. getClassName(): string;
  64993. private _isReady;
  64994. /**
  64995. * Sets the new light position for light scattering effect
  64996. * @param position The new custom light position
  64997. */
  64998. setCustomMeshPosition(position: Vector3): void;
  64999. /**
  65000. * Returns the light position for light scattering effect
  65001. * @return Vector3 The custom light position
  65002. */
  65003. getCustomMeshPosition(): Vector3;
  65004. /**
  65005. * Disposes the internal assets and detaches the post-process from the camera
  65006. */
  65007. dispose(camera: Camera): void;
  65008. /**
  65009. * Returns the render target texture used by the post-process
  65010. * @return the render target texture used by the post-process
  65011. */
  65012. getPass(): RenderTargetTexture;
  65013. private _meshExcluded;
  65014. private _createPass;
  65015. private _updateMeshScreenCoordinates;
  65016. /**
  65017. * Creates a default mesh for the Volumeric Light Scattering post-process
  65018. * @param name The mesh name
  65019. * @param scene The scene where to create the mesh
  65020. * @return the default mesh
  65021. */
  65022. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65023. }
  65024. }
  65025. declare module "babylonjs/PostProcesses/index" {
  65026. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65027. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65028. export * from "babylonjs/PostProcesses/bloomEffect";
  65029. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65030. export * from "babylonjs/PostProcesses/blurPostProcess";
  65031. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65032. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65033. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65034. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65035. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65036. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65037. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65038. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65039. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65040. export * from "babylonjs/PostProcesses/filterPostProcess";
  65041. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65042. export * from "babylonjs/PostProcesses/grainPostProcess";
  65043. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65044. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65045. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65046. export * from "babylonjs/PostProcesses/passPostProcess";
  65047. export * from "babylonjs/PostProcesses/postProcess";
  65048. export * from "babylonjs/PostProcesses/postProcessManager";
  65049. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65050. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65051. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65052. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65053. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65054. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65055. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65056. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65057. }
  65058. declare module "babylonjs/Probes/index" {
  65059. export * from "babylonjs/Probes/reflectionProbe";
  65060. }
  65061. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65062. import { Scene } from "babylonjs/scene";
  65063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65064. import { SmartArray } from "babylonjs/Misc/smartArray";
  65065. import { ISceneComponent } from "babylonjs/sceneComponent";
  65066. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65067. import "babylonjs/Meshes/Builders/boxBuilder";
  65068. import "babylonjs/Shaders/color.fragment";
  65069. import "babylonjs/Shaders/color.vertex";
  65070. import { Color3 } from "babylonjs/Maths/math.color";
  65071. module "babylonjs/scene" {
  65072. interface Scene {
  65073. /** @hidden (Backing field) */
  65074. _boundingBoxRenderer: BoundingBoxRenderer;
  65075. /** @hidden (Backing field) */
  65076. _forceShowBoundingBoxes: boolean;
  65077. /**
  65078. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65079. */
  65080. forceShowBoundingBoxes: boolean;
  65081. /**
  65082. * Gets the bounding box renderer associated with the scene
  65083. * @returns a BoundingBoxRenderer
  65084. */
  65085. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65086. }
  65087. }
  65088. module "babylonjs/Meshes/abstractMesh" {
  65089. interface AbstractMesh {
  65090. /** @hidden (Backing field) */
  65091. _showBoundingBox: boolean;
  65092. /**
  65093. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65094. */
  65095. showBoundingBox: boolean;
  65096. }
  65097. }
  65098. /**
  65099. * Component responsible of rendering the bounding box of the meshes in a scene.
  65100. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65101. */
  65102. export class BoundingBoxRenderer implements ISceneComponent {
  65103. /**
  65104. * The component name helpfull to identify the component in the list of scene components.
  65105. */
  65106. readonly name: string;
  65107. /**
  65108. * The scene the component belongs to.
  65109. */
  65110. scene: Scene;
  65111. /**
  65112. * Color of the bounding box lines placed in front of an object
  65113. */
  65114. frontColor: Color3;
  65115. /**
  65116. * Color of the bounding box lines placed behind an object
  65117. */
  65118. backColor: Color3;
  65119. /**
  65120. * Defines if the renderer should show the back lines or not
  65121. */
  65122. showBackLines: boolean;
  65123. /**
  65124. * @hidden
  65125. */
  65126. renderList: SmartArray<BoundingBox>;
  65127. private _colorShader;
  65128. private _vertexBuffers;
  65129. private _indexBuffer;
  65130. private _fillIndexBuffer;
  65131. private _fillIndexData;
  65132. /**
  65133. * Instantiates a new bounding box renderer in a scene.
  65134. * @param scene the scene the renderer renders in
  65135. */
  65136. constructor(scene: Scene);
  65137. /**
  65138. * Registers the component in a given scene
  65139. */
  65140. register(): void;
  65141. private _evaluateSubMesh;
  65142. private _activeMesh;
  65143. private _prepareRessources;
  65144. private _createIndexBuffer;
  65145. /**
  65146. * Rebuilds the elements related to this component in case of
  65147. * context lost for instance.
  65148. */
  65149. rebuild(): void;
  65150. /**
  65151. * @hidden
  65152. */
  65153. reset(): void;
  65154. /**
  65155. * Render the bounding boxes of a specific rendering group
  65156. * @param renderingGroupId defines the rendering group to render
  65157. */
  65158. render(renderingGroupId: number): void;
  65159. /**
  65160. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65161. * @param mesh Define the mesh to render the occlusion bounding box for
  65162. */
  65163. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65164. /**
  65165. * Dispose and release the resources attached to this renderer.
  65166. */
  65167. dispose(): void;
  65168. }
  65169. }
  65170. declare module "babylonjs/Shaders/depth.fragment" {
  65171. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65172. /** @hidden */
  65173. export var depthPixelShader: {
  65174. name: string;
  65175. shader: string;
  65176. };
  65177. }
  65178. declare module "babylonjs/Rendering/depthRenderer" {
  65179. import { Nullable } from "babylonjs/types";
  65180. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65181. import { Scene } from "babylonjs/scene";
  65182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65183. import { Camera } from "babylonjs/Cameras/camera";
  65184. import "babylonjs/Shaders/depth.fragment";
  65185. import "babylonjs/Shaders/depth.vertex";
  65186. /**
  65187. * This represents a depth renderer in Babylon.
  65188. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65189. */
  65190. export class DepthRenderer {
  65191. private _scene;
  65192. private _depthMap;
  65193. private _effect;
  65194. private readonly _storeNonLinearDepth;
  65195. private readonly _clearColor;
  65196. /** Get if the depth renderer is using packed depth or not */
  65197. readonly isPacked: boolean;
  65198. private _cachedDefines;
  65199. private _camera;
  65200. /**
  65201. * Specifiess that the depth renderer will only be used within
  65202. * the camera it is created for.
  65203. * This can help forcing its rendering during the camera processing.
  65204. */
  65205. useOnlyInActiveCamera: boolean;
  65206. /** @hidden */
  65207. static _SceneComponentInitialization: (scene: Scene) => void;
  65208. /**
  65209. * Instantiates a depth renderer
  65210. * @param scene The scene the renderer belongs to
  65211. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65212. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65213. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65214. */
  65215. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65216. /**
  65217. * Creates the depth rendering effect and checks if the effect is ready.
  65218. * @param subMesh The submesh to be used to render the depth map of
  65219. * @param useInstances If multiple world instances should be used
  65220. * @returns if the depth renderer is ready to render the depth map
  65221. */
  65222. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65223. /**
  65224. * Gets the texture which the depth map will be written to.
  65225. * @returns The depth map texture
  65226. */
  65227. getDepthMap(): RenderTargetTexture;
  65228. /**
  65229. * Disposes of the depth renderer.
  65230. */
  65231. dispose(): void;
  65232. }
  65233. }
  65234. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65235. import { Nullable } from "babylonjs/types";
  65236. import { Scene } from "babylonjs/scene";
  65237. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65238. import { Camera } from "babylonjs/Cameras/camera";
  65239. import { ISceneComponent } from "babylonjs/sceneComponent";
  65240. module "babylonjs/scene" {
  65241. interface Scene {
  65242. /** @hidden (Backing field) */
  65243. _depthRenderer: {
  65244. [id: string]: DepthRenderer;
  65245. };
  65246. /**
  65247. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65248. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65249. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65250. * @returns the created depth renderer
  65251. */
  65252. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65253. /**
  65254. * Disables a depth renderer for a given camera
  65255. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65256. */
  65257. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65258. }
  65259. }
  65260. /**
  65261. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65262. * in several rendering techniques.
  65263. */
  65264. export class DepthRendererSceneComponent implements ISceneComponent {
  65265. /**
  65266. * The component name helpfull to identify the component in the list of scene components.
  65267. */
  65268. readonly name: string;
  65269. /**
  65270. * The scene the component belongs to.
  65271. */
  65272. scene: Scene;
  65273. /**
  65274. * Creates a new instance of the component for the given scene
  65275. * @param scene Defines the scene to register the component in
  65276. */
  65277. constructor(scene: Scene);
  65278. /**
  65279. * Registers the component in a given scene
  65280. */
  65281. register(): void;
  65282. /**
  65283. * Rebuilds the elements related to this component in case of
  65284. * context lost for instance.
  65285. */
  65286. rebuild(): void;
  65287. /**
  65288. * Disposes the component and the associated ressources
  65289. */
  65290. dispose(): void;
  65291. private _gatherRenderTargets;
  65292. private _gatherActiveCameraRenderTargets;
  65293. }
  65294. }
  65295. declare module "babylonjs/Shaders/outline.fragment" {
  65296. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65297. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65298. /** @hidden */
  65299. export var outlinePixelShader: {
  65300. name: string;
  65301. shader: string;
  65302. };
  65303. }
  65304. declare module "babylonjs/Shaders/outline.vertex" {
  65305. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65308. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65309. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65310. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65311. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65312. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65313. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65314. /** @hidden */
  65315. export var outlineVertexShader: {
  65316. name: string;
  65317. shader: string;
  65318. };
  65319. }
  65320. declare module "babylonjs/Rendering/outlineRenderer" {
  65321. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65322. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65323. import { Scene } from "babylonjs/scene";
  65324. import { ISceneComponent } from "babylonjs/sceneComponent";
  65325. import "babylonjs/Shaders/outline.fragment";
  65326. import "babylonjs/Shaders/outline.vertex";
  65327. module "babylonjs/scene" {
  65328. interface Scene {
  65329. /** @hidden */
  65330. _outlineRenderer: OutlineRenderer;
  65331. /**
  65332. * Gets the outline renderer associated with the scene
  65333. * @returns a OutlineRenderer
  65334. */
  65335. getOutlineRenderer(): OutlineRenderer;
  65336. }
  65337. }
  65338. module "babylonjs/Meshes/abstractMesh" {
  65339. interface AbstractMesh {
  65340. /** @hidden (Backing field) */
  65341. _renderOutline: boolean;
  65342. /**
  65343. * Gets or sets a boolean indicating if the outline must be rendered as well
  65344. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65345. */
  65346. renderOutline: boolean;
  65347. /** @hidden (Backing field) */
  65348. _renderOverlay: boolean;
  65349. /**
  65350. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65351. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65352. */
  65353. renderOverlay: boolean;
  65354. }
  65355. }
  65356. /**
  65357. * This class is responsible to draw bothe outline/overlay of meshes.
  65358. * It should not be used directly but through the available method on mesh.
  65359. */
  65360. export class OutlineRenderer implements ISceneComponent {
  65361. /**
  65362. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65363. */
  65364. private static _StencilReference;
  65365. /**
  65366. * The name of the component. Each component must have a unique name.
  65367. */
  65368. name: string;
  65369. /**
  65370. * The scene the component belongs to.
  65371. */
  65372. scene: Scene;
  65373. /**
  65374. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65375. */
  65376. zOffset: number;
  65377. private _engine;
  65378. private _effect;
  65379. private _cachedDefines;
  65380. private _savedDepthWrite;
  65381. /**
  65382. * Instantiates a new outline renderer. (There could be only one per scene).
  65383. * @param scene Defines the scene it belongs to
  65384. */
  65385. constructor(scene: Scene);
  65386. /**
  65387. * Register the component to one instance of a scene.
  65388. */
  65389. register(): void;
  65390. /**
  65391. * Rebuilds the elements related to this component in case of
  65392. * context lost for instance.
  65393. */
  65394. rebuild(): void;
  65395. /**
  65396. * Disposes the component and the associated ressources.
  65397. */
  65398. dispose(): void;
  65399. /**
  65400. * Renders the outline in the canvas.
  65401. * @param subMesh Defines the sumesh to render
  65402. * @param batch Defines the batch of meshes in case of instances
  65403. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65404. */
  65405. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65406. /**
  65407. * Returns whether or not the outline renderer is ready for a given submesh.
  65408. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65409. * @param subMesh Defines the submesh to check readyness for
  65410. * @param useInstances Defines wheter wee are trying to render instances or not
  65411. * @returns true if ready otherwise false
  65412. */
  65413. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65414. private _beforeRenderingMesh;
  65415. private _afterRenderingMesh;
  65416. }
  65417. }
  65418. declare module "babylonjs/Rendering/index" {
  65419. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65420. export * from "babylonjs/Rendering/depthRenderer";
  65421. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65422. export * from "babylonjs/Rendering/edgesRenderer";
  65423. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65424. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65425. export * from "babylonjs/Rendering/outlineRenderer";
  65426. export * from "babylonjs/Rendering/renderingGroup";
  65427. export * from "babylonjs/Rendering/renderingManager";
  65428. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65429. }
  65430. declare module "babylonjs/Sprites/spritePackedManager" {
  65431. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65432. import { Scene } from "babylonjs/scene";
  65433. /**
  65434. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65435. * @see http://doc.babylonjs.com/babylon101/sprites
  65436. */
  65437. export class SpritePackedManager extends SpriteManager {
  65438. /** defines the packed manager's name */
  65439. name: string;
  65440. /**
  65441. * Creates a new sprite manager from a packed sprite sheet
  65442. * @param name defines the manager's name
  65443. * @param imgUrl defines the sprite sheet url
  65444. * @param capacity defines the maximum allowed number of sprites
  65445. * @param scene defines the hosting scene
  65446. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65447. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65448. * @param samplingMode defines the smapling mode to use with spritesheet
  65449. * @param fromPacked set to true; do not alter
  65450. */
  65451. constructor(
  65452. /** defines the packed manager's name */
  65453. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65454. }
  65455. }
  65456. declare module "babylonjs/Sprites/index" {
  65457. export * from "babylonjs/Sprites/sprite";
  65458. export * from "babylonjs/Sprites/spriteManager";
  65459. export * from "babylonjs/Sprites/spritePackedManager";
  65460. export * from "babylonjs/Sprites/spriteSceneComponent";
  65461. }
  65462. declare module "babylonjs/States/index" {
  65463. export * from "babylonjs/States/alphaCullingState";
  65464. export * from "babylonjs/States/depthCullingState";
  65465. export * from "babylonjs/States/stencilState";
  65466. }
  65467. declare module "babylonjs/Misc/assetsManager" {
  65468. import { Scene } from "babylonjs/scene";
  65469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65470. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65471. import { Skeleton } from "babylonjs/Bones/skeleton";
  65472. import { Observable } from "babylonjs/Misc/observable";
  65473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65474. import { Texture } from "babylonjs/Materials/Textures/texture";
  65475. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65476. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65477. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65478. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65479. /**
  65480. * Defines the list of states available for a task inside a AssetsManager
  65481. */
  65482. export enum AssetTaskState {
  65483. /**
  65484. * Initialization
  65485. */
  65486. INIT = 0,
  65487. /**
  65488. * Running
  65489. */
  65490. RUNNING = 1,
  65491. /**
  65492. * Done
  65493. */
  65494. DONE = 2,
  65495. /**
  65496. * Error
  65497. */
  65498. ERROR = 3
  65499. }
  65500. /**
  65501. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65502. */
  65503. export abstract class AbstractAssetTask {
  65504. /**
  65505. * Task name
  65506. */ name: string;
  65507. /**
  65508. * Callback called when the task is successful
  65509. */
  65510. onSuccess: (task: any) => void;
  65511. /**
  65512. * Callback called when the task is not successful
  65513. */
  65514. onError: (task: any, message?: string, exception?: any) => void;
  65515. /**
  65516. * Creates a new AssetsManager
  65517. * @param name defines the name of the task
  65518. */
  65519. constructor(
  65520. /**
  65521. * Task name
  65522. */ name: string);
  65523. private _isCompleted;
  65524. private _taskState;
  65525. private _errorObject;
  65526. /**
  65527. * Get if the task is completed
  65528. */
  65529. readonly isCompleted: boolean;
  65530. /**
  65531. * Gets the current state of the task
  65532. */
  65533. readonly taskState: AssetTaskState;
  65534. /**
  65535. * Gets the current error object (if task is in error)
  65536. */
  65537. readonly errorObject: {
  65538. message?: string;
  65539. exception?: any;
  65540. };
  65541. /**
  65542. * Internal only
  65543. * @hidden
  65544. */
  65545. _setErrorObject(message?: string, exception?: any): void;
  65546. /**
  65547. * Execute the current task
  65548. * @param scene defines the scene where you want your assets to be loaded
  65549. * @param onSuccess is a callback called when the task is successfully executed
  65550. * @param onError is a callback called if an error occurs
  65551. */
  65552. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65553. /**
  65554. * Execute the current task
  65555. * @param scene defines the scene where you want your assets to be loaded
  65556. * @param onSuccess is a callback called when the task is successfully executed
  65557. * @param onError is a callback called if an error occurs
  65558. */
  65559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65560. /**
  65561. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65562. * This can be used with failed tasks that have the reason for failure fixed.
  65563. */
  65564. reset(): void;
  65565. private onErrorCallback;
  65566. private onDoneCallback;
  65567. }
  65568. /**
  65569. * Define the interface used by progress events raised during assets loading
  65570. */
  65571. export interface IAssetsProgressEvent {
  65572. /**
  65573. * Defines the number of remaining tasks to process
  65574. */
  65575. remainingCount: number;
  65576. /**
  65577. * Defines the total number of tasks
  65578. */
  65579. totalCount: number;
  65580. /**
  65581. * Defines the task that was just processed
  65582. */
  65583. task: AbstractAssetTask;
  65584. }
  65585. /**
  65586. * Class used to share progress information about assets loading
  65587. */
  65588. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65589. /**
  65590. * Defines the number of remaining tasks to process
  65591. */
  65592. remainingCount: number;
  65593. /**
  65594. * Defines the total number of tasks
  65595. */
  65596. totalCount: number;
  65597. /**
  65598. * Defines the task that was just processed
  65599. */
  65600. task: AbstractAssetTask;
  65601. /**
  65602. * Creates a AssetsProgressEvent
  65603. * @param remainingCount defines the number of remaining tasks to process
  65604. * @param totalCount defines the total number of tasks
  65605. * @param task defines the task that was just processed
  65606. */
  65607. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65608. }
  65609. /**
  65610. * Define a task used by AssetsManager to load meshes
  65611. */
  65612. export class MeshAssetTask extends AbstractAssetTask {
  65613. /**
  65614. * Defines the name of the task
  65615. */
  65616. name: string;
  65617. /**
  65618. * Defines the list of mesh's names you want to load
  65619. */
  65620. meshesNames: any;
  65621. /**
  65622. * Defines the root url to use as a base to load your meshes and associated resources
  65623. */
  65624. rootUrl: string;
  65625. /**
  65626. * Defines the filename of the scene to load from
  65627. */
  65628. sceneFilename: string;
  65629. /**
  65630. * Gets the list of loaded meshes
  65631. */
  65632. loadedMeshes: Array<AbstractMesh>;
  65633. /**
  65634. * Gets the list of loaded particle systems
  65635. */
  65636. loadedParticleSystems: Array<IParticleSystem>;
  65637. /**
  65638. * Gets the list of loaded skeletons
  65639. */
  65640. loadedSkeletons: Array<Skeleton>;
  65641. /**
  65642. * Gets the list of loaded animation groups
  65643. */
  65644. loadedAnimationGroups: Array<AnimationGroup>;
  65645. /**
  65646. * Callback called when the task is successful
  65647. */
  65648. onSuccess: (task: MeshAssetTask) => void;
  65649. /**
  65650. * Callback called when the task is successful
  65651. */
  65652. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65653. /**
  65654. * Creates a new MeshAssetTask
  65655. * @param name defines the name of the task
  65656. * @param meshesNames defines the list of mesh's names you want to load
  65657. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65658. * @param sceneFilename defines the filename of the scene to load from
  65659. */
  65660. constructor(
  65661. /**
  65662. * Defines the name of the task
  65663. */
  65664. name: string,
  65665. /**
  65666. * Defines the list of mesh's names you want to load
  65667. */
  65668. meshesNames: any,
  65669. /**
  65670. * Defines the root url to use as a base to load your meshes and associated resources
  65671. */
  65672. rootUrl: string,
  65673. /**
  65674. * Defines the filename of the scene to load from
  65675. */
  65676. sceneFilename: string);
  65677. /**
  65678. * Execute the current task
  65679. * @param scene defines the scene where you want your assets to be loaded
  65680. * @param onSuccess is a callback called when the task is successfully executed
  65681. * @param onError is a callback called if an error occurs
  65682. */
  65683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65684. }
  65685. /**
  65686. * Define a task used by AssetsManager to load text content
  65687. */
  65688. export class TextFileAssetTask extends AbstractAssetTask {
  65689. /**
  65690. * Defines the name of the task
  65691. */
  65692. name: string;
  65693. /**
  65694. * Defines the location of the file to load
  65695. */
  65696. url: string;
  65697. /**
  65698. * Gets the loaded text string
  65699. */
  65700. text: string;
  65701. /**
  65702. * Callback called when the task is successful
  65703. */
  65704. onSuccess: (task: TextFileAssetTask) => void;
  65705. /**
  65706. * Callback called when the task is successful
  65707. */
  65708. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65709. /**
  65710. * Creates a new TextFileAssetTask object
  65711. * @param name defines the name of the task
  65712. * @param url defines the location of the file to load
  65713. */
  65714. constructor(
  65715. /**
  65716. * Defines the name of the task
  65717. */
  65718. name: string,
  65719. /**
  65720. * Defines the location of the file to load
  65721. */
  65722. url: string);
  65723. /**
  65724. * Execute the current task
  65725. * @param scene defines the scene where you want your assets to be loaded
  65726. * @param onSuccess is a callback called when the task is successfully executed
  65727. * @param onError is a callback called if an error occurs
  65728. */
  65729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65730. }
  65731. /**
  65732. * Define a task used by AssetsManager to load binary data
  65733. */
  65734. export class BinaryFileAssetTask extends AbstractAssetTask {
  65735. /**
  65736. * Defines the name of the task
  65737. */
  65738. name: string;
  65739. /**
  65740. * Defines the location of the file to load
  65741. */
  65742. url: string;
  65743. /**
  65744. * Gets the lodaded data (as an array buffer)
  65745. */
  65746. data: ArrayBuffer;
  65747. /**
  65748. * Callback called when the task is successful
  65749. */
  65750. onSuccess: (task: BinaryFileAssetTask) => void;
  65751. /**
  65752. * Callback called when the task is successful
  65753. */
  65754. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65755. /**
  65756. * Creates a new BinaryFileAssetTask object
  65757. * @param name defines the name of the new task
  65758. * @param url defines the location of the file to load
  65759. */
  65760. constructor(
  65761. /**
  65762. * Defines the name of the task
  65763. */
  65764. name: string,
  65765. /**
  65766. * Defines the location of the file to load
  65767. */
  65768. url: string);
  65769. /**
  65770. * Execute the current task
  65771. * @param scene defines the scene where you want your assets to be loaded
  65772. * @param onSuccess is a callback called when the task is successfully executed
  65773. * @param onError is a callback called if an error occurs
  65774. */
  65775. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65776. }
  65777. /**
  65778. * Define a task used by AssetsManager to load images
  65779. */
  65780. export class ImageAssetTask extends AbstractAssetTask {
  65781. /**
  65782. * Defines the name of the task
  65783. */
  65784. name: string;
  65785. /**
  65786. * Defines the location of the image to load
  65787. */
  65788. url: string;
  65789. /**
  65790. * Gets the loaded images
  65791. */
  65792. image: HTMLImageElement;
  65793. /**
  65794. * Callback called when the task is successful
  65795. */
  65796. onSuccess: (task: ImageAssetTask) => void;
  65797. /**
  65798. * Callback called when the task is successful
  65799. */
  65800. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65801. /**
  65802. * Creates a new ImageAssetTask
  65803. * @param name defines the name of the task
  65804. * @param url defines the location of the image to load
  65805. */
  65806. constructor(
  65807. /**
  65808. * Defines the name of the task
  65809. */
  65810. name: string,
  65811. /**
  65812. * Defines the location of the image to load
  65813. */
  65814. url: string);
  65815. /**
  65816. * Execute the current task
  65817. * @param scene defines the scene where you want your assets to be loaded
  65818. * @param onSuccess is a callback called when the task is successfully executed
  65819. * @param onError is a callback called if an error occurs
  65820. */
  65821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65822. }
  65823. /**
  65824. * Defines the interface used by texture loading tasks
  65825. */
  65826. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65827. /**
  65828. * Gets the loaded texture
  65829. */
  65830. texture: TEX;
  65831. }
  65832. /**
  65833. * Define a task used by AssetsManager to load 2D textures
  65834. */
  65835. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65836. /**
  65837. * Defines the name of the task
  65838. */
  65839. name: string;
  65840. /**
  65841. * Defines the location of the file to load
  65842. */
  65843. url: string;
  65844. /**
  65845. * Defines if mipmap should not be generated (default is false)
  65846. */
  65847. noMipmap?: boolean | undefined;
  65848. /**
  65849. * Defines if texture must be inverted on Y axis (default is false)
  65850. */
  65851. invertY?: boolean | undefined;
  65852. /**
  65853. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65854. */
  65855. samplingMode: number;
  65856. /**
  65857. * Gets the loaded texture
  65858. */
  65859. texture: Texture;
  65860. /**
  65861. * Callback called when the task is successful
  65862. */
  65863. onSuccess: (task: TextureAssetTask) => void;
  65864. /**
  65865. * Callback called when the task is successful
  65866. */
  65867. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65868. /**
  65869. * Creates a new TextureAssetTask object
  65870. * @param name defines the name of the task
  65871. * @param url defines the location of the file to load
  65872. * @param noMipmap defines if mipmap should not be generated (default is false)
  65873. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65874. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65875. */
  65876. constructor(
  65877. /**
  65878. * Defines the name of the task
  65879. */
  65880. name: string,
  65881. /**
  65882. * Defines the location of the file to load
  65883. */
  65884. url: string,
  65885. /**
  65886. * Defines if mipmap should not be generated (default is false)
  65887. */
  65888. noMipmap?: boolean | undefined,
  65889. /**
  65890. * Defines if texture must be inverted on Y axis (default is false)
  65891. */
  65892. invertY?: boolean | undefined,
  65893. /**
  65894. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65895. */
  65896. samplingMode?: number);
  65897. /**
  65898. * Execute the current task
  65899. * @param scene defines the scene where you want your assets to be loaded
  65900. * @param onSuccess is a callback called when the task is successfully executed
  65901. * @param onError is a callback called if an error occurs
  65902. */
  65903. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65904. }
  65905. /**
  65906. * Define a task used by AssetsManager to load cube textures
  65907. */
  65908. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65909. /**
  65910. * Defines the name of the task
  65911. */
  65912. name: string;
  65913. /**
  65914. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65915. */
  65916. url: string;
  65917. /**
  65918. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65919. */
  65920. extensions?: string[] | undefined;
  65921. /**
  65922. * Defines if mipmaps should not be generated (default is false)
  65923. */
  65924. noMipmap?: boolean | undefined;
  65925. /**
  65926. * Defines the explicit list of files (undefined by default)
  65927. */
  65928. files?: string[] | undefined;
  65929. /**
  65930. * Gets the loaded texture
  65931. */
  65932. texture: CubeTexture;
  65933. /**
  65934. * Callback called when the task is successful
  65935. */
  65936. onSuccess: (task: CubeTextureAssetTask) => void;
  65937. /**
  65938. * Callback called when the task is successful
  65939. */
  65940. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65941. /**
  65942. * Creates a new CubeTextureAssetTask
  65943. * @param name defines the name of the task
  65944. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65945. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65946. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65947. * @param files defines the explicit list of files (undefined by default)
  65948. */
  65949. constructor(
  65950. /**
  65951. * Defines the name of the task
  65952. */
  65953. name: string,
  65954. /**
  65955. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65956. */
  65957. url: string,
  65958. /**
  65959. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65960. */
  65961. extensions?: string[] | undefined,
  65962. /**
  65963. * Defines if mipmaps should not be generated (default is false)
  65964. */
  65965. noMipmap?: boolean | undefined,
  65966. /**
  65967. * Defines the explicit list of files (undefined by default)
  65968. */
  65969. files?: string[] | undefined);
  65970. /**
  65971. * Execute the current task
  65972. * @param scene defines the scene where you want your assets to be loaded
  65973. * @param onSuccess is a callback called when the task is successfully executed
  65974. * @param onError is a callback called if an error occurs
  65975. */
  65976. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65977. }
  65978. /**
  65979. * Define a task used by AssetsManager to load HDR cube textures
  65980. */
  65981. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65982. /**
  65983. * Defines the name of the task
  65984. */
  65985. name: string;
  65986. /**
  65987. * Defines the location of the file to load
  65988. */
  65989. url: string;
  65990. /**
  65991. * Defines the desired size (the more it increases the longer the generation will be)
  65992. */
  65993. size: number;
  65994. /**
  65995. * Defines if mipmaps should not be generated (default is false)
  65996. */
  65997. noMipmap: boolean;
  65998. /**
  65999. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66000. */
  66001. generateHarmonics: boolean;
  66002. /**
  66003. * 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)
  66004. */
  66005. gammaSpace: boolean;
  66006. /**
  66007. * Internal Use Only
  66008. */
  66009. reserved: boolean;
  66010. /**
  66011. * Gets the loaded texture
  66012. */
  66013. texture: HDRCubeTexture;
  66014. /**
  66015. * Callback called when the task is successful
  66016. */
  66017. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66018. /**
  66019. * Callback called when the task is successful
  66020. */
  66021. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66022. /**
  66023. * Creates a new HDRCubeTextureAssetTask object
  66024. * @param name defines the name of the task
  66025. * @param url defines the location of the file to load
  66026. * @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.
  66027. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66028. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66029. * @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)
  66030. * @param reserved Internal use only
  66031. */
  66032. constructor(
  66033. /**
  66034. * Defines the name of the task
  66035. */
  66036. name: string,
  66037. /**
  66038. * Defines the location of the file to load
  66039. */
  66040. url: string,
  66041. /**
  66042. * Defines the desired size (the more it increases the longer the generation will be)
  66043. */
  66044. size: number,
  66045. /**
  66046. * Defines if mipmaps should not be generated (default is false)
  66047. */
  66048. noMipmap?: boolean,
  66049. /**
  66050. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66051. */
  66052. generateHarmonics?: boolean,
  66053. /**
  66054. * 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)
  66055. */
  66056. gammaSpace?: boolean,
  66057. /**
  66058. * Internal Use Only
  66059. */
  66060. reserved?: boolean);
  66061. /**
  66062. * Execute the current task
  66063. * @param scene defines the scene where you want your assets to be loaded
  66064. * @param onSuccess is a callback called when the task is successfully executed
  66065. * @param onError is a callback called if an error occurs
  66066. */
  66067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66068. }
  66069. /**
  66070. * Define a task used by AssetsManager to load Equirectangular cube textures
  66071. */
  66072. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66073. /**
  66074. * Defines the name of the task
  66075. */
  66076. name: string;
  66077. /**
  66078. * Defines the location of the file to load
  66079. */
  66080. url: string;
  66081. /**
  66082. * Defines the desired size (the more it increases the longer the generation will be)
  66083. */
  66084. size: number;
  66085. /**
  66086. * Defines if mipmaps should not be generated (default is false)
  66087. */
  66088. noMipmap: boolean;
  66089. /**
  66090. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66091. * but the standard material would require them in Gamma space) (default is true)
  66092. */
  66093. gammaSpace: boolean;
  66094. /**
  66095. * Gets the loaded texture
  66096. */
  66097. texture: EquiRectangularCubeTexture;
  66098. /**
  66099. * Callback called when the task is successful
  66100. */
  66101. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66102. /**
  66103. * Callback called when the task is successful
  66104. */
  66105. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66106. /**
  66107. * Creates a new EquiRectangularCubeTextureAssetTask object
  66108. * @param name defines the name of the task
  66109. * @param url defines the location of the file to load
  66110. * @param size defines the desired size (the more it increases the longer the generation will be)
  66111. * If the size is omitted this implies you are using a preprocessed cubemap.
  66112. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66113. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66114. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66115. * (default is true)
  66116. */
  66117. constructor(
  66118. /**
  66119. * Defines the name of the task
  66120. */
  66121. name: string,
  66122. /**
  66123. * Defines the location of the file to load
  66124. */
  66125. url: string,
  66126. /**
  66127. * Defines the desired size (the more it increases the longer the generation will be)
  66128. */
  66129. size: number,
  66130. /**
  66131. * Defines if mipmaps should not be generated (default is false)
  66132. */
  66133. noMipmap?: boolean,
  66134. /**
  66135. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66136. * but the standard material would require them in Gamma space) (default is true)
  66137. */
  66138. gammaSpace?: boolean);
  66139. /**
  66140. * Execute the current task
  66141. * @param scene defines the scene where you want your assets to be loaded
  66142. * @param onSuccess is a callback called when the task is successfully executed
  66143. * @param onError is a callback called if an error occurs
  66144. */
  66145. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66146. }
  66147. /**
  66148. * This class can be used to easily import assets into a scene
  66149. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66150. */
  66151. export class AssetsManager {
  66152. private _scene;
  66153. private _isLoading;
  66154. protected _tasks: AbstractAssetTask[];
  66155. protected _waitingTasksCount: number;
  66156. protected _totalTasksCount: number;
  66157. /**
  66158. * Callback called when all tasks are processed
  66159. */
  66160. onFinish: (tasks: AbstractAssetTask[]) => void;
  66161. /**
  66162. * Callback called when a task is successful
  66163. */
  66164. onTaskSuccess: (task: AbstractAssetTask) => void;
  66165. /**
  66166. * Callback called when a task had an error
  66167. */
  66168. onTaskError: (task: AbstractAssetTask) => void;
  66169. /**
  66170. * Callback called when a task is done (whatever the result is)
  66171. */
  66172. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66173. /**
  66174. * Observable called when all tasks are processed
  66175. */
  66176. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66177. /**
  66178. * Observable called when a task had an error
  66179. */
  66180. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66181. /**
  66182. * Observable called when all tasks were executed
  66183. */
  66184. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66185. /**
  66186. * Observable called when a task is done (whatever the result is)
  66187. */
  66188. onProgressObservable: Observable<IAssetsProgressEvent>;
  66189. /**
  66190. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66192. */
  66193. useDefaultLoadingScreen: boolean;
  66194. /**
  66195. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66196. * when all assets have been downloaded.
  66197. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66198. */
  66199. autoHideLoadingUI: boolean;
  66200. /**
  66201. * Creates a new AssetsManager
  66202. * @param scene defines the scene to work on
  66203. */
  66204. constructor(scene: Scene);
  66205. /**
  66206. * Add a MeshAssetTask to the list of active tasks
  66207. * @param taskName defines the name of the new task
  66208. * @param meshesNames defines the name of meshes to load
  66209. * @param rootUrl defines the root url to use to locate files
  66210. * @param sceneFilename defines the filename of the scene file
  66211. * @returns a new MeshAssetTask object
  66212. */
  66213. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66214. /**
  66215. * Add a TextFileAssetTask to the list of active tasks
  66216. * @param taskName defines the name of the new task
  66217. * @param url defines the url of the file to load
  66218. * @returns a new TextFileAssetTask object
  66219. */
  66220. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66221. /**
  66222. * Add a BinaryFileAssetTask to the list of active tasks
  66223. * @param taskName defines the name of the new task
  66224. * @param url defines the url of the file to load
  66225. * @returns a new BinaryFileAssetTask object
  66226. */
  66227. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66228. /**
  66229. * Add a ImageAssetTask to the list of active tasks
  66230. * @param taskName defines the name of the new task
  66231. * @param url defines the url of the file to load
  66232. * @returns a new ImageAssetTask object
  66233. */
  66234. addImageTask(taskName: string, url: string): ImageAssetTask;
  66235. /**
  66236. * Add a TextureAssetTask to the list of active tasks
  66237. * @param taskName defines the name of the new task
  66238. * @param url defines the url of the file to load
  66239. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66240. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66241. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66242. * @returns a new TextureAssetTask object
  66243. */
  66244. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66245. /**
  66246. * Add a CubeTextureAssetTask to the list of active tasks
  66247. * @param taskName defines the name of the new task
  66248. * @param url defines the url of the file to load
  66249. * @param extensions defines the extension to use to load the cube map (can be null)
  66250. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66251. * @param files defines the list of files to load (can be null)
  66252. * @returns a new CubeTextureAssetTask object
  66253. */
  66254. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66255. /**
  66256. *
  66257. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66258. * @param taskName defines the name of the new task
  66259. * @param url defines the url of the file to load
  66260. * @param size defines the size you want for the cubemap (can be null)
  66261. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66262. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66263. * @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)
  66264. * @param reserved Internal use only
  66265. * @returns a new HDRCubeTextureAssetTask object
  66266. */
  66267. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66268. /**
  66269. *
  66270. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66271. * @param taskName defines the name of the new task
  66272. * @param url defines the url of the file to load
  66273. * @param size defines the size you want for the cubemap (can be null)
  66274. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66275. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66276. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66277. * @returns a new EquiRectangularCubeTextureAssetTask object
  66278. */
  66279. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66280. /**
  66281. * Remove a task from the assets manager.
  66282. * @param task the task to remove
  66283. */
  66284. removeTask(task: AbstractAssetTask): void;
  66285. private _decreaseWaitingTasksCount;
  66286. private _runTask;
  66287. /**
  66288. * Reset the AssetsManager and remove all tasks
  66289. * @return the current instance of the AssetsManager
  66290. */
  66291. reset(): AssetsManager;
  66292. /**
  66293. * Start the loading process
  66294. * @return the current instance of the AssetsManager
  66295. */
  66296. load(): AssetsManager;
  66297. /**
  66298. * Start the loading process as an async operation
  66299. * @return a promise returning the list of failed tasks
  66300. */
  66301. loadAsync(): Promise<void>;
  66302. }
  66303. }
  66304. declare module "babylonjs/Misc/deferred" {
  66305. /**
  66306. * Wrapper class for promise with external resolve and reject.
  66307. */
  66308. export class Deferred<T> {
  66309. /**
  66310. * The promise associated with this deferred object.
  66311. */
  66312. readonly promise: Promise<T>;
  66313. private _resolve;
  66314. private _reject;
  66315. /**
  66316. * The resolve method of the promise associated with this deferred object.
  66317. */
  66318. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66319. /**
  66320. * The reject method of the promise associated with this deferred object.
  66321. */
  66322. readonly reject: (reason?: any) => void;
  66323. /**
  66324. * Constructor for this deferred object.
  66325. */
  66326. constructor();
  66327. }
  66328. }
  66329. declare module "babylonjs/Misc/meshExploder" {
  66330. import { Mesh } from "babylonjs/Meshes/mesh";
  66331. /**
  66332. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66333. */
  66334. export class MeshExploder {
  66335. private _centerMesh;
  66336. private _meshes;
  66337. private _meshesOrigins;
  66338. private _toCenterVectors;
  66339. private _scaledDirection;
  66340. private _newPosition;
  66341. private _centerPosition;
  66342. /**
  66343. * Explodes meshes from a center mesh.
  66344. * @param meshes The meshes to explode.
  66345. * @param centerMesh The mesh to be center of explosion.
  66346. */
  66347. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66348. private _setCenterMesh;
  66349. /**
  66350. * Get class name
  66351. * @returns "MeshExploder"
  66352. */
  66353. getClassName(): string;
  66354. /**
  66355. * "Exploded meshes"
  66356. * @returns Array of meshes with the centerMesh at index 0.
  66357. */
  66358. getMeshes(): Array<Mesh>;
  66359. /**
  66360. * Explodes meshes giving a specific direction
  66361. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66362. */
  66363. explode(direction?: number): void;
  66364. }
  66365. }
  66366. declare module "babylonjs/Misc/filesInput" {
  66367. import { Engine } from "babylonjs/Engines/engine";
  66368. import { Scene } from "babylonjs/scene";
  66369. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66370. /**
  66371. * Class used to help managing file picking and drag'n'drop
  66372. */
  66373. export class FilesInput {
  66374. /**
  66375. * List of files ready to be loaded
  66376. */
  66377. static readonly FilesToLoad: {
  66378. [key: string]: File;
  66379. };
  66380. /**
  66381. * Callback called when a file is processed
  66382. */
  66383. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66384. private _engine;
  66385. private _currentScene;
  66386. private _sceneLoadedCallback;
  66387. private _progressCallback;
  66388. private _additionalRenderLoopLogicCallback;
  66389. private _textureLoadingCallback;
  66390. private _startingProcessingFilesCallback;
  66391. private _onReloadCallback;
  66392. private _errorCallback;
  66393. private _elementToMonitor;
  66394. private _sceneFileToLoad;
  66395. private _filesToLoad;
  66396. /**
  66397. * Creates a new FilesInput
  66398. * @param engine defines the rendering engine
  66399. * @param scene defines the hosting scene
  66400. * @param sceneLoadedCallback callback called when scene is loaded
  66401. * @param progressCallback callback called to track progress
  66402. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66403. * @param textureLoadingCallback callback called when a texture is loading
  66404. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66405. * @param onReloadCallback callback called when a reload is requested
  66406. * @param errorCallback callback call if an error occurs
  66407. */
  66408. 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);
  66409. private _dragEnterHandler;
  66410. private _dragOverHandler;
  66411. private _dropHandler;
  66412. /**
  66413. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66414. * @param elementToMonitor defines the DOM element to track
  66415. */
  66416. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66417. /**
  66418. * Release all associated resources
  66419. */
  66420. dispose(): void;
  66421. private renderFunction;
  66422. private drag;
  66423. private drop;
  66424. private _traverseFolder;
  66425. private _processFiles;
  66426. /**
  66427. * Load files from a drop event
  66428. * @param event defines the drop event to use as source
  66429. */
  66430. loadFiles(event: any): void;
  66431. private _processReload;
  66432. /**
  66433. * Reload the current scene from the loaded files
  66434. */
  66435. reload(): void;
  66436. }
  66437. }
  66438. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66439. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66440. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66441. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66442. }
  66443. declare module "babylonjs/Misc/sceneOptimizer" {
  66444. import { Scene, IDisposable } from "babylonjs/scene";
  66445. import { Observable } from "babylonjs/Misc/observable";
  66446. /**
  66447. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66449. */
  66450. export class SceneOptimization {
  66451. /**
  66452. * Defines the priority of this optimization (0 by default which means first in the list)
  66453. */
  66454. priority: number;
  66455. /**
  66456. * Gets a string describing the action executed by the current optimization
  66457. * @returns description string
  66458. */
  66459. getDescription(): string;
  66460. /**
  66461. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66462. * @param scene defines the current scene where to apply this optimization
  66463. * @param optimizer defines the current optimizer
  66464. * @returns true if everything that can be done was applied
  66465. */
  66466. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66467. /**
  66468. * Creates the SceneOptimization object
  66469. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66470. * @param desc defines the description associated with the optimization
  66471. */
  66472. constructor(
  66473. /**
  66474. * Defines the priority of this optimization (0 by default which means first in the list)
  66475. */
  66476. priority?: number);
  66477. }
  66478. /**
  66479. * Defines an optimization used to reduce the size of render target textures
  66480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66481. */
  66482. export class TextureOptimization extends SceneOptimization {
  66483. /**
  66484. * Defines the priority of this optimization (0 by default which means first in the list)
  66485. */
  66486. priority: number;
  66487. /**
  66488. * 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
  66489. */
  66490. maximumSize: number;
  66491. /**
  66492. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66493. */
  66494. step: number;
  66495. /**
  66496. * Gets a string describing the action executed by the current optimization
  66497. * @returns description string
  66498. */
  66499. getDescription(): string;
  66500. /**
  66501. * Creates the TextureOptimization object
  66502. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66503. * @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
  66504. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66505. */
  66506. constructor(
  66507. /**
  66508. * Defines the priority of this optimization (0 by default which means first in the list)
  66509. */
  66510. priority?: number,
  66511. /**
  66512. * 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
  66513. */
  66514. maximumSize?: number,
  66515. /**
  66516. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66517. */
  66518. step?: number);
  66519. /**
  66520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66521. * @param scene defines the current scene where to apply this optimization
  66522. * @param optimizer defines the current optimizer
  66523. * @returns true if everything that can be done was applied
  66524. */
  66525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66526. }
  66527. /**
  66528. * Defines an optimization used to increase or decrease the rendering resolution
  66529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66530. */
  66531. export class HardwareScalingOptimization extends SceneOptimization {
  66532. /**
  66533. * Defines the priority of this optimization (0 by default which means first in the list)
  66534. */
  66535. priority: number;
  66536. /**
  66537. * Defines the maximum scale to use (2 by default)
  66538. */
  66539. maximumScale: number;
  66540. /**
  66541. * Defines the step to use between two passes (0.5 by default)
  66542. */
  66543. step: number;
  66544. private _currentScale;
  66545. private _directionOffset;
  66546. /**
  66547. * Gets a string describing the action executed by the current optimization
  66548. * @return description string
  66549. */
  66550. getDescription(): string;
  66551. /**
  66552. * Creates the HardwareScalingOptimization object
  66553. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66554. * @param maximumScale defines the maximum scale to use (2 by default)
  66555. * @param step defines the step to use between two passes (0.5 by default)
  66556. */
  66557. constructor(
  66558. /**
  66559. * Defines the priority of this optimization (0 by default which means first in the list)
  66560. */
  66561. priority?: number,
  66562. /**
  66563. * Defines the maximum scale to use (2 by default)
  66564. */
  66565. maximumScale?: number,
  66566. /**
  66567. * Defines the step to use between two passes (0.5 by default)
  66568. */
  66569. step?: number);
  66570. /**
  66571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66572. * @param scene defines the current scene where to apply this optimization
  66573. * @param optimizer defines the current optimizer
  66574. * @returns true if everything that can be done was applied
  66575. */
  66576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66577. }
  66578. /**
  66579. * Defines an optimization used to remove shadows
  66580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66581. */
  66582. export class ShadowsOptimization extends SceneOptimization {
  66583. /**
  66584. * Gets a string describing the action executed by the current optimization
  66585. * @return description string
  66586. */
  66587. getDescription(): string;
  66588. /**
  66589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66590. * @param scene defines the current scene where to apply this optimization
  66591. * @param optimizer defines the current optimizer
  66592. * @returns true if everything that can be done was applied
  66593. */
  66594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66595. }
  66596. /**
  66597. * Defines an optimization used to turn post-processes off
  66598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66599. */
  66600. export class PostProcessesOptimization extends SceneOptimization {
  66601. /**
  66602. * Gets a string describing the action executed by the current optimization
  66603. * @return description string
  66604. */
  66605. getDescription(): string;
  66606. /**
  66607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66608. * @param scene defines the current scene where to apply this optimization
  66609. * @param optimizer defines the current optimizer
  66610. * @returns true if everything that can be done was applied
  66611. */
  66612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66613. }
  66614. /**
  66615. * Defines an optimization used to turn lens flares off
  66616. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66617. */
  66618. export class LensFlaresOptimization extends SceneOptimization {
  66619. /**
  66620. * Gets a string describing the action executed by the current optimization
  66621. * @return description string
  66622. */
  66623. getDescription(): string;
  66624. /**
  66625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66626. * @param scene defines the current scene where to apply this optimization
  66627. * @param optimizer defines the current optimizer
  66628. * @returns true if everything that can be done was applied
  66629. */
  66630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66631. }
  66632. /**
  66633. * Defines an optimization based on user defined callback.
  66634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66635. */
  66636. export class CustomOptimization extends SceneOptimization {
  66637. /**
  66638. * Callback called to apply the custom optimization.
  66639. */
  66640. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66641. /**
  66642. * Callback called to get custom description
  66643. */
  66644. onGetDescription: () => string;
  66645. /**
  66646. * Gets a string describing the action executed by the current optimization
  66647. * @returns description string
  66648. */
  66649. getDescription(): string;
  66650. /**
  66651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66652. * @param scene defines the current scene where to apply this optimization
  66653. * @param optimizer defines the current optimizer
  66654. * @returns true if everything that can be done was applied
  66655. */
  66656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66657. }
  66658. /**
  66659. * Defines an optimization used to turn particles off
  66660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66661. */
  66662. export class ParticlesOptimization extends SceneOptimization {
  66663. /**
  66664. * Gets a string describing the action executed by the current optimization
  66665. * @return description string
  66666. */
  66667. getDescription(): string;
  66668. /**
  66669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66670. * @param scene defines the current scene where to apply this optimization
  66671. * @param optimizer defines the current optimizer
  66672. * @returns true if everything that can be done was applied
  66673. */
  66674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66675. }
  66676. /**
  66677. * Defines an optimization used to turn render targets off
  66678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66679. */
  66680. export class RenderTargetsOptimization extends SceneOptimization {
  66681. /**
  66682. * Gets a string describing the action executed by the current optimization
  66683. * @return description string
  66684. */
  66685. getDescription(): string;
  66686. /**
  66687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66688. * @param scene defines the current scene where to apply this optimization
  66689. * @param optimizer defines the current optimizer
  66690. * @returns true if everything that can be done was applied
  66691. */
  66692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66693. }
  66694. /**
  66695. * Defines an optimization used to merge meshes with compatible materials
  66696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66697. */
  66698. export class MergeMeshesOptimization extends SceneOptimization {
  66699. private static _UpdateSelectionTree;
  66700. /**
  66701. * Gets or sets a boolean which defines if optimization octree has to be updated
  66702. */
  66703. /**
  66704. * Gets or sets a boolean which defines if optimization octree has to be updated
  66705. */
  66706. static UpdateSelectionTree: boolean;
  66707. /**
  66708. * Gets a string describing the action executed by the current optimization
  66709. * @return description string
  66710. */
  66711. getDescription(): string;
  66712. private _canBeMerged;
  66713. /**
  66714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66715. * @param scene defines the current scene where to apply this optimization
  66716. * @param optimizer defines the current optimizer
  66717. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66718. * @returns true if everything that can be done was applied
  66719. */
  66720. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66721. }
  66722. /**
  66723. * Defines a list of options used by SceneOptimizer
  66724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66725. */
  66726. export class SceneOptimizerOptions {
  66727. /**
  66728. * Defines the target frame rate to reach (60 by default)
  66729. */
  66730. targetFrameRate: number;
  66731. /**
  66732. * Defines the interval between two checkes (2000ms by default)
  66733. */
  66734. trackerDuration: number;
  66735. /**
  66736. * Gets the list of optimizations to apply
  66737. */
  66738. optimizations: SceneOptimization[];
  66739. /**
  66740. * Creates a new list of options used by SceneOptimizer
  66741. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66742. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66743. */
  66744. constructor(
  66745. /**
  66746. * Defines the target frame rate to reach (60 by default)
  66747. */
  66748. targetFrameRate?: number,
  66749. /**
  66750. * Defines the interval between two checkes (2000ms by default)
  66751. */
  66752. trackerDuration?: number);
  66753. /**
  66754. * Add a new optimization
  66755. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66756. * @returns the current SceneOptimizerOptions
  66757. */
  66758. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66759. /**
  66760. * Add a new custom optimization
  66761. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66762. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66763. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66764. * @returns the current SceneOptimizerOptions
  66765. */
  66766. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66767. /**
  66768. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66769. * @param targetFrameRate defines the target frame rate (60 by default)
  66770. * @returns a SceneOptimizerOptions object
  66771. */
  66772. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66773. /**
  66774. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66775. * @param targetFrameRate defines the target frame rate (60 by default)
  66776. * @returns a SceneOptimizerOptions object
  66777. */
  66778. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66779. /**
  66780. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66781. * @param targetFrameRate defines the target frame rate (60 by default)
  66782. * @returns a SceneOptimizerOptions object
  66783. */
  66784. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66785. }
  66786. /**
  66787. * Class used to run optimizations in order to reach a target frame rate
  66788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66789. */
  66790. export class SceneOptimizer implements IDisposable {
  66791. private _isRunning;
  66792. private _options;
  66793. private _scene;
  66794. private _currentPriorityLevel;
  66795. private _targetFrameRate;
  66796. private _trackerDuration;
  66797. private _currentFrameRate;
  66798. private _sceneDisposeObserver;
  66799. private _improvementMode;
  66800. /**
  66801. * Defines an observable called when the optimizer reaches the target frame rate
  66802. */
  66803. onSuccessObservable: Observable<SceneOptimizer>;
  66804. /**
  66805. * Defines an observable called when the optimizer enables an optimization
  66806. */
  66807. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66808. /**
  66809. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66810. */
  66811. onFailureObservable: Observable<SceneOptimizer>;
  66812. /**
  66813. * Gets a boolean indicating if the optimizer is in improvement mode
  66814. */
  66815. readonly isInImprovementMode: boolean;
  66816. /**
  66817. * Gets the current priority level (0 at start)
  66818. */
  66819. readonly currentPriorityLevel: number;
  66820. /**
  66821. * Gets the current frame rate checked by the SceneOptimizer
  66822. */
  66823. readonly currentFrameRate: number;
  66824. /**
  66825. * Gets or sets the current target frame rate (60 by default)
  66826. */
  66827. /**
  66828. * Gets or sets the current target frame rate (60 by default)
  66829. */
  66830. targetFrameRate: number;
  66831. /**
  66832. * Gets or sets the current interval between two checks (every 2000ms by default)
  66833. */
  66834. /**
  66835. * Gets or sets the current interval between two checks (every 2000ms by default)
  66836. */
  66837. trackerDuration: number;
  66838. /**
  66839. * Gets the list of active optimizations
  66840. */
  66841. readonly optimizations: SceneOptimization[];
  66842. /**
  66843. * Creates a new SceneOptimizer
  66844. * @param scene defines the scene to work on
  66845. * @param options defines the options to use with the SceneOptimizer
  66846. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66847. * @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)
  66848. */
  66849. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66850. /**
  66851. * Stops the current optimizer
  66852. */
  66853. stop(): void;
  66854. /**
  66855. * Reset the optimizer to initial step (current priority level = 0)
  66856. */
  66857. reset(): void;
  66858. /**
  66859. * Start the optimizer. By default it will try to reach a specific framerate
  66860. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66861. */
  66862. start(): void;
  66863. private _checkCurrentState;
  66864. /**
  66865. * Release all resources
  66866. */
  66867. dispose(): void;
  66868. /**
  66869. * Helper function to create a SceneOptimizer with one single line of code
  66870. * @param scene defines the scene to work on
  66871. * @param options defines the options to use with the SceneOptimizer
  66872. * @param onSuccess defines a callback to call on success
  66873. * @param onFailure defines a callback to call on failure
  66874. * @returns the new SceneOptimizer object
  66875. */
  66876. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66877. }
  66878. }
  66879. declare module "babylonjs/Misc/sceneSerializer" {
  66880. import { Scene } from "babylonjs/scene";
  66881. /**
  66882. * Class used to serialize a scene into a string
  66883. */
  66884. export class SceneSerializer {
  66885. /**
  66886. * Clear cache used by a previous serialization
  66887. */
  66888. static ClearCache(): void;
  66889. /**
  66890. * Serialize a scene into a JSON compatible object
  66891. * @param scene defines the scene to serialize
  66892. * @returns a JSON compatible object
  66893. */
  66894. static Serialize(scene: Scene): any;
  66895. /**
  66896. * Serialize a mesh into a JSON compatible object
  66897. * @param toSerialize defines the mesh to serialize
  66898. * @param withParents defines if parents must be serialized as well
  66899. * @param withChildren defines if children must be serialized as well
  66900. * @returns a JSON compatible object
  66901. */
  66902. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66903. }
  66904. }
  66905. declare module "babylonjs/Misc/textureTools" {
  66906. import { Texture } from "babylonjs/Materials/Textures/texture";
  66907. /**
  66908. * Class used to host texture specific utilities
  66909. */
  66910. export class TextureTools {
  66911. /**
  66912. * Uses the GPU to create a copy texture rescaled at a given size
  66913. * @param texture Texture to copy from
  66914. * @param width defines the desired width
  66915. * @param height defines the desired height
  66916. * @param useBilinearMode defines if bilinear mode has to be used
  66917. * @return the generated texture
  66918. */
  66919. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66920. }
  66921. }
  66922. declare module "babylonjs/Misc/videoRecorder" {
  66923. import { Nullable } from "babylonjs/types";
  66924. import { Engine } from "babylonjs/Engines/engine";
  66925. /**
  66926. * This represents the different options available for the video capture.
  66927. */
  66928. export interface VideoRecorderOptions {
  66929. /** Defines the mime type of the video. */
  66930. mimeType: string;
  66931. /** Defines the FPS the video should be recorded at. */
  66932. fps: number;
  66933. /** Defines the chunk size for the recording data. */
  66934. recordChunckSize: number;
  66935. /** The audio tracks to attach to the recording. */
  66936. audioTracks?: MediaStreamTrack[];
  66937. }
  66938. /**
  66939. * This can help with recording videos from BabylonJS.
  66940. * This is based on the available WebRTC functionalities of the browser.
  66941. *
  66942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66943. */
  66944. export class VideoRecorder {
  66945. private static readonly _defaultOptions;
  66946. /**
  66947. * Returns whether or not the VideoRecorder is available in your browser.
  66948. * @param engine Defines the Babylon Engine.
  66949. * @returns true if supported otherwise false.
  66950. */
  66951. static IsSupported(engine: Engine): boolean;
  66952. private readonly _options;
  66953. private _canvas;
  66954. private _mediaRecorder;
  66955. private _recordedChunks;
  66956. private _fileName;
  66957. private _resolve;
  66958. private _reject;
  66959. /**
  66960. * True when a recording is already in progress.
  66961. */
  66962. readonly isRecording: boolean;
  66963. /**
  66964. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66965. * @param engine Defines the BabylonJS Engine you wish to record.
  66966. * @param options Defines options that can be used to customize the capture.
  66967. */
  66968. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66969. /**
  66970. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66971. */
  66972. stopRecording(): void;
  66973. /**
  66974. * Starts recording the canvas for a max duration specified in parameters.
  66975. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66976. * If null no automatic download will start and you can rely on the promise to get the data back.
  66977. * @param maxDuration Defines the maximum recording time in seconds.
  66978. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66979. * @return A promise callback at the end of the recording with the video data in Blob.
  66980. */
  66981. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66982. /**
  66983. * Releases internal resources used during the recording.
  66984. */
  66985. dispose(): void;
  66986. private _handleDataAvailable;
  66987. private _handleError;
  66988. private _handleStop;
  66989. }
  66990. }
  66991. declare module "babylonjs/Misc/screenshotTools" {
  66992. import { Camera } from "babylonjs/Cameras/camera";
  66993. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66994. import { Engine } from "babylonjs/Engines/engine";
  66995. /**
  66996. * Class containing a set of static utilities functions for screenshots
  66997. */
  66998. export class ScreenshotTools {
  66999. /**
  67000. * Captures a screenshot of the current rendering
  67001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67002. * @param engine defines the rendering engine
  67003. * @param camera defines the source camera
  67004. * @param size This parameter can be set to a single number or to an object with the
  67005. * following (optional) properties: precision, width, height. If a single number is passed,
  67006. * it will be used for both width and height. If an object is passed, the screenshot size
  67007. * will be derived from the parameters. The precision property is a multiplier allowing
  67008. * rendering at a higher or lower resolution
  67009. * @param successCallback defines the callback receives a single parameter which contains the
  67010. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67011. * src parameter of an <img> to display it
  67012. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67013. * Check your browser for supported MIME types
  67014. */
  67015. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67016. /**
  67017. * Captures a screenshot of the current rendering
  67018. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67019. * @param engine defines the rendering engine
  67020. * @param camera defines the source camera
  67021. * @param size This parameter can be set to a single number or to an object with the
  67022. * following (optional) properties: precision, width, height. If a single number is passed,
  67023. * it will be used for both width and height. If an object is passed, the screenshot size
  67024. * will be derived from the parameters. The precision property is a multiplier allowing
  67025. * rendering at a higher or lower resolution
  67026. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67027. * Check your browser for supported MIME types
  67028. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67029. * to the src parameter of an <img> to display it
  67030. */
  67031. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67032. /**
  67033. * Generates an image screenshot from the specified camera.
  67034. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67035. * @param engine The engine to use for rendering
  67036. * @param camera The camera to use for rendering
  67037. * @param size This parameter can be set to a single number or to an object with the
  67038. * following (optional) properties: precision, width, height. If a single number is passed,
  67039. * it will be used for both width and height. If an object is passed, the screenshot size
  67040. * will be derived from the parameters. The precision property is a multiplier allowing
  67041. * rendering at a higher or lower resolution
  67042. * @param successCallback The callback receives a single parameter which contains the
  67043. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67044. * src parameter of an <img> to display it
  67045. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67046. * Check your browser for supported MIME types
  67047. * @param samples Texture samples (default: 1)
  67048. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67049. * @param fileName A name for for the downloaded file.
  67050. */
  67051. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67052. /**
  67053. * Generates an image screenshot from the specified camera.
  67054. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67055. * @param engine The engine to use for rendering
  67056. * @param camera The camera to use for rendering
  67057. * @param size This parameter can be set to a single number or to an object with the
  67058. * following (optional) properties: precision, width, height. If a single number is passed,
  67059. * it will be used for both width and height. If an object is passed, the screenshot size
  67060. * will be derived from the parameters. The precision property is a multiplier allowing
  67061. * rendering at a higher or lower resolution
  67062. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67063. * Check your browser for supported MIME types
  67064. * @param samples Texture samples (default: 1)
  67065. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67066. * @param fileName A name for for the downloaded file.
  67067. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67068. * to the src parameter of an <img> to display it
  67069. */
  67070. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67071. /**
  67072. * Gets height and width for screenshot size
  67073. * @private
  67074. */
  67075. private static _getScreenshotSize;
  67076. }
  67077. }
  67078. declare module "babylonjs/Misc/index" {
  67079. export * from "babylonjs/Misc/andOrNotEvaluator";
  67080. export * from "babylonjs/Misc/assetsManager";
  67081. export * from "babylonjs/Misc/dds";
  67082. export * from "babylonjs/Misc/decorators";
  67083. export * from "babylonjs/Misc/deferred";
  67084. export * from "babylonjs/Misc/environmentTextureTools";
  67085. export * from "babylonjs/Misc/meshExploder";
  67086. export * from "babylonjs/Misc/filesInput";
  67087. export * from "babylonjs/Misc/HighDynamicRange/index";
  67088. export * from "babylonjs/Misc/khronosTextureContainer";
  67089. export * from "babylonjs/Misc/observable";
  67090. export * from "babylonjs/Misc/performanceMonitor";
  67091. export * from "babylonjs/Misc/promise";
  67092. export * from "babylonjs/Misc/sceneOptimizer";
  67093. export * from "babylonjs/Misc/sceneSerializer";
  67094. export * from "babylonjs/Misc/smartArray";
  67095. export * from "babylonjs/Misc/stringDictionary";
  67096. export * from "babylonjs/Misc/tags";
  67097. export * from "babylonjs/Misc/textureTools";
  67098. export * from "babylonjs/Misc/tga";
  67099. export * from "babylonjs/Misc/tools";
  67100. export * from "babylonjs/Misc/videoRecorder";
  67101. export * from "babylonjs/Misc/virtualJoystick";
  67102. export * from "babylonjs/Misc/workerPool";
  67103. export * from "babylonjs/Misc/logger";
  67104. export * from "babylonjs/Misc/typeStore";
  67105. export * from "babylonjs/Misc/filesInputStore";
  67106. export * from "babylonjs/Misc/deepCopier";
  67107. export * from "babylonjs/Misc/pivotTools";
  67108. export * from "babylonjs/Misc/precisionDate";
  67109. export * from "babylonjs/Misc/screenshotTools";
  67110. export * from "babylonjs/Misc/typeStore";
  67111. export * from "babylonjs/Misc/webRequest";
  67112. export * from "babylonjs/Misc/iInspectable";
  67113. export * from "babylonjs/Misc/brdfTextureTools";
  67114. export * from "babylonjs/Misc/rgbdTextureTools";
  67115. export * from "babylonjs/Misc/gradients";
  67116. export * from "babylonjs/Misc/perfCounter";
  67117. export * from "babylonjs/Misc/fileRequest";
  67118. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67119. export * from "babylonjs/Misc/retryStrategy";
  67120. export * from "babylonjs/Misc/loadFileError";
  67121. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67122. export * from "babylonjs/Misc/canvasGenerator";
  67123. }
  67124. declare module "babylonjs/index" {
  67125. export * from "babylonjs/abstractScene";
  67126. export * from "babylonjs/Actions/index";
  67127. export * from "babylonjs/Animations/index";
  67128. export * from "babylonjs/assetContainer";
  67129. export * from "babylonjs/Audio/index";
  67130. export * from "babylonjs/Behaviors/index";
  67131. export * from "babylonjs/Bones/index";
  67132. export * from "babylonjs/Cameras/index";
  67133. export * from "babylonjs/Collisions/index";
  67134. export * from "babylonjs/Culling/index";
  67135. export * from "babylonjs/Debug/index";
  67136. export * from "babylonjs/Engines/index";
  67137. export * from "babylonjs/Events/index";
  67138. export * from "babylonjs/Gamepads/index";
  67139. export * from "babylonjs/Gizmos/index";
  67140. export * from "babylonjs/Helpers/index";
  67141. export * from "babylonjs/Instrumentation/index";
  67142. export * from "babylonjs/Layers/index";
  67143. export * from "babylonjs/LensFlares/index";
  67144. export * from "babylonjs/Lights/index";
  67145. export * from "babylonjs/Loading/index";
  67146. export * from "babylonjs/Materials/index";
  67147. export * from "babylonjs/Maths/index";
  67148. export * from "babylonjs/Meshes/index";
  67149. export * from "babylonjs/Morph/index";
  67150. export * from "babylonjs/Navigation/index";
  67151. export * from "babylonjs/node";
  67152. export * from "babylonjs/Offline/index";
  67153. export * from "babylonjs/Particles/index";
  67154. export * from "babylonjs/Physics/index";
  67155. export * from "babylonjs/PostProcesses/index";
  67156. export * from "babylonjs/Probes/index";
  67157. export * from "babylonjs/Rendering/index";
  67158. export * from "babylonjs/scene";
  67159. export * from "babylonjs/sceneComponent";
  67160. export * from "babylonjs/Sprites/index";
  67161. export * from "babylonjs/States/index";
  67162. export * from "babylonjs/Misc/index";
  67163. export * from "babylonjs/types";
  67164. }
  67165. declare module "babylonjs/Animations/pathCursor" {
  67166. import { Vector3 } from "babylonjs/Maths/math.vector";
  67167. import { Path2 } from "babylonjs/Maths/math.path";
  67168. /**
  67169. * A cursor which tracks a point on a path
  67170. */
  67171. export class PathCursor {
  67172. private path;
  67173. /**
  67174. * Stores path cursor callbacks for when an onchange event is triggered
  67175. */
  67176. private _onchange;
  67177. /**
  67178. * The value of the path cursor
  67179. */
  67180. value: number;
  67181. /**
  67182. * The animation array of the path cursor
  67183. */
  67184. animations: Animation[];
  67185. /**
  67186. * Initializes the path cursor
  67187. * @param path The path to track
  67188. */
  67189. constructor(path: Path2);
  67190. /**
  67191. * Gets the cursor point on the path
  67192. * @returns A point on the path cursor at the cursor location
  67193. */
  67194. getPoint(): Vector3;
  67195. /**
  67196. * Moves the cursor ahead by the step amount
  67197. * @param step The amount to move the cursor forward
  67198. * @returns This path cursor
  67199. */
  67200. moveAhead(step?: number): PathCursor;
  67201. /**
  67202. * Moves the cursor behind by the step amount
  67203. * @param step The amount to move the cursor back
  67204. * @returns This path cursor
  67205. */
  67206. moveBack(step?: number): PathCursor;
  67207. /**
  67208. * Moves the cursor by the step amount
  67209. * If the step amount is greater than one, an exception is thrown
  67210. * @param step The amount to move the cursor
  67211. * @returns This path cursor
  67212. */
  67213. move(step: number): PathCursor;
  67214. /**
  67215. * Ensures that the value is limited between zero and one
  67216. * @returns This path cursor
  67217. */
  67218. private ensureLimits;
  67219. /**
  67220. * Runs onchange callbacks on change (used by the animation engine)
  67221. * @returns This path cursor
  67222. */
  67223. private raiseOnChange;
  67224. /**
  67225. * Executes a function on change
  67226. * @param f A path cursor onchange callback
  67227. * @returns This path cursor
  67228. */
  67229. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67230. }
  67231. }
  67232. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67233. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67234. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67235. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67236. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67237. }
  67238. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67239. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67240. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67241. }
  67242. declare module "babylonjs/Engines/Processors/index" {
  67243. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67244. export * from "babylonjs/Engines/Processors/Expressions/index";
  67245. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67246. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67247. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67248. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67249. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67250. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67251. }
  67252. declare module "babylonjs/Legacy/legacy" {
  67253. import * as Babylon from "babylonjs/index";
  67254. export * from "babylonjs/index";
  67255. }
  67256. declare module "babylonjs/Shaders/blur.fragment" {
  67257. /** @hidden */
  67258. export var blurPixelShader: {
  67259. name: string;
  67260. shader: string;
  67261. };
  67262. }
  67263. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67264. /** @hidden */
  67265. export var pointCloudVertexDeclaration: {
  67266. name: string;
  67267. shader: string;
  67268. };
  67269. }
  67270. declare module "babylonjs" {
  67271. export * from "babylonjs/Legacy/legacy";
  67272. }
  67273. declare module BABYLON {
  67274. /** Alias type for value that can be null */
  67275. export type Nullable<T> = T | null;
  67276. /**
  67277. * Alias type for number that are floats
  67278. * @ignorenaming
  67279. */
  67280. export type float = number;
  67281. /**
  67282. * Alias type for number that are doubles.
  67283. * @ignorenaming
  67284. */
  67285. export type double = number;
  67286. /**
  67287. * Alias type for number that are integer
  67288. * @ignorenaming
  67289. */
  67290. export type int = number;
  67291. /** Alias type for number array or Float32Array */
  67292. export type FloatArray = number[] | Float32Array;
  67293. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67294. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67295. /**
  67296. * Alias for types that can be used by a Buffer or VertexBuffer.
  67297. */
  67298. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67299. /**
  67300. * Alias type for primitive types
  67301. * @ignorenaming
  67302. */
  67303. type Primitive = undefined | null | boolean | string | number | Function;
  67304. /**
  67305. * Type modifier to make all the properties of an object Readonly
  67306. */
  67307. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67308. /**
  67309. * Type modifier to make all the properties of an object Readonly recursively
  67310. */
  67311. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67312. /**
  67313. * Type modifier to make object properties readonly.
  67314. */
  67315. export type DeepImmutableObject<T> = {
  67316. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67317. };
  67318. /** @hidden */
  67319. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. /**
  67324. * A class serves as a medium between the observable and its observers
  67325. */
  67326. export class EventState {
  67327. /**
  67328. * Create a new EventState
  67329. * @param mask defines the mask associated with this state
  67330. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67331. * @param target defines the original target of the state
  67332. * @param currentTarget defines the current target of the state
  67333. */
  67334. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67335. /**
  67336. * Initialize the current event state
  67337. * @param mask defines the mask associated with this state
  67338. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67339. * @param target defines the original target of the state
  67340. * @param currentTarget defines the current target of the state
  67341. * @returns the current event state
  67342. */
  67343. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67344. /**
  67345. * An Observer can set this property to true to prevent subsequent observers of being notified
  67346. */
  67347. skipNextObservers: boolean;
  67348. /**
  67349. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67350. */
  67351. mask: number;
  67352. /**
  67353. * The object that originally notified the event
  67354. */
  67355. target?: any;
  67356. /**
  67357. * The current object in the bubbling phase
  67358. */
  67359. currentTarget?: any;
  67360. /**
  67361. * This will be populated with the return value of the last function that was executed.
  67362. * If it is the first function in the callback chain it will be the event data.
  67363. */
  67364. lastReturnValue?: any;
  67365. }
  67366. /**
  67367. * Represent an Observer registered to a given Observable object.
  67368. */
  67369. export class Observer<T> {
  67370. /**
  67371. * Defines the callback to call when the observer is notified
  67372. */
  67373. callback: (eventData: T, eventState: EventState) => void;
  67374. /**
  67375. * Defines the mask of the observer (used to filter notifications)
  67376. */
  67377. mask: number;
  67378. /**
  67379. * Defines the current scope used to restore the JS context
  67380. */
  67381. scope: any;
  67382. /** @hidden */
  67383. _willBeUnregistered: boolean;
  67384. /**
  67385. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67386. */
  67387. unregisterOnNextCall: boolean;
  67388. /**
  67389. * Creates a new observer
  67390. * @param callback defines the callback to call when the observer is notified
  67391. * @param mask defines the mask of the observer (used to filter notifications)
  67392. * @param scope defines the current scope used to restore the JS context
  67393. */
  67394. constructor(
  67395. /**
  67396. * Defines the callback to call when the observer is notified
  67397. */
  67398. callback: (eventData: T, eventState: EventState) => void,
  67399. /**
  67400. * Defines the mask of the observer (used to filter notifications)
  67401. */
  67402. mask: number,
  67403. /**
  67404. * Defines the current scope used to restore the JS context
  67405. */
  67406. scope?: any);
  67407. }
  67408. /**
  67409. * Represent a list of observers registered to multiple Observables object.
  67410. */
  67411. export class MultiObserver<T> {
  67412. private _observers;
  67413. private _observables;
  67414. /**
  67415. * Release associated resources
  67416. */
  67417. dispose(): void;
  67418. /**
  67419. * Raise a callback when one of the observable will notify
  67420. * @param observables defines a list of observables to watch
  67421. * @param callback defines the callback to call on notification
  67422. * @param mask defines the mask used to filter notifications
  67423. * @param scope defines the current scope used to restore the JS context
  67424. * @returns the new MultiObserver
  67425. */
  67426. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67427. }
  67428. /**
  67429. * The Observable class is a simple implementation of the Observable pattern.
  67430. *
  67431. * 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.
  67432. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67433. * 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).
  67434. * 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.
  67435. */
  67436. export class Observable<T> {
  67437. private _observers;
  67438. private _eventState;
  67439. private _onObserverAdded;
  67440. /**
  67441. * Gets the list of observers
  67442. */
  67443. readonly observers: Array<Observer<T>>;
  67444. /**
  67445. * Creates a new observable
  67446. * @param onObserverAdded defines a callback to call when a new observer is added
  67447. */
  67448. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67449. /**
  67450. * Create a new Observer with the specified callback
  67451. * @param callback the callback that will be executed for that Observer
  67452. * @param mask the mask used to filter observers
  67453. * @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.
  67454. * @param scope optional scope for the callback to be called from
  67455. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67456. * @returns the new observer created for the callback
  67457. */
  67458. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67459. /**
  67460. * Create a new Observer with the specified callback and unregisters after the next notification
  67461. * @param callback the callback that will be executed for that Observer
  67462. * @returns the new observer created for the callback
  67463. */
  67464. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67465. /**
  67466. * Remove an Observer from the Observable object
  67467. * @param observer the instance of the Observer to remove
  67468. * @returns false if it doesn't belong to this Observable
  67469. */
  67470. remove(observer: Nullable<Observer<T>>): boolean;
  67471. /**
  67472. * Remove a callback from the Observable object
  67473. * @param callback the callback to remove
  67474. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67475. * @returns false if it doesn't belong to this Observable
  67476. */
  67477. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67478. private _deferUnregister;
  67479. private _remove;
  67480. /**
  67481. * Moves the observable to the top of the observer list making it get called first when notified
  67482. * @param observer the observer to move
  67483. */
  67484. makeObserverTopPriority(observer: Observer<T>): void;
  67485. /**
  67486. * Moves the observable to the bottom of the observer list making it get called last when notified
  67487. * @param observer the observer to move
  67488. */
  67489. makeObserverBottomPriority(observer: Observer<T>): void;
  67490. /**
  67491. * Notify all Observers by calling their respective callback with the given data
  67492. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67493. * @param eventData defines the data to send to all observers
  67494. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67495. * @param target defines the original target of the state
  67496. * @param currentTarget defines the current target of the state
  67497. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67498. */
  67499. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67500. /**
  67501. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67502. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67503. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67504. * and it is crucial that all callbacks will be executed.
  67505. * The order of the callbacks is kept, callbacks are not executed parallel.
  67506. *
  67507. * @param eventData The data to be sent to each callback
  67508. * @param mask is used to filter observers defaults to -1
  67509. * @param target defines the callback target (see EventState)
  67510. * @param currentTarget defines he current object in the bubbling phase
  67511. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67512. */
  67513. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67514. /**
  67515. * Notify a specific observer
  67516. * @param observer defines the observer to notify
  67517. * @param eventData defines the data to be sent to each callback
  67518. * @param mask is used to filter observers defaults to -1
  67519. */
  67520. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67521. /**
  67522. * Gets a boolean indicating if the observable has at least one observer
  67523. * @returns true is the Observable has at least one Observer registered
  67524. */
  67525. hasObservers(): boolean;
  67526. /**
  67527. * Clear the list of observers
  67528. */
  67529. clear(): void;
  67530. /**
  67531. * Clone the current observable
  67532. * @returns a new observable
  67533. */
  67534. clone(): Observable<T>;
  67535. /**
  67536. * Does this observable handles observer registered with a given mask
  67537. * @param mask defines the mask to be tested
  67538. * @return whether or not one observer registered with the given mask is handeled
  67539. **/
  67540. hasSpecificMask(mask?: number): boolean;
  67541. }
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67546. * Babylon.js
  67547. */
  67548. export class DomManagement {
  67549. /**
  67550. * Checks if the window object exists
  67551. * @returns true if the window object exists
  67552. */
  67553. static IsWindowObjectExist(): boolean;
  67554. /**
  67555. * Checks if the navigator object exists
  67556. * @returns true if the navigator object exists
  67557. */
  67558. static IsNavigatorAvailable(): boolean;
  67559. /**
  67560. * Extracts text content from a DOM element hierarchy
  67561. * @param element defines the root element
  67562. * @returns a string
  67563. */
  67564. static GetDOMTextContent(element: HTMLElement): string;
  67565. }
  67566. }
  67567. declare module BABYLON {
  67568. /**
  67569. * Logger used througouht the application to allow configuration of
  67570. * the log level required for the messages.
  67571. */
  67572. export class Logger {
  67573. /**
  67574. * No log
  67575. */
  67576. static readonly NoneLogLevel: number;
  67577. /**
  67578. * Only message logs
  67579. */
  67580. static readonly MessageLogLevel: number;
  67581. /**
  67582. * Only warning logs
  67583. */
  67584. static readonly WarningLogLevel: number;
  67585. /**
  67586. * Only error logs
  67587. */
  67588. static readonly ErrorLogLevel: number;
  67589. /**
  67590. * All logs
  67591. */
  67592. static readonly AllLogLevel: number;
  67593. private static _LogCache;
  67594. /**
  67595. * Gets a value indicating the number of loading errors
  67596. * @ignorenaming
  67597. */
  67598. static errorsCount: number;
  67599. /**
  67600. * Callback called when a new log is added
  67601. */
  67602. static OnNewCacheEntry: (entry: string) => void;
  67603. private static _AddLogEntry;
  67604. private static _FormatMessage;
  67605. private static _LogDisabled;
  67606. private static _LogEnabled;
  67607. private static _WarnDisabled;
  67608. private static _WarnEnabled;
  67609. private static _ErrorDisabled;
  67610. private static _ErrorEnabled;
  67611. /**
  67612. * Log a message to the console
  67613. */
  67614. static Log: (message: string) => void;
  67615. /**
  67616. * Write a warning message to the console
  67617. */
  67618. static Warn: (message: string) => void;
  67619. /**
  67620. * Write an error message to the console
  67621. */
  67622. static Error: (message: string) => void;
  67623. /**
  67624. * Gets current log cache (list of logs)
  67625. */
  67626. static readonly LogCache: string;
  67627. /**
  67628. * Clears the log cache
  67629. */
  67630. static ClearLogCache(): void;
  67631. /**
  67632. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67633. */
  67634. static LogLevels: number;
  67635. }
  67636. }
  67637. declare module BABYLON {
  67638. /** @hidden */
  67639. export class _TypeStore {
  67640. /** @hidden */
  67641. static RegisteredTypes: {
  67642. [key: string]: Object;
  67643. };
  67644. /** @hidden */
  67645. static GetClass(fqdn: string): any;
  67646. }
  67647. }
  67648. declare module BABYLON {
  67649. /**
  67650. * Class containing a set of static utilities functions for deep copy.
  67651. */
  67652. export class DeepCopier {
  67653. /**
  67654. * Tries to copy an object by duplicating every property
  67655. * @param source defines the source object
  67656. * @param destination defines the target object
  67657. * @param doNotCopyList defines a list of properties to avoid
  67658. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67659. */
  67660. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67661. }
  67662. }
  67663. declare module BABYLON {
  67664. /**
  67665. * Class containing a set of static utilities functions for precision date
  67666. */
  67667. export class PrecisionDate {
  67668. /**
  67669. * Gets either window.performance.now() if supported or Date.now() else
  67670. */
  67671. static readonly Now: number;
  67672. }
  67673. }
  67674. declare module BABYLON {
  67675. /** @hidden */
  67676. export class _DevTools {
  67677. static WarnImport(name: string): string;
  67678. }
  67679. }
  67680. declare module BABYLON {
  67681. /**
  67682. * Interface used to define the mechanism to get data from the network
  67683. */
  67684. export interface IWebRequest {
  67685. /**
  67686. * Returns client's response url
  67687. */
  67688. responseURL: string;
  67689. /**
  67690. * Returns client's status
  67691. */
  67692. status: number;
  67693. /**
  67694. * Returns client's status as a text
  67695. */
  67696. statusText: string;
  67697. }
  67698. }
  67699. declare module BABYLON {
  67700. /**
  67701. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67702. */
  67703. export class WebRequest implements IWebRequest {
  67704. private _xhr;
  67705. /**
  67706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67707. * i.e. when loading files, where the server/service expects an Authorization header
  67708. */
  67709. static CustomRequestHeaders: {
  67710. [key: string]: string;
  67711. };
  67712. /**
  67713. * Add callback functions in this array to update all the requests before they get sent to the network
  67714. */
  67715. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67716. private _injectCustomRequestHeaders;
  67717. /**
  67718. * Gets or sets a function to be called when loading progress changes
  67719. */
  67720. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67721. /**
  67722. * Returns client's state
  67723. */
  67724. readonly readyState: number;
  67725. /**
  67726. * Returns client's status
  67727. */
  67728. readonly status: number;
  67729. /**
  67730. * Returns client's status as a text
  67731. */
  67732. readonly statusText: string;
  67733. /**
  67734. * Returns client's response
  67735. */
  67736. readonly response: any;
  67737. /**
  67738. * Returns client's response url
  67739. */
  67740. readonly responseURL: string;
  67741. /**
  67742. * Returns client's response as text
  67743. */
  67744. readonly responseText: string;
  67745. /**
  67746. * Gets or sets the expected response type
  67747. */
  67748. responseType: XMLHttpRequestResponseType;
  67749. /** @hidden */
  67750. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67751. /** @hidden */
  67752. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67753. /**
  67754. * Cancels any network activity
  67755. */
  67756. abort(): void;
  67757. /**
  67758. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67759. * @param body defines an optional request body
  67760. */
  67761. send(body?: Document | BodyInit | null): void;
  67762. /**
  67763. * Sets the request method, request URL
  67764. * @param method defines the method to use (GET, POST, etc..)
  67765. * @param url defines the url to connect with
  67766. */
  67767. open(method: string, url: string): void;
  67768. }
  67769. }
  67770. declare module BABYLON {
  67771. /**
  67772. * File request interface
  67773. */
  67774. export interface IFileRequest {
  67775. /**
  67776. * Raised when the request is complete (success or error).
  67777. */
  67778. onCompleteObservable: Observable<IFileRequest>;
  67779. /**
  67780. * Aborts the request for a file.
  67781. */
  67782. abort: () => void;
  67783. }
  67784. }
  67785. declare module BABYLON {
  67786. /**
  67787. * Define options used to create a render target texture
  67788. */
  67789. export class RenderTargetCreationOptions {
  67790. /**
  67791. * Specifies is mipmaps must be generated
  67792. */
  67793. generateMipMaps?: boolean;
  67794. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67795. generateDepthBuffer?: boolean;
  67796. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67797. generateStencilBuffer?: boolean;
  67798. /** Defines texture type (int by default) */
  67799. type?: number;
  67800. /** Defines sampling mode (trilinear by default) */
  67801. samplingMode?: number;
  67802. /** Defines format (RGBA by default) */
  67803. format?: number;
  67804. }
  67805. }
  67806. declare module BABYLON {
  67807. /**
  67808. * @hidden
  67809. **/
  67810. export class _TimeToken {
  67811. _startTimeQuery: Nullable<WebGLQuery>;
  67812. _endTimeQuery: Nullable<WebGLQuery>;
  67813. _timeElapsedQuery: Nullable<WebGLQuery>;
  67814. _timeElapsedQueryEnded: boolean;
  67815. }
  67816. }
  67817. declare module BABYLON {
  67818. /** Defines the cross module used constants to avoid circular dependncies */
  67819. export class Constants {
  67820. /** Defines that alpha blending is disabled */
  67821. static readonly ALPHA_DISABLE: number;
  67822. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67823. static readonly ALPHA_ADD: number;
  67824. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67825. static readonly ALPHA_COMBINE: number;
  67826. /** Defines that alpha blending to DEST - SRC * DEST */
  67827. static readonly ALPHA_SUBTRACT: number;
  67828. /** Defines that alpha blending to SRC * DEST */
  67829. static readonly ALPHA_MULTIPLY: number;
  67830. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67831. static readonly ALPHA_MAXIMIZED: number;
  67832. /** Defines that alpha blending to SRC + DEST */
  67833. static readonly ALPHA_ONEONE: number;
  67834. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67835. static readonly ALPHA_PREMULTIPLIED: number;
  67836. /**
  67837. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67838. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67839. */
  67840. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67841. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67842. static readonly ALPHA_INTERPOLATE: number;
  67843. /**
  67844. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67845. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67846. */
  67847. static readonly ALPHA_SCREENMODE: number;
  67848. /**
  67849. * Defines that alpha blending to SRC + DST
  67850. * Alpha will be set to SRC ALPHA + DST ALPHA
  67851. */
  67852. static readonly ALPHA_ONEONE_ONEONE: number;
  67853. /**
  67854. * Defines that alpha blending to SRC * DST ALPHA + DST
  67855. * Alpha will be set to 0
  67856. */
  67857. static readonly ALPHA_ALPHATOCOLOR: number;
  67858. /**
  67859. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67860. */
  67861. static readonly ALPHA_REVERSEONEMINUS: number;
  67862. /**
  67863. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67864. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67865. */
  67866. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67867. /**
  67868. * Defines that alpha blending to SRC + DST
  67869. * Alpha will be set to SRC ALPHA
  67870. */
  67871. static readonly ALPHA_ONEONE_ONEZERO: number;
  67872. /** Defines that alpha blending equation a SUM */
  67873. static readonly ALPHA_EQUATION_ADD: number;
  67874. /** Defines that alpha blending equation a SUBSTRACTION */
  67875. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67876. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67877. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67878. /** Defines that alpha blending equation a MAX operation */
  67879. static readonly ALPHA_EQUATION_MAX: number;
  67880. /** Defines that alpha blending equation a MIN operation */
  67881. static readonly ALPHA_EQUATION_MIN: number;
  67882. /**
  67883. * Defines that alpha blending equation a DARKEN operation:
  67884. * It takes the min of the src and sums the alpha channels.
  67885. */
  67886. static readonly ALPHA_EQUATION_DARKEN: number;
  67887. /** Defines that the ressource is not delayed*/
  67888. static readonly DELAYLOADSTATE_NONE: number;
  67889. /** Defines that the ressource was successfully delay loaded */
  67890. static readonly DELAYLOADSTATE_LOADED: number;
  67891. /** Defines that the ressource is currently delay loading */
  67892. static readonly DELAYLOADSTATE_LOADING: number;
  67893. /** Defines that the ressource is delayed and has not started loading */
  67894. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67896. static readonly NEVER: number;
  67897. /** 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 */
  67898. static readonly ALWAYS: number;
  67899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67900. static readonly LESS: number;
  67901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67902. static readonly EQUAL: number;
  67903. /** 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 */
  67904. static readonly LEQUAL: number;
  67905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67906. static readonly GREATER: number;
  67907. /** 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 */
  67908. static readonly GEQUAL: number;
  67909. /** 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 */
  67910. static readonly NOTEQUAL: number;
  67911. /** Passed to stencilOperation to specify that stencil value must be kept */
  67912. static readonly KEEP: number;
  67913. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67914. static readonly REPLACE: number;
  67915. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67916. static readonly INCR: number;
  67917. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67918. static readonly DECR: number;
  67919. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67920. static readonly INVERT: number;
  67921. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67922. static readonly INCR_WRAP: number;
  67923. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67924. static readonly DECR_WRAP: number;
  67925. /** Texture is not repeating outside of 0..1 UVs */
  67926. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67927. /** Texture is repeating outside of 0..1 UVs */
  67928. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67929. /** Texture is repeating and mirrored */
  67930. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67931. /** ALPHA */
  67932. static readonly TEXTUREFORMAT_ALPHA: number;
  67933. /** LUMINANCE */
  67934. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67935. /** LUMINANCE_ALPHA */
  67936. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67937. /** RGB */
  67938. static readonly TEXTUREFORMAT_RGB: number;
  67939. /** RGBA */
  67940. static readonly TEXTUREFORMAT_RGBA: number;
  67941. /** RED */
  67942. static readonly TEXTUREFORMAT_RED: number;
  67943. /** RED (2nd reference) */
  67944. static readonly TEXTUREFORMAT_R: number;
  67945. /** RG */
  67946. static readonly TEXTUREFORMAT_RG: number;
  67947. /** RED_INTEGER */
  67948. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67949. /** RED_INTEGER (2nd reference) */
  67950. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67951. /** RG_INTEGER */
  67952. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67953. /** RGB_INTEGER */
  67954. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67955. /** RGBA_INTEGER */
  67956. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67957. /** UNSIGNED_BYTE */
  67958. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67959. /** UNSIGNED_BYTE (2nd reference) */
  67960. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67961. /** FLOAT */
  67962. static readonly TEXTURETYPE_FLOAT: number;
  67963. /** HALF_FLOAT */
  67964. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67965. /** BYTE */
  67966. static readonly TEXTURETYPE_BYTE: number;
  67967. /** SHORT */
  67968. static readonly TEXTURETYPE_SHORT: number;
  67969. /** UNSIGNED_SHORT */
  67970. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67971. /** INT */
  67972. static readonly TEXTURETYPE_INT: number;
  67973. /** UNSIGNED_INT */
  67974. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67975. /** UNSIGNED_SHORT_4_4_4_4 */
  67976. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67977. /** UNSIGNED_SHORT_5_5_5_1 */
  67978. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67979. /** UNSIGNED_SHORT_5_6_5 */
  67980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67981. /** UNSIGNED_INT_2_10_10_10_REV */
  67982. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67983. /** UNSIGNED_INT_24_8 */
  67984. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67985. /** UNSIGNED_INT_10F_11F_11F_REV */
  67986. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67987. /** UNSIGNED_INT_5_9_9_9_REV */
  67988. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67989. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67990. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67991. /** nearest is mag = nearest and min = nearest and mip = linear */
  67992. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67994. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67995. /** Trilinear is mag = linear and min = linear and mip = linear */
  67996. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67997. /** nearest is mag = nearest and min = nearest and mip = linear */
  67998. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68000. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68001. /** Trilinear is mag = linear and min = linear and mip = linear */
  68002. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68003. /** mag = nearest and min = nearest and mip = nearest */
  68004. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68005. /** mag = nearest and min = linear and mip = nearest */
  68006. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68007. /** mag = nearest and min = linear and mip = linear */
  68008. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68009. /** mag = nearest and min = linear and mip = none */
  68010. static readonly TEXTURE_NEAREST_LINEAR: number;
  68011. /** mag = nearest and min = nearest and mip = none */
  68012. static readonly TEXTURE_NEAREST_NEAREST: number;
  68013. /** mag = linear and min = nearest and mip = nearest */
  68014. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68015. /** mag = linear and min = nearest and mip = linear */
  68016. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68017. /** mag = linear and min = linear and mip = none */
  68018. static readonly TEXTURE_LINEAR_LINEAR: number;
  68019. /** mag = linear and min = nearest and mip = none */
  68020. static readonly TEXTURE_LINEAR_NEAREST: number;
  68021. /** Explicit coordinates mode */
  68022. static readonly TEXTURE_EXPLICIT_MODE: number;
  68023. /** Spherical coordinates mode */
  68024. static readonly TEXTURE_SPHERICAL_MODE: number;
  68025. /** Planar coordinates mode */
  68026. static readonly TEXTURE_PLANAR_MODE: number;
  68027. /** Cubic coordinates mode */
  68028. static readonly TEXTURE_CUBIC_MODE: number;
  68029. /** Projection coordinates mode */
  68030. static readonly TEXTURE_PROJECTION_MODE: number;
  68031. /** Skybox coordinates mode */
  68032. static readonly TEXTURE_SKYBOX_MODE: number;
  68033. /** Inverse Cubic coordinates mode */
  68034. static readonly TEXTURE_INVCUBIC_MODE: number;
  68035. /** Equirectangular coordinates mode */
  68036. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68037. /** Equirectangular Fixed coordinates mode */
  68038. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68039. /** Equirectangular Fixed Mirrored coordinates mode */
  68040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68041. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68042. static readonly SCALEMODE_FLOOR: number;
  68043. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68044. static readonly SCALEMODE_NEAREST: number;
  68045. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68046. static readonly SCALEMODE_CEILING: number;
  68047. /**
  68048. * The dirty texture flag value
  68049. */
  68050. static readonly MATERIAL_TextureDirtyFlag: number;
  68051. /**
  68052. * The dirty light flag value
  68053. */
  68054. static readonly MATERIAL_LightDirtyFlag: number;
  68055. /**
  68056. * The dirty fresnel flag value
  68057. */
  68058. static readonly MATERIAL_FresnelDirtyFlag: number;
  68059. /**
  68060. * The dirty attribute flag value
  68061. */
  68062. static readonly MATERIAL_AttributesDirtyFlag: number;
  68063. /**
  68064. * The dirty misc flag value
  68065. */
  68066. static readonly MATERIAL_MiscDirtyFlag: number;
  68067. /**
  68068. * The all dirty flag value
  68069. */
  68070. static readonly MATERIAL_AllDirtyFlag: number;
  68071. /**
  68072. * Returns the triangle fill mode
  68073. */
  68074. static readonly MATERIAL_TriangleFillMode: number;
  68075. /**
  68076. * Returns the wireframe mode
  68077. */
  68078. static readonly MATERIAL_WireFrameFillMode: number;
  68079. /**
  68080. * Returns the point fill mode
  68081. */
  68082. static readonly MATERIAL_PointFillMode: number;
  68083. /**
  68084. * Returns the point list draw mode
  68085. */
  68086. static readonly MATERIAL_PointListDrawMode: number;
  68087. /**
  68088. * Returns the line list draw mode
  68089. */
  68090. static readonly MATERIAL_LineListDrawMode: number;
  68091. /**
  68092. * Returns the line loop draw mode
  68093. */
  68094. static readonly MATERIAL_LineLoopDrawMode: number;
  68095. /**
  68096. * Returns the line strip draw mode
  68097. */
  68098. static readonly MATERIAL_LineStripDrawMode: number;
  68099. /**
  68100. * Returns the triangle strip draw mode
  68101. */
  68102. static readonly MATERIAL_TriangleStripDrawMode: number;
  68103. /**
  68104. * Returns the triangle fan draw mode
  68105. */
  68106. static readonly MATERIAL_TriangleFanDrawMode: number;
  68107. /**
  68108. * Stores the clock-wise side orientation
  68109. */
  68110. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68111. /**
  68112. * Stores the counter clock-wise side orientation
  68113. */
  68114. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68115. /**
  68116. * Nothing
  68117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68118. */
  68119. static readonly ACTION_NothingTrigger: number;
  68120. /**
  68121. * On pick
  68122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68123. */
  68124. static readonly ACTION_OnPickTrigger: number;
  68125. /**
  68126. * On left pick
  68127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68128. */
  68129. static readonly ACTION_OnLeftPickTrigger: number;
  68130. /**
  68131. * On right pick
  68132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68133. */
  68134. static readonly ACTION_OnRightPickTrigger: number;
  68135. /**
  68136. * On center pick
  68137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68138. */
  68139. static readonly ACTION_OnCenterPickTrigger: number;
  68140. /**
  68141. * On pick down
  68142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68143. */
  68144. static readonly ACTION_OnPickDownTrigger: number;
  68145. /**
  68146. * On double pick
  68147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68148. */
  68149. static readonly ACTION_OnDoublePickTrigger: number;
  68150. /**
  68151. * On pick up
  68152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68153. */
  68154. static readonly ACTION_OnPickUpTrigger: number;
  68155. /**
  68156. * On pick out.
  68157. * This trigger will only be raised if you also declared a OnPickDown
  68158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68159. */
  68160. static readonly ACTION_OnPickOutTrigger: number;
  68161. /**
  68162. * On long press
  68163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68164. */
  68165. static readonly ACTION_OnLongPressTrigger: number;
  68166. /**
  68167. * On pointer over
  68168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68169. */
  68170. static readonly ACTION_OnPointerOverTrigger: number;
  68171. /**
  68172. * On pointer out
  68173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68174. */
  68175. static readonly ACTION_OnPointerOutTrigger: number;
  68176. /**
  68177. * On every frame
  68178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68179. */
  68180. static readonly ACTION_OnEveryFrameTrigger: number;
  68181. /**
  68182. * On intersection enter
  68183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68184. */
  68185. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68186. /**
  68187. * On intersection exit
  68188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68189. */
  68190. static readonly ACTION_OnIntersectionExitTrigger: number;
  68191. /**
  68192. * On key down
  68193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68194. */
  68195. static readonly ACTION_OnKeyDownTrigger: number;
  68196. /**
  68197. * On key up
  68198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68199. */
  68200. static readonly ACTION_OnKeyUpTrigger: number;
  68201. /**
  68202. * Billboard mode will only apply to Y axis
  68203. */
  68204. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68205. /**
  68206. * Billboard mode will apply to all axes
  68207. */
  68208. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68209. /**
  68210. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68211. */
  68212. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68213. /**
  68214. * Gets or sets base Assets URL
  68215. */
  68216. static PARTICLES_BaseAssetsUrl: string;
  68217. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68218. * Test order :
  68219. * Is the bounding sphere outside the frustum ?
  68220. * If not, are the bounding box vertices outside the frustum ?
  68221. * It not, then the cullable object is in the frustum.
  68222. */
  68223. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68224. /** Culling strategy : Bounding Sphere Only.
  68225. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68226. * It's also less accurate than the standard because some not visible objects can still be selected.
  68227. * Test : is the bounding sphere outside the frustum ?
  68228. * If not, then the cullable object is in the frustum.
  68229. */
  68230. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68231. /** Culling strategy : Optimistic Inclusion.
  68232. * This in an inclusion test first, then the standard exclusion test.
  68233. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68234. * 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.
  68235. * Anyway, it's as accurate as the standard strategy.
  68236. * Test :
  68237. * Is the cullable object bounding sphere center in the frustum ?
  68238. * If not, apply the default culling strategy.
  68239. */
  68240. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68241. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68242. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68243. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68244. * 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.
  68245. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68246. * Test :
  68247. * Is the cullable object bounding sphere center in the frustum ?
  68248. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68249. */
  68250. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68251. /**
  68252. * No logging while loading
  68253. */
  68254. static readonly SCENELOADER_NO_LOGGING: number;
  68255. /**
  68256. * Minimal logging while loading
  68257. */
  68258. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68259. /**
  68260. * Summary logging while loading
  68261. */
  68262. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68263. /**
  68264. * Detailled logging while loading
  68265. */
  68266. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68267. }
  68268. }
  68269. declare module BABYLON {
  68270. /**
  68271. * This represents the required contract to create a new type of texture loader.
  68272. */
  68273. export interface IInternalTextureLoader {
  68274. /**
  68275. * Defines wether the loader supports cascade loading the different faces.
  68276. */
  68277. supportCascades: boolean;
  68278. /**
  68279. * This returns if the loader support the current file information.
  68280. * @param extension defines the file extension of the file being loaded
  68281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68282. * @param fallback defines the fallback internal texture if any
  68283. * @param isBase64 defines whether the texture is encoded as a base64
  68284. * @param isBuffer defines whether the texture data are stored as a buffer
  68285. * @returns true if the loader can load the specified file
  68286. */
  68287. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68288. /**
  68289. * Transform the url before loading if required.
  68290. * @param rootUrl the url of the texture
  68291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68292. * @returns the transformed texture
  68293. */
  68294. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68295. /**
  68296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68297. * @param rootUrl the url of the texture
  68298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68299. * @returns the fallback texture
  68300. */
  68301. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68302. /**
  68303. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68304. * @param data contains the texture data
  68305. * @param texture defines the BabylonJS internal texture
  68306. * @param createPolynomials will be true if polynomials have been requested
  68307. * @param onLoad defines the callback to trigger once the texture is ready
  68308. * @param onError defines the callback to trigger in case of error
  68309. */
  68310. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68311. /**
  68312. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68313. * @param data contains the texture data
  68314. * @param texture defines the BabylonJS internal texture
  68315. * @param callback defines the method to call once ready to upload
  68316. */
  68317. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68318. }
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Class used to store and describe the pipeline context associated with an effect
  68323. */
  68324. export interface IPipelineContext {
  68325. /**
  68326. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68327. */
  68328. isAsync: boolean;
  68329. /**
  68330. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68331. */
  68332. isReady: boolean;
  68333. /** @hidden */
  68334. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68335. }
  68336. }
  68337. declare module BABYLON {
  68338. /**
  68339. * Class used to store gfx data (like WebGLBuffer)
  68340. */
  68341. export class DataBuffer {
  68342. /**
  68343. * Gets or sets the number of objects referencing this buffer
  68344. */
  68345. references: number;
  68346. /** Gets or sets the size of the underlying buffer */
  68347. capacity: number;
  68348. /**
  68349. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68350. */
  68351. is32Bits: boolean;
  68352. /**
  68353. * Gets the underlying buffer
  68354. */
  68355. readonly underlyingResource: any;
  68356. }
  68357. }
  68358. declare module BABYLON {
  68359. /** @hidden */
  68360. export interface IShaderProcessor {
  68361. attributeProcessor?: (attribute: string) => string;
  68362. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68363. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68364. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68365. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68366. lineProcessor?: (line: string, isFragment: boolean) => string;
  68367. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68368. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68369. }
  68370. }
  68371. declare module BABYLON {
  68372. /** @hidden */
  68373. export interface ProcessingOptions {
  68374. defines: string[];
  68375. indexParameters: any;
  68376. isFragment: boolean;
  68377. shouldUseHighPrecisionShader: boolean;
  68378. supportsUniformBuffers: boolean;
  68379. shadersRepository: string;
  68380. includesShadersStore: {
  68381. [key: string]: string;
  68382. };
  68383. processor?: IShaderProcessor;
  68384. version: string;
  68385. platformName: string;
  68386. lookForClosingBracketForUniformBuffer?: boolean;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /**
  68391. * Helper to manipulate strings
  68392. */
  68393. export class StringTools {
  68394. /**
  68395. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68396. * @param str Source string
  68397. * @param suffix Suffix to search for in the source string
  68398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68399. */
  68400. static EndsWith(str: string, suffix: string): boolean;
  68401. /**
  68402. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68403. * @param str Source string
  68404. * @param suffix Suffix to search for in the source string
  68405. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68406. */
  68407. static StartsWith(str: string, suffix: string): boolean;
  68408. }
  68409. }
  68410. declare module BABYLON {
  68411. /** @hidden */
  68412. export class ShaderCodeNode {
  68413. line: string;
  68414. children: ShaderCodeNode[];
  68415. additionalDefineKey?: string;
  68416. additionalDefineValue?: string;
  68417. isValid(preprocessors: {
  68418. [key: string]: string;
  68419. }): boolean;
  68420. process(preprocessors: {
  68421. [key: string]: string;
  68422. }, options: ProcessingOptions): string;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /** @hidden */
  68427. export class ShaderCodeCursor {
  68428. private _lines;
  68429. lineIndex: number;
  68430. readonly currentLine: string;
  68431. readonly canRead: boolean;
  68432. lines: string[];
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /** @hidden */
  68437. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68438. process(preprocessors: {
  68439. [key: string]: string;
  68440. }, options: ProcessingOptions): string;
  68441. }
  68442. }
  68443. declare module BABYLON {
  68444. /** @hidden */
  68445. export class ShaderDefineExpression {
  68446. isTrue(preprocessors: {
  68447. [key: string]: string;
  68448. }): boolean;
  68449. }
  68450. }
  68451. declare module BABYLON {
  68452. /** @hidden */
  68453. export class ShaderCodeTestNode extends ShaderCodeNode {
  68454. testExpression: ShaderDefineExpression;
  68455. isValid(preprocessors: {
  68456. [key: string]: string;
  68457. }): boolean;
  68458. }
  68459. }
  68460. declare module BABYLON {
  68461. /** @hidden */
  68462. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68463. define: string;
  68464. not: boolean;
  68465. constructor(define: string, not?: boolean);
  68466. isTrue(preprocessors: {
  68467. [key: string]: string;
  68468. }): boolean;
  68469. }
  68470. }
  68471. declare module BABYLON {
  68472. /** @hidden */
  68473. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68474. leftOperand: ShaderDefineExpression;
  68475. rightOperand: ShaderDefineExpression;
  68476. isTrue(preprocessors: {
  68477. [key: string]: string;
  68478. }): boolean;
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /** @hidden */
  68483. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68484. leftOperand: ShaderDefineExpression;
  68485. rightOperand: ShaderDefineExpression;
  68486. isTrue(preprocessors: {
  68487. [key: string]: string;
  68488. }): boolean;
  68489. }
  68490. }
  68491. declare module BABYLON {
  68492. /** @hidden */
  68493. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68494. define: string;
  68495. operand: string;
  68496. testValue: string;
  68497. constructor(define: string, operand: string, testValue: string);
  68498. isTrue(preprocessors: {
  68499. [key: string]: string;
  68500. }): boolean;
  68501. }
  68502. }
  68503. declare module BABYLON {
  68504. /**
  68505. * @ignore
  68506. * Application error to support additional information when loading a file
  68507. */
  68508. export class LoadFileError extends Error {
  68509. /** defines the optional web request */
  68510. request?: WebRequest | undefined;
  68511. private static _setPrototypeOf;
  68512. /**
  68513. * Creates a new LoadFileError
  68514. * @param message defines the message of the error
  68515. * @param request defines the optional web request
  68516. */
  68517. constructor(message: string,
  68518. /** defines the optional web request */
  68519. request?: WebRequest | undefined);
  68520. }
  68521. }
  68522. declare module BABYLON {
  68523. /**
  68524. * Class used to enable access to offline support
  68525. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68526. */
  68527. export interface IOfflineProvider {
  68528. /**
  68529. * Gets a boolean indicating if scene must be saved in the database
  68530. */
  68531. enableSceneOffline: boolean;
  68532. /**
  68533. * Gets a boolean indicating if textures must be saved in the database
  68534. */
  68535. enableTexturesOffline: boolean;
  68536. /**
  68537. * Open the offline support and make it available
  68538. * @param successCallback defines the callback to call on success
  68539. * @param errorCallback defines the callback to call on error
  68540. */
  68541. open(successCallback: () => void, errorCallback: () => void): void;
  68542. /**
  68543. * Loads an image from the offline support
  68544. * @param url defines the url to load from
  68545. * @param image defines the target DOM image
  68546. */
  68547. loadImage(url: string, image: HTMLImageElement): void;
  68548. /**
  68549. * Loads a file from offline support
  68550. * @param url defines the URL to load from
  68551. * @param sceneLoaded defines a callback to call on success
  68552. * @param progressCallBack defines a callback to call when progress changed
  68553. * @param errorCallback defines a callback to call on error
  68554. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68555. */
  68556. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /**
  68561. * Class used to help managing file picking and drag'n'drop
  68562. * File Storage
  68563. */
  68564. export class FilesInputStore {
  68565. /**
  68566. * List of files ready to be loaded
  68567. */
  68568. static FilesToLoad: {
  68569. [key: string]: File;
  68570. };
  68571. }
  68572. }
  68573. declare module BABYLON {
  68574. /**
  68575. * Class used to define a retry strategy when error happens while loading assets
  68576. */
  68577. export class RetryStrategy {
  68578. /**
  68579. * Function used to defines an exponential back off strategy
  68580. * @param maxRetries defines the maximum number of retries (3 by default)
  68581. * @param baseInterval defines the interval between retries
  68582. * @returns the strategy function to use
  68583. */
  68584. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * @hidden
  68590. */
  68591. export class FileTools {
  68592. /**
  68593. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68594. */
  68595. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68596. /**
  68597. * Gets or sets the base URL to use to load assets
  68598. */
  68599. static BaseUrl: string;
  68600. /**
  68601. * Default behaviour for cors in the application.
  68602. * It can be a string if the expected behavior is identical in the entire app.
  68603. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68604. */
  68605. static CorsBehavior: string | ((url: string | string[]) => string);
  68606. /**
  68607. * Gets or sets a function used to pre-process url before using them to load assets
  68608. */
  68609. static PreprocessUrl: (url: string) => string;
  68610. /**
  68611. * Removes unwanted characters from an url
  68612. * @param url defines the url to clean
  68613. * @returns the cleaned url
  68614. */
  68615. private static _CleanUrl;
  68616. /**
  68617. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68618. * @param url define the url we are trying
  68619. * @param element define the dom element where to configure the cors policy
  68620. */
  68621. static SetCorsBehavior(url: string | string[], element: {
  68622. crossOrigin: string | null;
  68623. }): void;
  68624. private static _ArrayBufferToBase64;
  68625. /**
  68626. * Loads an image as an HTMLImageElement.
  68627. * @param input url string, ArrayBuffer, or Blob to load
  68628. * @param onLoad callback called when the image successfully loads
  68629. * @param onError callback called when the image fails to load
  68630. * @param offlineProvider offline provider for caching
  68631. * @param mimeType optional mime type
  68632. * @returns the HTMLImageElement of the loaded image
  68633. */
  68634. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  68635. /**
  68636. * Loads a file
  68637. * @param fileToLoad defines the file to load
  68638. * @param callback defines the callback to call when data is loaded
  68639. * @param progressCallBack defines the callback to call during loading process
  68640. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68641. * @returns a file request object
  68642. */
  68643. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68644. /**
  68645. * Loads a file
  68646. * @param url url string, ArrayBuffer, or Blob to load
  68647. * @param onSuccess callback called when the file successfully loads
  68648. * @param onProgress callback called while file is loading (if the server supports this mode)
  68649. * @param offlineProvider defines the offline provider for caching
  68650. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68651. * @param onError callback called when the file fails to load
  68652. * @returns a file request object
  68653. */
  68654. 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;
  68655. /**
  68656. * Checks if the loaded document was accessed via `file:`-Protocol.
  68657. * @returns boolean
  68658. */
  68659. static IsFileURL(): boolean;
  68660. }
  68661. }
  68662. declare module BABYLON {
  68663. /** @hidden */
  68664. export class ShaderProcessor {
  68665. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68666. private static _ProcessPrecision;
  68667. private static _ExtractOperation;
  68668. private static _BuildSubExpression;
  68669. private static _BuildExpression;
  68670. private static _MoveCursorWithinIf;
  68671. private static _MoveCursor;
  68672. private static _EvaluatePreProcessors;
  68673. private static _PreparePreProcessors;
  68674. private static _ProcessShaderConversion;
  68675. private static _ProcessIncludes;
  68676. }
  68677. }
  68678. declare module BABYLON {
  68679. /**
  68680. * @hidden
  68681. */
  68682. export interface IColor4Like {
  68683. r: float;
  68684. g: float;
  68685. b: float;
  68686. a: float;
  68687. }
  68688. /**
  68689. * @hidden
  68690. */
  68691. export interface IColor3Like {
  68692. r: float;
  68693. g: float;
  68694. b: float;
  68695. }
  68696. /**
  68697. * @hidden
  68698. */
  68699. export interface IVector4Like {
  68700. x: float;
  68701. y: float;
  68702. z: float;
  68703. w: float;
  68704. }
  68705. /**
  68706. * @hidden
  68707. */
  68708. export interface IVector3Like {
  68709. x: float;
  68710. y: float;
  68711. z: float;
  68712. }
  68713. /**
  68714. * @hidden
  68715. */
  68716. export interface IVector2Like {
  68717. x: float;
  68718. y: float;
  68719. }
  68720. /**
  68721. * @hidden
  68722. */
  68723. export interface IMatrixLike {
  68724. toArray(): DeepImmutable<Float32Array>;
  68725. updateFlag: int;
  68726. }
  68727. /**
  68728. * @hidden
  68729. */
  68730. export interface IViewportLike {
  68731. x: float;
  68732. y: float;
  68733. width: float;
  68734. height: float;
  68735. }
  68736. /**
  68737. * @hidden
  68738. */
  68739. export interface IPlaneLike {
  68740. normal: IVector3Like;
  68741. d: float;
  68742. normalize(): void;
  68743. }
  68744. }
  68745. declare module BABYLON {
  68746. /**
  68747. * Interface used to define common properties for effect fallbacks
  68748. */
  68749. export interface IEffectFallbacks {
  68750. /**
  68751. * Removes the defines that should be removed when falling back.
  68752. * @param currentDefines defines the current define statements for the shader.
  68753. * @param effect defines the current effect we try to compile
  68754. * @returns The resulting defines with defines of the current rank removed.
  68755. */
  68756. reduce(currentDefines: string, effect: Effect): string;
  68757. /**
  68758. * Removes the fallback from the bound mesh.
  68759. */
  68760. unBindMesh(): void;
  68761. /**
  68762. * Checks to see if more fallbacks are still availible.
  68763. */
  68764. hasMoreFallbacks: boolean;
  68765. }
  68766. }
  68767. declare module BABYLON {
  68768. /**
  68769. * Class used to evalaute queries containing `and` and `or` operators
  68770. */
  68771. export class AndOrNotEvaluator {
  68772. /**
  68773. * Evaluate a query
  68774. * @param query defines the query to evaluate
  68775. * @param evaluateCallback defines the callback used to filter result
  68776. * @returns true if the query matches
  68777. */
  68778. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68779. private static _HandleParenthesisContent;
  68780. private static _SimplifyNegation;
  68781. }
  68782. }
  68783. declare module BABYLON {
  68784. /**
  68785. * Class used to store custom tags
  68786. */
  68787. export class Tags {
  68788. /**
  68789. * Adds support for tags on the given object
  68790. * @param obj defines the object to use
  68791. */
  68792. static EnableFor(obj: any): void;
  68793. /**
  68794. * Removes tags support
  68795. * @param obj defines the object to use
  68796. */
  68797. static DisableFor(obj: any): void;
  68798. /**
  68799. * Gets a boolean indicating if the given object has tags
  68800. * @param obj defines the object to use
  68801. * @returns a boolean
  68802. */
  68803. static HasTags(obj: any): boolean;
  68804. /**
  68805. * Gets the tags available on a given object
  68806. * @param obj defines the object to use
  68807. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68808. * @returns the tags
  68809. */
  68810. static GetTags(obj: any, asString?: boolean): any;
  68811. /**
  68812. * Adds tags to an object
  68813. * @param obj defines the object to use
  68814. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68815. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68816. */
  68817. static AddTagsTo(obj: any, tagsString: string): void;
  68818. /**
  68819. * @hidden
  68820. */
  68821. static _AddTagTo(obj: any, tag: string): void;
  68822. /**
  68823. * Removes specific tags from a specific object
  68824. * @param obj defines the object to use
  68825. * @param tagsString defines the tags to remove
  68826. */
  68827. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68828. /**
  68829. * @hidden
  68830. */
  68831. static _RemoveTagFrom(obj: any, tag: string): void;
  68832. /**
  68833. * Defines if tags hosted on an object match a given query
  68834. * @param obj defines the object to use
  68835. * @param tagsQuery defines the tag query
  68836. * @returns a boolean
  68837. */
  68838. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68839. }
  68840. }
  68841. declare module BABYLON {
  68842. /**
  68843. * Scalar computation library
  68844. */
  68845. export class Scalar {
  68846. /**
  68847. * Two pi constants convenient for computation.
  68848. */
  68849. static TwoPi: number;
  68850. /**
  68851. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68852. * @param a number
  68853. * @param b number
  68854. * @param epsilon (default = 1.401298E-45)
  68855. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68856. */
  68857. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68858. /**
  68859. * Returns a string : the upper case translation of the number i to hexadecimal.
  68860. * @param i number
  68861. * @returns the upper case translation of the number i to hexadecimal.
  68862. */
  68863. static ToHex(i: number): string;
  68864. /**
  68865. * Returns -1 if value is negative and +1 is value is positive.
  68866. * @param value the value
  68867. * @returns the value itself if it's equal to zero.
  68868. */
  68869. static Sign(value: number): number;
  68870. /**
  68871. * Returns the value itself if it's between min and max.
  68872. * Returns min if the value is lower than min.
  68873. * Returns max if the value is greater than max.
  68874. * @param value the value to clmap
  68875. * @param min the min value to clamp to (default: 0)
  68876. * @param max the max value to clamp to (default: 1)
  68877. * @returns the clamped value
  68878. */
  68879. static Clamp(value: number, min?: number, max?: number): number;
  68880. /**
  68881. * the log2 of value.
  68882. * @param value the value to compute log2 of
  68883. * @returns the log2 of value.
  68884. */
  68885. static Log2(value: number): number;
  68886. /**
  68887. * Loops the value, so that it is never larger than length and never smaller than 0.
  68888. *
  68889. * This is similar to the modulo operator but it works with floating point numbers.
  68890. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68891. * With t = 5 and length = 2.5, the result would be 0.0.
  68892. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68893. * @param value the value
  68894. * @param length the length
  68895. * @returns the looped value
  68896. */
  68897. static Repeat(value: number, length: number): number;
  68898. /**
  68899. * Normalize the value between 0.0 and 1.0 using min and max values
  68900. * @param value value to normalize
  68901. * @param min max to normalize between
  68902. * @param max min to normalize between
  68903. * @returns the normalized value
  68904. */
  68905. static Normalize(value: number, min: number, max: number): number;
  68906. /**
  68907. * Denormalize the value from 0.0 and 1.0 using min and max values
  68908. * @param normalized value to denormalize
  68909. * @param min max to denormalize between
  68910. * @param max min to denormalize between
  68911. * @returns the denormalized value
  68912. */
  68913. static Denormalize(normalized: number, min: number, max: number): number;
  68914. /**
  68915. * Calculates the shortest difference between two given angles given in degrees.
  68916. * @param current current angle in degrees
  68917. * @param target target angle in degrees
  68918. * @returns the delta
  68919. */
  68920. static DeltaAngle(current: number, target: number): number;
  68921. /**
  68922. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68923. * @param tx value
  68924. * @param length length
  68925. * @returns The returned value will move back and forth between 0 and length
  68926. */
  68927. static PingPong(tx: number, length: number): number;
  68928. /**
  68929. * Interpolates between min and max with smoothing at the limits.
  68930. *
  68931. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68932. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68933. * @param from from
  68934. * @param to to
  68935. * @param tx value
  68936. * @returns the smooth stepped value
  68937. */
  68938. static SmoothStep(from: number, to: number, tx: number): number;
  68939. /**
  68940. * Moves a value current towards target.
  68941. *
  68942. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68943. * Negative values of maxDelta pushes the value away from target.
  68944. * @param current current value
  68945. * @param target target value
  68946. * @param maxDelta max distance to move
  68947. * @returns resulting value
  68948. */
  68949. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68950. /**
  68951. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68952. *
  68953. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68954. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68955. * @param current current value
  68956. * @param target target value
  68957. * @param maxDelta max distance to move
  68958. * @returns resulting angle
  68959. */
  68960. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68961. /**
  68962. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68963. * @param start start value
  68964. * @param end target value
  68965. * @param amount amount to lerp between
  68966. * @returns the lerped value
  68967. */
  68968. static Lerp(start: number, end: number, amount: number): number;
  68969. /**
  68970. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68971. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68972. * @param start start value
  68973. * @param end target value
  68974. * @param amount amount to lerp between
  68975. * @returns the lerped value
  68976. */
  68977. static LerpAngle(start: number, end: number, amount: number): number;
  68978. /**
  68979. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68980. * @param a start value
  68981. * @param b target value
  68982. * @param value value between a and b
  68983. * @returns the inverseLerp value
  68984. */
  68985. static InverseLerp(a: number, b: number, value: number): number;
  68986. /**
  68987. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68988. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68989. * @param value1 spline value
  68990. * @param tangent1 spline value
  68991. * @param value2 spline value
  68992. * @param tangent2 spline value
  68993. * @param amount input value
  68994. * @returns hermite result
  68995. */
  68996. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68997. /**
  68998. * Returns a random float number between and min and max values
  68999. * @param min min value of random
  69000. * @param max max value of random
  69001. * @returns random value
  69002. */
  69003. static RandomRange(min: number, max: number): number;
  69004. /**
  69005. * This function returns percentage of a number in a given range.
  69006. *
  69007. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69008. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69009. * @param number to convert to percentage
  69010. * @param min min range
  69011. * @param max max range
  69012. * @returns the percentage
  69013. */
  69014. static RangeToPercent(number: number, min: number, max: number): number;
  69015. /**
  69016. * This function returns number that corresponds to the percentage in a given range.
  69017. *
  69018. * PercentToRange(0.34,0,100) will return 34.
  69019. * @param percent to convert to number
  69020. * @param min min range
  69021. * @param max max range
  69022. * @returns the number
  69023. */
  69024. static PercentToRange(percent: number, min: number, max: number): number;
  69025. /**
  69026. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69027. * @param angle The angle to normalize in radian.
  69028. * @return The converted angle.
  69029. */
  69030. static NormalizeRadians(angle: number): number;
  69031. }
  69032. }
  69033. declare module BABYLON {
  69034. /**
  69035. * Constant used to convert a value to gamma space
  69036. * @ignorenaming
  69037. */
  69038. export const ToGammaSpace: number;
  69039. /**
  69040. * Constant used to convert a value to linear space
  69041. * @ignorenaming
  69042. */
  69043. export const ToLinearSpace = 2.2;
  69044. /**
  69045. * Constant used to define the minimal number value in Babylon.js
  69046. * @ignorenaming
  69047. */
  69048. let Epsilon: number;
  69049. }
  69050. declare module BABYLON {
  69051. /**
  69052. * Class used to represent a viewport on screen
  69053. */
  69054. export class Viewport {
  69055. /** viewport left coordinate */
  69056. x: number;
  69057. /** viewport top coordinate */
  69058. y: number;
  69059. /**viewport width */
  69060. width: number;
  69061. /** viewport height */
  69062. height: number;
  69063. /**
  69064. * Creates a Viewport object located at (x, y) and sized (width, height)
  69065. * @param x defines viewport left coordinate
  69066. * @param y defines viewport top coordinate
  69067. * @param width defines the viewport width
  69068. * @param height defines the viewport height
  69069. */
  69070. constructor(
  69071. /** viewport left coordinate */
  69072. x: number,
  69073. /** viewport top coordinate */
  69074. y: number,
  69075. /**viewport width */
  69076. width: number,
  69077. /** viewport height */
  69078. height: number);
  69079. /**
  69080. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69081. * @param renderWidth defines the rendering width
  69082. * @param renderHeight defines the rendering height
  69083. * @returns a new Viewport
  69084. */
  69085. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69086. /**
  69087. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69088. * @param renderWidth defines the rendering width
  69089. * @param renderHeight defines the rendering height
  69090. * @param ref defines the target viewport
  69091. * @returns the current viewport
  69092. */
  69093. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69094. /**
  69095. * Returns a new Viewport copied from the current one
  69096. * @returns a new Viewport
  69097. */
  69098. clone(): Viewport;
  69099. }
  69100. }
  69101. declare module BABYLON {
  69102. /**
  69103. * Class containing a set of static utilities functions for arrays.
  69104. */
  69105. export class ArrayTools {
  69106. /**
  69107. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69108. * @param size the number of element to construct and put in the array
  69109. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69110. * @returns a new array filled with new objects
  69111. */
  69112. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * Class representing a vector containing 2 coordinates
  69118. */
  69119. export class Vector2 {
  69120. /** defines the first coordinate */
  69121. x: number;
  69122. /** defines the second coordinate */
  69123. y: number;
  69124. /**
  69125. * Creates a new Vector2 from the given x and y coordinates
  69126. * @param x defines the first coordinate
  69127. * @param y defines the second coordinate
  69128. */
  69129. constructor(
  69130. /** defines the first coordinate */
  69131. x?: number,
  69132. /** defines the second coordinate */
  69133. y?: number);
  69134. /**
  69135. * Gets a string with the Vector2 coordinates
  69136. * @returns a string with the Vector2 coordinates
  69137. */
  69138. toString(): string;
  69139. /**
  69140. * Gets class name
  69141. * @returns the string "Vector2"
  69142. */
  69143. getClassName(): string;
  69144. /**
  69145. * Gets current vector hash code
  69146. * @returns the Vector2 hash code as a number
  69147. */
  69148. getHashCode(): number;
  69149. /**
  69150. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69151. * @param array defines the source array
  69152. * @param index defines the offset in source array
  69153. * @returns the current Vector2
  69154. */
  69155. toArray(array: FloatArray, index?: number): Vector2;
  69156. /**
  69157. * Copy the current vector to an array
  69158. * @returns a new array with 2 elements: the Vector2 coordinates.
  69159. */
  69160. asArray(): number[];
  69161. /**
  69162. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69163. * @param source defines the source Vector2
  69164. * @returns the current updated Vector2
  69165. */
  69166. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69167. /**
  69168. * Sets the Vector2 coordinates with the given floats
  69169. * @param x defines the first coordinate
  69170. * @param y defines the second coordinate
  69171. * @returns the current updated Vector2
  69172. */
  69173. copyFromFloats(x: number, y: number): Vector2;
  69174. /**
  69175. * Sets the Vector2 coordinates with the given floats
  69176. * @param x defines the first coordinate
  69177. * @param y defines the second coordinate
  69178. * @returns the current updated Vector2
  69179. */
  69180. set(x: number, y: number): Vector2;
  69181. /**
  69182. * Add another vector with the current one
  69183. * @param otherVector defines the other vector
  69184. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69185. */
  69186. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69187. /**
  69188. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69189. * @param otherVector defines the other vector
  69190. * @param result defines the target vector
  69191. * @returns the unmodified current Vector2
  69192. */
  69193. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69194. /**
  69195. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69196. * @param otherVector defines the other vector
  69197. * @returns the current updated Vector2
  69198. */
  69199. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69200. /**
  69201. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69202. * @param otherVector defines the other vector
  69203. * @returns a new Vector2
  69204. */
  69205. addVector3(otherVector: Vector3): Vector2;
  69206. /**
  69207. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69208. * @param otherVector defines the other vector
  69209. * @returns a new Vector2
  69210. */
  69211. subtract(otherVector: Vector2): Vector2;
  69212. /**
  69213. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69214. * @param otherVector defines the other vector
  69215. * @param result defines the target vector
  69216. * @returns the unmodified current Vector2
  69217. */
  69218. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69219. /**
  69220. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69221. * @param otherVector defines the other vector
  69222. * @returns the current updated Vector2
  69223. */
  69224. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69225. /**
  69226. * Multiplies in place the current Vector2 coordinates by the given ones
  69227. * @param otherVector defines the other vector
  69228. * @returns the current updated Vector2
  69229. */
  69230. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69231. /**
  69232. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69233. * @param otherVector defines the other vector
  69234. * @returns a new Vector2
  69235. */
  69236. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69237. /**
  69238. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69239. * @param otherVector defines the other vector
  69240. * @param result defines the target vector
  69241. * @returns the unmodified current Vector2
  69242. */
  69243. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69244. /**
  69245. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69246. * @param x defines the first coordinate
  69247. * @param y defines the second coordinate
  69248. * @returns a new Vector2
  69249. */
  69250. multiplyByFloats(x: number, y: number): Vector2;
  69251. /**
  69252. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69253. * @param otherVector defines the other vector
  69254. * @returns a new Vector2
  69255. */
  69256. divide(otherVector: Vector2): Vector2;
  69257. /**
  69258. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69259. * @param otherVector defines the other vector
  69260. * @param result defines the target vector
  69261. * @returns the unmodified current Vector2
  69262. */
  69263. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69264. /**
  69265. * Divides the current Vector2 coordinates by the given ones
  69266. * @param otherVector defines the other vector
  69267. * @returns the current updated Vector2
  69268. */
  69269. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69270. /**
  69271. * Gets a new Vector2 with current Vector2 negated coordinates
  69272. * @returns a new Vector2
  69273. */
  69274. negate(): Vector2;
  69275. /**
  69276. * Multiply the Vector2 coordinates by scale
  69277. * @param scale defines the scaling factor
  69278. * @returns the current updated Vector2
  69279. */
  69280. scaleInPlace(scale: number): Vector2;
  69281. /**
  69282. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69283. * @param scale defines the scaling factor
  69284. * @returns a new Vector2
  69285. */
  69286. scale(scale: number): Vector2;
  69287. /**
  69288. * Scale the current Vector2 values by a factor to a given Vector2
  69289. * @param scale defines the scale factor
  69290. * @param result defines the Vector2 object where to store the result
  69291. * @returns the unmodified current Vector2
  69292. */
  69293. scaleToRef(scale: number, result: Vector2): Vector2;
  69294. /**
  69295. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69296. * @param scale defines the scale factor
  69297. * @param result defines the Vector2 object where to store the result
  69298. * @returns the unmodified current Vector2
  69299. */
  69300. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69301. /**
  69302. * Gets a boolean if two vectors are equals
  69303. * @param otherVector defines the other vector
  69304. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69305. */
  69306. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69307. /**
  69308. * Gets a boolean if two vectors are equals (using an epsilon value)
  69309. * @param otherVector defines the other vector
  69310. * @param epsilon defines the minimal distance to consider equality
  69311. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69312. */
  69313. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69314. /**
  69315. * Gets a new Vector2 from current Vector2 floored values
  69316. * @returns a new Vector2
  69317. */
  69318. floor(): Vector2;
  69319. /**
  69320. * Gets a new Vector2 from current Vector2 floored values
  69321. * @returns a new Vector2
  69322. */
  69323. fract(): Vector2;
  69324. /**
  69325. * Gets the length of the vector
  69326. * @returns the vector length (float)
  69327. */
  69328. length(): number;
  69329. /**
  69330. * Gets the vector squared length
  69331. * @returns the vector squared length (float)
  69332. */
  69333. lengthSquared(): number;
  69334. /**
  69335. * Normalize the vector
  69336. * @returns the current updated Vector2
  69337. */
  69338. normalize(): Vector2;
  69339. /**
  69340. * Gets a new Vector2 copied from the Vector2
  69341. * @returns a new Vector2
  69342. */
  69343. clone(): Vector2;
  69344. /**
  69345. * Gets a new Vector2(0, 0)
  69346. * @returns a new Vector2
  69347. */
  69348. static Zero(): Vector2;
  69349. /**
  69350. * Gets a new Vector2(1, 1)
  69351. * @returns a new Vector2
  69352. */
  69353. static One(): Vector2;
  69354. /**
  69355. * Gets a new Vector2 set from the given index element of the given array
  69356. * @param array defines the data source
  69357. * @param offset defines the offset in the data source
  69358. * @returns a new Vector2
  69359. */
  69360. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69361. /**
  69362. * Sets "result" from the given index element of the given array
  69363. * @param array defines the data source
  69364. * @param offset defines the offset in the data source
  69365. * @param result defines the target vector
  69366. */
  69367. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69368. /**
  69369. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69370. * @param value1 defines 1st point of control
  69371. * @param value2 defines 2nd point of control
  69372. * @param value3 defines 3rd point of control
  69373. * @param value4 defines 4th point of control
  69374. * @param amount defines the interpolation factor
  69375. * @returns a new Vector2
  69376. */
  69377. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69378. /**
  69379. * 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".
  69380. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69381. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69382. * @param value defines the value to clamp
  69383. * @param min defines the lower limit
  69384. * @param max defines the upper limit
  69385. * @returns a new Vector2
  69386. */
  69387. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69388. /**
  69389. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69390. * @param value1 defines the 1st control point
  69391. * @param tangent1 defines the outgoing tangent
  69392. * @param value2 defines the 2nd control point
  69393. * @param tangent2 defines the incoming tangent
  69394. * @param amount defines the interpolation factor
  69395. * @returns a new Vector2
  69396. */
  69397. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69398. /**
  69399. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69400. * @param start defines the start vector
  69401. * @param end defines the end vector
  69402. * @param amount defines the interpolation factor
  69403. * @returns a new Vector2
  69404. */
  69405. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69406. /**
  69407. * Gets the dot product of the vector "left" and the vector "right"
  69408. * @param left defines first vector
  69409. * @param right defines second vector
  69410. * @returns the dot product (float)
  69411. */
  69412. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69413. /**
  69414. * Returns a new Vector2 equal to the normalized given vector
  69415. * @param vector defines the vector to normalize
  69416. * @returns a new Vector2
  69417. */
  69418. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69419. /**
  69420. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69421. * @param left defines 1st vector
  69422. * @param right defines 2nd vector
  69423. * @returns a new Vector2
  69424. */
  69425. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69426. /**
  69427. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69428. * @param left defines 1st vector
  69429. * @param right defines 2nd vector
  69430. * @returns a new Vector2
  69431. */
  69432. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69433. /**
  69434. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69435. * @param vector defines the vector to transform
  69436. * @param transformation defines the matrix to apply
  69437. * @returns a new Vector2
  69438. */
  69439. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69440. /**
  69441. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69442. * @param vector defines the vector to transform
  69443. * @param transformation defines the matrix to apply
  69444. * @param result defines the target vector
  69445. */
  69446. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69447. /**
  69448. * Determines if a given vector is included in a triangle
  69449. * @param p defines the vector to test
  69450. * @param p0 defines 1st triangle point
  69451. * @param p1 defines 2nd triangle point
  69452. * @param p2 defines 3rd triangle point
  69453. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69454. */
  69455. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69456. /**
  69457. * Gets the distance between the vectors "value1" and "value2"
  69458. * @param value1 defines first vector
  69459. * @param value2 defines second vector
  69460. * @returns the distance between vectors
  69461. */
  69462. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69463. /**
  69464. * Returns the squared distance between the vectors "value1" and "value2"
  69465. * @param value1 defines first vector
  69466. * @param value2 defines second vector
  69467. * @returns the squared distance between vectors
  69468. */
  69469. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69470. /**
  69471. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69472. * @param value1 defines first vector
  69473. * @param value2 defines second vector
  69474. * @returns a new Vector2
  69475. */
  69476. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69477. /**
  69478. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69479. * @param p defines the middle point
  69480. * @param segA defines one point of the segment
  69481. * @param segB defines the other point of the segment
  69482. * @returns the shortest distance
  69483. */
  69484. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69485. }
  69486. /**
  69487. * Classed used to store (x,y,z) vector representation
  69488. * A Vector3 is the main object used in 3D geometry
  69489. * It can represent etiher the coordinates of a point the space, either a direction
  69490. * Reminder: js uses a left handed forward facing system
  69491. */
  69492. export class Vector3 {
  69493. /**
  69494. * Defines the first coordinates (on X axis)
  69495. */
  69496. x: number;
  69497. /**
  69498. * Defines the second coordinates (on Y axis)
  69499. */
  69500. y: number;
  69501. /**
  69502. * Defines the third coordinates (on Z axis)
  69503. */
  69504. z: number;
  69505. private static _UpReadOnly;
  69506. private static _ZeroReadOnly;
  69507. /**
  69508. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69509. * @param x defines the first coordinates (on X axis)
  69510. * @param y defines the second coordinates (on Y axis)
  69511. * @param z defines the third coordinates (on Z axis)
  69512. */
  69513. constructor(
  69514. /**
  69515. * Defines the first coordinates (on X axis)
  69516. */
  69517. x?: number,
  69518. /**
  69519. * Defines the second coordinates (on Y axis)
  69520. */
  69521. y?: number,
  69522. /**
  69523. * Defines the third coordinates (on Z axis)
  69524. */
  69525. z?: number);
  69526. /**
  69527. * Creates a string representation of the Vector3
  69528. * @returns a string with the Vector3 coordinates.
  69529. */
  69530. toString(): string;
  69531. /**
  69532. * Gets the class name
  69533. * @returns the string "Vector3"
  69534. */
  69535. getClassName(): string;
  69536. /**
  69537. * Creates the Vector3 hash code
  69538. * @returns a number which tends to be unique between Vector3 instances
  69539. */
  69540. getHashCode(): number;
  69541. /**
  69542. * Creates an array containing three elements : the coordinates of the Vector3
  69543. * @returns a new array of numbers
  69544. */
  69545. asArray(): number[];
  69546. /**
  69547. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69548. * @param array defines the destination array
  69549. * @param index defines the offset in the destination array
  69550. * @returns the current Vector3
  69551. */
  69552. toArray(array: FloatArray, index?: number): Vector3;
  69553. /**
  69554. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69555. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69556. */
  69557. toQuaternion(): Quaternion;
  69558. /**
  69559. * Adds the given vector to the current Vector3
  69560. * @param otherVector defines the second operand
  69561. * @returns the current updated Vector3
  69562. */
  69563. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69564. /**
  69565. * Adds the given coordinates to the current Vector3
  69566. * @param x defines the x coordinate of the operand
  69567. * @param y defines the y coordinate of the operand
  69568. * @param z defines the z coordinate of the operand
  69569. * @returns the current updated Vector3
  69570. */
  69571. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69572. /**
  69573. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69574. * @param otherVector defines the second operand
  69575. * @returns the resulting Vector3
  69576. */
  69577. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69578. /**
  69579. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69580. * @param otherVector defines the second operand
  69581. * @param result defines the Vector3 object where to store the result
  69582. * @returns the current Vector3
  69583. */
  69584. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69585. /**
  69586. * Subtract the given vector from the current Vector3
  69587. * @param otherVector defines the second operand
  69588. * @returns the current updated Vector3
  69589. */
  69590. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69591. /**
  69592. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69593. * @param otherVector defines the second operand
  69594. * @returns the resulting Vector3
  69595. */
  69596. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69597. /**
  69598. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69599. * @param otherVector defines the second operand
  69600. * @param result defines the Vector3 object where to store the result
  69601. * @returns the current Vector3
  69602. */
  69603. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69604. /**
  69605. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69606. * @param x defines the x coordinate of the operand
  69607. * @param y defines the y coordinate of the operand
  69608. * @param z defines the z coordinate of the operand
  69609. * @returns the resulting Vector3
  69610. */
  69611. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69612. /**
  69613. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69614. * @param x defines the x coordinate of the operand
  69615. * @param y defines the y coordinate of the operand
  69616. * @param z defines the z coordinate of the operand
  69617. * @param result defines the Vector3 object where to store the result
  69618. * @returns the current Vector3
  69619. */
  69620. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69621. /**
  69622. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69623. * @returns a new Vector3
  69624. */
  69625. negate(): Vector3;
  69626. /**
  69627. * Multiplies the Vector3 coordinates by the float "scale"
  69628. * @param scale defines the multiplier factor
  69629. * @returns the current updated Vector3
  69630. */
  69631. scaleInPlace(scale: number): Vector3;
  69632. /**
  69633. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69634. * @param scale defines the multiplier factor
  69635. * @returns a new Vector3
  69636. */
  69637. scale(scale: number): Vector3;
  69638. /**
  69639. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69640. * @param scale defines the multiplier factor
  69641. * @param result defines the Vector3 object where to store the result
  69642. * @returns the current Vector3
  69643. */
  69644. scaleToRef(scale: number, result: Vector3): Vector3;
  69645. /**
  69646. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69647. * @param scale defines the scale factor
  69648. * @param result defines the Vector3 object where to store the result
  69649. * @returns the unmodified current Vector3
  69650. */
  69651. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69652. /**
  69653. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69654. * @param otherVector defines the second operand
  69655. * @returns true if both vectors are equals
  69656. */
  69657. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69658. /**
  69659. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69660. * @param otherVector defines the second operand
  69661. * @param epsilon defines the minimal distance to define values as equals
  69662. * @returns true if both vectors are distant less than epsilon
  69663. */
  69664. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69665. /**
  69666. * Returns true if the current Vector3 coordinates equals the given floats
  69667. * @param x defines the x coordinate of the operand
  69668. * @param y defines the y coordinate of the operand
  69669. * @param z defines the z coordinate of the operand
  69670. * @returns true if both vectors are equals
  69671. */
  69672. equalsToFloats(x: number, y: number, z: number): boolean;
  69673. /**
  69674. * Multiplies the current Vector3 coordinates by the given ones
  69675. * @param otherVector defines the second operand
  69676. * @returns the current updated Vector3
  69677. */
  69678. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69679. /**
  69680. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69681. * @param otherVector defines the second operand
  69682. * @returns the new Vector3
  69683. */
  69684. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69685. /**
  69686. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69687. * @param otherVector defines the second operand
  69688. * @param result defines the Vector3 object where to store the result
  69689. * @returns the current Vector3
  69690. */
  69691. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69692. /**
  69693. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69694. * @param x defines the x coordinate of the operand
  69695. * @param y defines the y coordinate of the operand
  69696. * @param z defines the z coordinate of the operand
  69697. * @returns the new Vector3
  69698. */
  69699. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69700. /**
  69701. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69702. * @param otherVector defines the second operand
  69703. * @returns the new Vector3
  69704. */
  69705. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69706. /**
  69707. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69708. * @param otherVector defines the second operand
  69709. * @param result defines the Vector3 object where to store the result
  69710. * @returns the current Vector3
  69711. */
  69712. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69713. /**
  69714. * Divides the current Vector3 coordinates by the given ones.
  69715. * @param otherVector defines the second operand
  69716. * @returns the current updated Vector3
  69717. */
  69718. divideInPlace(otherVector: Vector3): Vector3;
  69719. /**
  69720. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69721. * @param other defines the second operand
  69722. * @returns the current updated Vector3
  69723. */
  69724. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69725. /**
  69726. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69727. * @param other defines the second operand
  69728. * @returns the current updated Vector3
  69729. */
  69730. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69731. /**
  69732. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69733. * @param x defines the x coordinate of the operand
  69734. * @param y defines the y coordinate of the operand
  69735. * @param z defines the z coordinate of the operand
  69736. * @returns the current updated Vector3
  69737. */
  69738. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69739. /**
  69740. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69741. * @param x defines the x coordinate of the operand
  69742. * @param y defines the y coordinate of the operand
  69743. * @param z defines the z coordinate of the operand
  69744. * @returns the current updated Vector3
  69745. */
  69746. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69747. /**
  69748. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69749. * Check if is non uniform within a certain amount of decimal places to account for this
  69750. * @param epsilon the amount the values can differ
  69751. * @returns if the the vector is non uniform to a certain number of decimal places
  69752. */
  69753. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69754. /**
  69755. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69756. */
  69757. readonly isNonUniform: boolean;
  69758. /**
  69759. * Gets a new Vector3 from current Vector3 floored values
  69760. * @returns a new Vector3
  69761. */
  69762. floor(): Vector3;
  69763. /**
  69764. * Gets a new Vector3 from current Vector3 floored values
  69765. * @returns a new Vector3
  69766. */
  69767. fract(): Vector3;
  69768. /**
  69769. * Gets the length of the Vector3
  69770. * @returns the length of the Vector3
  69771. */
  69772. length(): number;
  69773. /**
  69774. * Gets the squared length of the Vector3
  69775. * @returns squared length of the Vector3
  69776. */
  69777. lengthSquared(): number;
  69778. /**
  69779. * Normalize the current Vector3.
  69780. * Please note that this is an in place operation.
  69781. * @returns the current updated Vector3
  69782. */
  69783. normalize(): Vector3;
  69784. /**
  69785. * Reorders the x y z properties of the vector in place
  69786. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69787. * @returns the current updated vector
  69788. */
  69789. reorderInPlace(order: string): this;
  69790. /**
  69791. * Rotates the vector around 0,0,0 by a quaternion
  69792. * @param quaternion the rotation quaternion
  69793. * @param result vector to store the result
  69794. * @returns the resulting vector
  69795. */
  69796. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69797. /**
  69798. * Rotates a vector around a given point
  69799. * @param quaternion the rotation quaternion
  69800. * @param point the point to rotate around
  69801. * @param result vector to store the result
  69802. * @returns the resulting vector
  69803. */
  69804. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69805. /**
  69806. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69807. * The cross product is then orthogonal to both current and "other"
  69808. * @param other defines the right operand
  69809. * @returns the cross product
  69810. */
  69811. cross(other: Vector3): Vector3;
  69812. /**
  69813. * Normalize the current Vector3 with the given input length.
  69814. * Please note that this is an in place operation.
  69815. * @param len the length of the vector
  69816. * @returns the current updated Vector3
  69817. */
  69818. normalizeFromLength(len: number): Vector3;
  69819. /**
  69820. * Normalize the current Vector3 to a new vector
  69821. * @returns the new Vector3
  69822. */
  69823. normalizeToNew(): Vector3;
  69824. /**
  69825. * Normalize the current Vector3 to the reference
  69826. * @param reference define the Vector3 to update
  69827. * @returns the updated Vector3
  69828. */
  69829. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69830. /**
  69831. * Creates a new Vector3 copied from the current Vector3
  69832. * @returns the new Vector3
  69833. */
  69834. clone(): Vector3;
  69835. /**
  69836. * Copies the given vector coordinates to the current Vector3 ones
  69837. * @param source defines the source Vector3
  69838. * @returns the current updated Vector3
  69839. */
  69840. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69841. /**
  69842. * Copies the given floats to the current Vector3 coordinates
  69843. * @param x defines the x coordinate of the operand
  69844. * @param y defines the y coordinate of the operand
  69845. * @param z defines the z coordinate of the operand
  69846. * @returns the current updated Vector3
  69847. */
  69848. copyFromFloats(x: number, y: number, z: number): Vector3;
  69849. /**
  69850. * Copies the given floats to the current Vector3 coordinates
  69851. * @param x defines the x coordinate of the operand
  69852. * @param y defines the y coordinate of the operand
  69853. * @param z defines the z coordinate of the operand
  69854. * @returns the current updated Vector3
  69855. */
  69856. set(x: number, y: number, z: number): Vector3;
  69857. /**
  69858. * Copies the given float to the current Vector3 coordinates
  69859. * @param v defines the x, y and z coordinates of the operand
  69860. * @returns the current updated Vector3
  69861. */
  69862. setAll(v: number): Vector3;
  69863. /**
  69864. * Get the clip factor between two vectors
  69865. * @param vector0 defines the first operand
  69866. * @param vector1 defines the second operand
  69867. * @param axis defines the axis to use
  69868. * @param size defines the size along the axis
  69869. * @returns the clip factor
  69870. */
  69871. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69872. /**
  69873. * Get angle between two vectors
  69874. * @param vector0 angle between vector0 and vector1
  69875. * @param vector1 angle between vector0 and vector1
  69876. * @param normal direction of the normal
  69877. * @return the angle between vector0 and vector1
  69878. */
  69879. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69880. /**
  69881. * Returns a new Vector3 set from the index "offset" of the given array
  69882. * @param array defines the source array
  69883. * @param offset defines the offset in the source array
  69884. * @returns the new Vector3
  69885. */
  69886. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69887. /**
  69888. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69889. * This function is deprecated. Use FromArray instead
  69890. * @param array defines the source array
  69891. * @param offset defines the offset in the source array
  69892. * @returns the new Vector3
  69893. */
  69894. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69895. /**
  69896. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69897. * @param array defines the source array
  69898. * @param offset defines the offset in the source array
  69899. * @param result defines the Vector3 where to store the result
  69900. */
  69901. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69902. /**
  69903. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69904. * This function is deprecated. Use FromArrayToRef instead.
  69905. * @param array defines the source array
  69906. * @param offset defines the offset in the source array
  69907. * @param result defines the Vector3 where to store the result
  69908. */
  69909. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69910. /**
  69911. * Sets the given vector "result" with the given floats.
  69912. * @param x defines the x coordinate of the source
  69913. * @param y defines the y coordinate of the source
  69914. * @param z defines the z coordinate of the source
  69915. * @param result defines the Vector3 where to store the result
  69916. */
  69917. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69918. /**
  69919. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69920. * @returns a new empty Vector3
  69921. */
  69922. static Zero(): Vector3;
  69923. /**
  69924. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69925. * @returns a new unit Vector3
  69926. */
  69927. static One(): Vector3;
  69928. /**
  69929. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69930. * @returns a new up Vector3
  69931. */
  69932. static Up(): Vector3;
  69933. /**
  69934. * Gets a up Vector3 that must not be updated
  69935. */
  69936. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69937. /**
  69938. * Gets a zero Vector3 that must not be updated
  69939. */
  69940. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69941. /**
  69942. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69943. * @returns a new down Vector3
  69944. */
  69945. static Down(): Vector3;
  69946. /**
  69947. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69948. * @returns a new forward Vector3
  69949. */
  69950. static Forward(): Vector3;
  69951. /**
  69952. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69953. * @returns a new forward Vector3
  69954. */
  69955. static Backward(): Vector3;
  69956. /**
  69957. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69958. * @returns a new right Vector3
  69959. */
  69960. static Right(): Vector3;
  69961. /**
  69962. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69963. * @returns a new left Vector3
  69964. */
  69965. static Left(): Vector3;
  69966. /**
  69967. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69968. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69969. * @param vector defines the Vector3 to transform
  69970. * @param transformation defines the transformation matrix
  69971. * @returns the transformed Vector3
  69972. */
  69973. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69974. /**
  69975. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69976. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69977. * @param vector defines the Vector3 to transform
  69978. * @param transformation defines the transformation matrix
  69979. * @param result defines the Vector3 where to store the result
  69980. */
  69981. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69982. /**
  69983. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69984. * This method computes tranformed coordinates only, not transformed direction vectors
  69985. * @param x define the x coordinate of the source vector
  69986. * @param y define the y coordinate of the source vector
  69987. * @param z define the z coordinate of the source vector
  69988. * @param transformation defines the transformation matrix
  69989. * @param result defines the Vector3 where to store the result
  69990. */
  69991. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69992. /**
  69993. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69995. * @param vector defines the Vector3 to transform
  69996. * @param transformation defines the transformation matrix
  69997. * @returns the new Vector3
  69998. */
  69999. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70000. /**
  70001. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70002. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70003. * @param vector defines the Vector3 to transform
  70004. * @param transformation defines the transformation matrix
  70005. * @param result defines the Vector3 where to store the result
  70006. */
  70007. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70008. /**
  70009. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70010. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70011. * @param x define the x coordinate of the source vector
  70012. * @param y define the y coordinate of the source vector
  70013. * @param z define the z coordinate of the source vector
  70014. * @param transformation defines the transformation matrix
  70015. * @param result defines the Vector3 where to store the result
  70016. */
  70017. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70018. /**
  70019. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70020. * @param value1 defines the first control point
  70021. * @param value2 defines the second control point
  70022. * @param value3 defines the third control point
  70023. * @param value4 defines the fourth control point
  70024. * @param amount defines the amount on the spline to use
  70025. * @returns the new Vector3
  70026. */
  70027. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70028. /**
  70029. * 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"
  70030. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70031. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70032. * @param value defines the current value
  70033. * @param min defines the lower range value
  70034. * @param max defines the upper range value
  70035. * @returns the new Vector3
  70036. */
  70037. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70038. /**
  70039. * 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"
  70040. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70041. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70042. * @param value defines the current value
  70043. * @param min defines the lower range value
  70044. * @param max defines the upper range value
  70045. * @param result defines the Vector3 where to store the result
  70046. */
  70047. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70048. /**
  70049. * Checks if a given vector is inside a specific range
  70050. * @param v defines the vector to test
  70051. * @param min defines the minimum range
  70052. * @param max defines the maximum range
  70053. */
  70054. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70055. /**
  70056. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70057. * @param value1 defines the first control point
  70058. * @param tangent1 defines the first tangent vector
  70059. * @param value2 defines the second control point
  70060. * @param tangent2 defines the second tangent vector
  70061. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70062. * @returns the new Vector3
  70063. */
  70064. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70065. /**
  70066. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70067. * @param start defines the start value
  70068. * @param end defines the end value
  70069. * @param amount max defines amount between both (between 0 and 1)
  70070. * @returns the new Vector3
  70071. */
  70072. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70073. /**
  70074. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70075. * @param start defines the start value
  70076. * @param end defines the end value
  70077. * @param amount max defines amount between both (between 0 and 1)
  70078. * @param result defines the Vector3 where to store the result
  70079. */
  70080. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70081. /**
  70082. * Returns the dot product (float) between the vectors "left" and "right"
  70083. * @param left defines the left operand
  70084. * @param right defines the right operand
  70085. * @returns the dot product
  70086. */
  70087. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70088. /**
  70089. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70090. * The cross product is then orthogonal to both "left" and "right"
  70091. * @param left defines the left operand
  70092. * @param right defines the right operand
  70093. * @returns the cross product
  70094. */
  70095. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70096. /**
  70097. * Sets the given vector "result" with the cross product of "left" and "right"
  70098. * The cross product is then orthogonal to both "left" and "right"
  70099. * @param left defines the left operand
  70100. * @param right defines the right operand
  70101. * @param result defines the Vector3 where to store the result
  70102. */
  70103. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70104. /**
  70105. * Returns a new Vector3 as the normalization of the given vector
  70106. * @param vector defines the Vector3 to normalize
  70107. * @returns the new Vector3
  70108. */
  70109. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70110. /**
  70111. * Sets the given vector "result" with the normalization of the given first vector
  70112. * @param vector defines the Vector3 to normalize
  70113. * @param result defines the Vector3 where to store the result
  70114. */
  70115. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70116. /**
  70117. * Project a Vector3 onto screen space
  70118. * @param vector defines the Vector3 to project
  70119. * @param world defines the world matrix to use
  70120. * @param transform defines the transform (view x projection) matrix to use
  70121. * @param viewport defines the screen viewport to use
  70122. * @returns the new Vector3
  70123. */
  70124. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70125. /** @hidden */
  70126. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70127. /**
  70128. * Unproject from screen space to object space
  70129. * @param source defines the screen space Vector3 to use
  70130. * @param viewportWidth defines the current width of the viewport
  70131. * @param viewportHeight defines the current height of the viewport
  70132. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70133. * @param transform defines the transform (view x projection) matrix to use
  70134. * @returns the new Vector3
  70135. */
  70136. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70137. /**
  70138. * Unproject from screen space to object space
  70139. * @param source defines the screen space Vector3 to use
  70140. * @param viewportWidth defines the current width of the viewport
  70141. * @param viewportHeight defines the current height of the viewport
  70142. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70143. * @param view defines the view matrix to use
  70144. * @param projection defines the projection matrix to use
  70145. * @returns the new Vector3
  70146. */
  70147. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70148. /**
  70149. * Unproject from screen space to object space
  70150. * @param source defines the screen space Vector3 to use
  70151. * @param viewportWidth defines the current width of the viewport
  70152. * @param viewportHeight defines the current height of the viewport
  70153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70154. * @param view defines the view matrix to use
  70155. * @param projection defines the projection matrix to use
  70156. * @param result defines the Vector3 where to store the result
  70157. */
  70158. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70159. /**
  70160. * Unproject from screen space to object space
  70161. * @param sourceX defines the screen space x coordinate to use
  70162. * @param sourceY defines the screen space y coordinate to use
  70163. * @param sourceZ defines the screen space z coordinate to use
  70164. * @param viewportWidth defines the current width of the viewport
  70165. * @param viewportHeight defines the current height of the viewport
  70166. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70167. * @param view defines the view matrix to use
  70168. * @param projection defines the projection matrix to use
  70169. * @param result defines the Vector3 where to store the result
  70170. */
  70171. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70172. /**
  70173. * Gets the minimal coordinate values between two Vector3
  70174. * @param left defines the first operand
  70175. * @param right defines the second operand
  70176. * @returns the new Vector3
  70177. */
  70178. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70179. /**
  70180. * Gets the maximal coordinate values between two Vector3
  70181. * @param left defines the first operand
  70182. * @param right defines the second operand
  70183. * @returns the new Vector3
  70184. */
  70185. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70186. /**
  70187. * Returns the distance between the vectors "value1" and "value2"
  70188. * @param value1 defines the first operand
  70189. * @param value2 defines the second operand
  70190. * @returns the distance
  70191. */
  70192. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70193. /**
  70194. * Returns the squared distance between the vectors "value1" and "value2"
  70195. * @param value1 defines the first operand
  70196. * @param value2 defines the second operand
  70197. * @returns the squared distance
  70198. */
  70199. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70200. /**
  70201. * Returns a new Vector3 located at the center between "value1" and "value2"
  70202. * @param value1 defines the first operand
  70203. * @param value2 defines the second operand
  70204. * @returns the new Vector3
  70205. */
  70206. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70207. /**
  70208. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70209. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70210. * to something in order to rotate it from its local system to the given target system
  70211. * Note: axis1, axis2 and axis3 are normalized during this operation
  70212. * @param axis1 defines the first axis
  70213. * @param axis2 defines the second axis
  70214. * @param axis3 defines the third axis
  70215. * @returns a new Vector3
  70216. */
  70217. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70218. /**
  70219. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70220. * @param axis1 defines the first axis
  70221. * @param axis2 defines the second axis
  70222. * @param axis3 defines the third axis
  70223. * @param ref defines the Vector3 where to store the result
  70224. */
  70225. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70226. }
  70227. /**
  70228. * Vector4 class created for EulerAngle class conversion to Quaternion
  70229. */
  70230. export class Vector4 {
  70231. /** x value of the vector */
  70232. x: number;
  70233. /** y value of the vector */
  70234. y: number;
  70235. /** z value of the vector */
  70236. z: number;
  70237. /** w value of the vector */
  70238. w: number;
  70239. /**
  70240. * Creates a Vector4 object from the given floats.
  70241. * @param x x value of the vector
  70242. * @param y y value of the vector
  70243. * @param z z value of the vector
  70244. * @param w w value of the vector
  70245. */
  70246. constructor(
  70247. /** x value of the vector */
  70248. x: number,
  70249. /** y value of the vector */
  70250. y: number,
  70251. /** z value of the vector */
  70252. z: number,
  70253. /** w value of the vector */
  70254. w: number);
  70255. /**
  70256. * Returns the string with the Vector4 coordinates.
  70257. * @returns a string containing all the vector values
  70258. */
  70259. toString(): string;
  70260. /**
  70261. * Returns the string "Vector4".
  70262. * @returns "Vector4"
  70263. */
  70264. getClassName(): string;
  70265. /**
  70266. * Returns the Vector4 hash code.
  70267. * @returns a unique hash code
  70268. */
  70269. getHashCode(): number;
  70270. /**
  70271. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70272. * @returns the resulting array
  70273. */
  70274. asArray(): number[];
  70275. /**
  70276. * Populates the given array from the given index with the Vector4 coordinates.
  70277. * @param array array to populate
  70278. * @param index index of the array to start at (default: 0)
  70279. * @returns the Vector4.
  70280. */
  70281. toArray(array: FloatArray, index?: number): Vector4;
  70282. /**
  70283. * Adds the given vector to the current Vector4.
  70284. * @param otherVector the vector to add
  70285. * @returns the updated Vector4.
  70286. */
  70287. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70288. /**
  70289. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70290. * @param otherVector the vector to add
  70291. * @returns the resulting vector
  70292. */
  70293. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70294. /**
  70295. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70296. * @param otherVector the vector to add
  70297. * @param result the vector to store the result
  70298. * @returns the current Vector4.
  70299. */
  70300. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70301. /**
  70302. * Subtract in place the given vector from the current Vector4.
  70303. * @param otherVector the vector to subtract
  70304. * @returns the updated Vector4.
  70305. */
  70306. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70307. /**
  70308. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70309. * @param otherVector the vector to add
  70310. * @returns the new vector with the result
  70311. */
  70312. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70313. /**
  70314. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70315. * @param otherVector the vector to subtract
  70316. * @param result the vector to store the result
  70317. * @returns the current Vector4.
  70318. */
  70319. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70320. /**
  70321. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70322. */
  70323. /**
  70324. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70325. * @param x value to subtract
  70326. * @param y value to subtract
  70327. * @param z value to subtract
  70328. * @param w value to subtract
  70329. * @returns new vector containing the result
  70330. */
  70331. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70332. /**
  70333. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70334. * @param x value to subtract
  70335. * @param y value to subtract
  70336. * @param z value to subtract
  70337. * @param w value to subtract
  70338. * @param result the vector to store the result in
  70339. * @returns the current Vector4.
  70340. */
  70341. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70342. /**
  70343. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70344. * @returns a new vector with the negated values
  70345. */
  70346. negate(): Vector4;
  70347. /**
  70348. * Multiplies the current Vector4 coordinates by scale (float).
  70349. * @param scale the number to scale with
  70350. * @returns the updated Vector4.
  70351. */
  70352. scaleInPlace(scale: number): Vector4;
  70353. /**
  70354. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70355. * @param scale the number to scale with
  70356. * @returns a new vector with the result
  70357. */
  70358. scale(scale: number): Vector4;
  70359. /**
  70360. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70361. * @param scale the number to scale with
  70362. * @param result a vector to store the result in
  70363. * @returns the current Vector4.
  70364. */
  70365. scaleToRef(scale: number, result: Vector4): Vector4;
  70366. /**
  70367. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70368. * @param scale defines the scale factor
  70369. * @param result defines the Vector4 object where to store the result
  70370. * @returns the unmodified current Vector4
  70371. */
  70372. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70373. /**
  70374. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70375. * @param otherVector the vector to compare against
  70376. * @returns true if they are equal
  70377. */
  70378. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70379. /**
  70380. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70381. * @param otherVector vector to compare against
  70382. * @param epsilon (Default: very small number)
  70383. * @returns true if they are equal
  70384. */
  70385. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70386. /**
  70387. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70388. * @param x x value to compare against
  70389. * @param y y value to compare against
  70390. * @param z z value to compare against
  70391. * @param w w value to compare against
  70392. * @returns true if equal
  70393. */
  70394. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70395. /**
  70396. * Multiplies in place the current Vector4 by the given one.
  70397. * @param otherVector vector to multiple with
  70398. * @returns the updated Vector4.
  70399. */
  70400. multiplyInPlace(otherVector: Vector4): Vector4;
  70401. /**
  70402. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70403. * @param otherVector vector to multiple with
  70404. * @returns resulting new vector
  70405. */
  70406. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70407. /**
  70408. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70409. * @param otherVector vector to multiple with
  70410. * @param result vector to store the result
  70411. * @returns the current Vector4.
  70412. */
  70413. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70414. /**
  70415. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70416. * @param x x value multiply with
  70417. * @param y y value multiply with
  70418. * @param z z value multiply with
  70419. * @param w w value multiply with
  70420. * @returns resulting new vector
  70421. */
  70422. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70423. /**
  70424. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70425. * @param otherVector vector to devide with
  70426. * @returns resulting new vector
  70427. */
  70428. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70429. /**
  70430. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70431. * @param otherVector vector to devide with
  70432. * @param result vector to store the result
  70433. * @returns the current Vector4.
  70434. */
  70435. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70436. /**
  70437. * Divides the current Vector3 coordinates by the given ones.
  70438. * @param otherVector vector to devide with
  70439. * @returns the updated Vector3.
  70440. */
  70441. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70442. /**
  70443. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70444. * @param other defines the second operand
  70445. * @returns the current updated Vector4
  70446. */
  70447. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70448. /**
  70449. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70450. * @param other defines the second operand
  70451. * @returns the current updated Vector4
  70452. */
  70453. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70454. /**
  70455. * Gets a new Vector4 from current Vector4 floored values
  70456. * @returns a new Vector4
  70457. */
  70458. floor(): Vector4;
  70459. /**
  70460. * Gets a new Vector4 from current Vector3 floored values
  70461. * @returns a new Vector4
  70462. */
  70463. fract(): Vector4;
  70464. /**
  70465. * Returns the Vector4 length (float).
  70466. * @returns the length
  70467. */
  70468. length(): number;
  70469. /**
  70470. * Returns the Vector4 squared length (float).
  70471. * @returns the length squared
  70472. */
  70473. lengthSquared(): number;
  70474. /**
  70475. * Normalizes in place the Vector4.
  70476. * @returns the updated Vector4.
  70477. */
  70478. normalize(): Vector4;
  70479. /**
  70480. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70481. * @returns this converted to a new vector3
  70482. */
  70483. toVector3(): Vector3;
  70484. /**
  70485. * Returns a new Vector4 copied from the current one.
  70486. * @returns the new cloned vector
  70487. */
  70488. clone(): Vector4;
  70489. /**
  70490. * Updates the current Vector4 with the given one coordinates.
  70491. * @param source the source vector to copy from
  70492. * @returns the updated Vector4.
  70493. */
  70494. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70495. /**
  70496. * Updates the current Vector4 coordinates with the given floats.
  70497. * @param x float to copy from
  70498. * @param y float to copy from
  70499. * @param z float to copy from
  70500. * @param w float to copy from
  70501. * @returns the updated Vector4.
  70502. */
  70503. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70504. /**
  70505. * Updates the current Vector4 coordinates with the given floats.
  70506. * @param x float to set from
  70507. * @param y float to set from
  70508. * @param z float to set from
  70509. * @param w float to set from
  70510. * @returns the updated Vector4.
  70511. */
  70512. set(x: number, y: number, z: number, w: number): Vector4;
  70513. /**
  70514. * Copies the given float to the current Vector3 coordinates
  70515. * @param v defines the x, y, z and w coordinates of the operand
  70516. * @returns the current updated Vector3
  70517. */
  70518. setAll(v: number): Vector4;
  70519. /**
  70520. * Returns a new Vector4 set from the starting index of the given array.
  70521. * @param array the array to pull values from
  70522. * @param offset the offset into the array to start at
  70523. * @returns the new vector
  70524. */
  70525. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70526. /**
  70527. * Updates the given vector "result" from the starting index of the given array.
  70528. * @param array the array to pull values from
  70529. * @param offset the offset into the array to start at
  70530. * @param result the vector to store the result in
  70531. */
  70532. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70533. /**
  70534. * Updates the given vector "result" from the starting index of the given Float32Array.
  70535. * @param array the array to pull values from
  70536. * @param offset the offset into the array to start at
  70537. * @param result the vector to store the result in
  70538. */
  70539. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70540. /**
  70541. * Updates the given vector "result" coordinates from the given floats.
  70542. * @param x float to set from
  70543. * @param y float to set from
  70544. * @param z float to set from
  70545. * @param w float to set from
  70546. * @param result the vector to the floats in
  70547. */
  70548. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70549. /**
  70550. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70551. * @returns the new vector
  70552. */
  70553. static Zero(): Vector4;
  70554. /**
  70555. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70556. * @returns the new vector
  70557. */
  70558. static One(): Vector4;
  70559. /**
  70560. * Returns a new normalized Vector4 from the given one.
  70561. * @param vector the vector to normalize
  70562. * @returns the vector
  70563. */
  70564. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70565. /**
  70566. * Updates the given vector "result" from the normalization of the given one.
  70567. * @param vector the vector to normalize
  70568. * @param result the vector to store the result in
  70569. */
  70570. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70571. /**
  70572. * Returns a vector with the minimum values from the left and right vectors
  70573. * @param left left vector to minimize
  70574. * @param right right vector to minimize
  70575. * @returns a new vector with the minimum of the left and right vector values
  70576. */
  70577. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70578. /**
  70579. * Returns a vector with the maximum values from the left and right vectors
  70580. * @param left left vector to maximize
  70581. * @param right right vector to maximize
  70582. * @returns a new vector with the maximum of the left and right vector values
  70583. */
  70584. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70585. /**
  70586. * Returns the distance (float) between the vectors "value1" and "value2".
  70587. * @param value1 value to calulate the distance between
  70588. * @param value2 value to calulate the distance between
  70589. * @return the distance between the two vectors
  70590. */
  70591. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70592. /**
  70593. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70594. * @param value1 value to calulate the distance between
  70595. * @param value2 value to calulate the distance between
  70596. * @return the distance between the two vectors squared
  70597. */
  70598. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70599. /**
  70600. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70601. * @param value1 value to calulate the center between
  70602. * @param value2 value to calulate the center between
  70603. * @return the center between the two vectors
  70604. */
  70605. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70606. /**
  70607. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70608. * This methods computes transformed normalized direction vectors only.
  70609. * @param vector the vector to transform
  70610. * @param transformation the transformation matrix to apply
  70611. * @returns the new vector
  70612. */
  70613. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70614. /**
  70615. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70616. * This methods computes transformed normalized direction vectors only.
  70617. * @param vector the vector to transform
  70618. * @param transformation the transformation matrix to apply
  70619. * @param result the vector to store the result in
  70620. */
  70621. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70622. /**
  70623. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70624. * This methods computes transformed normalized direction vectors only.
  70625. * @param x value to transform
  70626. * @param y value to transform
  70627. * @param z value to transform
  70628. * @param w value to transform
  70629. * @param transformation the transformation matrix to apply
  70630. * @param result the vector to store the results in
  70631. */
  70632. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70633. /**
  70634. * Creates a new Vector4 from a Vector3
  70635. * @param source defines the source data
  70636. * @param w defines the 4th component (default is 0)
  70637. * @returns a new Vector4
  70638. */
  70639. static FromVector3(source: Vector3, w?: number): Vector4;
  70640. }
  70641. /**
  70642. * Class used to store quaternion data
  70643. * @see https://en.wikipedia.org/wiki/Quaternion
  70644. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70645. */
  70646. export class Quaternion {
  70647. /** defines the first component (0 by default) */
  70648. x: number;
  70649. /** defines the second component (0 by default) */
  70650. y: number;
  70651. /** defines the third component (0 by default) */
  70652. z: number;
  70653. /** defines the fourth component (1.0 by default) */
  70654. w: number;
  70655. /**
  70656. * Creates a new Quaternion from the given floats
  70657. * @param x defines the first component (0 by default)
  70658. * @param y defines the second component (0 by default)
  70659. * @param z defines the third component (0 by default)
  70660. * @param w defines the fourth component (1.0 by default)
  70661. */
  70662. constructor(
  70663. /** defines the first component (0 by default) */
  70664. x?: number,
  70665. /** defines the second component (0 by default) */
  70666. y?: number,
  70667. /** defines the third component (0 by default) */
  70668. z?: number,
  70669. /** defines the fourth component (1.0 by default) */
  70670. w?: number);
  70671. /**
  70672. * Gets a string representation for the current quaternion
  70673. * @returns a string with the Quaternion coordinates
  70674. */
  70675. toString(): string;
  70676. /**
  70677. * Gets the class name of the quaternion
  70678. * @returns the string "Quaternion"
  70679. */
  70680. getClassName(): string;
  70681. /**
  70682. * Gets a hash code for this quaternion
  70683. * @returns the quaternion hash code
  70684. */
  70685. getHashCode(): number;
  70686. /**
  70687. * Copy the quaternion to an array
  70688. * @returns a new array populated with 4 elements from the quaternion coordinates
  70689. */
  70690. asArray(): number[];
  70691. /**
  70692. * Check if two quaternions are equals
  70693. * @param otherQuaternion defines the second operand
  70694. * @return true if the current quaternion and the given one coordinates are strictly equals
  70695. */
  70696. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70697. /**
  70698. * Clone the current quaternion
  70699. * @returns a new quaternion copied from the current one
  70700. */
  70701. clone(): Quaternion;
  70702. /**
  70703. * Copy a quaternion to the current one
  70704. * @param other defines the other quaternion
  70705. * @returns the updated current quaternion
  70706. */
  70707. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70708. /**
  70709. * Updates the current quaternion with the given float coordinates
  70710. * @param x defines the x coordinate
  70711. * @param y defines the y coordinate
  70712. * @param z defines the z coordinate
  70713. * @param w defines the w coordinate
  70714. * @returns the updated current quaternion
  70715. */
  70716. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70717. /**
  70718. * Updates the current quaternion from the given float coordinates
  70719. * @param x defines the x coordinate
  70720. * @param y defines the y coordinate
  70721. * @param z defines the z coordinate
  70722. * @param w defines the w coordinate
  70723. * @returns the updated current quaternion
  70724. */
  70725. set(x: number, y: number, z: number, w: number): Quaternion;
  70726. /**
  70727. * Adds two quaternions
  70728. * @param other defines the second operand
  70729. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70730. */
  70731. add(other: DeepImmutable<Quaternion>): Quaternion;
  70732. /**
  70733. * Add a quaternion to the current one
  70734. * @param other defines the quaternion to add
  70735. * @returns the current quaternion
  70736. */
  70737. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70738. /**
  70739. * Subtract two quaternions
  70740. * @param other defines the second operand
  70741. * @returns a new quaternion as the subtraction result of the given one from the current one
  70742. */
  70743. subtract(other: Quaternion): Quaternion;
  70744. /**
  70745. * Multiplies the current quaternion by a scale factor
  70746. * @param value defines the scale factor
  70747. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70748. */
  70749. scale(value: number): Quaternion;
  70750. /**
  70751. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70752. * @param scale defines the scale factor
  70753. * @param result defines the Quaternion object where to store the result
  70754. * @returns the unmodified current quaternion
  70755. */
  70756. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70757. /**
  70758. * Multiplies in place the current quaternion by a scale factor
  70759. * @param value defines the scale factor
  70760. * @returns the current modified quaternion
  70761. */
  70762. scaleInPlace(value: number): Quaternion;
  70763. /**
  70764. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70765. * @param scale defines the scale factor
  70766. * @param result defines the Quaternion object where to store the result
  70767. * @returns the unmodified current quaternion
  70768. */
  70769. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70770. /**
  70771. * Multiplies two quaternions
  70772. * @param q1 defines the second operand
  70773. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70774. */
  70775. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70776. /**
  70777. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70778. * @param q1 defines the second operand
  70779. * @param result defines the target quaternion
  70780. * @returns the current quaternion
  70781. */
  70782. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70783. /**
  70784. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70785. * @param q1 defines the second operand
  70786. * @returns the currentupdated quaternion
  70787. */
  70788. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70789. /**
  70790. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70791. * @param ref defines the target quaternion
  70792. * @returns the current quaternion
  70793. */
  70794. conjugateToRef(ref: Quaternion): Quaternion;
  70795. /**
  70796. * Conjugates in place (1-q) the current quaternion
  70797. * @returns the current updated quaternion
  70798. */
  70799. conjugateInPlace(): Quaternion;
  70800. /**
  70801. * Conjugates in place (1-q) the current quaternion
  70802. * @returns a new quaternion
  70803. */
  70804. conjugate(): Quaternion;
  70805. /**
  70806. * Gets length of current quaternion
  70807. * @returns the quaternion length (float)
  70808. */
  70809. length(): number;
  70810. /**
  70811. * Normalize in place the current quaternion
  70812. * @returns the current updated quaternion
  70813. */
  70814. normalize(): Quaternion;
  70815. /**
  70816. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70817. * @param order is a reserved parameter and is ignore for now
  70818. * @returns a new Vector3 containing the Euler angles
  70819. */
  70820. toEulerAngles(order?: string): Vector3;
  70821. /**
  70822. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70823. * @param result defines the vector which will be filled with the Euler angles
  70824. * @param order is a reserved parameter and is ignore for now
  70825. * @returns the current unchanged quaternion
  70826. */
  70827. toEulerAnglesToRef(result: Vector3): Quaternion;
  70828. /**
  70829. * Updates the given rotation matrix with the current quaternion values
  70830. * @param result defines the target matrix
  70831. * @returns the current unchanged quaternion
  70832. */
  70833. toRotationMatrix(result: Matrix): Quaternion;
  70834. /**
  70835. * Updates the current quaternion from the given rotation matrix values
  70836. * @param matrix defines the source matrix
  70837. * @returns the current updated quaternion
  70838. */
  70839. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70840. /**
  70841. * Creates a new quaternion from a rotation matrix
  70842. * @param matrix defines the source matrix
  70843. * @returns a new quaternion created from the given rotation matrix values
  70844. */
  70845. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70846. /**
  70847. * Updates the given quaternion with the given rotation matrix values
  70848. * @param matrix defines the source matrix
  70849. * @param result defines the target quaternion
  70850. */
  70851. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70852. /**
  70853. * Returns the dot product (float) between the quaternions "left" and "right"
  70854. * @param left defines the left operand
  70855. * @param right defines the right operand
  70856. * @returns the dot product
  70857. */
  70858. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70859. /**
  70860. * Checks if the two quaternions are close to each other
  70861. * @param quat0 defines the first quaternion to check
  70862. * @param quat1 defines the second quaternion to check
  70863. * @returns true if the two quaternions are close to each other
  70864. */
  70865. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70866. /**
  70867. * Creates an empty quaternion
  70868. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70869. */
  70870. static Zero(): Quaternion;
  70871. /**
  70872. * Inverse a given quaternion
  70873. * @param q defines the source quaternion
  70874. * @returns a new quaternion as the inverted current quaternion
  70875. */
  70876. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70877. /**
  70878. * Inverse a given quaternion
  70879. * @param q defines the source quaternion
  70880. * @param result the quaternion the result will be stored in
  70881. * @returns the result quaternion
  70882. */
  70883. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70884. /**
  70885. * Creates an identity quaternion
  70886. * @returns the identity quaternion
  70887. */
  70888. static Identity(): Quaternion;
  70889. /**
  70890. * Gets a boolean indicating if the given quaternion is identity
  70891. * @param quaternion defines the quaternion to check
  70892. * @returns true if the quaternion is identity
  70893. */
  70894. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70895. /**
  70896. * Creates a quaternion from a rotation around an axis
  70897. * @param axis defines the axis to use
  70898. * @param angle defines the angle to use
  70899. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70900. */
  70901. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70902. /**
  70903. * Creates a rotation around an axis and stores it into the given quaternion
  70904. * @param axis defines the axis to use
  70905. * @param angle defines the angle to use
  70906. * @param result defines the target quaternion
  70907. * @returns the target quaternion
  70908. */
  70909. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70910. /**
  70911. * Creates a new quaternion from data stored into an array
  70912. * @param array defines the data source
  70913. * @param offset defines the offset in the source array where the data starts
  70914. * @returns a new quaternion
  70915. */
  70916. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70917. /**
  70918. * Create a quaternion from Euler rotation angles
  70919. * @param x Pitch
  70920. * @param y Yaw
  70921. * @param z Roll
  70922. * @returns the new Quaternion
  70923. */
  70924. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70925. /**
  70926. * Updates a quaternion from Euler rotation angles
  70927. * @param x Pitch
  70928. * @param y Yaw
  70929. * @param z Roll
  70930. * @param result the quaternion to store the result
  70931. * @returns the updated quaternion
  70932. */
  70933. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70934. /**
  70935. * Create a quaternion from Euler rotation vector
  70936. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70937. * @returns the new Quaternion
  70938. */
  70939. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70940. /**
  70941. * Updates a quaternion from Euler rotation vector
  70942. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70943. * @param result the quaternion to store the result
  70944. * @returns the updated quaternion
  70945. */
  70946. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70947. /**
  70948. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70949. * @param yaw defines the rotation around Y axis
  70950. * @param pitch defines the rotation around X axis
  70951. * @param roll defines the rotation around Z axis
  70952. * @returns the new quaternion
  70953. */
  70954. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70955. /**
  70956. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70957. * @param yaw defines the rotation around Y axis
  70958. * @param pitch defines the rotation around X axis
  70959. * @param roll defines the rotation around Z axis
  70960. * @param result defines the target quaternion
  70961. */
  70962. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70963. /**
  70964. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70965. * @param alpha defines the rotation around first axis
  70966. * @param beta defines the rotation around second axis
  70967. * @param gamma defines the rotation around third axis
  70968. * @returns the new quaternion
  70969. */
  70970. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70971. /**
  70972. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70973. * @param alpha defines the rotation around first axis
  70974. * @param beta defines the rotation around second axis
  70975. * @param gamma defines the rotation around third axis
  70976. * @param result defines the target quaternion
  70977. */
  70978. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70979. /**
  70980. * 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)
  70981. * @param axis1 defines the first axis
  70982. * @param axis2 defines the second axis
  70983. * @param axis3 defines the third axis
  70984. * @returns the new quaternion
  70985. */
  70986. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70987. /**
  70988. * 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
  70989. * @param axis1 defines the first axis
  70990. * @param axis2 defines the second axis
  70991. * @param axis3 defines the third axis
  70992. * @param ref defines the target quaternion
  70993. */
  70994. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70995. /**
  70996. * Interpolates between two quaternions
  70997. * @param left defines first quaternion
  70998. * @param right defines second quaternion
  70999. * @param amount defines the gradient to use
  71000. * @returns the new interpolated quaternion
  71001. */
  71002. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71003. /**
  71004. * Interpolates between two quaternions and stores it into a target quaternion
  71005. * @param left defines first quaternion
  71006. * @param right defines second quaternion
  71007. * @param amount defines the gradient to use
  71008. * @param result defines the target quaternion
  71009. */
  71010. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71011. /**
  71012. * Interpolate between two quaternions using Hermite interpolation
  71013. * @param value1 defines first quaternion
  71014. * @param tangent1 defines the incoming tangent
  71015. * @param value2 defines second quaternion
  71016. * @param tangent2 defines the outgoing tangent
  71017. * @param amount defines the target quaternion
  71018. * @returns the new interpolated quaternion
  71019. */
  71020. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71021. }
  71022. /**
  71023. * Class used to store matrix data (4x4)
  71024. */
  71025. export class Matrix {
  71026. private static _updateFlagSeed;
  71027. private static _identityReadOnly;
  71028. private _isIdentity;
  71029. private _isIdentityDirty;
  71030. private _isIdentity3x2;
  71031. private _isIdentity3x2Dirty;
  71032. /**
  71033. * Gets the update flag of the matrix which is an unique number for the matrix.
  71034. * It will be incremented every time the matrix data change.
  71035. * You can use it to speed the comparison between two versions of the same matrix.
  71036. */
  71037. updateFlag: number;
  71038. private readonly _m;
  71039. /**
  71040. * Gets the internal data of the matrix
  71041. */
  71042. readonly m: DeepImmutable<Float32Array>;
  71043. /** @hidden */
  71044. _markAsUpdated(): void;
  71045. /** @hidden */
  71046. private _updateIdentityStatus;
  71047. /**
  71048. * Creates an empty matrix (filled with zeros)
  71049. */
  71050. constructor();
  71051. /**
  71052. * Check if the current matrix is identity
  71053. * @returns true is the matrix is the identity matrix
  71054. */
  71055. isIdentity(): boolean;
  71056. /**
  71057. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71058. * @returns true is the matrix is the identity matrix
  71059. */
  71060. isIdentityAs3x2(): boolean;
  71061. /**
  71062. * Gets the determinant of the matrix
  71063. * @returns the matrix determinant
  71064. */
  71065. determinant(): number;
  71066. /**
  71067. * Returns the matrix as a Float32Array
  71068. * @returns the matrix underlying array
  71069. */
  71070. toArray(): DeepImmutable<Float32Array>;
  71071. /**
  71072. * Returns the matrix as a Float32Array
  71073. * @returns the matrix underlying array.
  71074. */
  71075. asArray(): DeepImmutable<Float32Array>;
  71076. /**
  71077. * Inverts the current matrix in place
  71078. * @returns the current inverted matrix
  71079. */
  71080. invert(): Matrix;
  71081. /**
  71082. * Sets all the matrix elements to zero
  71083. * @returns the current matrix
  71084. */
  71085. reset(): Matrix;
  71086. /**
  71087. * Adds the current matrix with a second one
  71088. * @param other defines the matrix to add
  71089. * @returns a new matrix as the addition of the current matrix and the given one
  71090. */
  71091. add(other: DeepImmutable<Matrix>): Matrix;
  71092. /**
  71093. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71094. * @param other defines the matrix to add
  71095. * @param result defines the target matrix
  71096. * @returns the current matrix
  71097. */
  71098. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71099. /**
  71100. * Adds in place the given matrix to the current matrix
  71101. * @param other defines the second operand
  71102. * @returns the current updated matrix
  71103. */
  71104. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71105. /**
  71106. * Sets the given matrix to the current inverted Matrix
  71107. * @param other defines the target matrix
  71108. * @returns the unmodified current matrix
  71109. */
  71110. invertToRef(other: Matrix): Matrix;
  71111. /**
  71112. * add a value at the specified position in the current Matrix
  71113. * @param index the index of the value within the matrix. between 0 and 15.
  71114. * @param value the value to be added
  71115. * @returns the current updated matrix
  71116. */
  71117. addAtIndex(index: number, value: number): Matrix;
  71118. /**
  71119. * mutiply the specified position in the current Matrix by a value
  71120. * @param index the index of the value within the matrix. between 0 and 15.
  71121. * @param value the value to be added
  71122. * @returns the current updated matrix
  71123. */
  71124. multiplyAtIndex(index: number, value: number): Matrix;
  71125. /**
  71126. * Inserts the translation vector (using 3 floats) in the current matrix
  71127. * @param x defines the 1st component of the translation
  71128. * @param y defines the 2nd component of the translation
  71129. * @param z defines the 3rd component of the translation
  71130. * @returns the current updated matrix
  71131. */
  71132. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71133. /**
  71134. * Adds the translation vector (using 3 floats) in the current matrix
  71135. * @param x defines the 1st component of the translation
  71136. * @param y defines the 2nd component of the translation
  71137. * @param z defines the 3rd component of the translation
  71138. * @returns the current updated matrix
  71139. */
  71140. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71141. /**
  71142. * Inserts the translation vector in the current matrix
  71143. * @param vector3 defines the translation to insert
  71144. * @returns the current updated matrix
  71145. */
  71146. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71147. /**
  71148. * Gets the translation value of the current matrix
  71149. * @returns a new Vector3 as the extracted translation from the matrix
  71150. */
  71151. getTranslation(): Vector3;
  71152. /**
  71153. * Fill a Vector3 with the extracted translation from the matrix
  71154. * @param result defines the Vector3 where to store the translation
  71155. * @returns the current matrix
  71156. */
  71157. getTranslationToRef(result: Vector3): Matrix;
  71158. /**
  71159. * Remove rotation and scaling part from the matrix
  71160. * @returns the updated matrix
  71161. */
  71162. removeRotationAndScaling(): Matrix;
  71163. /**
  71164. * Multiply two matrices
  71165. * @param other defines the second operand
  71166. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71167. */
  71168. multiply(other: DeepImmutable<Matrix>): Matrix;
  71169. /**
  71170. * Copy the current matrix from the given one
  71171. * @param other defines the source matrix
  71172. * @returns the current updated matrix
  71173. */
  71174. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71175. /**
  71176. * Populates the given array from the starting index with the current matrix values
  71177. * @param array defines the target array
  71178. * @param offset defines the offset in the target array where to start storing values
  71179. * @returns the current matrix
  71180. */
  71181. copyToArray(array: Float32Array, offset?: number): Matrix;
  71182. /**
  71183. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71184. * @param other defines the second operand
  71185. * @param result defines the matrix where to store the multiplication
  71186. * @returns the current matrix
  71187. */
  71188. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71189. /**
  71190. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71191. * @param other defines the second operand
  71192. * @param result defines the array where to store the multiplication
  71193. * @param offset defines the offset in the target array where to start storing values
  71194. * @returns the current matrix
  71195. */
  71196. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71197. /**
  71198. * Check equality between this matrix and a second one
  71199. * @param value defines the second matrix to compare
  71200. * @returns true is the current matrix and the given one values are strictly equal
  71201. */
  71202. equals(value: DeepImmutable<Matrix>): boolean;
  71203. /**
  71204. * Clone the current matrix
  71205. * @returns a new matrix from the current matrix
  71206. */
  71207. clone(): Matrix;
  71208. /**
  71209. * Returns the name of the current matrix class
  71210. * @returns the string "Matrix"
  71211. */
  71212. getClassName(): string;
  71213. /**
  71214. * Gets the hash code of the current matrix
  71215. * @returns the hash code
  71216. */
  71217. getHashCode(): number;
  71218. /**
  71219. * Decomposes the current Matrix into a translation, rotation and scaling components
  71220. * @param scale defines the scale vector3 given as a reference to update
  71221. * @param rotation defines the rotation quaternion given as a reference to update
  71222. * @param translation defines the translation vector3 given as a reference to update
  71223. * @returns true if operation was successful
  71224. */
  71225. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71226. /**
  71227. * Gets specific row of the matrix
  71228. * @param index defines the number of the row to get
  71229. * @returns the index-th row of the current matrix as a new Vector4
  71230. */
  71231. getRow(index: number): Nullable<Vector4>;
  71232. /**
  71233. * Sets the index-th row of the current matrix to the vector4 values
  71234. * @param index defines the number of the row to set
  71235. * @param row defines the target vector4
  71236. * @returns the updated current matrix
  71237. */
  71238. setRow(index: number, row: Vector4): Matrix;
  71239. /**
  71240. * Compute the transpose of the matrix
  71241. * @returns the new transposed matrix
  71242. */
  71243. transpose(): Matrix;
  71244. /**
  71245. * Compute the transpose of the matrix and store it in a given matrix
  71246. * @param result defines the target matrix
  71247. * @returns the current matrix
  71248. */
  71249. transposeToRef(result: Matrix): Matrix;
  71250. /**
  71251. * Sets the index-th row of the current matrix with the given 4 x float values
  71252. * @param index defines the row index
  71253. * @param x defines the x component to set
  71254. * @param y defines the y component to set
  71255. * @param z defines the z component to set
  71256. * @param w defines the w component to set
  71257. * @returns the updated current matrix
  71258. */
  71259. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71260. /**
  71261. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71262. * @param scale defines the scale factor
  71263. * @returns a new matrix
  71264. */
  71265. scale(scale: number): Matrix;
  71266. /**
  71267. * Scale the current matrix values by a factor to a given result matrix
  71268. * @param scale defines the scale factor
  71269. * @param result defines the matrix to store the result
  71270. * @returns the current matrix
  71271. */
  71272. scaleToRef(scale: number, result: Matrix): Matrix;
  71273. /**
  71274. * Scale the current matrix values by a factor and add the result to a given matrix
  71275. * @param scale defines the scale factor
  71276. * @param result defines the Matrix to store the result
  71277. * @returns the current matrix
  71278. */
  71279. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71280. /**
  71281. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71282. * @param ref matrix to store the result
  71283. */
  71284. toNormalMatrix(ref: Matrix): void;
  71285. /**
  71286. * Gets only rotation part of the current matrix
  71287. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71288. */
  71289. getRotationMatrix(): Matrix;
  71290. /**
  71291. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71292. * @param result defines the target matrix to store data to
  71293. * @returns the current matrix
  71294. */
  71295. getRotationMatrixToRef(result: Matrix): Matrix;
  71296. /**
  71297. * Toggles model matrix from being right handed to left handed in place and vice versa
  71298. */
  71299. toggleModelMatrixHandInPlace(): void;
  71300. /**
  71301. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71302. */
  71303. toggleProjectionMatrixHandInPlace(): void;
  71304. /**
  71305. * Creates a matrix from an array
  71306. * @param array defines the source array
  71307. * @param offset defines an offset in the source array
  71308. * @returns a new Matrix set from the starting index of the given array
  71309. */
  71310. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71311. /**
  71312. * Copy the content of an array into a given matrix
  71313. * @param array defines the source array
  71314. * @param offset defines an offset in the source array
  71315. * @param result defines the target matrix
  71316. */
  71317. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71318. /**
  71319. * Stores an array into a matrix after having multiplied each component by a given factor
  71320. * @param array defines the source array
  71321. * @param offset defines the offset in the source array
  71322. * @param scale defines the scaling factor
  71323. * @param result defines the target matrix
  71324. */
  71325. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71326. /**
  71327. * Gets an identity matrix that must not be updated
  71328. */
  71329. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71330. /**
  71331. * Stores a list of values (16) inside a given matrix
  71332. * @param initialM11 defines 1st value of 1st row
  71333. * @param initialM12 defines 2nd value of 1st row
  71334. * @param initialM13 defines 3rd value of 1st row
  71335. * @param initialM14 defines 4th value of 1st row
  71336. * @param initialM21 defines 1st value of 2nd row
  71337. * @param initialM22 defines 2nd value of 2nd row
  71338. * @param initialM23 defines 3rd value of 2nd row
  71339. * @param initialM24 defines 4th value of 2nd row
  71340. * @param initialM31 defines 1st value of 3rd row
  71341. * @param initialM32 defines 2nd value of 3rd row
  71342. * @param initialM33 defines 3rd value of 3rd row
  71343. * @param initialM34 defines 4th value of 3rd row
  71344. * @param initialM41 defines 1st value of 4th row
  71345. * @param initialM42 defines 2nd value of 4th row
  71346. * @param initialM43 defines 3rd value of 4th row
  71347. * @param initialM44 defines 4th value of 4th row
  71348. * @param result defines the target matrix
  71349. */
  71350. 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;
  71351. /**
  71352. * Creates new matrix from a list of values (16)
  71353. * @param initialM11 defines 1st value of 1st row
  71354. * @param initialM12 defines 2nd value of 1st row
  71355. * @param initialM13 defines 3rd value of 1st row
  71356. * @param initialM14 defines 4th value of 1st row
  71357. * @param initialM21 defines 1st value of 2nd row
  71358. * @param initialM22 defines 2nd value of 2nd row
  71359. * @param initialM23 defines 3rd value of 2nd row
  71360. * @param initialM24 defines 4th value of 2nd row
  71361. * @param initialM31 defines 1st value of 3rd row
  71362. * @param initialM32 defines 2nd value of 3rd row
  71363. * @param initialM33 defines 3rd value of 3rd row
  71364. * @param initialM34 defines 4th value of 3rd row
  71365. * @param initialM41 defines 1st value of 4th row
  71366. * @param initialM42 defines 2nd value of 4th row
  71367. * @param initialM43 defines 3rd value of 4th row
  71368. * @param initialM44 defines 4th value of 4th row
  71369. * @returns the new matrix
  71370. */
  71371. 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;
  71372. /**
  71373. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71374. * @param scale defines the scale vector3
  71375. * @param rotation defines the rotation quaternion
  71376. * @param translation defines the translation vector3
  71377. * @returns a new matrix
  71378. */
  71379. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71380. /**
  71381. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71382. * @param scale defines the scale vector3
  71383. * @param rotation defines the rotation quaternion
  71384. * @param translation defines the translation vector3
  71385. * @param result defines the target matrix
  71386. */
  71387. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71388. /**
  71389. * Creates a new identity matrix
  71390. * @returns a new identity matrix
  71391. */
  71392. static Identity(): Matrix;
  71393. /**
  71394. * Creates a new identity matrix and stores the result in a given matrix
  71395. * @param result defines the target matrix
  71396. */
  71397. static IdentityToRef(result: Matrix): void;
  71398. /**
  71399. * Creates a new zero matrix
  71400. * @returns a new zero matrix
  71401. */
  71402. static Zero(): Matrix;
  71403. /**
  71404. * Creates a new rotation matrix for "angle" radians around the X axis
  71405. * @param angle defines the angle (in radians) to use
  71406. * @return the new matrix
  71407. */
  71408. static RotationX(angle: number): Matrix;
  71409. /**
  71410. * Creates a new matrix as the invert of a given matrix
  71411. * @param source defines the source matrix
  71412. * @returns the new matrix
  71413. */
  71414. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71415. /**
  71416. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71417. * @param angle defines the angle (in radians) to use
  71418. * @param result defines the target matrix
  71419. */
  71420. static RotationXToRef(angle: number, result: Matrix): void;
  71421. /**
  71422. * Creates a new rotation matrix for "angle" radians around the Y axis
  71423. * @param angle defines the angle (in radians) to use
  71424. * @return the new matrix
  71425. */
  71426. static RotationY(angle: number): Matrix;
  71427. /**
  71428. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71429. * @param angle defines the angle (in radians) to use
  71430. * @param result defines the target matrix
  71431. */
  71432. static RotationYToRef(angle: number, result: Matrix): void;
  71433. /**
  71434. * Creates a new rotation matrix for "angle" radians around the Z axis
  71435. * @param angle defines the angle (in radians) to use
  71436. * @return the new matrix
  71437. */
  71438. static RotationZ(angle: number): Matrix;
  71439. /**
  71440. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71441. * @param angle defines the angle (in radians) to use
  71442. * @param result defines the target matrix
  71443. */
  71444. static RotationZToRef(angle: number, result: Matrix): void;
  71445. /**
  71446. * Creates a new rotation matrix for "angle" radians around the given axis
  71447. * @param axis defines the axis to use
  71448. * @param angle defines the angle (in radians) to use
  71449. * @return the new matrix
  71450. */
  71451. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71452. /**
  71453. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71454. * @param axis defines the axis to use
  71455. * @param angle defines the angle (in radians) to use
  71456. * @param result defines the target matrix
  71457. */
  71458. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71459. /**
  71460. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71461. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71462. * @param from defines the vector to align
  71463. * @param to defines the vector to align to
  71464. * @param result defines the target matrix
  71465. */
  71466. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71467. /**
  71468. * Creates a rotation matrix
  71469. * @param yaw defines the yaw angle in radians (Y axis)
  71470. * @param pitch defines the pitch angle in radians (X axis)
  71471. * @param roll defines the roll angle in radians (X axis)
  71472. * @returns the new rotation matrix
  71473. */
  71474. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71475. /**
  71476. * Creates a rotation matrix and stores it in a given matrix
  71477. * @param yaw defines the yaw angle in radians (Y axis)
  71478. * @param pitch defines the pitch angle in radians (X axis)
  71479. * @param roll defines the roll angle in radians (X axis)
  71480. * @param result defines the target matrix
  71481. */
  71482. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71483. /**
  71484. * Creates a scaling matrix
  71485. * @param x defines the scale factor on X axis
  71486. * @param y defines the scale factor on Y axis
  71487. * @param z defines the scale factor on Z axis
  71488. * @returns the new matrix
  71489. */
  71490. static Scaling(x: number, y: number, z: number): Matrix;
  71491. /**
  71492. * Creates a scaling matrix and stores it in a given matrix
  71493. * @param x defines the scale factor on X axis
  71494. * @param y defines the scale factor on Y axis
  71495. * @param z defines the scale factor on Z axis
  71496. * @param result defines the target matrix
  71497. */
  71498. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71499. /**
  71500. * Creates a translation matrix
  71501. * @param x defines the translation on X axis
  71502. * @param y defines the translation on Y axis
  71503. * @param z defines the translationon Z axis
  71504. * @returns the new matrix
  71505. */
  71506. static Translation(x: number, y: number, z: number): Matrix;
  71507. /**
  71508. * Creates a translation matrix and stores it in a given matrix
  71509. * @param x defines the translation on X axis
  71510. * @param y defines the translation on Y axis
  71511. * @param z defines the translationon Z axis
  71512. * @param result defines the target matrix
  71513. */
  71514. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71515. /**
  71516. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71517. * @param startValue defines the start value
  71518. * @param endValue defines the end value
  71519. * @param gradient defines the gradient factor
  71520. * @returns the new matrix
  71521. */
  71522. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71523. /**
  71524. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71525. * @param startValue defines the start value
  71526. * @param endValue defines the end value
  71527. * @param gradient defines the gradient factor
  71528. * @param result defines the Matrix object where to store data
  71529. */
  71530. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71531. /**
  71532. * Builds a new matrix whose values are computed by:
  71533. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71534. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71535. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71536. * @param startValue defines the first matrix
  71537. * @param endValue defines the second matrix
  71538. * @param gradient defines the gradient between the two matrices
  71539. * @returns the new matrix
  71540. */
  71541. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71542. /**
  71543. * Update a matrix to values which are computed by:
  71544. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71545. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71546. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71547. * @param startValue defines the first matrix
  71548. * @param endValue defines the second matrix
  71549. * @param gradient defines the gradient between the two matrices
  71550. * @param result defines the target matrix
  71551. */
  71552. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71553. /**
  71554. * 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"
  71555. * This function works in left handed mode
  71556. * @param eye defines the final position of the entity
  71557. * @param target defines where the entity should look at
  71558. * @param up defines the up vector for the entity
  71559. * @returns the new matrix
  71560. */
  71561. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71562. /**
  71563. * 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".
  71564. * This function works in left handed mode
  71565. * @param eye defines the final position of the entity
  71566. * @param target defines where the entity should look at
  71567. * @param up defines the up vector for the entity
  71568. * @param result defines the target matrix
  71569. */
  71570. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71571. /**
  71572. * 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"
  71573. * This function works in right handed mode
  71574. * @param eye defines the final position of the entity
  71575. * @param target defines where the entity should look at
  71576. * @param up defines the up vector for the entity
  71577. * @returns the new matrix
  71578. */
  71579. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71580. /**
  71581. * 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".
  71582. * This function works in right handed mode
  71583. * @param eye defines the final position of the entity
  71584. * @param target defines where the entity should look at
  71585. * @param up defines the up vector for the entity
  71586. * @param result defines the target matrix
  71587. */
  71588. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71589. /**
  71590. * Create a left-handed orthographic projection matrix
  71591. * @param width defines the viewport width
  71592. * @param height defines the viewport height
  71593. * @param znear defines the near clip plane
  71594. * @param zfar defines the far clip plane
  71595. * @returns a new matrix as a left-handed orthographic projection matrix
  71596. */
  71597. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71598. /**
  71599. * Store a left-handed orthographic projection to a given matrix
  71600. * @param width defines the viewport width
  71601. * @param height defines the viewport height
  71602. * @param znear defines the near clip plane
  71603. * @param zfar defines the far clip plane
  71604. * @param result defines the target matrix
  71605. */
  71606. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71607. /**
  71608. * Create a left-handed orthographic projection matrix
  71609. * @param left defines the viewport left coordinate
  71610. * @param right defines the viewport right coordinate
  71611. * @param bottom defines the viewport bottom coordinate
  71612. * @param top defines the viewport top coordinate
  71613. * @param znear defines the near clip plane
  71614. * @param zfar defines the far clip plane
  71615. * @returns a new matrix as a left-handed orthographic projection matrix
  71616. */
  71617. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71618. /**
  71619. * Stores a left-handed orthographic projection into a given matrix
  71620. * @param left defines the viewport left coordinate
  71621. * @param right defines the viewport right coordinate
  71622. * @param bottom defines the viewport bottom coordinate
  71623. * @param top defines the viewport top coordinate
  71624. * @param znear defines the near clip plane
  71625. * @param zfar defines the far clip plane
  71626. * @param result defines the target matrix
  71627. */
  71628. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71629. /**
  71630. * Creates a right-handed orthographic projection matrix
  71631. * @param left defines the viewport left coordinate
  71632. * @param right defines the viewport right coordinate
  71633. * @param bottom defines the viewport bottom coordinate
  71634. * @param top defines the viewport top coordinate
  71635. * @param znear defines the near clip plane
  71636. * @param zfar defines the far clip plane
  71637. * @returns a new matrix as a right-handed orthographic projection matrix
  71638. */
  71639. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71640. /**
  71641. * Stores a right-handed orthographic projection into a given matrix
  71642. * @param left defines the viewport left coordinate
  71643. * @param right defines the viewport right coordinate
  71644. * @param bottom defines the viewport bottom coordinate
  71645. * @param top defines the viewport top coordinate
  71646. * @param znear defines the near clip plane
  71647. * @param zfar defines the far clip plane
  71648. * @param result defines the target matrix
  71649. */
  71650. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71651. /**
  71652. * Creates a left-handed perspective projection matrix
  71653. * @param width defines the viewport width
  71654. * @param height defines the viewport height
  71655. * @param znear defines the near clip plane
  71656. * @param zfar defines the far clip plane
  71657. * @returns a new matrix as a left-handed perspective projection matrix
  71658. */
  71659. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71660. /**
  71661. * Creates a left-handed perspective projection matrix
  71662. * @param fov defines the horizontal field of view
  71663. * @param aspect defines the aspect ratio
  71664. * @param znear defines the near clip plane
  71665. * @param zfar defines the far clip plane
  71666. * @returns a new matrix as a left-handed perspective projection matrix
  71667. */
  71668. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71669. /**
  71670. * Stores a left-handed perspective projection into a given matrix
  71671. * @param fov defines the horizontal field of view
  71672. * @param aspect defines the aspect ratio
  71673. * @param znear defines the near clip plane
  71674. * @param zfar defines the far clip plane
  71675. * @param result defines the target matrix
  71676. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71677. */
  71678. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71679. /**
  71680. * Creates a right-handed perspective projection matrix
  71681. * @param fov defines the horizontal field of view
  71682. * @param aspect defines the aspect ratio
  71683. * @param znear defines the near clip plane
  71684. * @param zfar defines the far clip plane
  71685. * @returns a new matrix as a right-handed perspective projection matrix
  71686. */
  71687. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71688. /**
  71689. * Stores a right-handed perspective projection into a given matrix
  71690. * @param fov defines the horizontal field of view
  71691. * @param aspect defines the aspect ratio
  71692. * @param znear defines the near clip plane
  71693. * @param zfar defines the far clip plane
  71694. * @param result defines the target matrix
  71695. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71696. */
  71697. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71698. /**
  71699. * Stores a perspective projection for WebVR info a given matrix
  71700. * @param fov defines the field of view
  71701. * @param znear defines the near clip plane
  71702. * @param zfar defines the far clip plane
  71703. * @param result defines the target matrix
  71704. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71705. */
  71706. static PerspectiveFovWebVRToRef(fov: {
  71707. upDegrees: number;
  71708. downDegrees: number;
  71709. leftDegrees: number;
  71710. rightDegrees: number;
  71711. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71712. /**
  71713. * Computes a complete transformation matrix
  71714. * @param viewport defines the viewport to use
  71715. * @param world defines the world matrix
  71716. * @param view defines the view matrix
  71717. * @param projection defines the projection matrix
  71718. * @param zmin defines the near clip plane
  71719. * @param zmax defines the far clip plane
  71720. * @returns the transformation matrix
  71721. */
  71722. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71723. /**
  71724. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71725. * @param matrix defines the matrix to use
  71726. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71727. */
  71728. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71729. /**
  71730. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71731. * @param matrix defines the matrix to use
  71732. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71733. */
  71734. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71735. /**
  71736. * Compute the transpose of a given matrix
  71737. * @param matrix defines the matrix to transpose
  71738. * @returns the new matrix
  71739. */
  71740. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71741. /**
  71742. * Compute the transpose of a matrix and store it in a target matrix
  71743. * @param matrix defines the matrix to transpose
  71744. * @param result defines the target matrix
  71745. */
  71746. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71747. /**
  71748. * Computes a reflection matrix from a plane
  71749. * @param plane defines the reflection plane
  71750. * @returns a new matrix
  71751. */
  71752. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71753. /**
  71754. * Computes a reflection matrix from a plane
  71755. * @param plane defines the reflection plane
  71756. * @param result defines the target matrix
  71757. */
  71758. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71759. /**
  71760. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71761. * @param xaxis defines the value of the 1st axis
  71762. * @param yaxis defines the value of the 2nd axis
  71763. * @param zaxis defines the value of the 3rd axis
  71764. * @param result defines the target matrix
  71765. */
  71766. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71767. /**
  71768. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71769. * @param quat defines the quaternion to use
  71770. * @param result defines the target matrix
  71771. */
  71772. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71773. }
  71774. /**
  71775. * @hidden
  71776. */
  71777. export class TmpVectors {
  71778. static Vector2: Vector2[];
  71779. static Vector3: Vector3[];
  71780. static Vector4: Vector4[];
  71781. static Quaternion: Quaternion[];
  71782. static Matrix: Matrix[];
  71783. }
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Defines potential orientation for back face culling
  71788. */
  71789. export enum Orientation {
  71790. /**
  71791. * Clockwise
  71792. */
  71793. CW = 0,
  71794. /** Counter clockwise */
  71795. CCW = 1
  71796. }
  71797. /** Class used to represent a Bezier curve */
  71798. export class BezierCurve {
  71799. /**
  71800. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71801. * @param t defines the time
  71802. * @param x1 defines the left coordinate on X axis
  71803. * @param y1 defines the left coordinate on Y axis
  71804. * @param x2 defines the right coordinate on X axis
  71805. * @param y2 defines the right coordinate on Y axis
  71806. * @returns the interpolated value
  71807. */
  71808. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71809. }
  71810. /**
  71811. * Defines angle representation
  71812. */
  71813. export class Angle {
  71814. private _radians;
  71815. /**
  71816. * Creates an Angle object of "radians" radians (float).
  71817. * @param radians the angle in radians
  71818. */
  71819. constructor(radians: number);
  71820. /**
  71821. * Get value in degrees
  71822. * @returns the Angle value in degrees (float)
  71823. */
  71824. degrees(): number;
  71825. /**
  71826. * Get value in radians
  71827. * @returns the Angle value in radians (float)
  71828. */
  71829. radians(): number;
  71830. /**
  71831. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71832. * @param a defines first vector
  71833. * @param b defines second vector
  71834. * @returns a new Angle
  71835. */
  71836. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71837. /**
  71838. * Gets a new Angle object from the given float in radians
  71839. * @param radians defines the angle value in radians
  71840. * @returns a new Angle
  71841. */
  71842. static FromRadians(radians: number): Angle;
  71843. /**
  71844. * Gets a new Angle object from the given float in degrees
  71845. * @param degrees defines the angle value in degrees
  71846. * @returns a new Angle
  71847. */
  71848. static FromDegrees(degrees: number): Angle;
  71849. }
  71850. /**
  71851. * This represents an arc in a 2d space.
  71852. */
  71853. export class Arc2 {
  71854. /** Defines the start point of the arc */
  71855. startPoint: Vector2;
  71856. /** Defines the mid point of the arc */
  71857. midPoint: Vector2;
  71858. /** Defines the end point of the arc */
  71859. endPoint: Vector2;
  71860. /**
  71861. * Defines the center point of the arc.
  71862. */
  71863. centerPoint: Vector2;
  71864. /**
  71865. * Defines the radius of the arc.
  71866. */
  71867. radius: number;
  71868. /**
  71869. * Defines the angle of the arc (from mid point to end point).
  71870. */
  71871. angle: Angle;
  71872. /**
  71873. * Defines the start angle of the arc (from start point to middle point).
  71874. */
  71875. startAngle: Angle;
  71876. /**
  71877. * Defines the orientation of the arc (clock wise/counter clock wise).
  71878. */
  71879. orientation: Orientation;
  71880. /**
  71881. * Creates an Arc object from the three given points : start, middle and end.
  71882. * @param startPoint Defines the start point of the arc
  71883. * @param midPoint Defines the midlle point of the arc
  71884. * @param endPoint Defines the end point of the arc
  71885. */
  71886. constructor(
  71887. /** Defines the start point of the arc */
  71888. startPoint: Vector2,
  71889. /** Defines the mid point of the arc */
  71890. midPoint: Vector2,
  71891. /** Defines the end point of the arc */
  71892. endPoint: Vector2);
  71893. }
  71894. /**
  71895. * Represents a 2D path made up of multiple 2D points
  71896. */
  71897. export class Path2 {
  71898. private _points;
  71899. private _length;
  71900. /**
  71901. * If the path start and end point are the same
  71902. */
  71903. closed: boolean;
  71904. /**
  71905. * Creates a Path2 object from the starting 2D coordinates x and y.
  71906. * @param x the starting points x value
  71907. * @param y the starting points y value
  71908. */
  71909. constructor(x: number, y: number);
  71910. /**
  71911. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71912. * @param x the added points x value
  71913. * @param y the added points y value
  71914. * @returns the updated Path2.
  71915. */
  71916. addLineTo(x: number, y: number): Path2;
  71917. /**
  71918. * 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.
  71919. * @param midX middle point x value
  71920. * @param midY middle point y value
  71921. * @param endX end point x value
  71922. * @param endY end point y value
  71923. * @param numberOfSegments (default: 36)
  71924. * @returns the updated Path2.
  71925. */
  71926. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71927. /**
  71928. * Closes the Path2.
  71929. * @returns the Path2.
  71930. */
  71931. close(): Path2;
  71932. /**
  71933. * Gets the sum of the distance between each sequential point in the path
  71934. * @returns the Path2 total length (float).
  71935. */
  71936. length(): number;
  71937. /**
  71938. * Gets the points which construct the path
  71939. * @returns the Path2 internal array of points.
  71940. */
  71941. getPoints(): Vector2[];
  71942. /**
  71943. * Retreives the point at the distance aways from the starting point
  71944. * @param normalizedLengthPosition the length along the path to retreive the point from
  71945. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71946. */
  71947. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71948. /**
  71949. * Creates a new path starting from an x and y position
  71950. * @param x starting x value
  71951. * @param y starting y value
  71952. * @returns a new Path2 starting at the coordinates (x, y).
  71953. */
  71954. static StartingAt(x: number, y: number): Path2;
  71955. }
  71956. /**
  71957. * Represents a 3D path made up of multiple 3D points
  71958. */
  71959. export class Path3D {
  71960. /**
  71961. * an array of Vector3, the curve axis of the Path3D
  71962. */
  71963. path: Vector3[];
  71964. private _curve;
  71965. private _distances;
  71966. private _tangents;
  71967. private _normals;
  71968. private _binormals;
  71969. private _raw;
  71970. /**
  71971. * new Path3D(path, normal, raw)
  71972. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71973. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71974. * @param path an array of Vector3, the curve axis of the Path3D
  71975. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71976. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71977. */
  71978. constructor(
  71979. /**
  71980. * an array of Vector3, the curve axis of the Path3D
  71981. */
  71982. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71983. /**
  71984. * Returns the Path3D array of successive Vector3 designing its curve.
  71985. * @returns the Path3D array of successive Vector3 designing its curve.
  71986. */
  71987. getCurve(): Vector3[];
  71988. /**
  71989. * Returns an array populated with tangent vectors on each Path3D curve point.
  71990. * @returns an array populated with tangent vectors on each Path3D curve point.
  71991. */
  71992. getTangents(): Vector3[];
  71993. /**
  71994. * Returns an array populated with normal vectors on each Path3D curve point.
  71995. * @returns an array populated with normal vectors on each Path3D curve point.
  71996. */
  71997. getNormals(): Vector3[];
  71998. /**
  71999. * Returns an array populated with binormal vectors on each Path3D curve point.
  72000. * @returns an array populated with binormal vectors on each Path3D curve point.
  72001. */
  72002. getBinormals(): Vector3[];
  72003. /**
  72004. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72005. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72006. */
  72007. getDistances(): number[];
  72008. /**
  72009. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72010. * @param path path which all values are copied into the curves points
  72011. * @param firstNormal which should be projected onto the curve
  72012. * @returns the same object updated.
  72013. */
  72014. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72015. private _compute;
  72016. private _getFirstNonNullVector;
  72017. private _getLastNonNullVector;
  72018. private _normalVector;
  72019. }
  72020. /**
  72021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72022. * A Curve3 is designed from a series of successive Vector3.
  72023. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72024. */
  72025. export class Curve3 {
  72026. private _points;
  72027. private _length;
  72028. /**
  72029. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72030. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72031. * @param v1 (Vector3) the control point
  72032. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72033. * @param nbPoints (integer) the wanted number of points in the curve
  72034. * @returns the created Curve3
  72035. */
  72036. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72037. /**
  72038. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72039. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72040. * @param v1 (Vector3) the first control point
  72041. * @param v2 (Vector3) the second control point
  72042. * @param v3 (Vector3) the end point of the Cubic Bezier
  72043. * @param nbPoints (integer) the wanted number of points in the curve
  72044. * @returns the created Curve3
  72045. */
  72046. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72047. /**
  72048. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72049. * @param p1 (Vector3) the origin point of the Hermite Spline
  72050. * @param t1 (Vector3) the tangent vector at the origin point
  72051. * @param p2 (Vector3) the end point of the Hermite Spline
  72052. * @param t2 (Vector3) the tangent vector at the end point
  72053. * @param nbPoints (integer) the wanted number of points in the curve
  72054. * @returns the created Curve3
  72055. */
  72056. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72057. /**
  72058. * Returns a Curve3 object along a CatmullRom Spline curve :
  72059. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72060. * @param nbPoints (integer) the wanted number of points between each curve control points
  72061. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72062. * @returns the created Curve3
  72063. */
  72064. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72065. /**
  72066. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72067. * A Curve3 is designed from a series of successive Vector3.
  72068. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72069. * @param points points which make up the curve
  72070. */
  72071. constructor(points: Vector3[]);
  72072. /**
  72073. * @returns the Curve3 stored array of successive Vector3
  72074. */
  72075. getPoints(): Vector3[];
  72076. /**
  72077. * @returns the computed length (float) of the curve.
  72078. */
  72079. length(): number;
  72080. /**
  72081. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72082. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72083. * curveA and curveB keep unchanged.
  72084. * @param curve the curve to continue from this curve
  72085. * @returns the newly constructed curve
  72086. */
  72087. continue(curve: DeepImmutable<Curve3>): Curve3;
  72088. private _computeLength;
  72089. }
  72090. }
  72091. declare module BABYLON {
  72092. /**
  72093. * This represents the main contract an easing function should follow.
  72094. * Easing functions are used throughout the animation system.
  72095. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72096. */
  72097. export interface IEasingFunction {
  72098. /**
  72099. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72100. * of the easing function.
  72101. * The link below provides some of the most common examples of easing functions.
  72102. * @see https://easings.net/
  72103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72104. * @returns the corresponding value on the curve defined by the easing function
  72105. */
  72106. ease(gradient: number): number;
  72107. }
  72108. /**
  72109. * Base class used for every default easing function.
  72110. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72111. */
  72112. export class EasingFunction implements IEasingFunction {
  72113. /**
  72114. * Interpolation follows the mathematical formula associated with the easing function.
  72115. */
  72116. static readonly EASINGMODE_EASEIN: number;
  72117. /**
  72118. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72119. */
  72120. static readonly EASINGMODE_EASEOUT: number;
  72121. /**
  72122. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72123. */
  72124. static readonly EASINGMODE_EASEINOUT: number;
  72125. private _easingMode;
  72126. /**
  72127. * Sets the easing mode of the current function.
  72128. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72129. */
  72130. setEasingMode(easingMode: number): void;
  72131. /**
  72132. * Gets the current easing mode.
  72133. * @returns the easing mode
  72134. */
  72135. getEasingMode(): number;
  72136. /**
  72137. * @hidden
  72138. */
  72139. easeInCore(gradient: number): number;
  72140. /**
  72141. * Given an input gradient between 0 and 1, this returns the corresponding value
  72142. * of the easing function.
  72143. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72144. * @returns the corresponding value on the curve defined by the easing function
  72145. */
  72146. ease(gradient: number): number;
  72147. }
  72148. /**
  72149. * Easing function with a circle shape (see link below).
  72150. * @see https://easings.net/#easeInCirc
  72151. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72152. */
  72153. export class CircleEase extends EasingFunction implements IEasingFunction {
  72154. /** @hidden */
  72155. easeInCore(gradient: number): number;
  72156. }
  72157. /**
  72158. * Easing function with a ease back shape (see link below).
  72159. * @see https://easings.net/#easeInBack
  72160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72161. */
  72162. export class BackEase extends EasingFunction implements IEasingFunction {
  72163. /** Defines the amplitude of the function */
  72164. amplitude: number;
  72165. /**
  72166. * Instantiates a back ease easing
  72167. * @see https://easings.net/#easeInBack
  72168. * @param amplitude Defines the amplitude of the function
  72169. */
  72170. constructor(
  72171. /** Defines the amplitude of the function */
  72172. amplitude?: number);
  72173. /** @hidden */
  72174. easeInCore(gradient: number): number;
  72175. }
  72176. /**
  72177. * Easing function with a bouncing shape (see link below).
  72178. * @see https://easings.net/#easeInBounce
  72179. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72180. */
  72181. export class BounceEase extends EasingFunction implements IEasingFunction {
  72182. /** Defines the number of bounces */
  72183. bounces: number;
  72184. /** Defines the amplitude of the bounce */
  72185. bounciness: number;
  72186. /**
  72187. * Instantiates a bounce easing
  72188. * @see https://easings.net/#easeInBounce
  72189. * @param bounces Defines the number of bounces
  72190. * @param bounciness Defines the amplitude of the bounce
  72191. */
  72192. constructor(
  72193. /** Defines the number of bounces */
  72194. bounces?: number,
  72195. /** Defines the amplitude of the bounce */
  72196. bounciness?: number);
  72197. /** @hidden */
  72198. easeInCore(gradient: number): number;
  72199. }
  72200. /**
  72201. * Easing function with a power of 3 shape (see link below).
  72202. * @see https://easings.net/#easeInCubic
  72203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72204. */
  72205. export class CubicEase extends EasingFunction implements IEasingFunction {
  72206. /** @hidden */
  72207. easeInCore(gradient: number): number;
  72208. }
  72209. /**
  72210. * Easing function with an elastic shape (see link below).
  72211. * @see https://easings.net/#easeInElastic
  72212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72213. */
  72214. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72215. /** Defines the number of oscillations*/
  72216. oscillations: number;
  72217. /** Defines the amplitude of the oscillations*/
  72218. springiness: number;
  72219. /**
  72220. * Instantiates an elastic easing function
  72221. * @see https://easings.net/#easeInElastic
  72222. * @param oscillations Defines the number of oscillations
  72223. * @param springiness Defines the amplitude of the oscillations
  72224. */
  72225. constructor(
  72226. /** Defines the number of oscillations*/
  72227. oscillations?: number,
  72228. /** Defines the amplitude of the oscillations*/
  72229. springiness?: number);
  72230. /** @hidden */
  72231. easeInCore(gradient: number): number;
  72232. }
  72233. /**
  72234. * Easing function with an exponential shape (see link below).
  72235. * @see https://easings.net/#easeInExpo
  72236. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72237. */
  72238. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72239. /** Defines the exponent of the function */
  72240. exponent: number;
  72241. /**
  72242. * Instantiates an exponential easing function
  72243. * @see https://easings.net/#easeInExpo
  72244. * @param exponent Defines the exponent of the function
  72245. */
  72246. constructor(
  72247. /** Defines the exponent of the function */
  72248. exponent?: number);
  72249. /** @hidden */
  72250. easeInCore(gradient: number): number;
  72251. }
  72252. /**
  72253. * Easing function with a power shape (see link below).
  72254. * @see https://easings.net/#easeInQuad
  72255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72256. */
  72257. export class PowerEase extends EasingFunction implements IEasingFunction {
  72258. /** Defines the power of the function */
  72259. power: number;
  72260. /**
  72261. * Instantiates an power base easing function
  72262. * @see https://easings.net/#easeInQuad
  72263. * @param power Defines the power of the function
  72264. */
  72265. constructor(
  72266. /** Defines the power of the function */
  72267. power?: number);
  72268. /** @hidden */
  72269. easeInCore(gradient: number): number;
  72270. }
  72271. /**
  72272. * Easing function with a power of 2 shape (see link below).
  72273. * @see https://easings.net/#easeInQuad
  72274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72275. */
  72276. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72277. /** @hidden */
  72278. easeInCore(gradient: number): number;
  72279. }
  72280. /**
  72281. * Easing function with a power of 4 shape (see link below).
  72282. * @see https://easings.net/#easeInQuart
  72283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72284. */
  72285. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72286. /** @hidden */
  72287. easeInCore(gradient: number): number;
  72288. }
  72289. /**
  72290. * Easing function with a power of 5 shape (see link below).
  72291. * @see https://easings.net/#easeInQuint
  72292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72293. */
  72294. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72295. /** @hidden */
  72296. easeInCore(gradient: number): number;
  72297. }
  72298. /**
  72299. * Easing function with a sin shape (see link below).
  72300. * @see https://easings.net/#easeInSine
  72301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72302. */
  72303. export class SineEase extends EasingFunction implements IEasingFunction {
  72304. /** @hidden */
  72305. easeInCore(gradient: number): number;
  72306. }
  72307. /**
  72308. * Easing function with a bezier shape (see link below).
  72309. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72311. */
  72312. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72313. /** Defines the x component of the start tangent in the bezier curve */
  72314. x1: number;
  72315. /** Defines the y component of the start tangent in the bezier curve */
  72316. y1: number;
  72317. /** Defines the x component of the end tangent in the bezier curve */
  72318. x2: number;
  72319. /** Defines the y component of the end tangent in the bezier curve */
  72320. y2: number;
  72321. /**
  72322. * Instantiates a bezier function
  72323. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72324. * @param x1 Defines the x component of the start tangent in the bezier curve
  72325. * @param y1 Defines the y component of the start tangent in the bezier curve
  72326. * @param x2 Defines the x component of the end tangent in the bezier curve
  72327. * @param y2 Defines the y component of the end tangent in the bezier curve
  72328. */
  72329. constructor(
  72330. /** Defines the x component of the start tangent in the bezier curve */
  72331. x1?: number,
  72332. /** Defines the y component of the start tangent in the bezier curve */
  72333. y1?: number,
  72334. /** Defines the x component of the end tangent in the bezier curve */
  72335. x2?: number,
  72336. /** Defines the y component of the end tangent in the bezier curve */
  72337. y2?: number);
  72338. /** @hidden */
  72339. easeInCore(gradient: number): number;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. /**
  72344. * Class used to hold a RBG color
  72345. */
  72346. export class Color3 {
  72347. /**
  72348. * Defines the red component (between 0 and 1, default is 0)
  72349. */
  72350. r: number;
  72351. /**
  72352. * Defines the green component (between 0 and 1, default is 0)
  72353. */
  72354. g: number;
  72355. /**
  72356. * Defines the blue component (between 0 and 1, default is 0)
  72357. */
  72358. b: number;
  72359. /**
  72360. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72361. * @param r defines the red component (between 0 and 1, default is 0)
  72362. * @param g defines the green component (between 0 and 1, default is 0)
  72363. * @param b defines the blue component (between 0 and 1, default is 0)
  72364. */
  72365. constructor(
  72366. /**
  72367. * Defines the red component (between 0 and 1, default is 0)
  72368. */
  72369. r?: number,
  72370. /**
  72371. * Defines the green component (between 0 and 1, default is 0)
  72372. */
  72373. g?: number,
  72374. /**
  72375. * Defines the blue component (between 0 and 1, default is 0)
  72376. */
  72377. b?: number);
  72378. /**
  72379. * Creates a string with the Color3 current values
  72380. * @returns the string representation of the Color3 object
  72381. */
  72382. toString(): string;
  72383. /**
  72384. * Returns the string "Color3"
  72385. * @returns "Color3"
  72386. */
  72387. getClassName(): string;
  72388. /**
  72389. * Compute the Color3 hash code
  72390. * @returns an unique number that can be used to hash Color3 objects
  72391. */
  72392. getHashCode(): number;
  72393. /**
  72394. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72395. * @param array defines the array where to store the r,g,b components
  72396. * @param index defines an optional index in the target array to define where to start storing values
  72397. * @returns the current Color3 object
  72398. */
  72399. toArray(array: FloatArray, index?: number): Color3;
  72400. /**
  72401. * Returns a new Color4 object from the current Color3 and the given alpha
  72402. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72403. * @returns a new Color4 object
  72404. */
  72405. toColor4(alpha?: number): Color4;
  72406. /**
  72407. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72408. * @returns the new array
  72409. */
  72410. asArray(): number[];
  72411. /**
  72412. * Returns the luminance value
  72413. * @returns a float value
  72414. */
  72415. toLuminance(): number;
  72416. /**
  72417. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72418. * @param otherColor defines the second operand
  72419. * @returns the new Color3 object
  72420. */
  72421. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72422. /**
  72423. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72424. * @param otherColor defines the second operand
  72425. * @param result defines the Color3 object where to store the result
  72426. * @returns the current Color3
  72427. */
  72428. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72429. /**
  72430. * Determines equality between Color3 objects
  72431. * @param otherColor defines the second operand
  72432. * @returns true if the rgb values are equal to the given ones
  72433. */
  72434. equals(otherColor: DeepImmutable<Color3>): boolean;
  72435. /**
  72436. * Determines equality between the current Color3 object and a set of r,b,g values
  72437. * @param r defines the red component to check
  72438. * @param g defines the green component to check
  72439. * @param b defines the blue component to check
  72440. * @returns true if the rgb values are equal to the given ones
  72441. */
  72442. equalsFloats(r: number, g: number, b: number): boolean;
  72443. /**
  72444. * Multiplies in place each rgb value by scale
  72445. * @param scale defines the scaling factor
  72446. * @returns the updated Color3
  72447. */
  72448. scale(scale: number): Color3;
  72449. /**
  72450. * Multiplies the rgb values by scale and stores the result into "result"
  72451. * @param scale defines the scaling factor
  72452. * @param result defines the Color3 object where to store the result
  72453. * @returns the unmodified current Color3
  72454. */
  72455. scaleToRef(scale: number, result: Color3): Color3;
  72456. /**
  72457. * Scale the current Color3 values by a factor and add the result to a given Color3
  72458. * @param scale defines the scale factor
  72459. * @param result defines color to store the result into
  72460. * @returns the unmodified current Color3
  72461. */
  72462. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72463. /**
  72464. * Clamps the rgb values by the min and max values and stores the result into "result"
  72465. * @param min defines minimum clamping value (default is 0)
  72466. * @param max defines maximum clamping value (default is 1)
  72467. * @param result defines color to store the result into
  72468. * @returns the original Color3
  72469. */
  72470. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72471. /**
  72472. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72473. * @param otherColor defines the second operand
  72474. * @returns the new Color3
  72475. */
  72476. add(otherColor: DeepImmutable<Color3>): Color3;
  72477. /**
  72478. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72479. * @param otherColor defines the second operand
  72480. * @param result defines Color3 object to store the result into
  72481. * @returns the unmodified current Color3
  72482. */
  72483. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72484. /**
  72485. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72486. * @param otherColor defines the second operand
  72487. * @returns the new Color3
  72488. */
  72489. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72490. /**
  72491. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72492. * @param otherColor defines the second operand
  72493. * @param result defines Color3 object to store the result into
  72494. * @returns the unmodified current Color3
  72495. */
  72496. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72497. /**
  72498. * Copy the current object
  72499. * @returns a new Color3 copied the current one
  72500. */
  72501. clone(): Color3;
  72502. /**
  72503. * Copies the rgb values from the source in the current Color3
  72504. * @param source defines the source Color3 object
  72505. * @returns the updated Color3 object
  72506. */
  72507. copyFrom(source: DeepImmutable<Color3>): Color3;
  72508. /**
  72509. * Updates the Color3 rgb values from the given floats
  72510. * @param r defines the red component to read from
  72511. * @param g defines the green component to read from
  72512. * @param b defines the blue component to read from
  72513. * @returns the current Color3 object
  72514. */
  72515. copyFromFloats(r: number, g: number, b: number): Color3;
  72516. /**
  72517. * Updates the Color3 rgb values from the given floats
  72518. * @param r defines the red component to read from
  72519. * @param g defines the green component to read from
  72520. * @param b defines the blue component to read from
  72521. * @returns the current Color3 object
  72522. */
  72523. set(r: number, g: number, b: number): Color3;
  72524. /**
  72525. * Compute the Color3 hexadecimal code as a string
  72526. * @returns a string containing the hexadecimal representation of the Color3 object
  72527. */
  72528. toHexString(): string;
  72529. /**
  72530. * Computes a new Color3 converted from the current one to linear space
  72531. * @returns a new Color3 object
  72532. */
  72533. toLinearSpace(): Color3;
  72534. /**
  72535. * Converts current color in rgb space to HSV values
  72536. * @returns a new color3 representing the HSV values
  72537. */
  72538. toHSV(): Color3;
  72539. /**
  72540. * Converts current color in rgb space to HSV values
  72541. * @param result defines the Color3 where to store the HSV values
  72542. */
  72543. toHSVToRef(result: Color3): void;
  72544. /**
  72545. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72546. * @param convertedColor defines the Color3 object where to store the linear space version
  72547. * @returns the unmodified Color3
  72548. */
  72549. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72550. /**
  72551. * Computes a new Color3 converted from the current one to gamma space
  72552. * @returns a new Color3 object
  72553. */
  72554. toGammaSpace(): Color3;
  72555. /**
  72556. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72557. * @param convertedColor defines the Color3 object where to store the gamma space version
  72558. * @returns the unmodified Color3
  72559. */
  72560. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72561. private static _BlackReadOnly;
  72562. /**
  72563. * Convert Hue, saturation and value to a Color3 (RGB)
  72564. * @param hue defines the hue
  72565. * @param saturation defines the saturation
  72566. * @param value defines the value
  72567. * @param result defines the Color3 where to store the RGB values
  72568. */
  72569. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72570. /**
  72571. * Creates a new Color3 from the string containing valid hexadecimal values
  72572. * @param hex defines a string containing valid hexadecimal values
  72573. * @returns a new Color3 object
  72574. */
  72575. static FromHexString(hex: string): Color3;
  72576. /**
  72577. * Creates a new Color3 from the starting index of the given array
  72578. * @param array defines the source array
  72579. * @param offset defines an offset in the source array
  72580. * @returns a new Color3 object
  72581. */
  72582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72583. /**
  72584. * Creates a new Color3 from integer values (< 256)
  72585. * @param r defines the red component to read from (value between 0 and 255)
  72586. * @param g defines the green component to read from (value between 0 and 255)
  72587. * @param b defines the blue component to read from (value between 0 and 255)
  72588. * @returns a new Color3 object
  72589. */
  72590. static FromInts(r: number, g: number, b: number): Color3;
  72591. /**
  72592. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72593. * @param start defines the start Color3 value
  72594. * @param end defines the end Color3 value
  72595. * @param amount defines the gradient value between start and end
  72596. * @returns a new Color3 object
  72597. */
  72598. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72599. /**
  72600. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72601. * @param left defines the start value
  72602. * @param right defines the end value
  72603. * @param amount defines the gradient factor
  72604. * @param result defines the Color3 object where to store the result
  72605. */
  72606. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72607. /**
  72608. * Returns a Color3 value containing a red color
  72609. * @returns a new Color3 object
  72610. */
  72611. static Red(): Color3;
  72612. /**
  72613. * Returns a Color3 value containing a green color
  72614. * @returns a new Color3 object
  72615. */
  72616. static Green(): Color3;
  72617. /**
  72618. * Returns a Color3 value containing a blue color
  72619. * @returns a new Color3 object
  72620. */
  72621. static Blue(): Color3;
  72622. /**
  72623. * Returns a Color3 value containing a black color
  72624. * @returns a new Color3 object
  72625. */
  72626. static Black(): Color3;
  72627. /**
  72628. * Gets a Color3 value containing a black color that must not be updated
  72629. */
  72630. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72631. /**
  72632. * Returns a Color3 value containing a white color
  72633. * @returns a new Color3 object
  72634. */
  72635. static White(): Color3;
  72636. /**
  72637. * Returns a Color3 value containing a purple color
  72638. * @returns a new Color3 object
  72639. */
  72640. static Purple(): Color3;
  72641. /**
  72642. * Returns a Color3 value containing a magenta color
  72643. * @returns a new Color3 object
  72644. */
  72645. static Magenta(): Color3;
  72646. /**
  72647. * Returns a Color3 value containing a yellow color
  72648. * @returns a new Color3 object
  72649. */
  72650. static Yellow(): Color3;
  72651. /**
  72652. * Returns a Color3 value containing a gray color
  72653. * @returns a new Color3 object
  72654. */
  72655. static Gray(): Color3;
  72656. /**
  72657. * Returns a Color3 value containing a teal color
  72658. * @returns a new Color3 object
  72659. */
  72660. static Teal(): Color3;
  72661. /**
  72662. * Returns a Color3 value containing a random color
  72663. * @returns a new Color3 object
  72664. */
  72665. static Random(): Color3;
  72666. }
  72667. /**
  72668. * Class used to hold a RBGA color
  72669. */
  72670. export class Color4 {
  72671. /**
  72672. * Defines the red component (between 0 and 1, default is 0)
  72673. */
  72674. r: number;
  72675. /**
  72676. * Defines the green component (between 0 and 1, default is 0)
  72677. */
  72678. g: number;
  72679. /**
  72680. * Defines the blue component (between 0 and 1, default is 0)
  72681. */
  72682. b: number;
  72683. /**
  72684. * Defines the alpha component (between 0 and 1, default is 1)
  72685. */
  72686. a: number;
  72687. /**
  72688. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72689. * @param r defines the red component (between 0 and 1, default is 0)
  72690. * @param g defines the green component (between 0 and 1, default is 0)
  72691. * @param b defines the blue component (between 0 and 1, default is 0)
  72692. * @param a defines the alpha component (between 0 and 1, default is 1)
  72693. */
  72694. constructor(
  72695. /**
  72696. * Defines the red component (between 0 and 1, default is 0)
  72697. */
  72698. r?: number,
  72699. /**
  72700. * Defines the green component (between 0 and 1, default is 0)
  72701. */
  72702. g?: number,
  72703. /**
  72704. * Defines the blue component (between 0 and 1, default is 0)
  72705. */
  72706. b?: number,
  72707. /**
  72708. * Defines the alpha component (between 0 and 1, default is 1)
  72709. */
  72710. a?: number);
  72711. /**
  72712. * Adds in place the given Color4 values to the current Color4 object
  72713. * @param right defines the second operand
  72714. * @returns the current updated Color4 object
  72715. */
  72716. addInPlace(right: DeepImmutable<Color4>): Color4;
  72717. /**
  72718. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72719. * @returns the new array
  72720. */
  72721. asArray(): number[];
  72722. /**
  72723. * Stores from the starting index in the given array the Color4 successive values
  72724. * @param array defines the array where to store the r,g,b components
  72725. * @param index defines an optional index in the target array to define where to start storing values
  72726. * @returns the current Color4 object
  72727. */
  72728. toArray(array: number[], index?: number): Color4;
  72729. /**
  72730. * Determines equality between Color4 objects
  72731. * @param otherColor defines the second operand
  72732. * @returns true if the rgba values are equal to the given ones
  72733. */
  72734. equals(otherColor: DeepImmutable<Color4>): boolean;
  72735. /**
  72736. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72737. * @param right defines the second operand
  72738. * @returns a new Color4 object
  72739. */
  72740. add(right: DeepImmutable<Color4>): Color4;
  72741. /**
  72742. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72743. * @param right defines the second operand
  72744. * @returns a new Color4 object
  72745. */
  72746. subtract(right: DeepImmutable<Color4>): Color4;
  72747. /**
  72748. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72749. * @param right defines the second operand
  72750. * @param result defines the Color4 object where to store the result
  72751. * @returns the current Color4 object
  72752. */
  72753. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72754. /**
  72755. * Creates a new Color4 with the current Color4 values multiplied by scale
  72756. * @param scale defines the scaling factor to apply
  72757. * @returns a new Color4 object
  72758. */
  72759. scale(scale: number): Color4;
  72760. /**
  72761. * Multiplies the current Color4 values by scale and stores the result in "result"
  72762. * @param scale defines the scaling factor to apply
  72763. * @param result defines the Color4 object where to store the result
  72764. * @returns the current unmodified Color4
  72765. */
  72766. scaleToRef(scale: number, result: Color4): Color4;
  72767. /**
  72768. * Scale the current Color4 values by a factor and add the result to a given Color4
  72769. * @param scale defines the scale factor
  72770. * @param result defines the Color4 object where to store the result
  72771. * @returns the unmodified current Color4
  72772. */
  72773. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72774. /**
  72775. * Clamps the rgb values by the min and max values and stores the result into "result"
  72776. * @param min defines minimum clamping value (default is 0)
  72777. * @param max defines maximum clamping value (default is 1)
  72778. * @param result defines color to store the result into.
  72779. * @returns the cuurent Color4
  72780. */
  72781. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72782. /**
  72783. * Multipy an Color4 value by another and return a new Color4 object
  72784. * @param color defines the Color4 value to multiply by
  72785. * @returns a new Color4 object
  72786. */
  72787. multiply(color: Color4): Color4;
  72788. /**
  72789. * Multipy a Color4 value by another and push the result in a reference value
  72790. * @param color defines the Color4 value to multiply by
  72791. * @param result defines the Color4 to fill the result in
  72792. * @returns the result Color4
  72793. */
  72794. multiplyToRef(color: Color4, result: Color4): Color4;
  72795. /**
  72796. * Creates a string with the Color4 current values
  72797. * @returns the string representation of the Color4 object
  72798. */
  72799. toString(): string;
  72800. /**
  72801. * Returns the string "Color4"
  72802. * @returns "Color4"
  72803. */
  72804. getClassName(): string;
  72805. /**
  72806. * Compute the Color4 hash code
  72807. * @returns an unique number that can be used to hash Color4 objects
  72808. */
  72809. getHashCode(): number;
  72810. /**
  72811. * Creates a new Color4 copied from the current one
  72812. * @returns a new Color4 object
  72813. */
  72814. clone(): Color4;
  72815. /**
  72816. * Copies the given Color4 values into the current one
  72817. * @param source defines the source Color4 object
  72818. * @returns the current updated Color4 object
  72819. */
  72820. copyFrom(source: Color4): Color4;
  72821. /**
  72822. * Copies the given float values into the current one
  72823. * @param r defines the red component to read from
  72824. * @param g defines the green component to read from
  72825. * @param b defines the blue component to read from
  72826. * @param a defines the alpha component to read from
  72827. * @returns the current updated Color4 object
  72828. */
  72829. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72830. /**
  72831. * Copies the given float values into the current one
  72832. * @param r defines the red component to read from
  72833. * @param g defines the green component to read from
  72834. * @param b defines the blue component to read from
  72835. * @param a defines the alpha component to read from
  72836. * @returns the current updated Color4 object
  72837. */
  72838. set(r: number, g: number, b: number, a: number): Color4;
  72839. /**
  72840. * Compute the Color4 hexadecimal code as a string
  72841. * @returns a string containing the hexadecimal representation of the Color4 object
  72842. */
  72843. toHexString(): string;
  72844. /**
  72845. * Computes a new Color4 converted from the current one to linear space
  72846. * @returns a new Color4 object
  72847. */
  72848. toLinearSpace(): Color4;
  72849. /**
  72850. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72851. * @param convertedColor defines the Color4 object where to store the linear space version
  72852. * @returns the unmodified Color4
  72853. */
  72854. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72855. /**
  72856. * Computes a new Color4 converted from the current one to gamma space
  72857. * @returns a new Color4 object
  72858. */
  72859. toGammaSpace(): Color4;
  72860. /**
  72861. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72862. * @param convertedColor defines the Color4 object where to store the gamma space version
  72863. * @returns the unmodified Color4
  72864. */
  72865. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72866. /**
  72867. * Creates a new Color4 from the string containing valid hexadecimal values
  72868. * @param hex defines a string containing valid hexadecimal values
  72869. * @returns a new Color4 object
  72870. */
  72871. static FromHexString(hex: string): Color4;
  72872. /**
  72873. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72874. * @param left defines the start value
  72875. * @param right defines the end value
  72876. * @param amount defines the gradient factor
  72877. * @returns a new Color4 object
  72878. */
  72879. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72880. /**
  72881. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72882. * @param left defines the start value
  72883. * @param right defines the end value
  72884. * @param amount defines the gradient factor
  72885. * @param result defines the Color4 object where to store data
  72886. */
  72887. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72888. /**
  72889. * Creates a new Color4 from a Color3 and an alpha value
  72890. * @param color3 defines the source Color3 to read from
  72891. * @param alpha defines the alpha component (1.0 by default)
  72892. * @returns a new Color4 object
  72893. */
  72894. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72895. /**
  72896. * Creates a new Color4 from the starting index element of the given array
  72897. * @param array defines the source array to read from
  72898. * @param offset defines the offset in the source array
  72899. * @returns a new Color4 object
  72900. */
  72901. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72902. /**
  72903. * Creates a new Color3 from integer values (< 256)
  72904. * @param r defines the red component to read from (value between 0 and 255)
  72905. * @param g defines the green component to read from (value between 0 and 255)
  72906. * @param b defines the blue component to read from (value between 0 and 255)
  72907. * @param a defines the alpha component to read from (value between 0 and 255)
  72908. * @returns a new Color3 object
  72909. */
  72910. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72911. /**
  72912. * Check the content of a given array and convert it to an array containing RGBA data
  72913. * If the original array was already containing count * 4 values then it is returned directly
  72914. * @param colors defines the array to check
  72915. * @param count defines the number of RGBA data to expect
  72916. * @returns an array containing count * 4 values (RGBA)
  72917. */
  72918. static CheckColors4(colors: number[], count: number): number[];
  72919. }
  72920. /**
  72921. * @hidden
  72922. */
  72923. export class TmpColors {
  72924. static Color3: Color3[];
  72925. static Color4: Color4[];
  72926. }
  72927. }
  72928. declare module BABYLON {
  72929. /**
  72930. * Defines an interface which represents an animation key frame
  72931. */
  72932. export interface IAnimationKey {
  72933. /**
  72934. * Frame of the key frame
  72935. */
  72936. frame: number;
  72937. /**
  72938. * Value at the specifies key frame
  72939. */
  72940. value: any;
  72941. /**
  72942. * The input tangent for the cubic hermite spline
  72943. */
  72944. inTangent?: any;
  72945. /**
  72946. * The output tangent for the cubic hermite spline
  72947. */
  72948. outTangent?: any;
  72949. /**
  72950. * The animation interpolation type
  72951. */
  72952. interpolation?: AnimationKeyInterpolation;
  72953. }
  72954. /**
  72955. * Enum for the animation key frame interpolation type
  72956. */
  72957. export enum AnimationKeyInterpolation {
  72958. /**
  72959. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72960. */
  72961. STEP = 1
  72962. }
  72963. }
  72964. declare module BABYLON {
  72965. /**
  72966. * Represents the range of an animation
  72967. */
  72968. export class AnimationRange {
  72969. /**The name of the animation range**/
  72970. name: string;
  72971. /**The starting frame of the animation */
  72972. from: number;
  72973. /**The ending frame of the animation*/
  72974. to: number;
  72975. /**
  72976. * Initializes the range of an animation
  72977. * @param name The name of the animation range
  72978. * @param from The starting frame of the animation
  72979. * @param to The ending frame of the animation
  72980. */
  72981. constructor(
  72982. /**The name of the animation range**/
  72983. name: string,
  72984. /**The starting frame of the animation */
  72985. from: number,
  72986. /**The ending frame of the animation*/
  72987. to: number);
  72988. /**
  72989. * Makes a copy of the animation range
  72990. * @returns A copy of the animation range
  72991. */
  72992. clone(): AnimationRange;
  72993. }
  72994. }
  72995. declare module BABYLON {
  72996. /**
  72997. * Composed of a frame, and an action function
  72998. */
  72999. export class AnimationEvent {
  73000. /** The frame for which the event is triggered **/
  73001. frame: number;
  73002. /** The event to perform when triggered **/
  73003. action: (currentFrame: number) => void;
  73004. /** Specifies if the event should be triggered only once**/
  73005. onlyOnce?: boolean | undefined;
  73006. /**
  73007. * Specifies if the animation event is done
  73008. */
  73009. isDone: boolean;
  73010. /**
  73011. * Initializes the animation event
  73012. * @param frame The frame for which the event is triggered
  73013. * @param action The event to perform when triggered
  73014. * @param onlyOnce Specifies if the event should be triggered only once
  73015. */
  73016. constructor(
  73017. /** The frame for which the event is triggered **/
  73018. frame: number,
  73019. /** The event to perform when triggered **/
  73020. action: (currentFrame: number) => void,
  73021. /** Specifies if the event should be triggered only once**/
  73022. onlyOnce?: boolean | undefined);
  73023. /** @hidden */
  73024. _clone(): AnimationEvent;
  73025. }
  73026. }
  73027. declare module BABYLON {
  73028. /**
  73029. * Interface used to define a behavior
  73030. */
  73031. export interface Behavior<T> {
  73032. /** gets or sets behavior's name */
  73033. name: string;
  73034. /**
  73035. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73036. */
  73037. init(): void;
  73038. /**
  73039. * Called when the behavior is attached to a target
  73040. * @param target defines the target where the behavior is attached to
  73041. */
  73042. attach(target: T): void;
  73043. /**
  73044. * Called when the behavior is detached from its target
  73045. */
  73046. detach(): void;
  73047. }
  73048. /**
  73049. * Interface implemented by classes supporting behaviors
  73050. */
  73051. export interface IBehaviorAware<T> {
  73052. /**
  73053. * Attach a behavior
  73054. * @param behavior defines the behavior to attach
  73055. * @returns the current host
  73056. */
  73057. addBehavior(behavior: Behavior<T>): T;
  73058. /**
  73059. * Remove a behavior from the current object
  73060. * @param behavior defines the behavior to detach
  73061. * @returns the current host
  73062. */
  73063. removeBehavior(behavior: Behavior<T>): T;
  73064. /**
  73065. * Gets a behavior using its name to search
  73066. * @param name defines the name to search
  73067. * @returns the behavior or null if not found
  73068. */
  73069. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73070. }
  73071. }
  73072. declare module BABYLON {
  73073. /**
  73074. * Defines an array and its length.
  73075. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73076. */
  73077. export interface ISmartArrayLike<T> {
  73078. /**
  73079. * The data of the array.
  73080. */
  73081. data: Array<T>;
  73082. /**
  73083. * The active length of the array.
  73084. */
  73085. length: number;
  73086. }
  73087. /**
  73088. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73089. */
  73090. export class SmartArray<T> implements ISmartArrayLike<T> {
  73091. /**
  73092. * The full set of data from the array.
  73093. */
  73094. data: Array<T>;
  73095. /**
  73096. * The active length of the array.
  73097. */
  73098. length: number;
  73099. protected _id: number;
  73100. /**
  73101. * Instantiates a Smart Array.
  73102. * @param capacity defines the default capacity of the array.
  73103. */
  73104. constructor(capacity: number);
  73105. /**
  73106. * Pushes a value at the end of the active data.
  73107. * @param value defines the object to push in the array.
  73108. */
  73109. push(value: T): void;
  73110. /**
  73111. * Iterates over the active data and apply the lambda to them.
  73112. * @param func defines the action to apply on each value.
  73113. */
  73114. forEach(func: (content: T) => void): void;
  73115. /**
  73116. * Sorts the full sets of data.
  73117. * @param compareFn defines the comparison function to apply.
  73118. */
  73119. sort(compareFn: (a: T, b: T) => number): void;
  73120. /**
  73121. * Resets the active data to an empty array.
  73122. */
  73123. reset(): void;
  73124. /**
  73125. * Releases all the data from the array as well as the array.
  73126. */
  73127. dispose(): void;
  73128. /**
  73129. * Concats the active data with a given array.
  73130. * @param array defines the data to concatenate with.
  73131. */
  73132. concat(array: any): void;
  73133. /**
  73134. * Returns the position of a value in the active data.
  73135. * @param value defines the value to find the index for
  73136. * @returns the index if found in the active data otherwise -1
  73137. */
  73138. indexOf(value: T): number;
  73139. /**
  73140. * Returns whether an element is part of the active data.
  73141. * @param value defines the value to look for
  73142. * @returns true if found in the active data otherwise false
  73143. */
  73144. contains(value: T): boolean;
  73145. private static _GlobalId;
  73146. }
  73147. /**
  73148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73149. * The data in this array can only be present once
  73150. */
  73151. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73152. private _duplicateId;
  73153. /**
  73154. * Pushes a value at the end of the active data.
  73155. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73156. * @param value defines the object to push in the array.
  73157. */
  73158. push(value: T): void;
  73159. /**
  73160. * Pushes a value at the end of the active data.
  73161. * If the data is already present, it won t be added again
  73162. * @param value defines the object to push in the array.
  73163. * @returns true if added false if it was already present
  73164. */
  73165. pushNoDuplicate(value: T): boolean;
  73166. /**
  73167. * Resets the active data to an empty array.
  73168. */
  73169. reset(): void;
  73170. /**
  73171. * Concats the active data with a given array.
  73172. * This ensures no dupplicate will be present in the result.
  73173. * @param array defines the data to concatenate with.
  73174. */
  73175. concatWithNoDuplicate(array: any): void;
  73176. }
  73177. }
  73178. declare module BABYLON {
  73179. /**
  73180. * @ignore
  73181. * This is a list of all the different input types that are available in the application.
  73182. * Fo instance: ArcRotateCameraGamepadInput...
  73183. */
  73184. export var CameraInputTypes: {};
  73185. /**
  73186. * This is the contract to implement in order to create a new input class.
  73187. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73188. */
  73189. export interface ICameraInput<TCamera extends Camera> {
  73190. /**
  73191. * Defines the camera the input is attached to.
  73192. */
  73193. camera: Nullable<TCamera>;
  73194. /**
  73195. * Gets the class name of the current intput.
  73196. * @returns the class name
  73197. */
  73198. getClassName(): string;
  73199. /**
  73200. * Get the friendly name associated with the input class.
  73201. * @returns the input friendly name
  73202. */
  73203. getSimpleName(): string;
  73204. /**
  73205. * Attach the input controls to a specific dom element to get the input from.
  73206. * @param element Defines the element the controls should be listened from
  73207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73208. */
  73209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73210. /**
  73211. * Detach the current controls from the specified dom element.
  73212. * @param element Defines the element to stop listening the inputs from
  73213. */
  73214. detachControl(element: Nullable<HTMLElement>): void;
  73215. /**
  73216. * Update the current camera state depending on the inputs that have been used this frame.
  73217. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73218. */
  73219. checkInputs?: () => void;
  73220. }
  73221. /**
  73222. * Represents a map of input types to input instance or input index to input instance.
  73223. */
  73224. export interface CameraInputsMap<TCamera extends Camera> {
  73225. /**
  73226. * Accessor to the input by input type.
  73227. */
  73228. [name: string]: ICameraInput<TCamera>;
  73229. /**
  73230. * Accessor to the input by input index.
  73231. */
  73232. [idx: number]: ICameraInput<TCamera>;
  73233. }
  73234. /**
  73235. * This represents the input manager used within a camera.
  73236. * It helps dealing with all the different kind of input attached to a camera.
  73237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73238. */
  73239. export class CameraInputsManager<TCamera extends Camera> {
  73240. /**
  73241. * Defines the list of inputs attahed to the camera.
  73242. */
  73243. attached: CameraInputsMap<TCamera>;
  73244. /**
  73245. * Defines the dom element the camera is collecting inputs from.
  73246. * This is null if the controls have not been attached.
  73247. */
  73248. attachedElement: Nullable<HTMLElement>;
  73249. /**
  73250. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73251. */
  73252. noPreventDefault: boolean;
  73253. /**
  73254. * Defined the camera the input manager belongs to.
  73255. */
  73256. camera: TCamera;
  73257. /**
  73258. * Update the current camera state depending on the inputs that have been used this frame.
  73259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73260. */
  73261. checkInputs: () => void;
  73262. /**
  73263. * Instantiate a new Camera Input Manager.
  73264. * @param camera Defines the camera the input manager blongs to
  73265. */
  73266. constructor(camera: TCamera);
  73267. /**
  73268. * Add an input method to a camera
  73269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73270. * @param input camera input method
  73271. */
  73272. add(input: ICameraInput<TCamera>): void;
  73273. /**
  73274. * Remove a specific input method from a camera
  73275. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73276. * @param inputToRemove camera input method
  73277. */
  73278. remove(inputToRemove: ICameraInput<TCamera>): void;
  73279. /**
  73280. * Remove a specific input type from a camera
  73281. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73282. * @param inputType the type of the input to remove
  73283. */
  73284. removeByType(inputType: string): void;
  73285. private _addCheckInputs;
  73286. /**
  73287. * Attach the input controls to the currently attached dom element to listen the events from.
  73288. * @param input Defines the input to attach
  73289. */
  73290. attachInput(input: ICameraInput<TCamera>): void;
  73291. /**
  73292. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73293. * @param element Defines the dom element to collect the events from
  73294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73295. */
  73296. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73297. /**
  73298. * Detach the current manager inputs controls from a specific dom element.
  73299. * @param element Defines the dom element to collect the events from
  73300. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73301. */
  73302. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73303. /**
  73304. * Rebuild the dynamic inputCheck function from the current list of
  73305. * defined inputs in the manager.
  73306. */
  73307. rebuildInputCheck(): void;
  73308. /**
  73309. * Remove all attached input methods from a camera
  73310. */
  73311. clear(): void;
  73312. /**
  73313. * Serialize the current input manager attached to a camera.
  73314. * This ensures than once parsed,
  73315. * the input associated to the camera will be identical to the current ones
  73316. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73317. */
  73318. serialize(serializedCamera: any): void;
  73319. /**
  73320. * Parses an input manager serialized JSON to restore the previous list of inputs
  73321. * and states associated to a camera.
  73322. * @param parsedCamera Defines the JSON to parse
  73323. */
  73324. parse(parsedCamera: any): void;
  73325. }
  73326. }
  73327. declare module BABYLON {
  73328. /**
  73329. * Class used to store data that will be store in GPU memory
  73330. */
  73331. export class Buffer {
  73332. private _engine;
  73333. private _buffer;
  73334. /** @hidden */
  73335. _data: Nullable<DataArray>;
  73336. private _updatable;
  73337. private _instanced;
  73338. private _divisor;
  73339. /**
  73340. * Gets the byte stride.
  73341. */
  73342. readonly byteStride: number;
  73343. /**
  73344. * Constructor
  73345. * @param engine the engine
  73346. * @param data the data to use for this buffer
  73347. * @param updatable whether the data is updatable
  73348. * @param stride the stride (optional)
  73349. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73350. * @param instanced whether the buffer is instanced (optional)
  73351. * @param useBytes set to true if the stride in in bytes (optional)
  73352. * @param divisor sets an optional divisor for instances (1 by default)
  73353. */
  73354. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73355. /**
  73356. * Create a new VertexBuffer based on the current buffer
  73357. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73358. * @param offset defines offset in the buffer (0 by default)
  73359. * @param size defines the size in floats of attributes (position is 3 for instance)
  73360. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73361. * @param instanced defines if the vertex buffer contains indexed data
  73362. * @param useBytes defines if the offset and stride are in bytes *
  73363. * @param divisor sets an optional divisor for instances (1 by default)
  73364. * @returns the new vertex buffer
  73365. */
  73366. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73367. /**
  73368. * Gets a boolean indicating if the Buffer is updatable?
  73369. * @returns true if the buffer is updatable
  73370. */
  73371. isUpdatable(): boolean;
  73372. /**
  73373. * Gets current buffer's data
  73374. * @returns a DataArray or null
  73375. */
  73376. getData(): Nullable<DataArray>;
  73377. /**
  73378. * Gets underlying native buffer
  73379. * @returns underlying native buffer
  73380. */
  73381. getBuffer(): Nullable<DataBuffer>;
  73382. /**
  73383. * Gets the stride in float32 units (i.e. byte stride / 4).
  73384. * May not be an integer if the byte stride is not divisible by 4.
  73385. * DEPRECATED. Use byteStride instead.
  73386. * @returns the stride in float32 units
  73387. */
  73388. getStrideSize(): number;
  73389. /**
  73390. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73391. * @param data defines the data to store
  73392. */
  73393. create(data?: Nullable<DataArray>): void;
  73394. /** @hidden */
  73395. _rebuild(): void;
  73396. /**
  73397. * Update current buffer data
  73398. * @param data defines the data to store
  73399. */
  73400. update(data: DataArray): void;
  73401. /**
  73402. * Updates the data directly.
  73403. * @param data the new data
  73404. * @param offset the new offset
  73405. * @param vertexCount the vertex count (optional)
  73406. * @param useBytes set to true if the offset is in bytes
  73407. */
  73408. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73409. /**
  73410. * Release all resources
  73411. */
  73412. dispose(): void;
  73413. }
  73414. /**
  73415. * Specialized buffer used to store vertex data
  73416. */
  73417. export class VertexBuffer {
  73418. /** @hidden */
  73419. _buffer: Buffer;
  73420. private _kind;
  73421. private _size;
  73422. private _ownsBuffer;
  73423. private _instanced;
  73424. private _instanceDivisor;
  73425. /**
  73426. * The byte type.
  73427. */
  73428. static readonly BYTE: number;
  73429. /**
  73430. * The unsigned byte type.
  73431. */
  73432. static readonly UNSIGNED_BYTE: number;
  73433. /**
  73434. * The short type.
  73435. */
  73436. static readonly SHORT: number;
  73437. /**
  73438. * The unsigned short type.
  73439. */
  73440. static readonly UNSIGNED_SHORT: number;
  73441. /**
  73442. * The integer type.
  73443. */
  73444. static readonly INT: number;
  73445. /**
  73446. * The unsigned integer type.
  73447. */
  73448. static readonly UNSIGNED_INT: number;
  73449. /**
  73450. * The float type.
  73451. */
  73452. static readonly FLOAT: number;
  73453. /**
  73454. * Gets or sets the instance divisor when in instanced mode
  73455. */
  73456. instanceDivisor: number;
  73457. /**
  73458. * Gets the byte stride.
  73459. */
  73460. readonly byteStride: number;
  73461. /**
  73462. * Gets the byte offset.
  73463. */
  73464. readonly byteOffset: number;
  73465. /**
  73466. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73467. */
  73468. readonly normalized: boolean;
  73469. /**
  73470. * Gets the data type of each component in the array.
  73471. */
  73472. readonly type: number;
  73473. /**
  73474. * Constructor
  73475. * @param engine the engine
  73476. * @param data the data to use for this vertex buffer
  73477. * @param kind the vertex buffer kind
  73478. * @param updatable whether the data is updatable
  73479. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73480. * @param stride the stride (optional)
  73481. * @param instanced whether the buffer is instanced (optional)
  73482. * @param offset the offset of the data (optional)
  73483. * @param size the number of components (optional)
  73484. * @param type the type of the component (optional)
  73485. * @param normalized whether the data contains normalized data (optional)
  73486. * @param useBytes set to true if stride and offset are in bytes (optional)
  73487. * @param divisor defines the instance divisor to use (1 by default)
  73488. */
  73489. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  73490. /** @hidden */
  73491. _rebuild(): void;
  73492. /**
  73493. * Returns the kind of the VertexBuffer (string)
  73494. * @returns a string
  73495. */
  73496. getKind(): string;
  73497. /**
  73498. * Gets a boolean indicating if the VertexBuffer is updatable?
  73499. * @returns true if the buffer is updatable
  73500. */
  73501. isUpdatable(): boolean;
  73502. /**
  73503. * Gets current buffer's data
  73504. * @returns a DataArray or null
  73505. */
  73506. getData(): Nullable<DataArray>;
  73507. /**
  73508. * Gets underlying native buffer
  73509. * @returns underlying native buffer
  73510. */
  73511. getBuffer(): Nullable<DataBuffer>;
  73512. /**
  73513. * Gets the stride in float32 units (i.e. byte stride / 4).
  73514. * May not be an integer if the byte stride is not divisible by 4.
  73515. * DEPRECATED. Use byteStride instead.
  73516. * @returns the stride in float32 units
  73517. */
  73518. getStrideSize(): number;
  73519. /**
  73520. * Returns the offset as a multiple of the type byte length.
  73521. * DEPRECATED. Use byteOffset instead.
  73522. * @returns the offset in bytes
  73523. */
  73524. getOffset(): number;
  73525. /**
  73526. * Returns the number of components per vertex attribute (integer)
  73527. * @returns the size in float
  73528. */
  73529. getSize(): number;
  73530. /**
  73531. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73532. * @returns true if this buffer is instanced
  73533. */
  73534. getIsInstanced(): boolean;
  73535. /**
  73536. * Returns the instancing divisor, zero for non-instanced (integer).
  73537. * @returns a number
  73538. */
  73539. getInstanceDivisor(): number;
  73540. /**
  73541. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73542. * @param data defines the data to store
  73543. */
  73544. create(data?: DataArray): void;
  73545. /**
  73546. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73547. * This function will create a new buffer if the current one is not updatable
  73548. * @param data defines the data to store
  73549. */
  73550. update(data: DataArray): void;
  73551. /**
  73552. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73553. * Returns the directly updated WebGLBuffer.
  73554. * @param data the new data
  73555. * @param offset the new offset
  73556. * @param useBytes set to true if the offset is in bytes
  73557. */
  73558. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73559. /**
  73560. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73561. */
  73562. dispose(): void;
  73563. /**
  73564. * Enumerates each value of this vertex buffer as numbers.
  73565. * @param count the number of values to enumerate
  73566. * @param callback the callback function called for each value
  73567. */
  73568. forEach(count: number, callback: (value: number, index: number) => void): void;
  73569. /**
  73570. * Positions
  73571. */
  73572. static readonly PositionKind: string;
  73573. /**
  73574. * Normals
  73575. */
  73576. static readonly NormalKind: string;
  73577. /**
  73578. * Tangents
  73579. */
  73580. static readonly TangentKind: string;
  73581. /**
  73582. * Texture coordinates
  73583. */
  73584. static readonly UVKind: string;
  73585. /**
  73586. * Texture coordinates 2
  73587. */
  73588. static readonly UV2Kind: string;
  73589. /**
  73590. * Texture coordinates 3
  73591. */
  73592. static readonly UV3Kind: string;
  73593. /**
  73594. * Texture coordinates 4
  73595. */
  73596. static readonly UV4Kind: string;
  73597. /**
  73598. * Texture coordinates 5
  73599. */
  73600. static readonly UV5Kind: string;
  73601. /**
  73602. * Texture coordinates 6
  73603. */
  73604. static readonly UV6Kind: string;
  73605. /**
  73606. * Colors
  73607. */
  73608. static readonly ColorKind: string;
  73609. /**
  73610. * Matrix indices (for bones)
  73611. */
  73612. static readonly MatricesIndicesKind: string;
  73613. /**
  73614. * Matrix weights (for bones)
  73615. */
  73616. static readonly MatricesWeightsKind: string;
  73617. /**
  73618. * Additional matrix indices (for bones)
  73619. */
  73620. static readonly MatricesIndicesExtraKind: string;
  73621. /**
  73622. * Additional matrix weights (for bones)
  73623. */
  73624. static readonly MatricesWeightsExtraKind: string;
  73625. /**
  73626. * Deduces the stride given a kind.
  73627. * @param kind The kind string to deduce
  73628. * @returns The deduced stride
  73629. */
  73630. static DeduceStride(kind: string): number;
  73631. /**
  73632. * Gets the byte length of the given type.
  73633. * @param type the type
  73634. * @returns the number of bytes
  73635. */
  73636. static GetTypeByteLength(type: number): number;
  73637. /**
  73638. * Enumerates each value of the given parameters as numbers.
  73639. * @param data the data to enumerate
  73640. * @param byteOffset the byte offset of the data
  73641. * @param byteStride the byte stride of the data
  73642. * @param componentCount the number of components per element
  73643. * @param componentType the type of the component
  73644. * @param count the number of values to enumerate
  73645. * @param normalized whether the data is normalized
  73646. * @param callback the callback function called for each value
  73647. */
  73648. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73649. private static _GetFloatValue;
  73650. }
  73651. }
  73652. declare module BABYLON {
  73653. /**
  73654. * @hidden
  73655. */
  73656. export class IntersectionInfo {
  73657. bu: Nullable<number>;
  73658. bv: Nullable<number>;
  73659. distance: number;
  73660. faceId: number;
  73661. subMeshId: number;
  73662. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73663. }
  73664. }
  73665. declare module BABYLON {
  73666. /**
  73667. * Represens a plane by the equation ax + by + cz + d = 0
  73668. */
  73669. export class Plane {
  73670. private static _TmpMatrix;
  73671. /**
  73672. * Normal of the plane (a,b,c)
  73673. */
  73674. normal: Vector3;
  73675. /**
  73676. * d component of the plane
  73677. */
  73678. d: number;
  73679. /**
  73680. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73681. * @param a a component of the plane
  73682. * @param b b component of the plane
  73683. * @param c c component of the plane
  73684. * @param d d component of the plane
  73685. */
  73686. constructor(a: number, b: number, c: number, d: number);
  73687. /**
  73688. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73689. */
  73690. asArray(): number[];
  73691. /**
  73692. * @returns a new plane copied from the current Plane.
  73693. */
  73694. clone(): Plane;
  73695. /**
  73696. * @returns the string "Plane".
  73697. */
  73698. getClassName(): string;
  73699. /**
  73700. * @returns the Plane hash code.
  73701. */
  73702. getHashCode(): number;
  73703. /**
  73704. * Normalize the current Plane in place.
  73705. * @returns the updated Plane.
  73706. */
  73707. normalize(): Plane;
  73708. /**
  73709. * Applies a transformation the plane and returns the result
  73710. * @param transformation the transformation matrix to be applied to the plane
  73711. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73712. */
  73713. transform(transformation: DeepImmutable<Matrix>): Plane;
  73714. /**
  73715. * Calcualtte the dot product between the point and the plane normal
  73716. * @param point point to calculate the dot product with
  73717. * @returns the dot product (float) of the point coordinates and the plane normal.
  73718. */
  73719. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73720. /**
  73721. * Updates the current Plane from the plane defined by the three given points.
  73722. * @param point1 one of the points used to contruct the plane
  73723. * @param point2 one of the points used to contruct the plane
  73724. * @param point3 one of the points used to contruct the plane
  73725. * @returns the updated Plane.
  73726. */
  73727. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73728. /**
  73729. * Checks if the plane is facing a given direction
  73730. * @param direction the direction to check if the plane is facing
  73731. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73732. * @returns True is the vector "direction" is the same side than the plane normal.
  73733. */
  73734. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73735. /**
  73736. * Calculates the distance to a point
  73737. * @param point point to calculate distance to
  73738. * @returns the signed distance (float) from the given point to the Plane.
  73739. */
  73740. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73741. /**
  73742. * Creates a plane from an array
  73743. * @param array the array to create a plane from
  73744. * @returns a new Plane from the given array.
  73745. */
  73746. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73747. /**
  73748. * Creates a plane from three points
  73749. * @param point1 point used to create the plane
  73750. * @param point2 point used to create the plane
  73751. * @param point3 point used to create the plane
  73752. * @returns a new Plane defined by the three given points.
  73753. */
  73754. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73755. /**
  73756. * Creates a plane from an origin point and a normal
  73757. * @param origin origin of the plane to be constructed
  73758. * @param normal normal of the plane to be constructed
  73759. * @returns a new Plane the normal vector to this plane at the given origin point.
  73760. * Note : the vector "normal" is updated because normalized.
  73761. */
  73762. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73763. /**
  73764. * Calculates the distance from a plane and a point
  73765. * @param origin origin of the plane to be constructed
  73766. * @param normal normal of the plane to be constructed
  73767. * @param point point to calculate distance to
  73768. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73769. */
  73770. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73771. }
  73772. }
  73773. declare module BABYLON {
  73774. /**
  73775. * Class used to store bounding sphere information
  73776. */
  73777. export class BoundingSphere {
  73778. /**
  73779. * Gets the center of the bounding sphere in local space
  73780. */
  73781. readonly center: Vector3;
  73782. /**
  73783. * Radius of the bounding sphere in local space
  73784. */
  73785. radius: number;
  73786. /**
  73787. * Gets the center of the bounding sphere in world space
  73788. */
  73789. readonly centerWorld: Vector3;
  73790. /**
  73791. * Radius of the bounding sphere in world space
  73792. */
  73793. radiusWorld: number;
  73794. /**
  73795. * Gets the minimum vector in local space
  73796. */
  73797. readonly minimum: Vector3;
  73798. /**
  73799. * Gets the maximum vector in local space
  73800. */
  73801. readonly maximum: Vector3;
  73802. private _worldMatrix;
  73803. private static readonly TmpVector3;
  73804. /**
  73805. * Creates a new bounding sphere
  73806. * @param min defines the minimum vector (in local space)
  73807. * @param max defines the maximum vector (in local space)
  73808. * @param worldMatrix defines the new world matrix
  73809. */
  73810. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73811. /**
  73812. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73813. * @param min defines the new minimum vector (in local space)
  73814. * @param max defines the new maximum vector (in local space)
  73815. * @param worldMatrix defines the new world matrix
  73816. */
  73817. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73818. /**
  73819. * Scale the current bounding sphere by applying a scale factor
  73820. * @param factor defines the scale factor to apply
  73821. * @returns the current bounding box
  73822. */
  73823. scale(factor: number): BoundingSphere;
  73824. /**
  73825. * Gets the world matrix of the bounding box
  73826. * @returns a matrix
  73827. */
  73828. getWorldMatrix(): DeepImmutable<Matrix>;
  73829. /** @hidden */
  73830. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73831. /**
  73832. * Tests if the bounding sphere is intersecting the frustum planes
  73833. * @param frustumPlanes defines the frustum planes to test
  73834. * @returns true if there is an intersection
  73835. */
  73836. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73837. /**
  73838. * Tests if the bounding sphere center is in between the frustum planes.
  73839. * Used for optimistic fast inclusion.
  73840. * @param frustumPlanes defines the frustum planes to test
  73841. * @returns true if the sphere center is in between the frustum planes
  73842. */
  73843. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73844. /**
  73845. * Tests if a point is inside the bounding sphere
  73846. * @param point defines the point to test
  73847. * @returns true if the point is inside the bounding sphere
  73848. */
  73849. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73850. /**
  73851. * Checks if two sphere intersct
  73852. * @param sphere0 sphere 0
  73853. * @param sphere1 sphere 1
  73854. * @returns true if the speres intersect
  73855. */
  73856. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73857. }
  73858. }
  73859. declare module BABYLON {
  73860. /**
  73861. * Class used to store bounding box information
  73862. */
  73863. export class BoundingBox implements ICullable {
  73864. /**
  73865. * Gets the 8 vectors representing the bounding box in local space
  73866. */
  73867. readonly vectors: Vector3[];
  73868. /**
  73869. * Gets the center of the bounding box in local space
  73870. */
  73871. readonly center: Vector3;
  73872. /**
  73873. * Gets the center of the bounding box in world space
  73874. */
  73875. readonly centerWorld: Vector3;
  73876. /**
  73877. * Gets the extend size in local space
  73878. */
  73879. readonly extendSize: Vector3;
  73880. /**
  73881. * Gets the extend size in world space
  73882. */
  73883. readonly extendSizeWorld: Vector3;
  73884. /**
  73885. * Gets the OBB (object bounding box) directions
  73886. */
  73887. readonly directions: Vector3[];
  73888. /**
  73889. * Gets the 8 vectors representing the bounding box in world space
  73890. */
  73891. readonly vectorsWorld: Vector3[];
  73892. /**
  73893. * Gets the minimum vector in world space
  73894. */
  73895. readonly minimumWorld: Vector3;
  73896. /**
  73897. * Gets the maximum vector in world space
  73898. */
  73899. readonly maximumWorld: Vector3;
  73900. /**
  73901. * Gets the minimum vector in local space
  73902. */
  73903. readonly minimum: Vector3;
  73904. /**
  73905. * Gets the maximum vector in local space
  73906. */
  73907. readonly maximum: Vector3;
  73908. private _worldMatrix;
  73909. private static readonly TmpVector3;
  73910. /**
  73911. * @hidden
  73912. */
  73913. _tag: number;
  73914. /**
  73915. * Creates a new bounding box
  73916. * @param min defines the minimum vector (in local space)
  73917. * @param max defines the maximum vector (in local space)
  73918. * @param worldMatrix defines the new world matrix
  73919. */
  73920. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73921. /**
  73922. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73923. * @param min defines the new minimum vector (in local space)
  73924. * @param max defines the new maximum vector (in local space)
  73925. * @param worldMatrix defines the new world matrix
  73926. */
  73927. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73928. /**
  73929. * Scale the current bounding box by applying a scale factor
  73930. * @param factor defines the scale factor to apply
  73931. * @returns the current bounding box
  73932. */
  73933. scale(factor: number): BoundingBox;
  73934. /**
  73935. * Gets the world matrix of the bounding box
  73936. * @returns a matrix
  73937. */
  73938. getWorldMatrix(): DeepImmutable<Matrix>;
  73939. /** @hidden */
  73940. _update(world: DeepImmutable<Matrix>): void;
  73941. /**
  73942. * Tests if the bounding box is intersecting the frustum planes
  73943. * @param frustumPlanes defines the frustum planes to test
  73944. * @returns true if there is an intersection
  73945. */
  73946. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73947. /**
  73948. * Tests if the bounding box is entirely inside the frustum planes
  73949. * @param frustumPlanes defines the frustum planes to test
  73950. * @returns true if there is an inclusion
  73951. */
  73952. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73953. /**
  73954. * Tests if a point is inside the bounding box
  73955. * @param point defines the point to test
  73956. * @returns true if the point is inside the bounding box
  73957. */
  73958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73959. /**
  73960. * Tests if the bounding box intersects with a bounding sphere
  73961. * @param sphere defines the sphere to test
  73962. * @returns true if there is an intersection
  73963. */
  73964. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73965. /**
  73966. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73967. * @param min defines the min vector to use
  73968. * @param max defines the max vector to use
  73969. * @returns true if there is an intersection
  73970. */
  73971. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73972. /**
  73973. * Tests if two bounding boxes are intersections
  73974. * @param box0 defines the first box to test
  73975. * @param box1 defines the second box to test
  73976. * @returns true if there is an intersection
  73977. */
  73978. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73979. /**
  73980. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73981. * @param minPoint defines the minimum vector of the bounding box
  73982. * @param maxPoint defines the maximum vector of the bounding box
  73983. * @param sphereCenter defines the sphere center
  73984. * @param sphereRadius defines the sphere radius
  73985. * @returns true if there is an intersection
  73986. */
  73987. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73988. /**
  73989. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73990. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73991. * @param frustumPlanes defines the frustum planes to test
  73992. * @return true if there is an inclusion
  73993. */
  73994. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73995. /**
  73996. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73997. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73998. * @param frustumPlanes defines the frustum planes to test
  73999. * @return true if there is an intersection
  74000. */
  74001. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74002. }
  74003. }
  74004. declare module BABYLON {
  74005. /** @hidden */
  74006. export class Collider {
  74007. /** Define if a collision was found */
  74008. collisionFound: boolean;
  74009. /**
  74010. * Define last intersection point in local space
  74011. */
  74012. intersectionPoint: Vector3;
  74013. /**
  74014. * Define last collided mesh
  74015. */
  74016. collidedMesh: Nullable<AbstractMesh>;
  74017. private _collisionPoint;
  74018. private _planeIntersectionPoint;
  74019. private _tempVector;
  74020. private _tempVector2;
  74021. private _tempVector3;
  74022. private _tempVector4;
  74023. private _edge;
  74024. private _baseToVertex;
  74025. private _destinationPoint;
  74026. private _slidePlaneNormal;
  74027. private _displacementVector;
  74028. /** @hidden */
  74029. _radius: Vector3;
  74030. /** @hidden */
  74031. _retry: number;
  74032. private _velocity;
  74033. private _basePoint;
  74034. private _epsilon;
  74035. /** @hidden */
  74036. _velocityWorldLength: number;
  74037. /** @hidden */
  74038. _basePointWorld: Vector3;
  74039. private _velocityWorld;
  74040. private _normalizedVelocity;
  74041. /** @hidden */
  74042. _initialVelocity: Vector3;
  74043. /** @hidden */
  74044. _initialPosition: Vector3;
  74045. private _nearestDistance;
  74046. private _collisionMask;
  74047. collisionMask: number;
  74048. /**
  74049. * Gets the plane normal used to compute the sliding response (in local space)
  74050. */
  74051. readonly slidePlaneNormal: Vector3;
  74052. /** @hidden */
  74053. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74054. /** @hidden */
  74055. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74056. /** @hidden */
  74057. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74058. /** @hidden */
  74059. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74060. /** @hidden */
  74061. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74062. /** @hidden */
  74063. _getResponse(pos: Vector3, vel: Vector3): void;
  74064. }
  74065. }
  74066. declare module BABYLON {
  74067. /**
  74068. * Interface for cullable objects
  74069. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74070. */
  74071. export interface ICullable {
  74072. /**
  74073. * Checks if the object or part of the object is in the frustum
  74074. * @param frustumPlanes Camera near/planes
  74075. * @returns true if the object is in frustum otherwise false
  74076. */
  74077. isInFrustum(frustumPlanes: Plane[]): boolean;
  74078. /**
  74079. * Checks if a cullable object (mesh...) is in the camera frustum
  74080. * Unlike isInFrustum this cheks the full bounding box
  74081. * @param frustumPlanes Camera near/planes
  74082. * @returns true if the object is in frustum otherwise false
  74083. */
  74084. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74085. }
  74086. /**
  74087. * Info for a bounding data of a mesh
  74088. */
  74089. export class BoundingInfo implements ICullable {
  74090. /**
  74091. * Bounding box for the mesh
  74092. */
  74093. readonly boundingBox: BoundingBox;
  74094. /**
  74095. * Bounding sphere for the mesh
  74096. */
  74097. readonly boundingSphere: BoundingSphere;
  74098. private _isLocked;
  74099. private static readonly TmpVector3;
  74100. /**
  74101. * Constructs bounding info
  74102. * @param minimum min vector of the bounding box/sphere
  74103. * @param maximum max vector of the bounding box/sphere
  74104. * @param worldMatrix defines the new world matrix
  74105. */
  74106. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74107. /**
  74108. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74109. * @param min defines the new minimum vector (in local space)
  74110. * @param max defines the new maximum vector (in local space)
  74111. * @param worldMatrix defines the new world matrix
  74112. */
  74113. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74114. /**
  74115. * min vector of the bounding box/sphere
  74116. */
  74117. readonly minimum: Vector3;
  74118. /**
  74119. * max vector of the bounding box/sphere
  74120. */
  74121. readonly maximum: Vector3;
  74122. /**
  74123. * If the info is locked and won't be updated to avoid perf overhead
  74124. */
  74125. isLocked: boolean;
  74126. /**
  74127. * Updates the bounding sphere and box
  74128. * @param world world matrix to be used to update
  74129. */
  74130. update(world: DeepImmutable<Matrix>): void;
  74131. /**
  74132. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74133. * @param center New center of the bounding info
  74134. * @param extend New extend of the bounding info
  74135. * @returns the current bounding info
  74136. */
  74137. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74138. /**
  74139. * Scale the current bounding info by applying a scale factor
  74140. * @param factor defines the scale factor to apply
  74141. * @returns the current bounding info
  74142. */
  74143. scale(factor: number): BoundingInfo;
  74144. /**
  74145. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74146. * @param frustumPlanes defines the frustum to test
  74147. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74148. * @returns true if the bounding info is in the frustum planes
  74149. */
  74150. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74151. /**
  74152. * Gets the world distance between the min and max points of the bounding box
  74153. */
  74154. readonly diagonalLength: number;
  74155. /**
  74156. * Checks if a cullable object (mesh...) is in the camera frustum
  74157. * Unlike isInFrustum this cheks the full bounding box
  74158. * @param frustumPlanes Camera near/planes
  74159. * @returns true if the object is in frustum otherwise false
  74160. */
  74161. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74162. /** @hidden */
  74163. _checkCollision(collider: Collider): boolean;
  74164. /**
  74165. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74166. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74167. * @param point the point to check intersection with
  74168. * @returns if the point intersects
  74169. */
  74170. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74171. /**
  74172. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74173. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74174. * @param boundingInfo the bounding info to check intersection with
  74175. * @param precise if the intersection should be done using OBB
  74176. * @returns if the bounding info intersects
  74177. */
  74178. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /**
  74183. * Extracts minimum and maximum values from a list of indexed positions
  74184. * @param positions defines the positions to use
  74185. * @param indices defines the indices to the positions
  74186. * @param indexStart defines the start index
  74187. * @param indexCount defines the end index
  74188. * @param bias defines bias value to add to the result
  74189. * @return minimum and maximum values
  74190. */
  74191. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74192. minimum: Vector3;
  74193. maximum: Vector3;
  74194. };
  74195. /**
  74196. * Extracts minimum and maximum values from a list of positions
  74197. * @param positions defines the positions to use
  74198. * @param start defines the start index in the positions array
  74199. * @param count defines the number of positions to handle
  74200. * @param bias defines bias value to add to the result
  74201. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74202. * @return minimum and maximum values
  74203. */
  74204. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74205. minimum: Vector3;
  74206. maximum: Vector3;
  74207. };
  74208. }
  74209. declare module BABYLON {
  74210. /** @hidden */
  74211. export class WebGLDataBuffer extends DataBuffer {
  74212. private _buffer;
  74213. constructor(resource: WebGLBuffer);
  74214. readonly underlyingResource: any;
  74215. }
  74216. }
  74217. declare module BABYLON {
  74218. /** @hidden */
  74219. export class WebGLPipelineContext implements IPipelineContext {
  74220. engine: ThinEngine;
  74221. program: Nullable<WebGLProgram>;
  74222. context?: WebGLRenderingContext;
  74223. vertexShader?: WebGLShader;
  74224. fragmentShader?: WebGLShader;
  74225. isParallelCompiled: boolean;
  74226. onCompiled?: () => void;
  74227. transformFeedback?: WebGLTransformFeedback | null;
  74228. readonly isAsync: boolean;
  74229. readonly isReady: boolean;
  74230. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74231. }
  74232. }
  74233. declare module BABYLON {
  74234. interface ThinEngine {
  74235. /**
  74236. * Create an uniform buffer
  74237. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74238. * @param elements defines the content of the uniform buffer
  74239. * @returns the webGL uniform buffer
  74240. */
  74241. createUniformBuffer(elements: FloatArray): DataBuffer;
  74242. /**
  74243. * Create a dynamic uniform buffer
  74244. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74245. * @param elements defines the content of the uniform buffer
  74246. * @returns the webGL uniform buffer
  74247. */
  74248. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74249. /**
  74250. * Update an existing uniform buffer
  74251. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74252. * @param uniformBuffer defines the target uniform buffer
  74253. * @param elements defines the content to update
  74254. * @param offset defines the offset in the uniform buffer where update should start
  74255. * @param count defines the size of the data to update
  74256. */
  74257. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74258. /**
  74259. * Bind an uniform buffer to the current webGL context
  74260. * @param buffer defines the buffer to bind
  74261. */
  74262. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74263. /**
  74264. * Bind a buffer to the current webGL context at a given location
  74265. * @param buffer defines the buffer to bind
  74266. * @param location defines the index where to bind the buffer
  74267. */
  74268. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74269. /**
  74270. * Bind a specific block at a given index in a specific shader program
  74271. * @param pipelineContext defines the pipeline context to use
  74272. * @param blockName defines the block name
  74273. * @param index defines the index where to bind the block
  74274. */
  74275. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74276. }
  74277. }
  74278. declare module BABYLON {
  74279. /**
  74280. * Uniform buffer objects.
  74281. *
  74282. * Handles blocks of uniform on the GPU.
  74283. *
  74284. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74285. *
  74286. * For more information, please refer to :
  74287. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74288. */
  74289. export class UniformBuffer {
  74290. private _engine;
  74291. private _buffer;
  74292. private _data;
  74293. private _bufferData;
  74294. private _dynamic?;
  74295. private _uniformLocations;
  74296. private _uniformSizes;
  74297. private _uniformLocationPointer;
  74298. private _needSync;
  74299. private _noUBO;
  74300. private _currentEffect;
  74301. private static _MAX_UNIFORM_SIZE;
  74302. private static _tempBuffer;
  74303. /**
  74304. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74305. * This is dynamic to allow compat with webgl 1 and 2.
  74306. * You will need to pass the name of the uniform as well as the value.
  74307. */
  74308. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74309. /**
  74310. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74311. * This is dynamic to allow compat with webgl 1 and 2.
  74312. * You will need to pass the name of the uniform as well as the value.
  74313. */
  74314. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74315. /**
  74316. * Lambda to Update a single float in a uniform buffer.
  74317. * This is dynamic to allow compat with webgl 1 and 2.
  74318. * You will need to pass the name of the uniform as well as the value.
  74319. */
  74320. updateFloat: (name: string, x: number) => void;
  74321. /**
  74322. * Lambda to Update a vec2 of float in a uniform buffer.
  74323. * This is dynamic to allow compat with webgl 1 and 2.
  74324. * You will need to pass the name of the uniform as well as the value.
  74325. */
  74326. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74327. /**
  74328. * Lambda to Update a vec3 of float in a uniform buffer.
  74329. * This is dynamic to allow compat with webgl 1 and 2.
  74330. * You will need to pass the name of the uniform as well as the value.
  74331. */
  74332. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74333. /**
  74334. * Lambda to Update a vec4 of float in a uniform buffer.
  74335. * This is dynamic to allow compat with webgl 1 and 2.
  74336. * You will need to pass the name of the uniform as well as the value.
  74337. */
  74338. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74339. /**
  74340. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74341. * This is dynamic to allow compat with webgl 1 and 2.
  74342. * You will need to pass the name of the uniform as well as the value.
  74343. */
  74344. updateMatrix: (name: string, mat: Matrix) => void;
  74345. /**
  74346. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74347. * This is dynamic to allow compat with webgl 1 and 2.
  74348. * You will need to pass the name of the uniform as well as the value.
  74349. */
  74350. updateVector3: (name: string, vector: Vector3) => void;
  74351. /**
  74352. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74353. * This is dynamic to allow compat with webgl 1 and 2.
  74354. * You will need to pass the name of the uniform as well as the value.
  74355. */
  74356. updateVector4: (name: string, vector: Vector4) => void;
  74357. /**
  74358. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74359. * This is dynamic to allow compat with webgl 1 and 2.
  74360. * You will need to pass the name of the uniform as well as the value.
  74361. */
  74362. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74363. /**
  74364. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74365. * This is dynamic to allow compat with webgl 1 and 2.
  74366. * You will need to pass the name of the uniform as well as the value.
  74367. */
  74368. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74369. /**
  74370. * Instantiates a new Uniform buffer objects.
  74371. *
  74372. * Handles blocks of uniform on the GPU.
  74373. *
  74374. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74375. *
  74376. * For more information, please refer to :
  74377. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74378. * @param engine Define the engine the buffer is associated with
  74379. * @param data Define the data contained in the buffer
  74380. * @param dynamic Define if the buffer is updatable
  74381. */
  74382. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74383. /**
  74384. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74385. * or just falling back on setUniformXXX calls.
  74386. */
  74387. readonly useUbo: boolean;
  74388. /**
  74389. * Indicates if the WebGL underlying uniform buffer is in sync
  74390. * with the javascript cache data.
  74391. */
  74392. readonly isSync: boolean;
  74393. /**
  74394. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74395. * Also, a dynamic UniformBuffer will disable cache verification and always
  74396. * update the underlying WebGL uniform buffer to the GPU.
  74397. * @returns if Dynamic, otherwise false
  74398. */
  74399. isDynamic(): boolean;
  74400. /**
  74401. * The data cache on JS side.
  74402. * @returns the underlying data as a float array
  74403. */
  74404. getData(): Float32Array;
  74405. /**
  74406. * The underlying WebGL Uniform buffer.
  74407. * @returns the webgl buffer
  74408. */
  74409. getBuffer(): Nullable<DataBuffer>;
  74410. /**
  74411. * std140 layout specifies how to align data within an UBO structure.
  74412. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74413. * for specs.
  74414. */
  74415. private _fillAlignment;
  74416. /**
  74417. * Adds an uniform in the buffer.
  74418. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74419. * for the layout to be correct !
  74420. * @param name Name of the uniform, as used in the uniform block in the shader.
  74421. * @param size Data size, or data directly.
  74422. */
  74423. addUniform(name: string, size: number | number[]): void;
  74424. /**
  74425. * Adds a Matrix 4x4 to the uniform buffer.
  74426. * @param name Name of the uniform, as used in the uniform block in the shader.
  74427. * @param mat A 4x4 matrix.
  74428. */
  74429. addMatrix(name: string, mat: Matrix): void;
  74430. /**
  74431. * Adds a vec2 to the uniform buffer.
  74432. * @param name Name of the uniform, as used in the uniform block in the shader.
  74433. * @param x Define the x component value of the vec2
  74434. * @param y Define the y component value of the vec2
  74435. */
  74436. addFloat2(name: string, x: number, y: number): void;
  74437. /**
  74438. * Adds a vec3 to the uniform buffer.
  74439. * @param name Name of the uniform, as used in the uniform block in the shader.
  74440. * @param x Define the x component value of the vec3
  74441. * @param y Define the y component value of the vec3
  74442. * @param z Define the z component value of the vec3
  74443. */
  74444. addFloat3(name: string, x: number, y: number, z: number): void;
  74445. /**
  74446. * Adds a vec3 to the uniform buffer.
  74447. * @param name Name of the uniform, as used in the uniform block in the shader.
  74448. * @param color Define the vec3 from a Color
  74449. */
  74450. addColor3(name: string, color: Color3): void;
  74451. /**
  74452. * Adds a vec4 to the uniform buffer.
  74453. * @param name Name of the uniform, as used in the uniform block in the shader.
  74454. * @param color Define the rgb components from a Color
  74455. * @param alpha Define the a component of the vec4
  74456. */
  74457. addColor4(name: string, color: Color3, alpha: number): void;
  74458. /**
  74459. * Adds a vec3 to the uniform buffer.
  74460. * @param name Name of the uniform, as used in the uniform block in the shader.
  74461. * @param vector Define the vec3 components from a Vector
  74462. */
  74463. addVector3(name: string, vector: Vector3): void;
  74464. /**
  74465. * Adds a Matrix 3x3 to the uniform buffer.
  74466. * @param name Name of the uniform, as used in the uniform block in the shader.
  74467. */
  74468. addMatrix3x3(name: string): void;
  74469. /**
  74470. * Adds a Matrix 2x2 to the uniform buffer.
  74471. * @param name Name of the uniform, as used in the uniform block in the shader.
  74472. */
  74473. addMatrix2x2(name: string): void;
  74474. /**
  74475. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74476. */
  74477. create(): void;
  74478. /** @hidden */
  74479. _rebuild(): void;
  74480. /**
  74481. * Updates the WebGL Uniform Buffer on the GPU.
  74482. * If the `dynamic` flag is set to true, no cache comparison is done.
  74483. * Otherwise, the buffer will be updated only if the cache differs.
  74484. */
  74485. update(): void;
  74486. /**
  74487. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74488. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74489. * @param data Define the flattened data
  74490. * @param size Define the size of the data.
  74491. */
  74492. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74493. private _valueCache;
  74494. private _cacheMatrix;
  74495. private _updateMatrix3x3ForUniform;
  74496. private _updateMatrix3x3ForEffect;
  74497. private _updateMatrix2x2ForEffect;
  74498. private _updateMatrix2x2ForUniform;
  74499. private _updateFloatForEffect;
  74500. private _updateFloatForUniform;
  74501. private _updateFloat2ForEffect;
  74502. private _updateFloat2ForUniform;
  74503. private _updateFloat3ForEffect;
  74504. private _updateFloat3ForUniform;
  74505. private _updateFloat4ForEffect;
  74506. private _updateFloat4ForUniform;
  74507. private _updateMatrixForEffect;
  74508. private _updateMatrixForUniform;
  74509. private _updateVector3ForEffect;
  74510. private _updateVector3ForUniform;
  74511. private _updateVector4ForEffect;
  74512. private _updateVector4ForUniform;
  74513. private _updateColor3ForEffect;
  74514. private _updateColor3ForUniform;
  74515. private _updateColor4ForEffect;
  74516. private _updateColor4ForUniform;
  74517. /**
  74518. * Sets a sampler uniform on the effect.
  74519. * @param name Define the name of the sampler.
  74520. * @param texture Define the texture to set in the sampler
  74521. */
  74522. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74523. /**
  74524. * Directly updates the value of the uniform in the cache AND on the GPU.
  74525. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74526. * @param data Define the flattened data
  74527. */
  74528. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74529. /**
  74530. * Binds this uniform buffer to an effect.
  74531. * @param effect Define the effect to bind the buffer to
  74532. * @param name Name of the uniform block in the shader.
  74533. */
  74534. bindToEffect(effect: Effect, name: string): void;
  74535. /**
  74536. * Disposes the uniform buffer.
  74537. */
  74538. dispose(): void;
  74539. }
  74540. }
  74541. declare module BABYLON {
  74542. /**
  74543. * Enum that determines the text-wrapping mode to use.
  74544. */
  74545. export enum InspectableType {
  74546. /**
  74547. * Checkbox for booleans
  74548. */
  74549. Checkbox = 0,
  74550. /**
  74551. * Sliders for numbers
  74552. */
  74553. Slider = 1,
  74554. /**
  74555. * Vector3
  74556. */
  74557. Vector3 = 2,
  74558. /**
  74559. * Quaternions
  74560. */
  74561. Quaternion = 3,
  74562. /**
  74563. * Color3
  74564. */
  74565. Color3 = 4,
  74566. /**
  74567. * String
  74568. */
  74569. String = 5
  74570. }
  74571. /**
  74572. * Interface used to define custom inspectable properties.
  74573. * This interface is used by the inspector to display custom property grids
  74574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74575. */
  74576. export interface IInspectable {
  74577. /**
  74578. * Gets the label to display
  74579. */
  74580. label: string;
  74581. /**
  74582. * Gets the name of the property to edit
  74583. */
  74584. propertyName: string;
  74585. /**
  74586. * Gets the type of the editor to use
  74587. */
  74588. type: InspectableType;
  74589. /**
  74590. * Gets the minimum value of the property when using in "slider" mode
  74591. */
  74592. min?: number;
  74593. /**
  74594. * Gets the maximum value of the property when using in "slider" mode
  74595. */
  74596. max?: number;
  74597. /**
  74598. * Gets the setp to use when using in "slider" mode
  74599. */
  74600. step?: number;
  74601. }
  74602. }
  74603. declare module BABYLON {
  74604. /**
  74605. * Class used to provide helper for timing
  74606. */
  74607. export class TimingTools {
  74608. /**
  74609. * Polyfill for setImmediate
  74610. * @param action defines the action to execute after the current execution block
  74611. */
  74612. static SetImmediate(action: () => void): void;
  74613. }
  74614. }
  74615. declare module BABYLON {
  74616. /**
  74617. * Class used to enable instatition of objects by class name
  74618. */
  74619. export class InstantiationTools {
  74620. /**
  74621. * Use this object to register external classes like custom textures or material
  74622. * to allow the laoders to instantiate them
  74623. */
  74624. static RegisteredExternalClasses: {
  74625. [key: string]: Object;
  74626. };
  74627. /**
  74628. * Tries to instantiate a new object from a given class name
  74629. * @param className defines the class name to instantiate
  74630. * @returns the new object or null if the system was not able to do the instantiation
  74631. */
  74632. static Instantiate(className: string): any;
  74633. }
  74634. }
  74635. declare module BABYLON {
  74636. /**
  74637. * Define options used to create a depth texture
  74638. */
  74639. export class DepthTextureCreationOptions {
  74640. /** Specifies whether or not a stencil should be allocated in the texture */
  74641. generateStencil?: boolean;
  74642. /** Specifies whether or not bilinear filtering is enable on the texture */
  74643. bilinearFiltering?: boolean;
  74644. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74645. comparisonFunction?: number;
  74646. /** Specifies if the created texture is a cube texture */
  74647. isCube?: boolean;
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. interface ThinEngine {
  74652. /**
  74653. * Creates a depth stencil cube texture.
  74654. * This is only available in WebGL 2.
  74655. * @param size The size of face edge in the cube texture.
  74656. * @param options The options defining the cube texture.
  74657. * @returns The cube texture
  74658. */
  74659. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74660. /**
  74661. * Creates a cube texture
  74662. * @param rootUrl defines the url where the files to load is located
  74663. * @param scene defines the current scene
  74664. * @param files defines the list of files to load (1 per face)
  74665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74666. * @param onLoad defines an optional callback raised when the texture is loaded
  74667. * @param onError defines an optional callback raised if there is an issue to load the texture
  74668. * @param format defines the format of the data
  74669. * @param forcedExtension defines the extension to use to pick the right loader
  74670. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74671. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74672. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74673. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74674. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74675. * @returns the cube texture as an InternalTexture
  74676. */
  74677. 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;
  74678. /**
  74679. * Creates a cube texture
  74680. * @param rootUrl defines the url where the files to load is located
  74681. * @param scene defines the current scene
  74682. * @param files defines the list of files to load (1 per face)
  74683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74684. * @param onLoad defines an optional callback raised when the texture is loaded
  74685. * @param onError defines an optional callback raised if there is an issue to load the texture
  74686. * @param format defines the format of the data
  74687. * @param forcedExtension defines the extension to use to pick the right loader
  74688. * @returns the cube texture as an InternalTexture
  74689. */
  74690. 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;
  74691. /**
  74692. * Creates a cube texture
  74693. * @param rootUrl defines the url where the files to load is located
  74694. * @param scene defines the current scene
  74695. * @param files defines the list of files to load (1 per face)
  74696. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74697. * @param onLoad defines an optional callback raised when the texture is loaded
  74698. * @param onError defines an optional callback raised if there is an issue to load the texture
  74699. * @param format defines the format of the data
  74700. * @param forcedExtension defines the extension to use to pick the right loader
  74701. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74702. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74703. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74704. * @returns the cube texture as an InternalTexture
  74705. */
  74706. 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;
  74707. /** @hidden */
  74708. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74709. /** @hidden */
  74710. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74711. /** @hidden */
  74712. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74713. /** @hidden */
  74714. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74715. }
  74716. }
  74717. declare module BABYLON {
  74718. /**
  74719. * Class for creating a cube texture
  74720. */
  74721. export class CubeTexture extends BaseTexture {
  74722. private _delayedOnLoad;
  74723. /**
  74724. * The url of the texture
  74725. */
  74726. url: string;
  74727. /**
  74728. * Gets or sets the center of the bounding box associated with the cube texture.
  74729. * It must define where the camera used to render the texture was set
  74730. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74731. */
  74732. boundingBoxPosition: Vector3;
  74733. private _boundingBoxSize;
  74734. /**
  74735. * Gets or sets the size of the bounding box associated with the cube texture
  74736. * When defined, the cubemap will switch to local mode
  74737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74738. * @example https://www.babylonjs-playground.com/#RNASML
  74739. */
  74740. /**
  74741. * Returns the bounding box size
  74742. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74743. */
  74744. boundingBoxSize: Vector3;
  74745. protected _rotationY: number;
  74746. /**
  74747. * Sets texture matrix rotation angle around Y axis in radians.
  74748. */
  74749. /**
  74750. * Gets texture matrix rotation angle around Y axis radians.
  74751. */
  74752. rotationY: number;
  74753. /**
  74754. * Are mip maps generated for this texture or not.
  74755. */
  74756. readonly noMipmap: boolean;
  74757. private _noMipmap;
  74758. private _files;
  74759. protected _forcedExtension: Nullable<string>;
  74760. private _extensions;
  74761. private _textureMatrix;
  74762. private _format;
  74763. private _createPolynomials;
  74764. /** @hidden */
  74765. _prefiltered: boolean;
  74766. /**
  74767. * Creates a cube texture from an array of image urls
  74768. * @param files defines an array of image urls
  74769. * @param scene defines the hosting scene
  74770. * @param noMipmap specifies if mip maps are not used
  74771. * @returns a cube texture
  74772. */
  74773. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74774. /**
  74775. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74776. * @param url defines the url of the prefiltered texture
  74777. * @param scene defines the scene the texture is attached to
  74778. * @param forcedExtension defines the extension of the file if different from the url
  74779. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74780. * @return the prefiltered texture
  74781. */
  74782. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74783. /**
  74784. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74785. * as prefiltered data.
  74786. * @param rootUrl defines the url of the texture or the root name of the six images
  74787. * @param scene defines the scene the texture is attached to
  74788. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74789. * @param noMipmap defines if mipmaps should be created or not
  74790. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74791. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74792. * @param onError defines a callback triggered in case of error during load
  74793. * @param format defines the internal format to use for the texture once loaded
  74794. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74795. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74796. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74797. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74798. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74799. * @return the cube texture
  74800. */
  74801. 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);
  74802. /**
  74803. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74804. */
  74805. readonly isPrefiltered: boolean;
  74806. /**
  74807. * Get the current class name of the texture useful for serialization or dynamic coding.
  74808. * @returns "CubeTexture"
  74809. */
  74810. getClassName(): string;
  74811. /**
  74812. * Update the url (and optional buffer) of this texture if url was null during construction.
  74813. * @param url the url of the texture
  74814. * @param forcedExtension defines the extension to use
  74815. * @param onLoad callback called when the texture is loaded (defaults to null)
  74816. */
  74817. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74818. /**
  74819. * Delays loading of the cube texture
  74820. * @param forcedExtension defines the extension to use
  74821. */
  74822. delayLoad(forcedExtension?: string): void;
  74823. /**
  74824. * Returns the reflection texture matrix
  74825. * @returns the reflection texture matrix
  74826. */
  74827. getReflectionTextureMatrix(): Matrix;
  74828. /**
  74829. * Sets the reflection texture matrix
  74830. * @param value Reflection texture matrix
  74831. */
  74832. setReflectionTextureMatrix(value: Matrix): void;
  74833. /**
  74834. * Parses text to create a cube texture
  74835. * @param parsedTexture define the serialized text to read from
  74836. * @param scene defines the hosting scene
  74837. * @param rootUrl defines the root url of the cube texture
  74838. * @returns a cube texture
  74839. */
  74840. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74841. /**
  74842. * Makes a clone, or deep copy, of the cube texture
  74843. * @returns a new cube texture
  74844. */
  74845. clone(): CubeTexture;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * Manages the defines for the Material
  74851. */
  74852. export class MaterialDefines {
  74853. /** @hidden */
  74854. protected _keys: string[];
  74855. private _isDirty;
  74856. /** @hidden */
  74857. _renderId: number;
  74858. /** @hidden */
  74859. _areLightsDirty: boolean;
  74860. /** @hidden */
  74861. _areLightsDisposed: boolean;
  74862. /** @hidden */
  74863. _areAttributesDirty: boolean;
  74864. /** @hidden */
  74865. _areTexturesDirty: boolean;
  74866. /** @hidden */
  74867. _areFresnelDirty: boolean;
  74868. /** @hidden */
  74869. _areMiscDirty: boolean;
  74870. /** @hidden */
  74871. _areImageProcessingDirty: boolean;
  74872. /** @hidden */
  74873. _normals: boolean;
  74874. /** @hidden */
  74875. _uvs: boolean;
  74876. /** @hidden */
  74877. _needNormals: boolean;
  74878. /** @hidden */
  74879. _needUVs: boolean;
  74880. [id: string]: any;
  74881. /**
  74882. * Specifies if the material needs to be re-calculated
  74883. */
  74884. readonly isDirty: boolean;
  74885. /**
  74886. * Marks the material to indicate that it has been re-calculated
  74887. */
  74888. markAsProcessed(): void;
  74889. /**
  74890. * Marks the material to indicate that it needs to be re-calculated
  74891. */
  74892. markAsUnprocessed(): void;
  74893. /**
  74894. * Marks the material to indicate all of its defines need to be re-calculated
  74895. */
  74896. markAllAsDirty(): void;
  74897. /**
  74898. * Marks the material to indicate that image processing needs to be re-calculated
  74899. */
  74900. markAsImageProcessingDirty(): void;
  74901. /**
  74902. * Marks the material to indicate the lights need to be re-calculated
  74903. * @param disposed Defines whether the light is dirty due to dispose or not
  74904. */
  74905. markAsLightDirty(disposed?: boolean): void;
  74906. /**
  74907. * Marks the attribute state as changed
  74908. */
  74909. markAsAttributesDirty(): void;
  74910. /**
  74911. * Marks the texture state as changed
  74912. */
  74913. markAsTexturesDirty(): void;
  74914. /**
  74915. * Marks the fresnel state as changed
  74916. */
  74917. markAsFresnelDirty(): void;
  74918. /**
  74919. * Marks the misc state as changed
  74920. */
  74921. markAsMiscDirty(): void;
  74922. /**
  74923. * Rebuilds the material defines
  74924. */
  74925. rebuild(): void;
  74926. /**
  74927. * Specifies if two material defines are equal
  74928. * @param other - A material define instance to compare to
  74929. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74930. */
  74931. isEqual(other: MaterialDefines): boolean;
  74932. /**
  74933. * Clones this instance's defines to another instance
  74934. * @param other - material defines to clone values to
  74935. */
  74936. cloneTo(other: MaterialDefines): void;
  74937. /**
  74938. * Resets the material define values
  74939. */
  74940. reset(): void;
  74941. /**
  74942. * Converts the material define values to a string
  74943. * @returns - String of material define information
  74944. */
  74945. toString(): string;
  74946. }
  74947. }
  74948. declare module BABYLON {
  74949. /**
  74950. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74951. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74952. * 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;
  74953. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74954. */
  74955. export class ColorCurves {
  74956. private _dirty;
  74957. private _tempColor;
  74958. private _globalCurve;
  74959. private _highlightsCurve;
  74960. private _midtonesCurve;
  74961. private _shadowsCurve;
  74962. private _positiveCurve;
  74963. private _negativeCurve;
  74964. private _globalHue;
  74965. private _globalDensity;
  74966. private _globalSaturation;
  74967. private _globalExposure;
  74968. /**
  74969. * Gets the global Hue value.
  74970. * 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).
  74971. */
  74972. /**
  74973. * Sets the global Hue value.
  74974. * 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).
  74975. */
  74976. globalHue: number;
  74977. /**
  74978. * Gets the global Density value.
  74979. * 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.
  74980. * Values less than zero provide a filter of opposite hue.
  74981. */
  74982. /**
  74983. * Sets the global Density value.
  74984. * 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.
  74985. * Values less than zero provide a filter of opposite hue.
  74986. */
  74987. globalDensity: number;
  74988. /**
  74989. * Gets the global Saturation value.
  74990. * 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.
  74991. */
  74992. /**
  74993. * Sets the global Saturation value.
  74994. * 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.
  74995. */
  74996. globalSaturation: number;
  74997. /**
  74998. * Gets the global Exposure value.
  74999. * 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.
  75000. */
  75001. /**
  75002. * Sets the global Exposure value.
  75003. * 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.
  75004. */
  75005. globalExposure: number;
  75006. private _highlightsHue;
  75007. private _highlightsDensity;
  75008. private _highlightsSaturation;
  75009. private _highlightsExposure;
  75010. /**
  75011. * Gets the highlights Hue value.
  75012. * 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).
  75013. */
  75014. /**
  75015. * Sets the highlights Hue value.
  75016. * 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).
  75017. */
  75018. highlightsHue: number;
  75019. /**
  75020. * Gets the highlights Density value.
  75021. * 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.
  75022. * Values less than zero provide a filter of opposite hue.
  75023. */
  75024. /**
  75025. * Sets the highlights Density value.
  75026. * 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.
  75027. * Values less than zero provide a filter of opposite hue.
  75028. */
  75029. highlightsDensity: number;
  75030. /**
  75031. * Gets the highlights Saturation value.
  75032. * 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.
  75033. */
  75034. /**
  75035. * Sets the highlights Saturation value.
  75036. * 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.
  75037. */
  75038. highlightsSaturation: number;
  75039. /**
  75040. * Gets the highlights Exposure value.
  75041. * 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.
  75042. */
  75043. /**
  75044. * Sets the highlights Exposure value.
  75045. * 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.
  75046. */
  75047. highlightsExposure: number;
  75048. private _midtonesHue;
  75049. private _midtonesDensity;
  75050. private _midtonesSaturation;
  75051. private _midtonesExposure;
  75052. /**
  75053. * Gets the midtones Hue value.
  75054. * 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).
  75055. */
  75056. /**
  75057. * Sets the midtones Hue value.
  75058. * 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).
  75059. */
  75060. midtonesHue: number;
  75061. /**
  75062. * Gets the midtones Density value.
  75063. * 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.
  75064. * Values less than zero provide a filter of opposite hue.
  75065. */
  75066. /**
  75067. * Sets the midtones Density value.
  75068. * 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.
  75069. * Values less than zero provide a filter of opposite hue.
  75070. */
  75071. midtonesDensity: number;
  75072. /**
  75073. * Gets the midtones Saturation value.
  75074. * 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.
  75075. */
  75076. /**
  75077. * Sets the midtones Saturation value.
  75078. * 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.
  75079. */
  75080. midtonesSaturation: number;
  75081. /**
  75082. * Gets the midtones Exposure value.
  75083. * 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.
  75084. */
  75085. /**
  75086. * Sets the midtones Exposure value.
  75087. * 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.
  75088. */
  75089. midtonesExposure: number;
  75090. private _shadowsHue;
  75091. private _shadowsDensity;
  75092. private _shadowsSaturation;
  75093. private _shadowsExposure;
  75094. /**
  75095. * Gets the shadows Hue value.
  75096. * 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).
  75097. */
  75098. /**
  75099. * Sets the shadows Hue value.
  75100. * 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).
  75101. */
  75102. shadowsHue: number;
  75103. /**
  75104. * Gets the shadows Density value.
  75105. * 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.
  75106. * Values less than zero provide a filter of opposite hue.
  75107. */
  75108. /**
  75109. * Sets the shadows Density value.
  75110. * 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.
  75111. * Values less than zero provide a filter of opposite hue.
  75112. */
  75113. shadowsDensity: number;
  75114. /**
  75115. * Gets the shadows Saturation value.
  75116. * 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.
  75117. */
  75118. /**
  75119. * Sets the shadows Saturation value.
  75120. * 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.
  75121. */
  75122. shadowsSaturation: number;
  75123. /**
  75124. * Gets the shadows Exposure value.
  75125. * 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.
  75126. */
  75127. /**
  75128. * Sets the shadows Exposure value.
  75129. * 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.
  75130. */
  75131. shadowsExposure: number;
  75132. /**
  75133. * Returns the class name
  75134. * @returns The class name
  75135. */
  75136. getClassName(): string;
  75137. /**
  75138. * Binds the color curves to the shader.
  75139. * @param colorCurves The color curve to bind
  75140. * @param effect The effect to bind to
  75141. * @param positiveUniform The positive uniform shader parameter
  75142. * @param neutralUniform The neutral uniform shader parameter
  75143. * @param negativeUniform The negative uniform shader parameter
  75144. */
  75145. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75146. /**
  75147. * Prepare the list of uniforms associated with the ColorCurves effects.
  75148. * @param uniformsList The list of uniforms used in the effect
  75149. */
  75150. static PrepareUniforms(uniformsList: string[]): void;
  75151. /**
  75152. * Returns color grading data based on a hue, density, saturation and exposure value.
  75153. * @param filterHue The hue of the color filter.
  75154. * @param filterDensity The density of the color filter.
  75155. * @param saturation The saturation.
  75156. * @param exposure The exposure.
  75157. * @param result The result data container.
  75158. */
  75159. private getColorGradingDataToRef;
  75160. /**
  75161. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75162. * @param value The input slider value in range [-100,100].
  75163. * @returns Adjusted value.
  75164. */
  75165. private static applyColorGradingSliderNonlinear;
  75166. /**
  75167. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75168. * @param hue The hue (H) input.
  75169. * @param saturation The saturation (S) input.
  75170. * @param brightness The brightness (B) input.
  75171. * @result An RGBA color represented as Vector4.
  75172. */
  75173. private static fromHSBToRef;
  75174. /**
  75175. * Returns a value clamped between min and max
  75176. * @param value The value to clamp
  75177. * @param min The minimum of value
  75178. * @param max The maximum of value
  75179. * @returns The clamped value.
  75180. */
  75181. private static clamp;
  75182. /**
  75183. * Clones the current color curve instance.
  75184. * @return The cloned curves
  75185. */
  75186. clone(): ColorCurves;
  75187. /**
  75188. * Serializes the current color curve instance to a json representation.
  75189. * @return a JSON representation
  75190. */
  75191. serialize(): any;
  75192. /**
  75193. * Parses the color curve from a json representation.
  75194. * @param source the JSON source to parse
  75195. * @return The parsed curves
  75196. */
  75197. static Parse(source: any): ColorCurves;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /**
  75202. * Interface to follow in your material defines to integrate easily the
  75203. * Image proccessing functions.
  75204. * @hidden
  75205. */
  75206. export interface IImageProcessingConfigurationDefines {
  75207. IMAGEPROCESSING: boolean;
  75208. VIGNETTE: boolean;
  75209. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75210. VIGNETTEBLENDMODEOPAQUE: boolean;
  75211. TONEMAPPING: boolean;
  75212. TONEMAPPING_ACES: boolean;
  75213. CONTRAST: boolean;
  75214. EXPOSURE: boolean;
  75215. COLORCURVES: boolean;
  75216. COLORGRADING: boolean;
  75217. COLORGRADING3D: boolean;
  75218. SAMPLER3DGREENDEPTH: boolean;
  75219. SAMPLER3DBGRMAP: boolean;
  75220. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75221. }
  75222. /**
  75223. * @hidden
  75224. */
  75225. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75226. IMAGEPROCESSING: boolean;
  75227. VIGNETTE: boolean;
  75228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75229. VIGNETTEBLENDMODEOPAQUE: boolean;
  75230. TONEMAPPING: boolean;
  75231. TONEMAPPING_ACES: boolean;
  75232. CONTRAST: boolean;
  75233. COLORCURVES: boolean;
  75234. COLORGRADING: boolean;
  75235. COLORGRADING3D: boolean;
  75236. SAMPLER3DGREENDEPTH: boolean;
  75237. SAMPLER3DBGRMAP: boolean;
  75238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75239. EXPOSURE: boolean;
  75240. constructor();
  75241. }
  75242. /**
  75243. * This groups together the common properties used for image processing either in direct forward pass
  75244. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75245. * or not.
  75246. */
  75247. export class ImageProcessingConfiguration {
  75248. /**
  75249. * Default tone mapping applied in BabylonJS.
  75250. */
  75251. static readonly TONEMAPPING_STANDARD: number;
  75252. /**
  75253. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75254. * to other engines rendering to increase portability.
  75255. */
  75256. static readonly TONEMAPPING_ACES: number;
  75257. /**
  75258. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75259. */
  75260. colorCurves: Nullable<ColorCurves>;
  75261. private _colorCurvesEnabled;
  75262. /**
  75263. * Gets wether the color curves effect is enabled.
  75264. */
  75265. /**
  75266. * Sets wether the color curves effect is enabled.
  75267. */
  75268. colorCurvesEnabled: boolean;
  75269. private _colorGradingTexture;
  75270. /**
  75271. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75272. */
  75273. /**
  75274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75275. */
  75276. colorGradingTexture: Nullable<BaseTexture>;
  75277. private _colorGradingEnabled;
  75278. /**
  75279. * Gets wether the color grading effect is enabled.
  75280. */
  75281. /**
  75282. * Sets wether the color grading effect is enabled.
  75283. */
  75284. colorGradingEnabled: boolean;
  75285. private _colorGradingWithGreenDepth;
  75286. /**
  75287. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75288. */
  75289. /**
  75290. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75291. */
  75292. colorGradingWithGreenDepth: boolean;
  75293. private _colorGradingBGR;
  75294. /**
  75295. * Gets wether the color grading texture contains BGR values.
  75296. */
  75297. /**
  75298. * Sets wether the color grading texture contains BGR values.
  75299. */
  75300. colorGradingBGR: boolean;
  75301. /** @hidden */
  75302. _exposure: number;
  75303. /**
  75304. * Gets the Exposure used in the effect.
  75305. */
  75306. /**
  75307. * Sets the Exposure used in the effect.
  75308. */
  75309. exposure: number;
  75310. private _toneMappingEnabled;
  75311. /**
  75312. * Gets wether the tone mapping effect is enabled.
  75313. */
  75314. /**
  75315. * Sets wether the tone mapping effect is enabled.
  75316. */
  75317. toneMappingEnabled: boolean;
  75318. private _toneMappingType;
  75319. /**
  75320. * Gets the type of tone mapping effect.
  75321. */
  75322. /**
  75323. * Sets the type of tone mapping effect used in BabylonJS.
  75324. */
  75325. toneMappingType: number;
  75326. protected _contrast: number;
  75327. /**
  75328. * Gets the contrast used in the effect.
  75329. */
  75330. /**
  75331. * Sets the contrast used in the effect.
  75332. */
  75333. contrast: number;
  75334. /**
  75335. * Vignette stretch size.
  75336. */
  75337. vignetteStretch: number;
  75338. /**
  75339. * Vignette centre X Offset.
  75340. */
  75341. vignetteCentreX: number;
  75342. /**
  75343. * Vignette centre Y Offset.
  75344. */
  75345. vignetteCentreY: number;
  75346. /**
  75347. * Vignette weight or intensity of the vignette effect.
  75348. */
  75349. vignetteWeight: number;
  75350. /**
  75351. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75352. * if vignetteEnabled is set to true.
  75353. */
  75354. vignetteColor: Color4;
  75355. /**
  75356. * Camera field of view used by the Vignette effect.
  75357. */
  75358. vignetteCameraFov: number;
  75359. private _vignetteBlendMode;
  75360. /**
  75361. * Gets the vignette blend mode allowing different kind of effect.
  75362. */
  75363. /**
  75364. * Sets the vignette blend mode allowing different kind of effect.
  75365. */
  75366. vignetteBlendMode: number;
  75367. private _vignetteEnabled;
  75368. /**
  75369. * Gets wether the vignette effect is enabled.
  75370. */
  75371. /**
  75372. * Sets wether the vignette effect is enabled.
  75373. */
  75374. vignetteEnabled: boolean;
  75375. private _applyByPostProcess;
  75376. /**
  75377. * Gets wether the image processing is applied through a post process or not.
  75378. */
  75379. /**
  75380. * Sets wether the image processing is applied through a post process or not.
  75381. */
  75382. applyByPostProcess: boolean;
  75383. private _isEnabled;
  75384. /**
  75385. * Gets wether the image processing is enabled or not.
  75386. */
  75387. /**
  75388. * Sets wether the image processing is enabled or not.
  75389. */
  75390. isEnabled: boolean;
  75391. /**
  75392. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75393. */
  75394. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75395. /**
  75396. * Method called each time the image processing information changes requires to recompile the effect.
  75397. */
  75398. protected _updateParameters(): void;
  75399. /**
  75400. * Gets the current class name.
  75401. * @return "ImageProcessingConfiguration"
  75402. */
  75403. getClassName(): string;
  75404. /**
  75405. * Prepare the list of uniforms associated with the Image Processing effects.
  75406. * @param uniforms The list of uniforms used in the effect
  75407. * @param defines the list of defines currently in use
  75408. */
  75409. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75410. /**
  75411. * Prepare the list of samplers associated with the Image Processing effects.
  75412. * @param samplersList The list of uniforms used in the effect
  75413. * @param defines the list of defines currently in use
  75414. */
  75415. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75416. /**
  75417. * Prepare the list of defines associated to the shader.
  75418. * @param defines the list of defines to complete
  75419. * @param forPostProcess Define if we are currently in post process mode or not
  75420. */
  75421. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75422. /**
  75423. * Returns true if all the image processing information are ready.
  75424. * @returns True if ready, otherwise, false
  75425. */
  75426. isReady(): boolean;
  75427. /**
  75428. * Binds the image processing to the shader.
  75429. * @param effect The effect to bind to
  75430. * @param aspectRatio Define the current aspect ratio of the effect
  75431. */
  75432. bind(effect: Effect, aspectRatio?: number): void;
  75433. /**
  75434. * Clones the current image processing instance.
  75435. * @return The cloned image processing
  75436. */
  75437. clone(): ImageProcessingConfiguration;
  75438. /**
  75439. * Serializes the current image processing instance to a json representation.
  75440. * @return a JSON representation
  75441. */
  75442. serialize(): any;
  75443. /**
  75444. * Parses the image processing from a json representation.
  75445. * @param source the JSON source to parse
  75446. * @return The parsed image processing
  75447. */
  75448. static Parse(source: any): ImageProcessingConfiguration;
  75449. private static _VIGNETTEMODE_MULTIPLY;
  75450. private static _VIGNETTEMODE_OPAQUE;
  75451. /**
  75452. * Used to apply the vignette as a mix with the pixel color.
  75453. */
  75454. static readonly VIGNETTEMODE_MULTIPLY: number;
  75455. /**
  75456. * Used to apply the vignette as a replacement of the pixel color.
  75457. */
  75458. static readonly VIGNETTEMODE_OPAQUE: number;
  75459. }
  75460. }
  75461. declare module BABYLON {
  75462. /** @hidden */
  75463. export var postprocessVertexShader: {
  75464. name: string;
  75465. shader: string;
  75466. };
  75467. }
  75468. declare module BABYLON {
  75469. interface ThinEngine {
  75470. /**
  75471. * Creates a new render target texture
  75472. * @param size defines the size of the texture
  75473. * @param options defines the options used to create the texture
  75474. * @returns a new render target texture stored in an InternalTexture
  75475. */
  75476. createRenderTargetTexture(size: number | {
  75477. width: number;
  75478. height: number;
  75479. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75480. }
  75481. }
  75482. declare module BABYLON {
  75483. /** Defines supported spaces */
  75484. export enum Space {
  75485. /** Local (object) space */
  75486. LOCAL = 0,
  75487. /** World space */
  75488. WORLD = 1,
  75489. /** Bone space */
  75490. BONE = 2
  75491. }
  75492. /** Defines the 3 main axes */
  75493. export class Axis {
  75494. /** X axis */
  75495. static X: Vector3;
  75496. /** Y axis */
  75497. static Y: Vector3;
  75498. /** Z axis */
  75499. static Z: Vector3;
  75500. }
  75501. }
  75502. declare module BABYLON {
  75503. /**
  75504. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75505. * This is the base of the follow, arc rotate cameras and Free camera
  75506. * @see http://doc.babylonjs.com/features/cameras
  75507. */
  75508. export class TargetCamera extends Camera {
  75509. private static _RigCamTransformMatrix;
  75510. private static _TargetTransformMatrix;
  75511. private static _TargetFocalPoint;
  75512. /**
  75513. * Define the current direction the camera is moving to
  75514. */
  75515. cameraDirection: Vector3;
  75516. /**
  75517. * Define the current rotation the camera is rotating to
  75518. */
  75519. cameraRotation: Vector2;
  75520. /**
  75521. * When set, the up vector of the camera will be updated by the rotation of the camera
  75522. */
  75523. updateUpVectorFromRotation: boolean;
  75524. private _tmpQuaternion;
  75525. /**
  75526. * Define the current rotation of the camera
  75527. */
  75528. rotation: Vector3;
  75529. /**
  75530. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75531. */
  75532. rotationQuaternion: Quaternion;
  75533. /**
  75534. * Define the current speed of the camera
  75535. */
  75536. speed: number;
  75537. /**
  75538. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75539. * around all axis.
  75540. */
  75541. noRotationConstraint: boolean;
  75542. /**
  75543. * Define the current target of the camera as an object or a position.
  75544. */
  75545. lockedTarget: any;
  75546. /** @hidden */
  75547. _currentTarget: Vector3;
  75548. /** @hidden */
  75549. _initialFocalDistance: number;
  75550. /** @hidden */
  75551. _viewMatrix: Matrix;
  75552. /** @hidden */
  75553. _camMatrix: Matrix;
  75554. /** @hidden */
  75555. _cameraTransformMatrix: Matrix;
  75556. /** @hidden */
  75557. _cameraRotationMatrix: Matrix;
  75558. /** @hidden */
  75559. _referencePoint: Vector3;
  75560. /** @hidden */
  75561. _transformedReferencePoint: Vector3;
  75562. protected _globalCurrentTarget: Vector3;
  75563. protected _globalCurrentUpVector: Vector3;
  75564. /** @hidden */
  75565. _reset: () => void;
  75566. private _defaultUp;
  75567. /**
  75568. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75569. * This is the base of the follow, arc rotate cameras and Free camera
  75570. * @see http://doc.babylonjs.com/features/cameras
  75571. * @param name Defines the name of the camera in the scene
  75572. * @param position Defines the start position of the camera in the scene
  75573. * @param scene Defines the scene the camera belongs to
  75574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75575. */
  75576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75577. /**
  75578. * Gets the position in front of the camera at a given distance.
  75579. * @param distance The distance from the camera we want the position to be
  75580. * @returns the position
  75581. */
  75582. getFrontPosition(distance: number): Vector3;
  75583. /** @hidden */
  75584. _getLockedTargetPosition(): Nullable<Vector3>;
  75585. private _storedPosition;
  75586. private _storedRotation;
  75587. private _storedRotationQuaternion;
  75588. /**
  75589. * Store current camera state of the camera (fov, position, rotation, etc..)
  75590. * @returns the camera
  75591. */
  75592. storeState(): Camera;
  75593. /**
  75594. * Restored camera state. You must call storeState() first
  75595. * @returns whether it was successful or not
  75596. * @hidden
  75597. */
  75598. _restoreStateValues(): boolean;
  75599. /** @hidden */
  75600. _initCache(): void;
  75601. /** @hidden */
  75602. _updateCache(ignoreParentClass?: boolean): void;
  75603. /** @hidden */
  75604. _isSynchronizedViewMatrix(): boolean;
  75605. /** @hidden */
  75606. _computeLocalCameraSpeed(): number;
  75607. /**
  75608. * Defines the target the camera should look at.
  75609. * @param target Defines the new target as a Vector or a mesh
  75610. */
  75611. setTarget(target: Vector3): void;
  75612. /**
  75613. * Return the current target position of the camera. This value is expressed in local space.
  75614. * @returns the target position
  75615. */
  75616. getTarget(): Vector3;
  75617. /** @hidden */
  75618. _decideIfNeedsToMove(): boolean;
  75619. /** @hidden */
  75620. _updatePosition(): void;
  75621. /** @hidden */
  75622. _checkInputs(): void;
  75623. protected _updateCameraRotationMatrix(): void;
  75624. /**
  75625. * 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)
  75626. * @returns the current camera
  75627. */
  75628. private _rotateUpVectorWithCameraRotationMatrix;
  75629. private _cachedRotationZ;
  75630. private _cachedQuaternionRotationZ;
  75631. /** @hidden */
  75632. _getViewMatrix(): Matrix;
  75633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75634. /**
  75635. * @hidden
  75636. */
  75637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75638. /**
  75639. * @hidden
  75640. */
  75641. _updateRigCameras(): void;
  75642. private _getRigCamPositionAndTarget;
  75643. /**
  75644. * Gets the current object class name.
  75645. * @return the class name
  75646. */
  75647. getClassName(): string;
  75648. }
  75649. }
  75650. declare module BABYLON {
  75651. /**
  75652. * Gather the list of keyboard event types as constants.
  75653. */
  75654. export class KeyboardEventTypes {
  75655. /**
  75656. * The keydown event is fired when a key becomes active (pressed).
  75657. */
  75658. static readonly KEYDOWN: number;
  75659. /**
  75660. * The keyup event is fired when a key has been released.
  75661. */
  75662. static readonly KEYUP: number;
  75663. }
  75664. /**
  75665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75666. */
  75667. export class KeyboardInfo {
  75668. /**
  75669. * Defines the type of event (KeyboardEventTypes)
  75670. */
  75671. type: number;
  75672. /**
  75673. * Defines the related dom event
  75674. */
  75675. event: KeyboardEvent;
  75676. /**
  75677. * Instantiates a new keyboard info.
  75678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75679. * @param type Defines the type of event (KeyboardEventTypes)
  75680. * @param event Defines the related dom event
  75681. */
  75682. constructor(
  75683. /**
  75684. * Defines the type of event (KeyboardEventTypes)
  75685. */
  75686. type: number,
  75687. /**
  75688. * Defines the related dom event
  75689. */
  75690. event: KeyboardEvent);
  75691. }
  75692. /**
  75693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75695. */
  75696. export class KeyboardInfoPre extends KeyboardInfo {
  75697. /**
  75698. * Defines the type of event (KeyboardEventTypes)
  75699. */
  75700. type: number;
  75701. /**
  75702. * Defines the related dom event
  75703. */
  75704. event: KeyboardEvent;
  75705. /**
  75706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75707. */
  75708. skipOnPointerObservable: boolean;
  75709. /**
  75710. * Instantiates a new keyboard pre info.
  75711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75712. * @param type Defines the type of event (KeyboardEventTypes)
  75713. * @param event Defines the related dom event
  75714. */
  75715. constructor(
  75716. /**
  75717. * Defines the type of event (KeyboardEventTypes)
  75718. */
  75719. type: number,
  75720. /**
  75721. * Defines the related dom event
  75722. */
  75723. event: KeyboardEvent);
  75724. }
  75725. }
  75726. declare module BABYLON {
  75727. /**
  75728. * Manage the keyboard inputs to control the movement of a free camera.
  75729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75730. */
  75731. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75732. /**
  75733. * Defines the camera the input is attached to.
  75734. */
  75735. camera: FreeCamera;
  75736. /**
  75737. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75738. */
  75739. keysUp: number[];
  75740. /**
  75741. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75742. */
  75743. keysDown: number[];
  75744. /**
  75745. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75746. */
  75747. keysLeft: number[];
  75748. /**
  75749. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75750. */
  75751. keysRight: number[];
  75752. private _keys;
  75753. private _onCanvasBlurObserver;
  75754. private _onKeyboardObserver;
  75755. private _engine;
  75756. private _scene;
  75757. /**
  75758. * Attach the input controls to a specific dom element to get the input from.
  75759. * @param element Defines the element the controls should be listened from
  75760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75761. */
  75762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75763. /**
  75764. * Detach the current controls from the specified dom element.
  75765. * @param element Defines the element to stop listening the inputs from
  75766. */
  75767. detachControl(element: Nullable<HTMLElement>): void;
  75768. /**
  75769. * Update the current camera state depending on the inputs that have been used this frame.
  75770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75771. */
  75772. checkInputs(): void;
  75773. /**
  75774. * Gets the class name of the current intput.
  75775. * @returns the class name
  75776. */
  75777. getClassName(): string;
  75778. /** @hidden */
  75779. _onLostFocus(): void;
  75780. /**
  75781. * Get the friendly name associated with the input class.
  75782. * @returns the input friendly name
  75783. */
  75784. getSimpleName(): string;
  75785. }
  75786. }
  75787. declare module BABYLON {
  75788. /**
  75789. * Interface describing all the common properties and methods a shadow light needs to implement.
  75790. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75791. * as well as binding the different shadow properties to the effects.
  75792. */
  75793. export interface IShadowLight extends Light {
  75794. /**
  75795. * The light id in the scene (used in scene.findLighById for instance)
  75796. */
  75797. id: string;
  75798. /**
  75799. * The position the shdow will be casted from.
  75800. */
  75801. position: Vector3;
  75802. /**
  75803. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75804. */
  75805. direction: Vector3;
  75806. /**
  75807. * The transformed position. Position of the light in world space taking parenting in account.
  75808. */
  75809. transformedPosition: Vector3;
  75810. /**
  75811. * The transformed direction. Direction of the light in world space taking parenting in account.
  75812. */
  75813. transformedDirection: Vector3;
  75814. /**
  75815. * The friendly name of the light in the scene.
  75816. */
  75817. name: string;
  75818. /**
  75819. * Defines the shadow projection clipping minimum z value.
  75820. */
  75821. shadowMinZ: number;
  75822. /**
  75823. * Defines the shadow projection clipping maximum z value.
  75824. */
  75825. shadowMaxZ: number;
  75826. /**
  75827. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75828. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75829. */
  75830. computeTransformedInformation(): boolean;
  75831. /**
  75832. * Gets the scene the light belongs to.
  75833. * @returns The scene
  75834. */
  75835. getScene(): Scene;
  75836. /**
  75837. * Callback defining a custom Projection Matrix Builder.
  75838. * This can be used to override the default projection matrix computation.
  75839. */
  75840. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75841. /**
  75842. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75843. * @param matrix The materix to updated with the projection information
  75844. * @param viewMatrix The transform matrix of the light
  75845. * @param renderList The list of mesh to render in the map
  75846. * @returns The current light
  75847. */
  75848. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75849. /**
  75850. * Gets the current depth scale used in ESM.
  75851. * @returns The scale
  75852. */
  75853. getDepthScale(): number;
  75854. /**
  75855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75856. * @returns true if a cube texture needs to be use
  75857. */
  75858. needCube(): boolean;
  75859. /**
  75860. * Detects if the projection matrix requires to be recomputed this frame.
  75861. * @returns true if it requires to be recomputed otherwise, false.
  75862. */
  75863. needProjectionMatrixCompute(): boolean;
  75864. /**
  75865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75866. */
  75867. forceProjectionMatrixCompute(): void;
  75868. /**
  75869. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75870. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75871. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75872. */
  75873. getShadowDirection(faceIndex?: number): Vector3;
  75874. /**
  75875. * Gets the minZ used for shadow according to both the scene and the light.
  75876. * @param activeCamera The camera we are returning the min for
  75877. * @returns the depth min z
  75878. */
  75879. getDepthMinZ(activeCamera: Camera): number;
  75880. /**
  75881. * Gets the maxZ used for shadow according to both the scene and the light.
  75882. * @param activeCamera The camera we are returning the max for
  75883. * @returns the depth max z
  75884. */
  75885. getDepthMaxZ(activeCamera: Camera): number;
  75886. }
  75887. /**
  75888. * Base implementation IShadowLight
  75889. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75890. */
  75891. export abstract class ShadowLight extends Light implements IShadowLight {
  75892. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75893. protected _position: Vector3;
  75894. protected _setPosition(value: Vector3): void;
  75895. /**
  75896. * Sets the position the shadow will be casted from. Also use as the light position for both
  75897. * point and spot lights.
  75898. */
  75899. /**
  75900. * Sets the position the shadow will be casted from. Also use as the light position for both
  75901. * point and spot lights.
  75902. */
  75903. position: Vector3;
  75904. protected _direction: Vector3;
  75905. protected _setDirection(value: Vector3): void;
  75906. /**
  75907. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75908. * Also use as the light direction on spot and directional lights.
  75909. */
  75910. /**
  75911. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75912. * Also use as the light direction on spot and directional lights.
  75913. */
  75914. direction: Vector3;
  75915. private _shadowMinZ;
  75916. /**
  75917. * Gets the shadow projection clipping minimum z value.
  75918. */
  75919. /**
  75920. * Sets the shadow projection clipping minimum z value.
  75921. */
  75922. shadowMinZ: number;
  75923. private _shadowMaxZ;
  75924. /**
  75925. * Sets the shadow projection clipping maximum z value.
  75926. */
  75927. /**
  75928. * Gets the shadow projection clipping maximum z value.
  75929. */
  75930. shadowMaxZ: number;
  75931. /**
  75932. * Callback defining a custom Projection Matrix Builder.
  75933. * This can be used to override the default projection matrix computation.
  75934. */
  75935. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75936. /**
  75937. * The transformed position. Position of the light in world space taking parenting in account.
  75938. */
  75939. transformedPosition: Vector3;
  75940. /**
  75941. * The transformed direction. Direction of the light in world space taking parenting in account.
  75942. */
  75943. transformedDirection: Vector3;
  75944. private _needProjectionMatrixCompute;
  75945. /**
  75946. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75947. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75948. */
  75949. computeTransformedInformation(): boolean;
  75950. /**
  75951. * Return the depth scale used for the shadow map.
  75952. * @returns the depth scale.
  75953. */
  75954. getDepthScale(): number;
  75955. /**
  75956. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75957. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75958. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75959. */
  75960. getShadowDirection(faceIndex?: number): Vector3;
  75961. /**
  75962. * Returns the ShadowLight absolute position in the World.
  75963. * @returns the position vector in world space
  75964. */
  75965. getAbsolutePosition(): Vector3;
  75966. /**
  75967. * Sets the ShadowLight direction toward the passed target.
  75968. * @param target The point to target in local space
  75969. * @returns the updated ShadowLight direction
  75970. */
  75971. setDirectionToTarget(target: Vector3): Vector3;
  75972. /**
  75973. * Returns the light rotation in euler definition.
  75974. * @returns the x y z rotation in local space.
  75975. */
  75976. getRotation(): Vector3;
  75977. /**
  75978. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75979. * @returns true if a cube texture needs to be use
  75980. */
  75981. needCube(): boolean;
  75982. /**
  75983. * Detects if the projection matrix requires to be recomputed this frame.
  75984. * @returns true if it requires to be recomputed otherwise, false.
  75985. */
  75986. needProjectionMatrixCompute(): boolean;
  75987. /**
  75988. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75989. */
  75990. forceProjectionMatrixCompute(): void;
  75991. /** @hidden */
  75992. _initCache(): void;
  75993. /** @hidden */
  75994. _isSynchronized(): boolean;
  75995. /**
  75996. * Computes the world matrix of the node
  75997. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75998. * @returns the world matrix
  75999. */
  76000. computeWorldMatrix(force?: boolean): Matrix;
  76001. /**
  76002. * Gets the minZ used for shadow according to both the scene and the light.
  76003. * @param activeCamera The camera we are returning the min for
  76004. * @returns the depth min z
  76005. */
  76006. getDepthMinZ(activeCamera: Camera): number;
  76007. /**
  76008. * Gets the maxZ used for shadow according to both the scene and the light.
  76009. * @param activeCamera The camera we are returning the max for
  76010. * @returns the depth max z
  76011. */
  76012. getDepthMaxZ(activeCamera: Camera): number;
  76013. /**
  76014. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76015. * @param matrix The materix to updated with the projection information
  76016. * @param viewMatrix The transform matrix of the light
  76017. * @param renderList The list of mesh to render in the map
  76018. * @returns The current light
  76019. */
  76020. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76021. }
  76022. }
  76023. declare module BABYLON {
  76024. /**
  76025. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76026. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76027. */
  76028. export class EffectFallbacks implements IEffectFallbacks {
  76029. private _defines;
  76030. private _currentRank;
  76031. private _maxRank;
  76032. private _mesh;
  76033. /**
  76034. * Removes the fallback from the bound mesh.
  76035. */
  76036. unBindMesh(): void;
  76037. /**
  76038. * Adds a fallback on the specified property.
  76039. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76040. * @param define The name of the define in the shader
  76041. */
  76042. addFallback(rank: number, define: string): void;
  76043. /**
  76044. * Sets the mesh to use CPU skinning when needing to fallback.
  76045. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76046. * @param mesh The mesh to use the fallbacks.
  76047. */
  76048. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76049. /**
  76050. * Checks to see if more fallbacks are still availible.
  76051. */
  76052. readonly hasMoreFallbacks: boolean;
  76053. /**
  76054. * Removes the defines that should be removed when falling back.
  76055. * @param currentDefines defines the current define statements for the shader.
  76056. * @param effect defines the current effect we try to compile
  76057. * @returns The resulting defines with defines of the current rank removed.
  76058. */
  76059. reduce(currentDefines: string, effect: Effect): string;
  76060. }
  76061. }
  76062. declare module BABYLON {
  76063. /**
  76064. * "Static Class" containing the most commonly used helper while dealing with material for
  76065. * rendering purpose.
  76066. *
  76067. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76068. *
  76069. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76070. */
  76071. export class MaterialHelper {
  76072. /**
  76073. * Bind the current view position to an effect.
  76074. * @param effect The effect to be bound
  76075. * @param scene The scene the eyes position is used from
  76076. */
  76077. static BindEyePosition(effect: Effect, scene: Scene): void;
  76078. /**
  76079. * Helps preparing the defines values about the UVs in used in the effect.
  76080. * UVs are shared as much as we can accross channels in the shaders.
  76081. * @param texture The texture we are preparing the UVs for
  76082. * @param defines The defines to update
  76083. * @param key The channel key "diffuse", "specular"... used in the shader
  76084. */
  76085. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76086. /**
  76087. * Binds a texture matrix value to its corrsponding uniform
  76088. * @param texture The texture to bind the matrix for
  76089. * @param uniformBuffer The uniform buffer receivin the data
  76090. * @param key The channel key "diffuse", "specular"... used in the shader
  76091. */
  76092. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76093. /**
  76094. * Gets the current status of the fog (should it be enabled?)
  76095. * @param mesh defines the mesh to evaluate for fog support
  76096. * @param scene defines the hosting scene
  76097. * @returns true if fog must be enabled
  76098. */
  76099. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76100. /**
  76101. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76102. * @param mesh defines the current mesh
  76103. * @param scene defines the current scene
  76104. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76105. * @param pointsCloud defines if point cloud rendering has to be turned on
  76106. * @param fogEnabled defines if fog has to be turned on
  76107. * @param alphaTest defines if alpha testing has to be turned on
  76108. * @param defines defines the current list of defines
  76109. */
  76110. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76111. /**
  76112. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76113. * @param scene defines the current scene
  76114. * @param engine defines the current engine
  76115. * @param defines specifies the list of active defines
  76116. * @param useInstances defines if instances have to be turned on
  76117. * @param useClipPlane defines if clip plane have to be turned on
  76118. */
  76119. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76120. /**
  76121. * Prepares the defines for bones
  76122. * @param mesh The mesh containing the geometry data we will draw
  76123. * @param defines The defines to update
  76124. */
  76125. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76126. /**
  76127. * Prepares the defines for morph targets
  76128. * @param mesh The mesh containing the geometry data we will draw
  76129. * @param defines The defines to update
  76130. */
  76131. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76132. /**
  76133. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76134. * @param mesh The mesh containing the geometry data we will draw
  76135. * @param defines The defines to update
  76136. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76137. * @param useBones Precise whether bones should be used or not (override mesh info)
  76138. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76139. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76140. * @returns false if defines are considered not dirty and have not been checked
  76141. */
  76142. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76143. /**
  76144. * Prepares the defines related to multiview
  76145. * @param scene The scene we are intending to draw
  76146. * @param defines The defines to update
  76147. */
  76148. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76149. /**
  76150. * Prepares the defines related to the light information passed in parameter
  76151. * @param scene The scene we are intending to draw
  76152. * @param mesh The mesh the effect is compiling for
  76153. * @param light The light the effect is compiling for
  76154. * @param lightIndex The index of the light
  76155. * @param defines The defines to update
  76156. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76157. * @param state Defines the current state regarding what is needed (normals, etc...)
  76158. */
  76159. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76160. needNormals: boolean;
  76161. needRebuild: boolean;
  76162. shadowEnabled: boolean;
  76163. specularEnabled: boolean;
  76164. lightmapMode: boolean;
  76165. }): void;
  76166. /**
  76167. * Prepares the defines related to the light information passed in parameter
  76168. * @param scene The scene we are intending to draw
  76169. * @param mesh The mesh the effect is compiling for
  76170. * @param defines The defines to update
  76171. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76172. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76173. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76174. * @returns true if normals will be required for the rest of the effect
  76175. */
  76176. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76177. /**
  76178. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76179. * @param lightIndex defines the light index
  76180. * @param uniformsList The uniform list
  76181. * @param samplersList The sampler list
  76182. * @param projectedLightTexture defines if projected texture must be used
  76183. * @param uniformBuffersList defines an optional list of uniform buffers
  76184. */
  76185. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76186. /**
  76187. * Prepares the uniforms and samplers list to be used in the effect
  76188. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76189. * @param samplersList The sampler list
  76190. * @param defines The defines helping in the list generation
  76191. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76192. */
  76193. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76194. /**
  76195. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76196. * @param defines The defines to update while falling back
  76197. * @param fallbacks The authorized effect fallbacks
  76198. * @param maxSimultaneousLights The maximum number of lights allowed
  76199. * @param rank the current rank of the Effect
  76200. * @returns The newly affected rank
  76201. */
  76202. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76203. private static _TmpMorphInfluencers;
  76204. /**
  76205. * Prepares the list of attributes required for morph targets according to the effect defines.
  76206. * @param attribs The current list of supported attribs
  76207. * @param mesh The mesh to prepare the morph targets attributes for
  76208. * @param influencers The number of influencers
  76209. */
  76210. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76211. /**
  76212. * Prepares the list of attributes required for morph targets according to the effect defines.
  76213. * @param attribs The current list of supported attribs
  76214. * @param mesh The mesh to prepare the morph targets attributes for
  76215. * @param defines The current Defines of the effect
  76216. */
  76217. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76218. /**
  76219. * Prepares the list of attributes required for bones according to the effect defines.
  76220. * @param attribs The current list of supported attribs
  76221. * @param mesh The mesh to prepare the bones attributes for
  76222. * @param defines The current Defines of the effect
  76223. * @param fallbacks The current efffect fallback strategy
  76224. */
  76225. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76226. /**
  76227. * Check and prepare the list of attributes required for instances according to the effect defines.
  76228. * @param attribs The current list of supported attribs
  76229. * @param defines The current MaterialDefines of the effect
  76230. */
  76231. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76232. /**
  76233. * Add the list of attributes required for instances to the attribs array.
  76234. * @param attribs The current list of supported attribs
  76235. */
  76236. static PushAttributesForInstances(attribs: string[]): void;
  76237. /**
  76238. * Binds the light shadow information to the effect for the given mesh.
  76239. * @param light The light containing the generator
  76240. * @param scene The scene the lights belongs to
  76241. * @param mesh The mesh we are binding the information to render
  76242. * @param lightIndex The light index in the effect used to render the mesh
  76243. * @param effect The effect we are binding the data to
  76244. */
  76245. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  76246. /**
  76247. * Binds the light information to the effect.
  76248. * @param light The light containing the generator
  76249. * @param effect The effect we are binding the data to
  76250. * @param lightIndex The light index in the effect used to render
  76251. */
  76252. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76253. /**
  76254. * Binds the lights information from the scene to the effect for the given mesh.
  76255. * @param light Light to bind
  76256. * @param lightIndex Light index
  76257. * @param scene The scene where the light belongs to
  76258. * @param mesh The mesh we are binding the information to render
  76259. * @param effect The effect we are binding the data to
  76260. * @param useSpecular Defines if specular is supported
  76261. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76262. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76263. */
  76264. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76265. /**
  76266. * Binds the lights information from the scene to the effect for the given mesh.
  76267. * @param scene The scene the lights belongs to
  76268. * @param mesh The mesh we are binding the information to render
  76269. * @param effect The effect we are binding the data to
  76270. * @param defines The generated defines for the effect
  76271. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76272. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76273. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76274. */
  76275. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76276. private static _tempFogColor;
  76277. /**
  76278. * Binds the fog information from the scene to the effect for the given mesh.
  76279. * @param scene The scene the lights belongs to
  76280. * @param mesh The mesh we are binding the information to render
  76281. * @param effect The effect we are binding the data to
  76282. * @param linearSpace Defines if the fog effect is applied in linear space
  76283. */
  76284. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76285. /**
  76286. * Binds the bones information from the mesh to the effect.
  76287. * @param mesh The mesh we are binding the information to render
  76288. * @param effect The effect we are binding the data to
  76289. */
  76290. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76291. /**
  76292. * Binds the morph targets information from the mesh to the effect.
  76293. * @param abstractMesh The mesh we are binding the information to render
  76294. * @param effect The effect we are binding the data to
  76295. */
  76296. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76297. /**
  76298. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76299. * @param defines The generated defines used in the effect
  76300. * @param effect The effect we are binding the data to
  76301. * @param scene The scene we are willing to render with logarithmic scale for
  76302. */
  76303. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76304. /**
  76305. * Binds the clip plane information from the scene to the effect.
  76306. * @param scene The scene the clip plane information are extracted from
  76307. * @param effect The effect we are binding the data to
  76308. */
  76309. static BindClipPlane(effect: Effect, scene: Scene): void;
  76310. }
  76311. }
  76312. declare module BABYLON {
  76313. /** @hidden */
  76314. export var packingFunctions: {
  76315. name: string;
  76316. shader: string;
  76317. };
  76318. }
  76319. declare module BABYLON {
  76320. /** @hidden */
  76321. export var shadowMapPixelShader: {
  76322. name: string;
  76323. shader: string;
  76324. };
  76325. }
  76326. declare module BABYLON {
  76327. /** @hidden */
  76328. export var bonesDeclaration: {
  76329. name: string;
  76330. shader: string;
  76331. };
  76332. }
  76333. declare module BABYLON {
  76334. /** @hidden */
  76335. export var morphTargetsVertexGlobalDeclaration: {
  76336. name: string;
  76337. shader: string;
  76338. };
  76339. }
  76340. declare module BABYLON {
  76341. /** @hidden */
  76342. export var morphTargetsVertexDeclaration: {
  76343. name: string;
  76344. shader: string;
  76345. };
  76346. }
  76347. declare module BABYLON {
  76348. /** @hidden */
  76349. export var instancesDeclaration: {
  76350. name: string;
  76351. shader: string;
  76352. };
  76353. }
  76354. declare module BABYLON {
  76355. /** @hidden */
  76356. export var helperFunctions: {
  76357. name: string;
  76358. shader: string;
  76359. };
  76360. }
  76361. declare module BABYLON {
  76362. /** @hidden */
  76363. export var morphTargetsVertex: {
  76364. name: string;
  76365. shader: string;
  76366. };
  76367. }
  76368. declare module BABYLON {
  76369. /** @hidden */
  76370. export var instancesVertex: {
  76371. name: string;
  76372. shader: string;
  76373. };
  76374. }
  76375. declare module BABYLON {
  76376. /** @hidden */
  76377. export var bonesVertex: {
  76378. name: string;
  76379. shader: string;
  76380. };
  76381. }
  76382. declare module BABYLON {
  76383. /** @hidden */
  76384. export var shadowMapVertexShader: {
  76385. name: string;
  76386. shader: string;
  76387. };
  76388. }
  76389. declare module BABYLON {
  76390. /** @hidden */
  76391. export var depthBoxBlurPixelShader: {
  76392. name: string;
  76393. shader: string;
  76394. };
  76395. }
  76396. declare module BABYLON {
  76397. /**
  76398. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76399. */
  76400. export interface ICustomShaderOptions {
  76401. /**
  76402. * Gets or sets the custom shader name to use
  76403. */
  76404. shaderName: string;
  76405. /**
  76406. * The list of attribute names used in the shader
  76407. */
  76408. attributes?: string[];
  76409. /**
  76410. * The list of unifrom names used in the shader
  76411. */
  76412. uniforms?: string[];
  76413. /**
  76414. * The list of sampler names used in the shader
  76415. */
  76416. samplers?: string[];
  76417. /**
  76418. * The list of defines used in the shader
  76419. */
  76420. defines?: string[];
  76421. }
  76422. /**
  76423. * Interface to implement to create a shadow generator compatible with BJS.
  76424. */
  76425. export interface IShadowGenerator {
  76426. /**
  76427. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76428. * @returns The render target texture if present otherwise, null
  76429. */
  76430. getShadowMap(): Nullable<RenderTargetTexture>;
  76431. /**
  76432. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76433. * @returns The render target texture if the shadow map is present otherwise, null
  76434. */
  76435. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76436. /**
  76437. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76438. * @param subMesh The submesh we want to render in the shadow map
  76439. * @param useInstances Defines wether will draw in the map using instances
  76440. * @returns true if ready otherwise, false
  76441. */
  76442. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76443. /**
  76444. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76445. * @param defines Defines of the material we want to update
  76446. * @param lightIndex Index of the light in the enabled light list of the material
  76447. */
  76448. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76449. /**
  76450. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76451. * defined in the generator but impacting the effect).
  76452. * It implies the unifroms available on the materials are the standard BJS ones.
  76453. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76454. * @param effect The effect we are binfing the information for
  76455. */
  76456. bindShadowLight(lightIndex: string, effect: Effect): void;
  76457. /**
  76458. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76459. * (eq to shadow prjection matrix * light transform matrix)
  76460. * @returns The transform matrix used to create the shadow map
  76461. */
  76462. getTransformMatrix(): Matrix;
  76463. /**
  76464. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76465. * Cube and 2D textures for instance.
  76466. */
  76467. recreateShadowMap(): void;
  76468. /**
  76469. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76470. * @param onCompiled Callback triggered at the and of the effects compilation
  76471. * @param options Sets of optional options forcing the compilation with different modes
  76472. */
  76473. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76474. useInstances: boolean;
  76475. }>): void;
  76476. /**
  76477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76478. * @param options Sets of optional options forcing the compilation with different modes
  76479. * @returns A promise that resolves when the compilation completes
  76480. */
  76481. forceCompilationAsync(options?: Partial<{
  76482. useInstances: boolean;
  76483. }>): Promise<void>;
  76484. /**
  76485. * Serializes the shadow generator setup to a json object.
  76486. * @returns The serialized JSON object
  76487. */
  76488. serialize(): any;
  76489. /**
  76490. * Disposes the Shadow map and related Textures and effects.
  76491. */
  76492. dispose(): void;
  76493. }
  76494. /**
  76495. * Default implementation IShadowGenerator.
  76496. * This is the main object responsible of generating shadows in the framework.
  76497. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76498. */
  76499. export class ShadowGenerator implements IShadowGenerator {
  76500. /**
  76501. * Shadow generator mode None: no filtering applied.
  76502. */
  76503. static readonly FILTER_NONE: number;
  76504. /**
  76505. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76506. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76507. */
  76508. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76509. /**
  76510. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76511. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76512. */
  76513. static readonly FILTER_POISSONSAMPLING: number;
  76514. /**
  76515. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76516. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76517. */
  76518. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76519. /**
  76520. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76521. * edge artifacts on steep falloff.
  76522. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76523. */
  76524. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76525. /**
  76526. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76527. * edge artifacts on steep falloff.
  76528. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76529. */
  76530. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76531. /**
  76532. * Shadow generator mode PCF: Percentage Closer Filtering
  76533. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76534. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76535. */
  76536. static readonly FILTER_PCF: number;
  76537. /**
  76538. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76539. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76540. * Contact Hardening
  76541. */
  76542. static readonly FILTER_PCSS: number;
  76543. /**
  76544. * Reserved for PCF and PCSS
  76545. * Highest Quality.
  76546. *
  76547. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76548. *
  76549. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76550. */
  76551. static readonly QUALITY_HIGH: number;
  76552. /**
  76553. * Reserved for PCF and PCSS
  76554. * Good tradeoff for quality/perf cross devices
  76555. *
  76556. * Execute PCF on a 3*3 kernel.
  76557. *
  76558. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76559. */
  76560. static readonly QUALITY_MEDIUM: number;
  76561. /**
  76562. * Reserved for PCF and PCSS
  76563. * The lowest quality but the fastest.
  76564. *
  76565. * Execute PCF on a 1*1 kernel.
  76566. *
  76567. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76568. */
  76569. static readonly QUALITY_LOW: number;
  76570. /** Gets or sets the custom shader name to use */
  76571. customShaderOptions: ICustomShaderOptions;
  76572. /**
  76573. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76574. */
  76575. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76576. /**
  76577. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76578. */
  76579. onAfterShadowMapRenderObservable: Observable<Effect>;
  76580. /**
  76581. * Observable triggered before a mesh is rendered in the shadow map.
  76582. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76583. */
  76584. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76585. /**
  76586. * Observable triggered after a mesh is rendered in the shadow map.
  76587. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76588. */
  76589. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76590. private _bias;
  76591. /**
  76592. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76593. */
  76594. /**
  76595. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76596. */
  76597. bias: number;
  76598. private _normalBias;
  76599. /**
  76600. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76601. */
  76602. /**
  76603. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76604. */
  76605. normalBias: number;
  76606. private _blurBoxOffset;
  76607. /**
  76608. * Gets the blur box offset: offset applied during the blur pass.
  76609. * Only useful if useKernelBlur = false
  76610. */
  76611. /**
  76612. * Sets the blur box offset: offset applied during the blur pass.
  76613. * Only useful if useKernelBlur = false
  76614. */
  76615. blurBoxOffset: number;
  76616. private _blurScale;
  76617. /**
  76618. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76619. * 2 means half of the size.
  76620. */
  76621. /**
  76622. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76623. * 2 means half of the size.
  76624. */
  76625. blurScale: number;
  76626. private _blurKernel;
  76627. /**
  76628. * Gets the blur kernel: kernel size of the blur pass.
  76629. * Only useful if useKernelBlur = true
  76630. */
  76631. /**
  76632. * Sets the blur kernel: kernel size of the blur pass.
  76633. * Only useful if useKernelBlur = true
  76634. */
  76635. blurKernel: number;
  76636. private _useKernelBlur;
  76637. /**
  76638. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76639. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76640. */
  76641. /**
  76642. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76644. */
  76645. useKernelBlur: boolean;
  76646. private _depthScale;
  76647. /**
  76648. * Gets the depth scale used in ESM mode.
  76649. */
  76650. /**
  76651. * Sets the depth scale used in ESM mode.
  76652. * This can override the scale stored on the light.
  76653. */
  76654. depthScale: number;
  76655. private _filter;
  76656. /**
  76657. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76659. */
  76660. /**
  76661. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76663. */
  76664. filter: number;
  76665. /**
  76666. * Gets if the current filter is set to Poisson Sampling.
  76667. */
  76668. /**
  76669. * Sets the current filter to Poisson Sampling.
  76670. */
  76671. usePoissonSampling: boolean;
  76672. /**
  76673. * Gets if the current filter is set to ESM.
  76674. */
  76675. /**
  76676. * Sets the current filter is to ESM.
  76677. */
  76678. useExponentialShadowMap: boolean;
  76679. /**
  76680. * Gets if the current filter is set to filtered ESM.
  76681. */
  76682. /**
  76683. * Gets if the current filter is set to filtered ESM.
  76684. */
  76685. useBlurExponentialShadowMap: boolean;
  76686. /**
  76687. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76688. * exponential to prevent steep falloff artifacts).
  76689. */
  76690. /**
  76691. * Sets the current filter to "close ESM" (using the inverse of the
  76692. * exponential to prevent steep falloff artifacts).
  76693. */
  76694. useCloseExponentialShadowMap: boolean;
  76695. /**
  76696. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76697. * exponential to prevent steep falloff artifacts).
  76698. */
  76699. /**
  76700. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76701. * exponential to prevent steep falloff artifacts).
  76702. */
  76703. useBlurCloseExponentialShadowMap: boolean;
  76704. /**
  76705. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76706. */
  76707. /**
  76708. * Sets the current filter to "PCF" (percentage closer filtering).
  76709. */
  76710. usePercentageCloserFiltering: boolean;
  76711. private _filteringQuality;
  76712. /**
  76713. * Gets the PCF or PCSS Quality.
  76714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76715. */
  76716. /**
  76717. * Sets the PCF or PCSS Quality.
  76718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76719. */
  76720. filteringQuality: number;
  76721. /**
  76722. * Gets if the current filter is set to "PCSS" (contact hardening).
  76723. */
  76724. /**
  76725. * Sets the current filter to "PCSS" (contact hardening).
  76726. */
  76727. useContactHardeningShadow: boolean;
  76728. private _contactHardeningLightSizeUVRatio;
  76729. /**
  76730. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76731. * Using a ratio helps keeping shape stability independently of the map size.
  76732. *
  76733. * It does not account for the light projection as it was having too much
  76734. * instability during the light setup or during light position changes.
  76735. *
  76736. * Only valid if useContactHardeningShadow is true.
  76737. */
  76738. /**
  76739. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76740. * Using a ratio helps keeping shape stability independently of the map size.
  76741. *
  76742. * It does not account for the light projection as it was having too much
  76743. * instability during the light setup or during light position changes.
  76744. *
  76745. * Only valid if useContactHardeningShadow is true.
  76746. */
  76747. contactHardeningLightSizeUVRatio: number;
  76748. private _darkness;
  76749. /** Gets or sets the actual darkness of a shadow */
  76750. darkness: number;
  76751. /**
  76752. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76753. * 0 means strongest and 1 would means no shadow.
  76754. * @returns the darkness.
  76755. */
  76756. getDarkness(): number;
  76757. /**
  76758. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76759. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76760. * @returns the shadow generator allowing fluent coding.
  76761. */
  76762. setDarkness(darkness: number): ShadowGenerator;
  76763. private _transparencyShadow;
  76764. /** Gets or sets the ability to have transparent shadow */
  76765. transparencyShadow: boolean;
  76766. /**
  76767. * Sets the ability to have transparent shadow (boolean).
  76768. * @param transparent True if transparent else False
  76769. * @returns the shadow generator allowing fluent coding
  76770. */
  76771. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76772. private _shadowMap;
  76773. private _shadowMap2;
  76774. /**
  76775. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76776. * @returns The render target texture if present otherwise, null
  76777. */
  76778. getShadowMap(): Nullable<RenderTargetTexture>;
  76779. /**
  76780. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76781. * @returns The render target texture if the shadow map is present otherwise, null
  76782. */
  76783. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76784. /**
  76785. * Gets the class name of that object
  76786. * @returns "ShadowGenerator"
  76787. */
  76788. getClassName(): string;
  76789. /**
  76790. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76791. * @param mesh Mesh to add
  76792. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76793. * @returns the Shadow Generator itself
  76794. */
  76795. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76796. /**
  76797. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76798. * @param mesh Mesh to remove
  76799. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76800. * @returns the Shadow Generator itself
  76801. */
  76802. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76803. /**
  76804. * Controls the extent to which the shadows fade out at the edge of the frustum
  76805. * Used only by directionals and spots
  76806. */
  76807. frustumEdgeFalloff: number;
  76808. private _light;
  76809. /**
  76810. * Returns the associated light object.
  76811. * @returns the light generating the shadow
  76812. */
  76813. getLight(): IShadowLight;
  76814. /**
  76815. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76816. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76817. * It might on the other hand introduce peter panning.
  76818. */
  76819. forceBackFacesOnly: boolean;
  76820. private _scene;
  76821. private _lightDirection;
  76822. private _effect;
  76823. private _viewMatrix;
  76824. private _projectionMatrix;
  76825. private _transformMatrix;
  76826. private _cachedPosition;
  76827. private _cachedDirection;
  76828. private _cachedDefines;
  76829. private _currentRenderID;
  76830. private _boxBlurPostprocess;
  76831. private _kernelBlurXPostprocess;
  76832. private _kernelBlurYPostprocess;
  76833. private _blurPostProcesses;
  76834. private _mapSize;
  76835. private _currentFaceIndex;
  76836. private _currentFaceIndexCache;
  76837. private _textureType;
  76838. private _defaultTextureMatrix;
  76839. private _storedUniqueId;
  76840. /** @hidden */
  76841. static _SceneComponentInitialization: (scene: Scene) => void;
  76842. /**
  76843. * Creates a ShadowGenerator object.
  76844. * A ShadowGenerator is the required tool to use the shadows.
  76845. * Each light casting shadows needs to use its own ShadowGenerator.
  76846. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76847. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76848. * @param light The light object generating the shadows.
  76849. * @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.
  76850. */
  76851. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76852. private _initializeGenerator;
  76853. private _initializeShadowMap;
  76854. private _initializeBlurRTTAndPostProcesses;
  76855. private _renderForShadowMap;
  76856. private _renderSubMeshForShadowMap;
  76857. private _applyFilterValues;
  76858. /**
  76859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76860. * @param onCompiled Callback triggered at the and of the effects compilation
  76861. * @param options Sets of optional options forcing the compilation with different modes
  76862. */
  76863. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76864. useInstances: boolean;
  76865. }>): void;
  76866. /**
  76867. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76868. * @param options Sets of optional options forcing the compilation with different modes
  76869. * @returns A promise that resolves when the compilation completes
  76870. */
  76871. forceCompilationAsync(options?: Partial<{
  76872. useInstances: boolean;
  76873. }>): Promise<void>;
  76874. /**
  76875. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76876. * @param subMesh The submesh we want to render in the shadow map
  76877. * @param useInstances Defines wether will draw in the map using instances
  76878. * @returns true if ready otherwise, false
  76879. */
  76880. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76881. /**
  76882. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76883. * @param defines Defines of the material we want to update
  76884. * @param lightIndex Index of the light in the enabled light list of the material
  76885. */
  76886. prepareDefines(defines: any, lightIndex: number): void;
  76887. /**
  76888. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76889. * defined in the generator but impacting the effect).
  76890. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76891. * @param effect The effect we are binfing the information for
  76892. */
  76893. bindShadowLight(lightIndex: string, effect: Effect): void;
  76894. /**
  76895. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76896. * (eq to shadow prjection matrix * light transform matrix)
  76897. * @returns The transform matrix used to create the shadow map
  76898. */
  76899. getTransformMatrix(): Matrix;
  76900. /**
  76901. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76902. * Cube and 2D textures for instance.
  76903. */
  76904. recreateShadowMap(): void;
  76905. private _disposeBlurPostProcesses;
  76906. private _disposeRTTandPostProcesses;
  76907. /**
  76908. * Disposes the ShadowGenerator.
  76909. * Returns nothing.
  76910. */
  76911. dispose(): void;
  76912. /**
  76913. * Serializes the shadow generator setup to a json object.
  76914. * @returns The serialized JSON object
  76915. */
  76916. serialize(): any;
  76917. /**
  76918. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76919. * @param parsedShadowGenerator The JSON object to parse
  76920. * @param scene The scene to create the shadow map for
  76921. * @returns The parsed shadow generator
  76922. */
  76923. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76924. }
  76925. }
  76926. declare module BABYLON {
  76927. /**
  76928. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76929. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76930. * 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.
  76931. */
  76932. export abstract class Light extends Node {
  76933. /**
  76934. * Falloff Default: light is falling off following the material specification:
  76935. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76936. */
  76937. static readonly FALLOFF_DEFAULT: number;
  76938. /**
  76939. * Falloff Physical: light is falling off following the inverse squared distance law.
  76940. */
  76941. static readonly FALLOFF_PHYSICAL: number;
  76942. /**
  76943. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76944. * to enhance interoperability with other engines.
  76945. */
  76946. static readonly FALLOFF_GLTF: number;
  76947. /**
  76948. * Falloff Standard: light is falling off like in the standard material
  76949. * to enhance interoperability with other materials.
  76950. */
  76951. static readonly FALLOFF_STANDARD: number;
  76952. /**
  76953. * If every light affecting the material is in this lightmapMode,
  76954. * material.lightmapTexture adds or multiplies
  76955. * (depends on material.useLightmapAsShadowmap)
  76956. * after every other light calculations.
  76957. */
  76958. static readonly LIGHTMAP_DEFAULT: number;
  76959. /**
  76960. * material.lightmapTexture as only diffuse lighting from this light
  76961. * adds only specular lighting from this light
  76962. * adds dynamic shadows
  76963. */
  76964. static readonly LIGHTMAP_SPECULAR: number;
  76965. /**
  76966. * material.lightmapTexture as only lighting
  76967. * no light calculation from this light
  76968. * only adds dynamic shadows from this light
  76969. */
  76970. static readonly LIGHTMAP_SHADOWSONLY: number;
  76971. /**
  76972. * Each light type uses the default quantity according to its type:
  76973. * point/spot lights use luminous intensity
  76974. * directional lights use illuminance
  76975. */
  76976. static readonly INTENSITYMODE_AUTOMATIC: number;
  76977. /**
  76978. * lumen (lm)
  76979. */
  76980. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76981. /**
  76982. * candela (lm/sr)
  76983. */
  76984. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76985. /**
  76986. * lux (lm/m^2)
  76987. */
  76988. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76989. /**
  76990. * nit (cd/m^2)
  76991. */
  76992. static readonly INTENSITYMODE_LUMINANCE: number;
  76993. /**
  76994. * Light type const id of the point light.
  76995. */
  76996. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76997. /**
  76998. * Light type const id of the directional light.
  76999. */
  77000. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77001. /**
  77002. * Light type const id of the spot light.
  77003. */
  77004. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77005. /**
  77006. * Light type const id of the hemispheric light.
  77007. */
  77008. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77009. /**
  77010. * Diffuse gives the basic color to an object.
  77011. */
  77012. diffuse: Color3;
  77013. /**
  77014. * Specular produces a highlight color on an object.
  77015. * Note: This is note affecting PBR materials.
  77016. */
  77017. specular: Color3;
  77018. /**
  77019. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77020. * falling off base on range or angle.
  77021. * This can be set to any values in Light.FALLOFF_x.
  77022. *
  77023. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77024. * other types of materials.
  77025. */
  77026. falloffType: number;
  77027. /**
  77028. * Strength of the light.
  77029. * Note: By default it is define in the framework own unit.
  77030. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77031. */
  77032. intensity: number;
  77033. private _range;
  77034. protected _inverseSquaredRange: number;
  77035. /**
  77036. * Defines how far from the source the light is impacting in scene units.
  77037. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77038. */
  77039. /**
  77040. * Defines how far from the source the light is impacting in scene units.
  77041. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77042. */
  77043. range: number;
  77044. /**
  77045. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77046. * of light.
  77047. */
  77048. private _photometricScale;
  77049. private _intensityMode;
  77050. /**
  77051. * Gets the photometric scale used to interpret the intensity.
  77052. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77053. */
  77054. /**
  77055. * Sets the photometric scale used to interpret the intensity.
  77056. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77057. */
  77058. intensityMode: number;
  77059. private _radius;
  77060. /**
  77061. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77062. */
  77063. /**
  77064. * sets the light radius used by PBR Materials to simulate soft area lights.
  77065. */
  77066. radius: number;
  77067. private _renderPriority;
  77068. /**
  77069. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77070. * exceeding the number allowed of the materials.
  77071. */
  77072. renderPriority: number;
  77073. private _shadowEnabled;
  77074. /**
  77075. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77076. * the current shadow generator.
  77077. */
  77078. /**
  77079. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77080. * the current shadow generator.
  77081. */
  77082. shadowEnabled: boolean;
  77083. private _includedOnlyMeshes;
  77084. /**
  77085. * Gets the only meshes impacted by this light.
  77086. */
  77087. /**
  77088. * Sets the only meshes impacted by this light.
  77089. */
  77090. includedOnlyMeshes: AbstractMesh[];
  77091. private _excludedMeshes;
  77092. /**
  77093. * Gets the meshes not impacted by this light.
  77094. */
  77095. /**
  77096. * Sets the meshes not impacted by this light.
  77097. */
  77098. excludedMeshes: AbstractMesh[];
  77099. private _excludeWithLayerMask;
  77100. /**
  77101. * Gets the layer id use to find what meshes are not impacted by the light.
  77102. * Inactive if 0
  77103. */
  77104. /**
  77105. * Sets the layer id use to find what meshes are not impacted by the light.
  77106. * Inactive if 0
  77107. */
  77108. excludeWithLayerMask: number;
  77109. private _includeOnlyWithLayerMask;
  77110. /**
  77111. * Gets the layer id use to find what meshes are impacted by the light.
  77112. * Inactive if 0
  77113. */
  77114. /**
  77115. * Sets the layer id use to find what meshes are impacted by the light.
  77116. * Inactive if 0
  77117. */
  77118. includeOnlyWithLayerMask: number;
  77119. private _lightmapMode;
  77120. /**
  77121. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77122. */
  77123. /**
  77124. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77125. */
  77126. lightmapMode: number;
  77127. /**
  77128. * Shadow generator associted to the light.
  77129. * @hidden Internal use only.
  77130. */
  77131. _shadowGenerator: Nullable<IShadowGenerator>;
  77132. /**
  77133. * @hidden Internal use only.
  77134. */
  77135. _excludedMeshesIds: string[];
  77136. /**
  77137. * @hidden Internal use only.
  77138. */
  77139. _includedOnlyMeshesIds: string[];
  77140. /**
  77141. * The current light unifom buffer.
  77142. * @hidden Internal use only.
  77143. */
  77144. _uniformBuffer: UniformBuffer;
  77145. /**
  77146. * Creates a Light object in the scene.
  77147. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77148. * @param name The firendly name of the light
  77149. * @param scene The scene the light belongs too
  77150. */
  77151. constructor(name: string, scene: Scene);
  77152. protected abstract _buildUniformLayout(): void;
  77153. /**
  77154. * Sets the passed Effect "effect" with the Light information.
  77155. * @param effect The effect to update
  77156. * @param lightIndex The index of the light in the effect to update
  77157. * @returns The light
  77158. */
  77159. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77160. /**
  77161. * Sets the passed Effect "effect" with the Light information.
  77162. * @param effect The effect to update
  77163. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77164. * @returns The light
  77165. */
  77166. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77167. /**
  77168. * Returns the string "Light".
  77169. * @returns the class name
  77170. */
  77171. getClassName(): string;
  77172. /** @hidden */
  77173. readonly _isLight: boolean;
  77174. /**
  77175. * Converts the light information to a readable string for debug purpose.
  77176. * @param fullDetails Supports for multiple levels of logging within scene loading
  77177. * @returns the human readable light info
  77178. */
  77179. toString(fullDetails?: boolean): string;
  77180. /** @hidden */
  77181. protected _syncParentEnabledState(): void;
  77182. /**
  77183. * Set the enabled state of this node.
  77184. * @param value - the new enabled state
  77185. */
  77186. setEnabled(value: boolean): void;
  77187. /**
  77188. * Returns the Light associated shadow generator if any.
  77189. * @return the associated shadow generator.
  77190. */
  77191. getShadowGenerator(): Nullable<IShadowGenerator>;
  77192. /**
  77193. * Returns a Vector3, the absolute light position in the World.
  77194. * @returns the world space position of the light
  77195. */
  77196. getAbsolutePosition(): Vector3;
  77197. /**
  77198. * Specifies if the light will affect the passed mesh.
  77199. * @param mesh The mesh to test against the light
  77200. * @return true the mesh is affected otherwise, false.
  77201. */
  77202. canAffectMesh(mesh: AbstractMesh): boolean;
  77203. /**
  77204. * Sort function to order lights for rendering.
  77205. * @param a First Light object to compare to second.
  77206. * @param b Second Light object to compare first.
  77207. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77208. */
  77209. static CompareLightsPriority(a: Light, b: Light): number;
  77210. /**
  77211. * Releases resources associated with this node.
  77212. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77213. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77214. */
  77215. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77216. /**
  77217. * Returns the light type ID (integer).
  77218. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77219. */
  77220. getTypeID(): number;
  77221. /**
  77222. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77223. * @returns the scaled intensity in intensity mode unit
  77224. */
  77225. getScaledIntensity(): number;
  77226. /**
  77227. * Returns a new Light object, named "name", from the current one.
  77228. * @param name The name of the cloned light
  77229. * @returns the new created light
  77230. */
  77231. clone(name: string): Nullable<Light>;
  77232. /**
  77233. * Serializes the current light into a Serialization object.
  77234. * @returns the serialized object.
  77235. */
  77236. serialize(): any;
  77237. /**
  77238. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77239. * This new light is named "name" and added to the passed scene.
  77240. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77241. * @param name The friendly name of the light
  77242. * @param scene The scene the new light will belong to
  77243. * @returns the constructor function
  77244. */
  77245. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77246. /**
  77247. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77248. * @param parsedLight The JSON representation of the light
  77249. * @param scene The scene to create the parsed light in
  77250. * @returns the created light after parsing
  77251. */
  77252. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77253. private _hookArrayForExcluded;
  77254. private _hookArrayForIncludedOnly;
  77255. private _resyncMeshes;
  77256. /**
  77257. * Forces the meshes to update their light related information in their rendering used effects
  77258. * @hidden Internal Use Only
  77259. */
  77260. _markMeshesAsLightDirty(): void;
  77261. /**
  77262. * Recomputes the cached photometric scale if needed.
  77263. */
  77264. private _computePhotometricScale;
  77265. /**
  77266. * Returns the Photometric Scale according to the light type and intensity mode.
  77267. */
  77268. private _getPhotometricScale;
  77269. /**
  77270. * Reorder the light in the scene according to their defined priority.
  77271. * @hidden Internal Use Only
  77272. */
  77273. _reorderLightsInScene(): void;
  77274. /**
  77275. * Prepares the list of defines specific to the light type.
  77276. * @param defines the list of defines
  77277. * @param lightIndex defines the index of the light for the effect
  77278. */
  77279. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77280. }
  77281. }
  77282. declare module BABYLON {
  77283. /**
  77284. * Interface used to define Action
  77285. */
  77286. export interface IAction {
  77287. /**
  77288. * Trigger for the action
  77289. */
  77290. trigger: number;
  77291. /** Options of the trigger */
  77292. triggerOptions: any;
  77293. /**
  77294. * Gets the trigger parameters
  77295. * @returns the trigger parameters
  77296. */
  77297. getTriggerParameter(): any;
  77298. /**
  77299. * Internal only - executes current action event
  77300. * @hidden
  77301. */
  77302. _executeCurrent(evt?: ActionEvent): void;
  77303. /**
  77304. * Serialize placeholder for child classes
  77305. * @param parent of child
  77306. * @returns the serialized object
  77307. */
  77308. serialize(parent: any): any;
  77309. /**
  77310. * Internal only
  77311. * @hidden
  77312. */
  77313. _prepare(): void;
  77314. /**
  77315. * Internal only - manager for action
  77316. * @hidden
  77317. */
  77318. _actionManager: AbstractActionManager;
  77319. /**
  77320. * Adds action to chain of actions, may be a DoNothingAction
  77321. * @param action defines the next action to execute
  77322. * @returns The action passed in
  77323. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77324. */
  77325. then(action: IAction): IAction;
  77326. }
  77327. /**
  77328. * The action to be carried out following a trigger
  77329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77330. */
  77331. export class Action implements IAction {
  77332. /** the trigger, with or without parameters, for the action */
  77333. triggerOptions: any;
  77334. /**
  77335. * Trigger for the action
  77336. */
  77337. trigger: number;
  77338. /**
  77339. * Internal only - manager for action
  77340. * @hidden
  77341. */
  77342. _actionManager: ActionManager;
  77343. private _nextActiveAction;
  77344. private _child;
  77345. private _condition?;
  77346. private _triggerParameter;
  77347. /**
  77348. * An event triggered prior to action being executed.
  77349. */
  77350. onBeforeExecuteObservable: Observable<Action>;
  77351. /**
  77352. * Creates a new Action
  77353. * @param triggerOptions the trigger, with or without parameters, for the action
  77354. * @param condition an optional determinant of action
  77355. */
  77356. constructor(
  77357. /** the trigger, with or without parameters, for the action */
  77358. triggerOptions: any, condition?: Condition);
  77359. /**
  77360. * Internal only
  77361. * @hidden
  77362. */
  77363. _prepare(): void;
  77364. /**
  77365. * Gets the trigger parameters
  77366. * @returns the trigger parameters
  77367. */
  77368. getTriggerParameter(): any;
  77369. /**
  77370. * Internal only - executes current action event
  77371. * @hidden
  77372. */
  77373. _executeCurrent(evt?: ActionEvent): void;
  77374. /**
  77375. * Execute placeholder for child classes
  77376. * @param evt optional action event
  77377. */
  77378. execute(evt?: ActionEvent): void;
  77379. /**
  77380. * Skips to next active action
  77381. */
  77382. skipToNextActiveAction(): void;
  77383. /**
  77384. * Adds action to chain of actions, may be a DoNothingAction
  77385. * @param action defines the next action to execute
  77386. * @returns The action passed in
  77387. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77388. */
  77389. then(action: Action): Action;
  77390. /**
  77391. * Internal only
  77392. * @hidden
  77393. */
  77394. _getProperty(propertyPath: string): string;
  77395. /**
  77396. * Internal only
  77397. * @hidden
  77398. */
  77399. _getEffectiveTarget(target: any, propertyPath: string): any;
  77400. /**
  77401. * Serialize placeholder for child classes
  77402. * @param parent of child
  77403. * @returns the serialized object
  77404. */
  77405. serialize(parent: any): any;
  77406. /**
  77407. * Internal only called by serialize
  77408. * @hidden
  77409. */
  77410. protected _serialize(serializedAction: any, parent?: any): any;
  77411. /**
  77412. * Internal only
  77413. * @hidden
  77414. */
  77415. static _SerializeValueAsString: (value: any) => string;
  77416. /**
  77417. * Internal only
  77418. * @hidden
  77419. */
  77420. static _GetTargetProperty: (target: Node | Scene) => {
  77421. name: string;
  77422. targetType: string;
  77423. value: string;
  77424. };
  77425. }
  77426. }
  77427. declare module BABYLON {
  77428. /**
  77429. * A Condition applied to an Action
  77430. */
  77431. export class Condition {
  77432. /**
  77433. * Internal only - manager for action
  77434. * @hidden
  77435. */
  77436. _actionManager: ActionManager;
  77437. /**
  77438. * Internal only
  77439. * @hidden
  77440. */
  77441. _evaluationId: number;
  77442. /**
  77443. * Internal only
  77444. * @hidden
  77445. */
  77446. _currentResult: boolean;
  77447. /**
  77448. * Creates a new Condition
  77449. * @param actionManager the manager of the action the condition is applied to
  77450. */
  77451. constructor(actionManager: ActionManager);
  77452. /**
  77453. * Check if the current condition is valid
  77454. * @returns a boolean
  77455. */
  77456. isValid(): boolean;
  77457. /**
  77458. * Internal only
  77459. * @hidden
  77460. */
  77461. _getProperty(propertyPath: string): string;
  77462. /**
  77463. * Internal only
  77464. * @hidden
  77465. */
  77466. _getEffectiveTarget(target: any, propertyPath: string): any;
  77467. /**
  77468. * Serialize placeholder for child classes
  77469. * @returns the serialized object
  77470. */
  77471. serialize(): any;
  77472. /**
  77473. * Internal only
  77474. * @hidden
  77475. */
  77476. protected _serialize(serializedCondition: any): any;
  77477. }
  77478. /**
  77479. * Defines specific conditional operators as extensions of Condition
  77480. */
  77481. export class ValueCondition extends Condition {
  77482. /** path to specify the property of the target the conditional operator uses */
  77483. propertyPath: string;
  77484. /** the value compared by the conditional operator against the current value of the property */
  77485. value: any;
  77486. /** the conditional operator, default ValueCondition.IsEqual */
  77487. operator: number;
  77488. /**
  77489. * Internal only
  77490. * @hidden
  77491. */
  77492. private static _IsEqual;
  77493. /**
  77494. * Internal only
  77495. * @hidden
  77496. */
  77497. private static _IsDifferent;
  77498. /**
  77499. * Internal only
  77500. * @hidden
  77501. */
  77502. private static _IsGreater;
  77503. /**
  77504. * Internal only
  77505. * @hidden
  77506. */
  77507. private static _IsLesser;
  77508. /**
  77509. * returns the number for IsEqual
  77510. */
  77511. static readonly IsEqual: number;
  77512. /**
  77513. * Returns the number for IsDifferent
  77514. */
  77515. static readonly IsDifferent: number;
  77516. /**
  77517. * Returns the number for IsGreater
  77518. */
  77519. static readonly IsGreater: number;
  77520. /**
  77521. * Returns the number for IsLesser
  77522. */
  77523. static readonly IsLesser: number;
  77524. /**
  77525. * Internal only The action manager for the condition
  77526. * @hidden
  77527. */
  77528. _actionManager: ActionManager;
  77529. /**
  77530. * Internal only
  77531. * @hidden
  77532. */
  77533. private _target;
  77534. /**
  77535. * Internal only
  77536. * @hidden
  77537. */
  77538. private _effectiveTarget;
  77539. /**
  77540. * Internal only
  77541. * @hidden
  77542. */
  77543. private _property;
  77544. /**
  77545. * Creates a new ValueCondition
  77546. * @param actionManager manager for the action the condition applies to
  77547. * @param target for the action
  77548. * @param propertyPath path to specify the property of the target the conditional operator uses
  77549. * @param value the value compared by the conditional operator against the current value of the property
  77550. * @param operator the conditional operator, default ValueCondition.IsEqual
  77551. */
  77552. constructor(actionManager: ActionManager, target: any,
  77553. /** path to specify the property of the target the conditional operator uses */
  77554. propertyPath: string,
  77555. /** the value compared by the conditional operator against the current value of the property */
  77556. value: any,
  77557. /** the conditional operator, default ValueCondition.IsEqual */
  77558. operator?: number);
  77559. /**
  77560. * Compares the given value with the property value for the specified conditional operator
  77561. * @returns the result of the comparison
  77562. */
  77563. isValid(): boolean;
  77564. /**
  77565. * Serialize the ValueCondition into a JSON compatible object
  77566. * @returns serialization object
  77567. */
  77568. serialize(): any;
  77569. /**
  77570. * Gets the name of the conditional operator for the ValueCondition
  77571. * @param operator the conditional operator
  77572. * @returns the name
  77573. */
  77574. static GetOperatorName(operator: number): string;
  77575. }
  77576. /**
  77577. * Defines a predicate condition as an extension of Condition
  77578. */
  77579. export class PredicateCondition extends Condition {
  77580. /** defines the predicate function used to validate the condition */
  77581. predicate: () => boolean;
  77582. /**
  77583. * Internal only - manager for action
  77584. * @hidden
  77585. */
  77586. _actionManager: ActionManager;
  77587. /**
  77588. * Creates a new PredicateCondition
  77589. * @param actionManager manager for the action the condition applies to
  77590. * @param predicate defines the predicate function used to validate the condition
  77591. */
  77592. constructor(actionManager: ActionManager,
  77593. /** defines the predicate function used to validate the condition */
  77594. predicate: () => boolean);
  77595. /**
  77596. * @returns the validity of the predicate condition
  77597. */
  77598. isValid(): boolean;
  77599. }
  77600. /**
  77601. * Defines a state condition as an extension of Condition
  77602. */
  77603. export class StateCondition extends Condition {
  77604. /** Value to compare with target state */
  77605. value: string;
  77606. /**
  77607. * Internal only - manager for action
  77608. * @hidden
  77609. */
  77610. _actionManager: ActionManager;
  77611. /**
  77612. * Internal only
  77613. * @hidden
  77614. */
  77615. private _target;
  77616. /**
  77617. * Creates a new StateCondition
  77618. * @param actionManager manager for the action the condition applies to
  77619. * @param target of the condition
  77620. * @param value to compare with target state
  77621. */
  77622. constructor(actionManager: ActionManager, target: any,
  77623. /** Value to compare with target state */
  77624. value: string);
  77625. /**
  77626. * Gets a boolean indicating if the current condition is met
  77627. * @returns the validity of the state
  77628. */
  77629. isValid(): boolean;
  77630. /**
  77631. * Serialize the StateCondition into a JSON compatible object
  77632. * @returns serialization object
  77633. */
  77634. serialize(): any;
  77635. }
  77636. }
  77637. declare module BABYLON {
  77638. /**
  77639. * This defines an action responsible to toggle a boolean once triggered.
  77640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77641. */
  77642. export class SwitchBooleanAction extends Action {
  77643. /**
  77644. * The path to the boolean property in the target object
  77645. */
  77646. propertyPath: string;
  77647. private _target;
  77648. private _effectiveTarget;
  77649. private _property;
  77650. /**
  77651. * Instantiate the action
  77652. * @param triggerOptions defines the trigger options
  77653. * @param target defines the object containing the boolean
  77654. * @param propertyPath defines the path to the boolean property in the target object
  77655. * @param condition defines the trigger related conditions
  77656. */
  77657. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77658. /** @hidden */
  77659. _prepare(): void;
  77660. /**
  77661. * Execute the action toggle the boolean value.
  77662. */
  77663. execute(): void;
  77664. /**
  77665. * Serializes the actions and its related information.
  77666. * @param parent defines the object to serialize in
  77667. * @returns the serialized object
  77668. */
  77669. serialize(parent: any): any;
  77670. }
  77671. /**
  77672. * This defines an action responsible to set a the state field of the target
  77673. * to a desired value once triggered.
  77674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77675. */
  77676. export class SetStateAction extends Action {
  77677. /**
  77678. * The value to store in the state field.
  77679. */
  77680. value: string;
  77681. private _target;
  77682. /**
  77683. * Instantiate the action
  77684. * @param triggerOptions defines the trigger options
  77685. * @param target defines the object containing the state property
  77686. * @param value defines the value to store in the state field
  77687. * @param condition defines the trigger related conditions
  77688. */
  77689. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77690. /**
  77691. * Execute the action and store the value on the target state property.
  77692. */
  77693. execute(): void;
  77694. /**
  77695. * Serializes the actions and its related information.
  77696. * @param parent defines the object to serialize in
  77697. * @returns the serialized object
  77698. */
  77699. serialize(parent: any): any;
  77700. }
  77701. /**
  77702. * This defines an action responsible to set a property of the target
  77703. * to a desired value once triggered.
  77704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77705. */
  77706. export class SetValueAction extends Action {
  77707. /**
  77708. * The path of the property to set in the target.
  77709. */
  77710. propertyPath: string;
  77711. /**
  77712. * The value to set in the property
  77713. */
  77714. value: any;
  77715. private _target;
  77716. private _effectiveTarget;
  77717. private _property;
  77718. /**
  77719. * Instantiate the action
  77720. * @param triggerOptions defines the trigger options
  77721. * @param target defines the object containing the property
  77722. * @param propertyPath defines the path of the property to set in the target
  77723. * @param value defines the value to set in the property
  77724. * @param condition defines the trigger related conditions
  77725. */
  77726. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77727. /** @hidden */
  77728. _prepare(): void;
  77729. /**
  77730. * Execute the action and set the targetted property to the desired value.
  77731. */
  77732. execute(): void;
  77733. /**
  77734. * Serializes the actions and its related information.
  77735. * @param parent defines the object to serialize in
  77736. * @returns the serialized object
  77737. */
  77738. serialize(parent: any): any;
  77739. }
  77740. /**
  77741. * This defines an action responsible to increment the target value
  77742. * to a desired value once triggered.
  77743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77744. */
  77745. export class IncrementValueAction extends Action {
  77746. /**
  77747. * The path of the property to increment in the target.
  77748. */
  77749. propertyPath: string;
  77750. /**
  77751. * The value we should increment the property by.
  77752. */
  77753. value: any;
  77754. private _target;
  77755. private _effectiveTarget;
  77756. private _property;
  77757. /**
  77758. * Instantiate the action
  77759. * @param triggerOptions defines the trigger options
  77760. * @param target defines the object containing the property
  77761. * @param propertyPath defines the path of the property to increment in the target
  77762. * @param value defines the value value we should increment the property by
  77763. * @param condition defines the trigger related conditions
  77764. */
  77765. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77766. /** @hidden */
  77767. _prepare(): void;
  77768. /**
  77769. * Execute the action and increment the target of the value amount.
  77770. */
  77771. execute(): void;
  77772. /**
  77773. * Serializes the actions and its related information.
  77774. * @param parent defines the object to serialize in
  77775. * @returns the serialized object
  77776. */
  77777. serialize(parent: any): any;
  77778. }
  77779. /**
  77780. * This defines an action responsible to start an animation once triggered.
  77781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77782. */
  77783. export class PlayAnimationAction extends Action {
  77784. /**
  77785. * Where the animation should start (animation frame)
  77786. */
  77787. from: number;
  77788. /**
  77789. * Where the animation should stop (animation frame)
  77790. */
  77791. to: number;
  77792. /**
  77793. * Define if the animation should loop or stop after the first play.
  77794. */
  77795. loop?: boolean;
  77796. private _target;
  77797. /**
  77798. * Instantiate the action
  77799. * @param triggerOptions defines the trigger options
  77800. * @param target defines the target animation or animation name
  77801. * @param from defines from where the animation should start (animation frame)
  77802. * @param end defines where the animation should stop (animation frame)
  77803. * @param loop defines if the animation should loop or stop after the first play
  77804. * @param condition defines the trigger related conditions
  77805. */
  77806. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77807. /** @hidden */
  77808. _prepare(): void;
  77809. /**
  77810. * Execute the action and play the animation.
  77811. */
  77812. execute(): void;
  77813. /**
  77814. * Serializes the actions and its related information.
  77815. * @param parent defines the object to serialize in
  77816. * @returns the serialized object
  77817. */
  77818. serialize(parent: any): any;
  77819. }
  77820. /**
  77821. * This defines an action responsible to stop an animation once triggered.
  77822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77823. */
  77824. export class StopAnimationAction extends Action {
  77825. private _target;
  77826. /**
  77827. * Instantiate the action
  77828. * @param triggerOptions defines the trigger options
  77829. * @param target defines the target animation or animation name
  77830. * @param condition defines the trigger related conditions
  77831. */
  77832. constructor(triggerOptions: any, target: any, condition?: Condition);
  77833. /** @hidden */
  77834. _prepare(): void;
  77835. /**
  77836. * Execute the action and stop the animation.
  77837. */
  77838. execute(): void;
  77839. /**
  77840. * Serializes the actions and its related information.
  77841. * @param parent defines the object to serialize in
  77842. * @returns the serialized object
  77843. */
  77844. serialize(parent: any): any;
  77845. }
  77846. /**
  77847. * This defines an action responsible that does nothing once triggered.
  77848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77849. */
  77850. export class DoNothingAction extends Action {
  77851. /**
  77852. * Instantiate the action
  77853. * @param triggerOptions defines the trigger options
  77854. * @param condition defines the trigger related conditions
  77855. */
  77856. constructor(triggerOptions?: any, condition?: Condition);
  77857. /**
  77858. * Execute the action and do nothing.
  77859. */
  77860. execute(): void;
  77861. /**
  77862. * Serializes the actions and its related information.
  77863. * @param parent defines the object to serialize in
  77864. * @returns the serialized object
  77865. */
  77866. serialize(parent: any): any;
  77867. }
  77868. /**
  77869. * This defines an action responsible to trigger several actions once triggered.
  77870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77871. */
  77872. export class CombineAction extends Action {
  77873. /**
  77874. * The list of aggregated animations to run.
  77875. */
  77876. children: Action[];
  77877. /**
  77878. * Instantiate the action
  77879. * @param triggerOptions defines the trigger options
  77880. * @param children defines the list of aggregated animations to run
  77881. * @param condition defines the trigger related conditions
  77882. */
  77883. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77884. /** @hidden */
  77885. _prepare(): void;
  77886. /**
  77887. * Execute the action and executes all the aggregated actions.
  77888. */
  77889. execute(evt: ActionEvent): void;
  77890. /**
  77891. * Serializes the actions and its related information.
  77892. * @param parent defines the object to serialize in
  77893. * @returns the serialized object
  77894. */
  77895. serialize(parent: any): any;
  77896. }
  77897. /**
  77898. * This defines an action responsible to run code (external event) once triggered.
  77899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77900. */
  77901. export class ExecuteCodeAction extends Action {
  77902. /**
  77903. * The callback function to run.
  77904. */
  77905. func: (evt: ActionEvent) => void;
  77906. /**
  77907. * Instantiate the action
  77908. * @param triggerOptions defines the trigger options
  77909. * @param func defines the callback function to run
  77910. * @param condition defines the trigger related conditions
  77911. */
  77912. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77913. /**
  77914. * Execute the action and run the attached code.
  77915. */
  77916. execute(evt: ActionEvent): void;
  77917. }
  77918. /**
  77919. * This defines an action responsible to set the parent property of the target once triggered.
  77920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77921. */
  77922. export class SetParentAction extends Action {
  77923. private _parent;
  77924. private _target;
  77925. /**
  77926. * Instantiate the action
  77927. * @param triggerOptions defines the trigger options
  77928. * @param target defines the target containing the parent property
  77929. * @param parent defines from where the animation should start (animation frame)
  77930. * @param condition defines the trigger related conditions
  77931. */
  77932. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77933. /** @hidden */
  77934. _prepare(): void;
  77935. /**
  77936. * Execute the action and set the parent property.
  77937. */
  77938. execute(): void;
  77939. /**
  77940. * Serializes the actions and its related information.
  77941. * @param parent defines the object to serialize in
  77942. * @returns the serialized object
  77943. */
  77944. serialize(parent: any): any;
  77945. }
  77946. }
  77947. declare module BABYLON {
  77948. /**
  77949. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77950. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77952. */
  77953. export class ActionManager extends AbstractActionManager {
  77954. /**
  77955. * Nothing
  77956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77957. */
  77958. static readonly NothingTrigger: number;
  77959. /**
  77960. * On pick
  77961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77962. */
  77963. static readonly OnPickTrigger: number;
  77964. /**
  77965. * On left pick
  77966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77967. */
  77968. static readonly OnLeftPickTrigger: number;
  77969. /**
  77970. * On right pick
  77971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77972. */
  77973. static readonly OnRightPickTrigger: number;
  77974. /**
  77975. * On center pick
  77976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77977. */
  77978. static readonly OnCenterPickTrigger: number;
  77979. /**
  77980. * On pick down
  77981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77982. */
  77983. static readonly OnPickDownTrigger: number;
  77984. /**
  77985. * On double pick
  77986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77987. */
  77988. static readonly OnDoublePickTrigger: number;
  77989. /**
  77990. * On pick up
  77991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77992. */
  77993. static readonly OnPickUpTrigger: number;
  77994. /**
  77995. * On pick out.
  77996. * This trigger will only be raised if you also declared a OnPickDown
  77997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77998. */
  77999. static readonly OnPickOutTrigger: number;
  78000. /**
  78001. * On long press
  78002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78003. */
  78004. static readonly OnLongPressTrigger: number;
  78005. /**
  78006. * On pointer over
  78007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78008. */
  78009. static readonly OnPointerOverTrigger: number;
  78010. /**
  78011. * On pointer out
  78012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78013. */
  78014. static readonly OnPointerOutTrigger: number;
  78015. /**
  78016. * On every frame
  78017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78018. */
  78019. static readonly OnEveryFrameTrigger: number;
  78020. /**
  78021. * On intersection enter
  78022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78023. */
  78024. static readonly OnIntersectionEnterTrigger: number;
  78025. /**
  78026. * On intersection exit
  78027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78028. */
  78029. static readonly OnIntersectionExitTrigger: number;
  78030. /**
  78031. * On key down
  78032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78033. */
  78034. static readonly OnKeyDownTrigger: number;
  78035. /**
  78036. * On key up
  78037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78038. */
  78039. static readonly OnKeyUpTrigger: number;
  78040. private _scene;
  78041. /**
  78042. * Creates a new action manager
  78043. * @param scene defines the hosting scene
  78044. */
  78045. constructor(scene: Scene);
  78046. /**
  78047. * Releases all associated resources
  78048. */
  78049. dispose(): void;
  78050. /**
  78051. * Gets hosting scene
  78052. * @returns the hosting scene
  78053. */
  78054. getScene(): Scene;
  78055. /**
  78056. * Does this action manager handles actions of any of the given triggers
  78057. * @param triggers defines the triggers to be tested
  78058. * @return a boolean indicating whether one (or more) of the triggers is handled
  78059. */
  78060. hasSpecificTriggers(triggers: number[]): boolean;
  78061. /**
  78062. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78063. * speed.
  78064. * @param triggerA defines the trigger to be tested
  78065. * @param triggerB defines the trigger to be tested
  78066. * @return a boolean indicating whether one (or more) of the triggers is handled
  78067. */
  78068. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78069. /**
  78070. * Does this action manager handles actions of a given trigger
  78071. * @param trigger defines the trigger to be tested
  78072. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78073. * @return whether the trigger is handled
  78074. */
  78075. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78076. /**
  78077. * Does this action manager has pointer triggers
  78078. */
  78079. readonly hasPointerTriggers: boolean;
  78080. /**
  78081. * Does this action manager has pick triggers
  78082. */
  78083. readonly hasPickTriggers: boolean;
  78084. /**
  78085. * Registers an action to this action manager
  78086. * @param action defines the action to be registered
  78087. * @return the action amended (prepared) after registration
  78088. */
  78089. registerAction(action: IAction): Nullable<IAction>;
  78090. /**
  78091. * Unregisters an action to this action manager
  78092. * @param action defines the action to be unregistered
  78093. * @return a boolean indicating whether the action has been unregistered
  78094. */
  78095. unregisterAction(action: IAction): Boolean;
  78096. /**
  78097. * Process a specific trigger
  78098. * @param trigger defines the trigger to process
  78099. * @param evt defines the event details to be processed
  78100. */
  78101. processTrigger(trigger: number, evt?: IActionEvent): void;
  78102. /** @hidden */
  78103. _getEffectiveTarget(target: any, propertyPath: string): any;
  78104. /** @hidden */
  78105. _getProperty(propertyPath: string): string;
  78106. /**
  78107. * Serialize this manager to a JSON object
  78108. * @param name defines the property name to store this manager
  78109. * @returns a JSON representation of this manager
  78110. */
  78111. serialize(name: string): any;
  78112. /**
  78113. * Creates a new ActionManager from a JSON data
  78114. * @param parsedActions defines the JSON data to read from
  78115. * @param object defines the hosting mesh
  78116. * @param scene defines the hosting scene
  78117. */
  78118. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78119. /**
  78120. * Get a trigger name by index
  78121. * @param trigger defines the trigger index
  78122. * @returns a trigger name
  78123. */
  78124. static GetTriggerName(trigger: number): string;
  78125. }
  78126. }
  78127. declare module BABYLON {
  78128. /**
  78129. * Class representing a ray with position and direction
  78130. */
  78131. export class Ray {
  78132. /** origin point */
  78133. origin: Vector3;
  78134. /** direction */
  78135. direction: Vector3;
  78136. /** length of the ray */
  78137. length: number;
  78138. private static readonly TmpVector3;
  78139. private _tmpRay;
  78140. /**
  78141. * Creates a new ray
  78142. * @param origin origin point
  78143. * @param direction direction
  78144. * @param length length of the ray
  78145. */
  78146. constructor(
  78147. /** origin point */
  78148. origin: Vector3,
  78149. /** direction */
  78150. direction: Vector3,
  78151. /** length of the ray */
  78152. length?: number);
  78153. /**
  78154. * Checks if the ray intersects a box
  78155. * @param minimum bound of the box
  78156. * @param maximum bound of the box
  78157. * @param intersectionTreshold extra extend to be added to the box in all direction
  78158. * @returns if the box was hit
  78159. */
  78160. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78161. /**
  78162. * Checks if the ray intersects a box
  78163. * @param box the bounding box to check
  78164. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78165. * @returns if the box was hit
  78166. */
  78167. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78168. /**
  78169. * If the ray hits a sphere
  78170. * @param sphere the bounding sphere to check
  78171. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78172. * @returns true if it hits the sphere
  78173. */
  78174. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78175. /**
  78176. * If the ray hits a triange
  78177. * @param vertex0 triangle vertex
  78178. * @param vertex1 triangle vertex
  78179. * @param vertex2 triangle vertex
  78180. * @returns intersection information if hit
  78181. */
  78182. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78183. /**
  78184. * Checks if ray intersects a plane
  78185. * @param plane the plane to check
  78186. * @returns the distance away it was hit
  78187. */
  78188. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78189. /**
  78190. * Calculate the intercept of a ray on a given axis
  78191. * @param axis to check 'x' | 'y' | 'z'
  78192. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78193. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78194. */
  78195. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78196. /**
  78197. * Checks if ray intersects a mesh
  78198. * @param mesh the mesh to check
  78199. * @param fastCheck if only the bounding box should checked
  78200. * @returns picking info of the intersecton
  78201. */
  78202. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78203. /**
  78204. * Checks if ray intersects a mesh
  78205. * @param meshes the meshes to check
  78206. * @param fastCheck if only the bounding box should checked
  78207. * @param results array to store result in
  78208. * @returns Array of picking infos
  78209. */
  78210. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78211. private _comparePickingInfo;
  78212. private static smallnum;
  78213. private static rayl;
  78214. /**
  78215. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78216. * @param sega the first point of the segment to test the intersection against
  78217. * @param segb the second point of the segment to test the intersection against
  78218. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78219. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78220. */
  78221. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78222. /**
  78223. * Update the ray from viewport position
  78224. * @param x position
  78225. * @param y y position
  78226. * @param viewportWidth viewport width
  78227. * @param viewportHeight viewport height
  78228. * @param world world matrix
  78229. * @param view view matrix
  78230. * @param projection projection matrix
  78231. * @returns this ray updated
  78232. */
  78233. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78234. /**
  78235. * Creates a ray with origin and direction of 0,0,0
  78236. * @returns the new ray
  78237. */
  78238. static Zero(): Ray;
  78239. /**
  78240. * Creates a new ray from screen space and viewport
  78241. * @param x position
  78242. * @param y y position
  78243. * @param viewportWidth viewport width
  78244. * @param viewportHeight viewport height
  78245. * @param world world matrix
  78246. * @param view view matrix
  78247. * @param projection projection matrix
  78248. * @returns new ray
  78249. */
  78250. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78251. /**
  78252. * 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
  78253. * transformed to the given world matrix.
  78254. * @param origin The origin point
  78255. * @param end The end point
  78256. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78257. * @returns the new ray
  78258. */
  78259. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78260. /**
  78261. * Transforms a ray by a matrix
  78262. * @param ray ray to transform
  78263. * @param matrix matrix to apply
  78264. * @returns the resulting new ray
  78265. */
  78266. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78267. /**
  78268. * Transforms a ray by a matrix
  78269. * @param ray ray to transform
  78270. * @param matrix matrix to apply
  78271. * @param result ray to store result in
  78272. */
  78273. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78274. /**
  78275. * Unproject a ray from screen space to object space
  78276. * @param sourceX defines the screen space x coordinate to use
  78277. * @param sourceY defines the screen space y coordinate to use
  78278. * @param viewportWidth defines the current width of the viewport
  78279. * @param viewportHeight defines the current height of the viewport
  78280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78281. * @param view defines the view matrix to use
  78282. * @param projection defines the projection matrix to use
  78283. */
  78284. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78285. }
  78286. /**
  78287. * Type used to define predicate used to select faces when a mesh intersection is detected
  78288. */
  78289. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78290. interface Scene {
  78291. /** @hidden */
  78292. _tempPickingRay: Nullable<Ray>;
  78293. /** @hidden */
  78294. _cachedRayForTransform: Ray;
  78295. /** @hidden */
  78296. _pickWithRayInverseMatrix: Matrix;
  78297. /** @hidden */
  78298. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78299. /** @hidden */
  78300. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78301. }
  78302. }
  78303. declare module BABYLON {
  78304. /**
  78305. * Groups all the scene component constants in one place to ease maintenance.
  78306. * @hidden
  78307. */
  78308. export class SceneComponentConstants {
  78309. static readonly NAME_EFFECTLAYER: string;
  78310. static readonly NAME_LAYER: string;
  78311. static readonly NAME_LENSFLARESYSTEM: string;
  78312. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78313. static readonly NAME_PARTICLESYSTEM: string;
  78314. static readonly NAME_GAMEPAD: string;
  78315. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78316. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78317. static readonly NAME_DEPTHRENDERER: string;
  78318. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78319. static readonly NAME_SPRITE: string;
  78320. static readonly NAME_OUTLINERENDERER: string;
  78321. static readonly NAME_PROCEDURALTEXTURE: string;
  78322. static readonly NAME_SHADOWGENERATOR: string;
  78323. static readonly NAME_OCTREE: string;
  78324. static readonly NAME_PHYSICSENGINE: string;
  78325. static readonly NAME_AUDIO: string;
  78326. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78327. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78328. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78329. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78330. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78331. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78332. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78333. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78334. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78335. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78336. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78337. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78338. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78339. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78340. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78341. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78342. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78343. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78344. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78345. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78346. static readonly STEP_AFTERRENDER_AUDIO: number;
  78347. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78348. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78349. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78350. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78351. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78352. static readonly STEP_POINTERMOVE_SPRITE: number;
  78353. static readonly STEP_POINTERDOWN_SPRITE: number;
  78354. static readonly STEP_POINTERUP_SPRITE: number;
  78355. }
  78356. /**
  78357. * This represents a scene component.
  78358. *
  78359. * This is used to decouple the dependency the scene is having on the different workloads like
  78360. * layers, post processes...
  78361. */
  78362. export interface ISceneComponent {
  78363. /**
  78364. * The name of the component. Each component must have a unique name.
  78365. */
  78366. name: string;
  78367. /**
  78368. * The scene the component belongs to.
  78369. */
  78370. scene: Scene;
  78371. /**
  78372. * Register the component to one instance of a scene.
  78373. */
  78374. register(): void;
  78375. /**
  78376. * Rebuilds the elements related to this component in case of
  78377. * context lost for instance.
  78378. */
  78379. rebuild(): void;
  78380. /**
  78381. * Disposes the component and the associated ressources.
  78382. */
  78383. dispose(): void;
  78384. }
  78385. /**
  78386. * This represents a SERIALIZABLE scene component.
  78387. *
  78388. * This extends Scene Component to add Serialization methods on top.
  78389. */
  78390. export interface ISceneSerializableComponent extends ISceneComponent {
  78391. /**
  78392. * Adds all the elements from the container to the scene
  78393. * @param container the container holding the elements
  78394. */
  78395. addFromContainer(container: AbstractScene): void;
  78396. /**
  78397. * Removes all the elements in the container from the scene
  78398. * @param container contains the elements to remove
  78399. * @param dispose if the removed element should be disposed (default: false)
  78400. */
  78401. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78402. /**
  78403. * Serializes the component data to the specified json object
  78404. * @param serializationObject The object to serialize to
  78405. */
  78406. serialize(serializationObject: any): void;
  78407. }
  78408. /**
  78409. * Strong typing of a Mesh related stage step action
  78410. */
  78411. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78412. /**
  78413. * Strong typing of a Evaluate Sub Mesh related stage step action
  78414. */
  78415. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78416. /**
  78417. * Strong typing of a Active Mesh related stage step action
  78418. */
  78419. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78420. /**
  78421. * Strong typing of a Camera related stage step action
  78422. */
  78423. export type CameraStageAction = (camera: Camera) => void;
  78424. /**
  78425. * Strong typing of a Camera Frame buffer related stage step action
  78426. */
  78427. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78428. /**
  78429. * Strong typing of a Render Target related stage step action
  78430. */
  78431. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78432. /**
  78433. * Strong typing of a RenderingGroup related stage step action
  78434. */
  78435. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78436. /**
  78437. * Strong typing of a Mesh Render related stage step action
  78438. */
  78439. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78440. /**
  78441. * Strong typing of a simple stage step action
  78442. */
  78443. export type SimpleStageAction = () => void;
  78444. /**
  78445. * Strong typing of a render target action.
  78446. */
  78447. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78448. /**
  78449. * Strong typing of a pointer move action.
  78450. */
  78451. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78452. /**
  78453. * Strong typing of a pointer up/down action.
  78454. */
  78455. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78456. /**
  78457. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78458. * @hidden
  78459. */
  78460. export class Stage<T extends Function> extends Array<{
  78461. index: number;
  78462. component: ISceneComponent;
  78463. action: T;
  78464. }> {
  78465. /**
  78466. * Hide ctor from the rest of the world.
  78467. * @param items The items to add.
  78468. */
  78469. private constructor();
  78470. /**
  78471. * Creates a new Stage.
  78472. * @returns A new instance of a Stage
  78473. */
  78474. static Create<T extends Function>(): Stage<T>;
  78475. /**
  78476. * Registers a step in an ordered way in the targeted stage.
  78477. * @param index Defines the position to register the step in
  78478. * @param component Defines the component attached to the step
  78479. * @param action Defines the action to launch during the step
  78480. */
  78481. registerStep(index: number, component: ISceneComponent, action: T): void;
  78482. /**
  78483. * Clears all the steps from the stage.
  78484. */
  78485. clear(): void;
  78486. }
  78487. }
  78488. declare module BABYLON {
  78489. interface Scene {
  78490. /** @hidden */
  78491. _pointerOverSprite: Nullable<Sprite>;
  78492. /** @hidden */
  78493. _pickedDownSprite: Nullable<Sprite>;
  78494. /** @hidden */
  78495. _tempSpritePickingRay: Nullable<Ray>;
  78496. /**
  78497. * All of the sprite managers added to this scene
  78498. * @see http://doc.babylonjs.com/babylon101/sprites
  78499. */
  78500. spriteManagers: Array<ISpriteManager>;
  78501. /**
  78502. * An event triggered when sprites rendering is about to start
  78503. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78504. */
  78505. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78506. /**
  78507. * An event triggered when sprites rendering is done
  78508. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78509. */
  78510. onAfterSpritesRenderingObservable: Observable<Scene>;
  78511. /** @hidden */
  78512. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78513. /** Launch a ray to try to pick a sprite in the scene
  78514. * @param x position on screen
  78515. * @param y position on screen
  78516. * @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
  78517. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78518. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78519. * @returns a PickingInfo
  78520. */
  78521. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78522. /** Use the given ray to pick a sprite in the scene
  78523. * @param ray The ray (in world space) to use to pick meshes
  78524. * @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
  78525. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78526. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78527. * @returns a PickingInfo
  78528. */
  78529. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78530. /** @hidden */
  78531. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78532. /** Launch a ray to try to pick sprites in the scene
  78533. * @param x position on screen
  78534. * @param y position on screen
  78535. * @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
  78536. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78537. * @returns a PickingInfo array
  78538. */
  78539. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78540. /** Use the given ray to pick sprites in the scene
  78541. * @param ray The ray (in world space) to use to pick meshes
  78542. * @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
  78543. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78544. * @returns a PickingInfo array
  78545. */
  78546. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78547. /**
  78548. * Force the sprite under the pointer
  78549. * @param sprite defines the sprite to use
  78550. */
  78551. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78552. /**
  78553. * Gets the sprite under the pointer
  78554. * @returns a Sprite or null if no sprite is under the pointer
  78555. */
  78556. getPointerOverSprite(): Nullable<Sprite>;
  78557. }
  78558. /**
  78559. * Defines the sprite scene component responsible to manage sprites
  78560. * in a given scene.
  78561. */
  78562. export class SpriteSceneComponent implements ISceneComponent {
  78563. /**
  78564. * The component name helpfull to identify the component in the list of scene components.
  78565. */
  78566. readonly name: string;
  78567. /**
  78568. * The scene the component belongs to.
  78569. */
  78570. scene: Scene;
  78571. /** @hidden */
  78572. private _spritePredicate;
  78573. /**
  78574. * Creates a new instance of the component for the given scene
  78575. * @param scene Defines the scene to register the component in
  78576. */
  78577. constructor(scene: Scene);
  78578. /**
  78579. * Registers the component in a given scene
  78580. */
  78581. register(): void;
  78582. /**
  78583. * Rebuilds the elements related to this component in case of
  78584. * context lost for instance.
  78585. */
  78586. rebuild(): void;
  78587. /**
  78588. * Disposes the component and the associated ressources.
  78589. */
  78590. dispose(): void;
  78591. private _pickSpriteButKeepRay;
  78592. private _pointerMove;
  78593. private _pointerDown;
  78594. private _pointerUp;
  78595. }
  78596. }
  78597. declare module BABYLON {
  78598. /** @hidden */
  78599. export var fogFragmentDeclaration: {
  78600. name: string;
  78601. shader: string;
  78602. };
  78603. }
  78604. declare module BABYLON {
  78605. /** @hidden */
  78606. export var fogFragment: {
  78607. name: string;
  78608. shader: string;
  78609. };
  78610. }
  78611. declare module BABYLON {
  78612. /** @hidden */
  78613. export var spritesPixelShader: {
  78614. name: string;
  78615. shader: string;
  78616. };
  78617. }
  78618. declare module BABYLON {
  78619. /** @hidden */
  78620. export var fogVertexDeclaration: {
  78621. name: string;
  78622. shader: string;
  78623. };
  78624. }
  78625. declare module BABYLON {
  78626. /** @hidden */
  78627. export var spritesVertexShader: {
  78628. name: string;
  78629. shader: string;
  78630. };
  78631. }
  78632. declare module BABYLON {
  78633. /**
  78634. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78635. */
  78636. export interface ISpriteManager extends IDisposable {
  78637. /**
  78638. * Restricts the camera to viewing objects with the same layerMask.
  78639. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78640. */
  78641. layerMask: number;
  78642. /**
  78643. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78644. */
  78645. isPickable: boolean;
  78646. /**
  78647. * Specifies the rendering group id for this mesh (0 by default)
  78648. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78649. */
  78650. renderingGroupId: number;
  78651. /**
  78652. * Defines the list of sprites managed by the manager.
  78653. */
  78654. sprites: Array<Sprite>;
  78655. /**
  78656. * Tests the intersection of a sprite with a specific ray.
  78657. * @param ray The ray we are sending to test the collision
  78658. * @param camera The camera space we are sending rays in
  78659. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78660. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78661. * @returns picking info or null.
  78662. */
  78663. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78664. /**
  78665. * Intersects the sprites with a ray
  78666. * @param ray defines the ray to intersect with
  78667. * @param camera defines the current active camera
  78668. * @param predicate defines a predicate used to select candidate sprites
  78669. * @returns null if no hit or a PickingInfo array
  78670. */
  78671. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78672. /**
  78673. * Renders the list of sprites on screen.
  78674. */
  78675. render(): void;
  78676. }
  78677. /**
  78678. * Class used to manage multiple sprites on the same spritesheet
  78679. * @see http://doc.babylonjs.com/babylon101/sprites
  78680. */
  78681. export class SpriteManager implements ISpriteManager {
  78682. /** defines the manager's name */
  78683. name: string;
  78684. /** Gets the list of sprites */
  78685. sprites: Sprite[];
  78686. /** Gets or sets the rendering group id (0 by default) */
  78687. renderingGroupId: number;
  78688. /** Gets or sets camera layer mask */
  78689. layerMask: number;
  78690. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78691. fogEnabled: boolean;
  78692. /** Gets or sets a boolean indicating if the sprites are pickable */
  78693. isPickable: boolean;
  78694. /** Defines the default width of a cell in the spritesheet */
  78695. cellWidth: number;
  78696. /** Defines the default height of a cell in the spritesheet */
  78697. cellHeight: number;
  78698. /** Associative array from JSON sprite data file */
  78699. private _cellData;
  78700. /** Array of sprite names from JSON sprite data file */
  78701. private _spriteMap;
  78702. /** True when packed cell data from JSON file is ready*/
  78703. private _packedAndReady;
  78704. /**
  78705. * An event triggered when the manager is disposed.
  78706. */
  78707. onDisposeObservable: Observable<SpriteManager>;
  78708. private _onDisposeObserver;
  78709. /**
  78710. * Callback called when the manager is disposed
  78711. */
  78712. onDispose: () => void;
  78713. private _capacity;
  78714. private _fromPacked;
  78715. private _spriteTexture;
  78716. private _epsilon;
  78717. private _scene;
  78718. private _vertexData;
  78719. private _buffer;
  78720. private _vertexBuffers;
  78721. private _indexBuffer;
  78722. private _effectBase;
  78723. private _effectFog;
  78724. /**
  78725. * Gets or sets the spritesheet texture
  78726. */
  78727. texture: Texture;
  78728. /**
  78729. * Creates a new sprite manager
  78730. * @param name defines the manager's name
  78731. * @param imgUrl defines the sprite sheet url
  78732. * @param capacity defines the maximum allowed number of sprites
  78733. * @param cellSize defines the size of a sprite cell
  78734. * @param scene defines the hosting scene
  78735. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78736. * @param samplingMode defines the smapling mode to use with spritesheet
  78737. * @param fromPacked set to false; do not alter
  78738. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78739. */
  78740. constructor(
  78741. /** defines the manager's name */
  78742. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78743. private _makePacked;
  78744. private _appendSpriteVertex;
  78745. /**
  78746. * Intersects the sprites with a ray
  78747. * @param ray defines the ray to intersect with
  78748. * @param camera defines the current active camera
  78749. * @param predicate defines a predicate used to select candidate sprites
  78750. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78751. * @returns null if no hit or a PickingInfo
  78752. */
  78753. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78754. /**
  78755. * Intersects the sprites with a ray
  78756. * @param ray defines the ray to intersect with
  78757. * @param camera defines the current active camera
  78758. * @param predicate defines a predicate used to select candidate sprites
  78759. * @returns null if no hit or a PickingInfo array
  78760. */
  78761. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78762. /**
  78763. * Render all child sprites
  78764. */
  78765. render(): void;
  78766. /**
  78767. * Release associated resources
  78768. */
  78769. dispose(): void;
  78770. }
  78771. }
  78772. declare module BABYLON {
  78773. /**
  78774. * Class used to represent a sprite
  78775. * @see http://doc.babylonjs.com/babylon101/sprites
  78776. */
  78777. export class Sprite {
  78778. /** defines the name */
  78779. name: string;
  78780. /** Gets or sets the current world position */
  78781. position: Vector3;
  78782. /** Gets or sets the main color */
  78783. color: Color4;
  78784. /** Gets or sets the width */
  78785. width: number;
  78786. /** Gets or sets the height */
  78787. height: number;
  78788. /** Gets or sets rotation angle */
  78789. angle: number;
  78790. /** Gets or sets the cell index in the sprite sheet */
  78791. cellIndex: number;
  78792. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78793. cellRef: string;
  78794. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78795. invertU: number;
  78796. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78797. invertV: number;
  78798. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78799. disposeWhenFinishedAnimating: boolean;
  78800. /** Gets the list of attached animations */
  78801. animations: Animation[];
  78802. /** Gets or sets a boolean indicating if the sprite can be picked */
  78803. isPickable: boolean;
  78804. /**
  78805. * Gets or sets the associated action manager
  78806. */
  78807. actionManager: Nullable<ActionManager>;
  78808. private _animationStarted;
  78809. private _loopAnimation;
  78810. private _fromIndex;
  78811. private _toIndex;
  78812. private _delay;
  78813. private _direction;
  78814. private _manager;
  78815. private _time;
  78816. private _onAnimationEnd;
  78817. /**
  78818. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78819. */
  78820. isVisible: boolean;
  78821. /**
  78822. * Gets or sets the sprite size
  78823. */
  78824. size: number;
  78825. /**
  78826. * Creates a new Sprite
  78827. * @param name defines the name
  78828. * @param manager defines the manager
  78829. */
  78830. constructor(
  78831. /** defines the name */
  78832. name: string, manager: ISpriteManager);
  78833. /**
  78834. * Starts an animation
  78835. * @param from defines the initial key
  78836. * @param to defines the end key
  78837. * @param loop defines if the animation must loop
  78838. * @param delay defines the start delay (in ms)
  78839. * @param onAnimationEnd defines a callback to call when animation ends
  78840. */
  78841. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78842. /** Stops current animation (if any) */
  78843. stopAnimation(): void;
  78844. /** @hidden */
  78845. _animate(deltaTime: number): void;
  78846. /** Release associated resources */
  78847. dispose(): void;
  78848. }
  78849. }
  78850. declare module BABYLON {
  78851. /**
  78852. * Information about the result of picking within a scene
  78853. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78854. */
  78855. export class PickingInfo {
  78856. /** @hidden */
  78857. _pickingUnavailable: boolean;
  78858. /**
  78859. * If the pick collided with an object
  78860. */
  78861. hit: boolean;
  78862. /**
  78863. * Distance away where the pick collided
  78864. */
  78865. distance: number;
  78866. /**
  78867. * The location of pick collision
  78868. */
  78869. pickedPoint: Nullable<Vector3>;
  78870. /**
  78871. * The mesh corresponding the the pick collision
  78872. */
  78873. pickedMesh: Nullable<AbstractMesh>;
  78874. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78875. bu: number;
  78876. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78877. bv: number;
  78878. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78879. faceId: number;
  78880. /** Id of the the submesh that was picked */
  78881. subMeshId: number;
  78882. /** If a sprite was picked, this will be the sprite the pick collided with */
  78883. pickedSprite: Nullable<Sprite>;
  78884. /**
  78885. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78886. */
  78887. originMesh: Nullable<AbstractMesh>;
  78888. /**
  78889. * The ray that was used to perform the picking.
  78890. */
  78891. ray: Nullable<Ray>;
  78892. /**
  78893. * Gets the normal correspodning to the face the pick collided with
  78894. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78895. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78896. * @returns The normal correspodning to the face the pick collided with
  78897. */
  78898. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78899. /**
  78900. * Gets the texture coordinates of where the pick occured
  78901. * @returns the vector containing the coordnates of the texture
  78902. */
  78903. getTextureCoordinates(): Nullable<Vector2>;
  78904. }
  78905. }
  78906. declare module BABYLON {
  78907. /**
  78908. * Gather the list of pointer event types as constants.
  78909. */
  78910. export class PointerEventTypes {
  78911. /**
  78912. * 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.
  78913. */
  78914. static readonly POINTERDOWN: number;
  78915. /**
  78916. * The pointerup event is fired when a pointer is no longer active.
  78917. */
  78918. static readonly POINTERUP: number;
  78919. /**
  78920. * The pointermove event is fired when a pointer changes coordinates.
  78921. */
  78922. static readonly POINTERMOVE: number;
  78923. /**
  78924. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78925. */
  78926. static readonly POINTERWHEEL: number;
  78927. /**
  78928. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78929. */
  78930. static readonly POINTERPICK: number;
  78931. /**
  78932. * The pointertap event is fired when a the object has been touched and released without drag.
  78933. */
  78934. static readonly POINTERTAP: number;
  78935. /**
  78936. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78937. */
  78938. static readonly POINTERDOUBLETAP: number;
  78939. }
  78940. /**
  78941. * Base class of pointer info types.
  78942. */
  78943. export class PointerInfoBase {
  78944. /**
  78945. * Defines the type of event (PointerEventTypes)
  78946. */
  78947. type: number;
  78948. /**
  78949. * Defines the related dom event
  78950. */
  78951. event: PointerEvent | MouseWheelEvent;
  78952. /**
  78953. * Instantiates the base class of pointers info.
  78954. * @param type Defines the type of event (PointerEventTypes)
  78955. * @param event Defines the related dom event
  78956. */
  78957. constructor(
  78958. /**
  78959. * Defines the type of event (PointerEventTypes)
  78960. */
  78961. type: number,
  78962. /**
  78963. * Defines the related dom event
  78964. */
  78965. event: PointerEvent | MouseWheelEvent);
  78966. }
  78967. /**
  78968. * This class is used to store pointer related info for the onPrePointerObservable event.
  78969. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78970. */
  78971. export class PointerInfoPre extends PointerInfoBase {
  78972. /**
  78973. * Ray from a pointer if availible (eg. 6dof controller)
  78974. */
  78975. ray: Nullable<Ray>;
  78976. /**
  78977. * Defines the local position of the pointer on the canvas.
  78978. */
  78979. localPosition: Vector2;
  78980. /**
  78981. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78982. */
  78983. skipOnPointerObservable: boolean;
  78984. /**
  78985. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78986. * @param type Defines the type of event (PointerEventTypes)
  78987. * @param event Defines the related dom event
  78988. * @param localX Defines the local x coordinates of the pointer when the event occured
  78989. * @param localY Defines the local y coordinates of the pointer when the event occured
  78990. */
  78991. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78992. }
  78993. /**
  78994. * This type contains all the data related to a pointer event in Babylon.js.
  78995. * 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.
  78996. */
  78997. export class PointerInfo extends PointerInfoBase {
  78998. /**
  78999. * Defines the picking info associated to the info (if any)\
  79000. */
  79001. pickInfo: Nullable<PickingInfo>;
  79002. /**
  79003. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79004. * @param type Defines the type of event (PointerEventTypes)
  79005. * @param event Defines the related dom event
  79006. * @param pickInfo Defines the picking info associated to the info (if any)\
  79007. */
  79008. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79009. /**
  79010. * Defines the picking info associated to the info (if any)\
  79011. */
  79012. pickInfo: Nullable<PickingInfo>);
  79013. }
  79014. /**
  79015. * Data relating to a touch event on the screen.
  79016. */
  79017. export interface PointerTouch {
  79018. /**
  79019. * X coordinate of touch.
  79020. */
  79021. x: number;
  79022. /**
  79023. * Y coordinate of touch.
  79024. */
  79025. y: number;
  79026. /**
  79027. * Id of touch. Unique for each finger.
  79028. */
  79029. pointerId: number;
  79030. /**
  79031. * Event type passed from DOM.
  79032. */
  79033. type: any;
  79034. }
  79035. }
  79036. declare module BABYLON {
  79037. /**
  79038. * Manage the mouse inputs to control the movement of a free camera.
  79039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79040. */
  79041. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79042. /**
  79043. * Define if touch is enabled in the mouse input
  79044. */
  79045. touchEnabled: boolean;
  79046. /**
  79047. * Defines the camera the input is attached to.
  79048. */
  79049. camera: FreeCamera;
  79050. /**
  79051. * Defines the buttons associated with the input to handle camera move.
  79052. */
  79053. buttons: number[];
  79054. /**
  79055. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79056. */
  79057. angularSensibility: number;
  79058. private _pointerInput;
  79059. private _onMouseMove;
  79060. private _observer;
  79061. private previousPosition;
  79062. /**
  79063. * Observable for when a pointer move event occurs containing the move offset
  79064. */
  79065. onPointerMovedObservable: Observable<{
  79066. offsetX: number;
  79067. offsetY: number;
  79068. }>;
  79069. /**
  79070. * @hidden
  79071. * If the camera should be rotated automatically based on pointer movement
  79072. */
  79073. _allowCameraRotation: boolean;
  79074. /**
  79075. * Manage the mouse inputs to control the movement of a free camera.
  79076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79077. * @param touchEnabled Defines if touch is enabled or not
  79078. */
  79079. constructor(
  79080. /**
  79081. * Define if touch is enabled in the mouse input
  79082. */
  79083. touchEnabled?: boolean);
  79084. /**
  79085. * Attach the input controls to a specific dom element to get the input from.
  79086. * @param element Defines the element the controls should be listened from
  79087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79088. */
  79089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79090. /**
  79091. * Called on JS contextmenu event.
  79092. * Override this method to provide functionality.
  79093. */
  79094. protected onContextMenu(evt: PointerEvent): void;
  79095. /**
  79096. * Detach the current controls from the specified dom element.
  79097. * @param element Defines the element to stop listening the inputs from
  79098. */
  79099. detachControl(element: Nullable<HTMLElement>): void;
  79100. /**
  79101. * Gets the class name of the current intput.
  79102. * @returns the class name
  79103. */
  79104. getClassName(): string;
  79105. /**
  79106. * Get the friendly name associated with the input class.
  79107. * @returns the input friendly name
  79108. */
  79109. getSimpleName(): string;
  79110. }
  79111. }
  79112. declare module BABYLON {
  79113. /**
  79114. * Manage the touch inputs to control the movement of a free camera.
  79115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79116. */
  79117. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79118. /**
  79119. * Defines the camera the input is attached to.
  79120. */
  79121. camera: FreeCamera;
  79122. /**
  79123. * Defines the touch sensibility for rotation.
  79124. * The higher the faster.
  79125. */
  79126. touchAngularSensibility: number;
  79127. /**
  79128. * Defines the touch sensibility for move.
  79129. * The higher the faster.
  79130. */
  79131. touchMoveSensibility: number;
  79132. private _offsetX;
  79133. private _offsetY;
  79134. private _pointerPressed;
  79135. private _pointerInput;
  79136. private _observer;
  79137. private _onLostFocus;
  79138. /**
  79139. * Attach the input controls to a specific dom element to get the input from.
  79140. * @param element Defines the element the controls should be listened from
  79141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79142. */
  79143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79144. /**
  79145. * Detach the current controls from the specified dom element.
  79146. * @param element Defines the element to stop listening the inputs from
  79147. */
  79148. detachControl(element: Nullable<HTMLElement>): void;
  79149. /**
  79150. * Update the current camera state depending on the inputs that have been used this frame.
  79151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79152. */
  79153. checkInputs(): void;
  79154. /**
  79155. * Gets the class name of the current intput.
  79156. * @returns the class name
  79157. */
  79158. getClassName(): string;
  79159. /**
  79160. * Get the friendly name associated with the input class.
  79161. * @returns the input friendly name
  79162. */
  79163. getSimpleName(): string;
  79164. }
  79165. }
  79166. declare module BABYLON {
  79167. /**
  79168. * Default Inputs manager for the FreeCamera.
  79169. * It groups all the default supported inputs for ease of use.
  79170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79171. */
  79172. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79173. /**
  79174. * @hidden
  79175. */
  79176. _mouseInput: Nullable<FreeCameraMouseInput>;
  79177. /**
  79178. * Instantiates a new FreeCameraInputsManager.
  79179. * @param camera Defines the camera the inputs belong to
  79180. */
  79181. constructor(camera: FreeCamera);
  79182. /**
  79183. * Add keyboard input support to the input manager.
  79184. * @returns the current input manager
  79185. */
  79186. addKeyboard(): FreeCameraInputsManager;
  79187. /**
  79188. * Add mouse input support to the input manager.
  79189. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79190. * @returns the current input manager
  79191. */
  79192. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79193. /**
  79194. * Removes the mouse input support from the manager
  79195. * @returns the current input manager
  79196. */
  79197. removeMouse(): FreeCameraInputsManager;
  79198. /**
  79199. * Add touch input support to the input manager.
  79200. * @returns the current input manager
  79201. */
  79202. addTouch(): FreeCameraInputsManager;
  79203. /**
  79204. * Remove all attached input methods from a camera
  79205. */
  79206. clear(): void;
  79207. }
  79208. }
  79209. declare module BABYLON {
  79210. /**
  79211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79214. */
  79215. export class FreeCamera extends TargetCamera {
  79216. /**
  79217. * Define the collision ellipsoid of the camera.
  79218. * This is helpful to simulate a camera body like the player body around the camera
  79219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79220. */
  79221. ellipsoid: Vector3;
  79222. /**
  79223. * Define an offset for the position of the ellipsoid around the camera.
  79224. * This can be helpful to determine the center of the body near the gravity center of the body
  79225. * instead of its head.
  79226. */
  79227. ellipsoidOffset: Vector3;
  79228. /**
  79229. * Enable or disable collisions of the camera with the rest of the scene objects.
  79230. */
  79231. checkCollisions: boolean;
  79232. /**
  79233. * Enable or disable gravity on the camera.
  79234. */
  79235. applyGravity: boolean;
  79236. /**
  79237. * Define the input manager associated to the camera.
  79238. */
  79239. inputs: FreeCameraInputsManager;
  79240. /**
  79241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79242. * Higher values reduce sensitivity.
  79243. */
  79244. /**
  79245. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79246. * Higher values reduce sensitivity.
  79247. */
  79248. angularSensibility: number;
  79249. /**
  79250. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79251. */
  79252. keysUp: number[];
  79253. /**
  79254. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79255. */
  79256. keysDown: number[];
  79257. /**
  79258. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79259. */
  79260. keysLeft: number[];
  79261. /**
  79262. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79263. */
  79264. keysRight: number[];
  79265. /**
  79266. * Event raised when the camera collide with a mesh in the scene.
  79267. */
  79268. onCollide: (collidedMesh: AbstractMesh) => void;
  79269. private _collider;
  79270. private _needMoveForGravity;
  79271. private _oldPosition;
  79272. private _diffPosition;
  79273. private _newPosition;
  79274. /** @hidden */
  79275. _localDirection: Vector3;
  79276. /** @hidden */
  79277. _transformedDirection: Vector3;
  79278. /**
  79279. * Instantiates a Free Camera.
  79280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79281. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79283. * @param name Define the name of the camera in the scene
  79284. * @param position Define the start position of the camera in the scene
  79285. * @param scene Define the scene the camera belongs to
  79286. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79287. */
  79288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79289. /**
  79290. * Attached controls to the current camera.
  79291. * @param element Defines the element the controls should be listened from
  79292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79293. */
  79294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79295. /**
  79296. * Detach the current controls from the camera.
  79297. * The camera will stop reacting to inputs.
  79298. * @param element Defines the element to stop listening the inputs from
  79299. */
  79300. detachControl(element: HTMLElement): void;
  79301. private _collisionMask;
  79302. /**
  79303. * Define a collision mask to limit the list of object the camera can collide with
  79304. */
  79305. collisionMask: number;
  79306. /** @hidden */
  79307. _collideWithWorld(displacement: Vector3): void;
  79308. private _onCollisionPositionChange;
  79309. /** @hidden */
  79310. _checkInputs(): void;
  79311. /** @hidden */
  79312. _decideIfNeedsToMove(): boolean;
  79313. /** @hidden */
  79314. _updatePosition(): void;
  79315. /**
  79316. * Destroy the camera and release the current resources hold by it.
  79317. */
  79318. dispose(): void;
  79319. /**
  79320. * Gets the current object class name.
  79321. * @return the class name
  79322. */
  79323. getClassName(): string;
  79324. }
  79325. }
  79326. declare module BABYLON {
  79327. /**
  79328. * Represents a gamepad control stick position
  79329. */
  79330. export class StickValues {
  79331. /**
  79332. * The x component of the control stick
  79333. */
  79334. x: number;
  79335. /**
  79336. * The y component of the control stick
  79337. */
  79338. y: number;
  79339. /**
  79340. * Initializes the gamepad x and y control stick values
  79341. * @param x The x component of the gamepad control stick value
  79342. * @param y The y component of the gamepad control stick value
  79343. */
  79344. constructor(
  79345. /**
  79346. * The x component of the control stick
  79347. */
  79348. x: number,
  79349. /**
  79350. * The y component of the control stick
  79351. */
  79352. y: number);
  79353. }
  79354. /**
  79355. * An interface which manages callbacks for gamepad button changes
  79356. */
  79357. export interface GamepadButtonChanges {
  79358. /**
  79359. * Called when a gamepad has been changed
  79360. */
  79361. changed: boolean;
  79362. /**
  79363. * Called when a gamepad press event has been triggered
  79364. */
  79365. pressChanged: boolean;
  79366. /**
  79367. * Called when a touch event has been triggered
  79368. */
  79369. touchChanged: boolean;
  79370. /**
  79371. * Called when a value has changed
  79372. */
  79373. valueChanged: boolean;
  79374. }
  79375. /**
  79376. * Represents a gamepad
  79377. */
  79378. export class Gamepad {
  79379. /**
  79380. * The id of the gamepad
  79381. */
  79382. id: string;
  79383. /**
  79384. * The index of the gamepad
  79385. */
  79386. index: number;
  79387. /**
  79388. * The browser gamepad
  79389. */
  79390. browserGamepad: any;
  79391. /**
  79392. * Specifies what type of gamepad this represents
  79393. */
  79394. type: number;
  79395. private _leftStick;
  79396. private _rightStick;
  79397. /** @hidden */
  79398. _isConnected: boolean;
  79399. private _leftStickAxisX;
  79400. private _leftStickAxisY;
  79401. private _rightStickAxisX;
  79402. private _rightStickAxisY;
  79403. /**
  79404. * Triggered when the left control stick has been changed
  79405. */
  79406. private _onleftstickchanged;
  79407. /**
  79408. * Triggered when the right control stick has been changed
  79409. */
  79410. private _onrightstickchanged;
  79411. /**
  79412. * Represents a gamepad controller
  79413. */
  79414. static GAMEPAD: number;
  79415. /**
  79416. * Represents a generic controller
  79417. */
  79418. static GENERIC: number;
  79419. /**
  79420. * Represents an XBox controller
  79421. */
  79422. static XBOX: number;
  79423. /**
  79424. * Represents a pose-enabled controller
  79425. */
  79426. static POSE_ENABLED: number;
  79427. /**
  79428. * Represents an Dual Shock controller
  79429. */
  79430. static DUALSHOCK: number;
  79431. /**
  79432. * Specifies whether the left control stick should be Y-inverted
  79433. */
  79434. protected _invertLeftStickY: boolean;
  79435. /**
  79436. * Specifies if the gamepad has been connected
  79437. */
  79438. readonly isConnected: boolean;
  79439. /**
  79440. * Initializes the gamepad
  79441. * @param id The id of the gamepad
  79442. * @param index The index of the gamepad
  79443. * @param browserGamepad The browser gamepad
  79444. * @param leftStickX The x component of the left joystick
  79445. * @param leftStickY The y component of the left joystick
  79446. * @param rightStickX The x component of the right joystick
  79447. * @param rightStickY The y component of the right joystick
  79448. */
  79449. constructor(
  79450. /**
  79451. * The id of the gamepad
  79452. */
  79453. id: string,
  79454. /**
  79455. * The index of the gamepad
  79456. */
  79457. index: number,
  79458. /**
  79459. * The browser gamepad
  79460. */
  79461. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79462. /**
  79463. * Callback triggered when the left joystick has changed
  79464. * @param callback
  79465. */
  79466. onleftstickchanged(callback: (values: StickValues) => void): void;
  79467. /**
  79468. * Callback triggered when the right joystick has changed
  79469. * @param callback
  79470. */
  79471. onrightstickchanged(callback: (values: StickValues) => void): void;
  79472. /**
  79473. * Gets the left joystick
  79474. */
  79475. /**
  79476. * Sets the left joystick values
  79477. */
  79478. leftStick: StickValues;
  79479. /**
  79480. * Gets the right joystick
  79481. */
  79482. /**
  79483. * Sets the right joystick value
  79484. */
  79485. rightStick: StickValues;
  79486. /**
  79487. * Updates the gamepad joystick positions
  79488. */
  79489. update(): void;
  79490. /**
  79491. * Disposes the gamepad
  79492. */
  79493. dispose(): void;
  79494. }
  79495. /**
  79496. * Represents a generic gamepad
  79497. */
  79498. export class GenericPad extends Gamepad {
  79499. private _buttons;
  79500. private _onbuttondown;
  79501. private _onbuttonup;
  79502. /**
  79503. * Observable triggered when a button has been pressed
  79504. */
  79505. onButtonDownObservable: Observable<number>;
  79506. /**
  79507. * Observable triggered when a button has been released
  79508. */
  79509. onButtonUpObservable: Observable<number>;
  79510. /**
  79511. * Callback triggered when a button has been pressed
  79512. * @param callback Called when a button has been pressed
  79513. */
  79514. onbuttondown(callback: (buttonPressed: number) => void): void;
  79515. /**
  79516. * Callback triggered when a button has been released
  79517. * @param callback Called when a button has been released
  79518. */
  79519. onbuttonup(callback: (buttonReleased: number) => void): void;
  79520. /**
  79521. * Initializes the generic gamepad
  79522. * @param id The id of the generic gamepad
  79523. * @param index The index of the generic gamepad
  79524. * @param browserGamepad The browser gamepad
  79525. */
  79526. constructor(id: string, index: number, browserGamepad: any);
  79527. private _setButtonValue;
  79528. /**
  79529. * Updates the generic gamepad
  79530. */
  79531. update(): void;
  79532. /**
  79533. * Disposes the generic gamepad
  79534. */
  79535. dispose(): void;
  79536. }
  79537. }
  79538. declare module BABYLON {
  79539. interface Engine {
  79540. /**
  79541. * Creates a raw texture
  79542. * @param data defines the data to store in the texture
  79543. * @param width defines the width of the texture
  79544. * @param height defines the height of the texture
  79545. * @param format defines the format of the data
  79546. * @param generateMipMaps defines if the engine should generate the mip levels
  79547. * @param invertY defines if data must be stored with Y axis inverted
  79548. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79549. * @param compression defines the compression used (null by default)
  79550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79551. * @returns the raw texture inside an InternalTexture
  79552. */
  79553. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79554. /**
  79555. * Update a raw texture
  79556. * @param texture defines the texture to update
  79557. * @param data defines the data to store in the texture
  79558. * @param format defines the format of the data
  79559. * @param invertY defines if data must be stored with Y axis inverted
  79560. */
  79561. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79562. /**
  79563. * Update a raw texture
  79564. * @param texture defines the texture to update
  79565. * @param data defines the data to store in the texture
  79566. * @param format defines the format of the data
  79567. * @param invertY defines if data must be stored with Y axis inverted
  79568. * @param compression defines the compression used (null by default)
  79569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79570. */
  79571. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79572. /**
  79573. * Creates a new raw cube texture
  79574. * @param data defines the array of data to use to create each face
  79575. * @param size defines the size of the textures
  79576. * @param format defines the format of the data
  79577. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79578. * @param generateMipMaps defines if the engine should generate the mip levels
  79579. * @param invertY defines if data must be stored with Y axis inverted
  79580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79581. * @param compression defines the compression used (null by default)
  79582. * @returns the cube texture as an InternalTexture
  79583. */
  79584. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79585. /**
  79586. * Update a raw cube texture
  79587. * @param texture defines the texture to udpdate
  79588. * @param data defines the data to store
  79589. * @param format defines the data format
  79590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79591. * @param invertY defines if data must be stored with Y axis inverted
  79592. */
  79593. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79594. /**
  79595. * Update a raw cube texture
  79596. * @param texture defines the texture to udpdate
  79597. * @param data defines the data to store
  79598. * @param format defines the data format
  79599. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79600. * @param invertY defines if data must be stored with Y axis inverted
  79601. * @param compression defines the compression used (null by default)
  79602. */
  79603. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79604. /**
  79605. * Update a raw cube texture
  79606. * @param texture defines the texture to udpdate
  79607. * @param data defines the data to store
  79608. * @param format defines the data format
  79609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79610. * @param invertY defines if data must be stored with Y axis inverted
  79611. * @param compression defines the compression used (null by default)
  79612. * @param level defines which level of the texture to update
  79613. */
  79614. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79615. /**
  79616. * Creates a new raw cube texture from a specified url
  79617. * @param url defines the url where the data is located
  79618. * @param scene defines the current scene
  79619. * @param size defines the size of the textures
  79620. * @param format defines the format of the data
  79621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79622. * @param noMipmap defines if the engine should avoid generating the mip levels
  79623. * @param callback defines a callback used to extract texture data from loaded data
  79624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79625. * @param onLoad defines a callback called when texture is loaded
  79626. * @param onError defines a callback called if there is an error
  79627. * @returns the cube texture as an InternalTexture
  79628. */
  79629. 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;
  79630. /**
  79631. * Creates a new raw cube texture from a specified url
  79632. * @param url defines the url where the data is located
  79633. * @param scene defines the current scene
  79634. * @param size defines the size of the textures
  79635. * @param format defines the format of the data
  79636. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79637. * @param noMipmap defines if the engine should avoid generating the mip levels
  79638. * @param callback defines a callback used to extract texture data from loaded data
  79639. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79640. * @param onLoad defines a callback called when texture is loaded
  79641. * @param onError defines a callback called if there is an error
  79642. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79643. * @param invertY defines if data must be stored with Y axis inverted
  79644. * @returns the cube texture as an InternalTexture
  79645. */
  79646. 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;
  79647. /**
  79648. * Creates a new raw 3D texture
  79649. * @param data defines the data used to create the texture
  79650. * @param width defines the width of the texture
  79651. * @param height defines the height of the texture
  79652. * @param depth defines the depth of the texture
  79653. * @param format defines the format of the texture
  79654. * @param generateMipMaps defines if the engine must generate mip levels
  79655. * @param invertY defines if data must be stored with Y axis inverted
  79656. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79657. * @param compression defines the compressed used (can be null)
  79658. * @param textureType defines the compressed used (can be null)
  79659. * @returns a new raw 3D texture (stored in an InternalTexture)
  79660. */
  79661. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79662. /**
  79663. * Update a raw 3D texture
  79664. * @param texture defines the texture to update
  79665. * @param data defines the data to store
  79666. * @param format defines the data format
  79667. * @param invertY defines if data must be stored with Y axis inverted
  79668. */
  79669. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79670. /**
  79671. * Update a raw 3D texture
  79672. * @param texture defines the texture to update
  79673. * @param data defines the data to store
  79674. * @param format defines the data format
  79675. * @param invertY defines if data must be stored with Y axis inverted
  79676. * @param compression defines the used compression (can be null)
  79677. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79678. */
  79679. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79680. }
  79681. }
  79682. declare module BABYLON {
  79683. /**
  79684. * Raw texture can help creating a texture directly from an array of data.
  79685. * This can be super useful if you either get the data from an uncompressed source or
  79686. * if you wish to create your texture pixel by pixel.
  79687. */
  79688. export class RawTexture extends Texture {
  79689. /**
  79690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79691. */
  79692. format: number;
  79693. private _engine;
  79694. /**
  79695. * Instantiates a new RawTexture.
  79696. * Raw texture can help creating a texture directly from an array of data.
  79697. * This can be super useful if you either get the data from an uncompressed source or
  79698. * if you wish to create your texture pixel by pixel.
  79699. * @param data define the array of data to use to create the texture
  79700. * @param width define the width of the texture
  79701. * @param height define the height of the texture
  79702. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79703. * @param scene define the scene the texture belongs to
  79704. * @param generateMipMaps define whether mip maps should be generated or not
  79705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79708. */
  79709. constructor(data: ArrayBufferView, width: number, height: number,
  79710. /**
  79711. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79712. */
  79713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79714. /**
  79715. * Updates the texture underlying data.
  79716. * @param data Define the new data of the texture
  79717. */
  79718. update(data: ArrayBufferView): void;
  79719. /**
  79720. * Creates a luminance texture from some data.
  79721. * @param data Define the texture data
  79722. * @param width Define the width of the texture
  79723. * @param height Define the height of the texture
  79724. * @param scene Define the scene the texture belongs to
  79725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79728. * @returns the luminance texture
  79729. */
  79730. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79731. /**
  79732. * Creates a luminance alpha texture from some data.
  79733. * @param data Define the texture data
  79734. * @param width Define the width of the texture
  79735. * @param height Define the height of the texture
  79736. * @param scene Define the scene the texture belongs to
  79737. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79738. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79739. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79740. * @returns the luminance alpha texture
  79741. */
  79742. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79743. /**
  79744. * Creates an alpha texture from some data.
  79745. * @param data Define the texture data
  79746. * @param width Define the width of the texture
  79747. * @param height Define the height of the texture
  79748. * @param scene Define the scene the texture belongs to
  79749. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79750. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79751. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79752. * @returns the alpha texture
  79753. */
  79754. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79755. /**
  79756. * Creates a RGB texture from some data.
  79757. * @param data Define the texture data
  79758. * @param width Define the width of the texture
  79759. * @param height Define the height of the texture
  79760. * @param scene Define the scene the texture belongs to
  79761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79765. * @returns the RGB alpha texture
  79766. */
  79767. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79768. /**
  79769. * Creates a RGBA texture from some data.
  79770. * @param data Define the texture data
  79771. * @param width Define the width of the texture
  79772. * @param height Define the height of the texture
  79773. * @param scene Define the scene the texture belongs to
  79774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79778. * @returns the RGBA texture
  79779. */
  79780. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79781. /**
  79782. * Creates a R texture from some data.
  79783. * @param data Define the texture data
  79784. * @param width Define the width of the texture
  79785. * @param height Define the height of the texture
  79786. * @param scene Define the scene the texture belongs to
  79787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79791. * @returns the R texture
  79792. */
  79793. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79794. }
  79795. }
  79796. declare module BABYLON {
  79797. /**
  79798. * Interface for the size containing width and height
  79799. */
  79800. export interface ISize {
  79801. /**
  79802. * Width
  79803. */
  79804. width: number;
  79805. /**
  79806. * Heighht
  79807. */
  79808. height: number;
  79809. }
  79810. /**
  79811. * Size containing widht and height
  79812. */
  79813. export class Size implements ISize {
  79814. /**
  79815. * Width
  79816. */
  79817. width: number;
  79818. /**
  79819. * Height
  79820. */
  79821. height: number;
  79822. /**
  79823. * Creates a Size object from the given width and height (floats).
  79824. * @param width width of the new size
  79825. * @param height height of the new size
  79826. */
  79827. constructor(width: number, height: number);
  79828. /**
  79829. * Returns a string with the Size width and height
  79830. * @returns a string with the Size width and height
  79831. */
  79832. toString(): string;
  79833. /**
  79834. * "Size"
  79835. * @returns the string "Size"
  79836. */
  79837. getClassName(): string;
  79838. /**
  79839. * Returns the Size hash code.
  79840. * @returns a hash code for a unique width and height
  79841. */
  79842. getHashCode(): number;
  79843. /**
  79844. * Updates the current size from the given one.
  79845. * @param src the given size
  79846. */
  79847. copyFrom(src: Size): void;
  79848. /**
  79849. * Updates in place the current Size from the given floats.
  79850. * @param width width of the new size
  79851. * @param height height of the new size
  79852. * @returns the updated Size.
  79853. */
  79854. copyFromFloats(width: number, height: number): Size;
  79855. /**
  79856. * Updates in place the current Size from the given floats.
  79857. * @param width width to set
  79858. * @param height height to set
  79859. * @returns the updated Size.
  79860. */
  79861. set(width: number, height: number): Size;
  79862. /**
  79863. * Multiplies the width and height by numbers
  79864. * @param w factor to multiple the width by
  79865. * @param h factor to multiple the height by
  79866. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79867. */
  79868. multiplyByFloats(w: number, h: number): Size;
  79869. /**
  79870. * Clones the size
  79871. * @returns a new Size copied from the given one.
  79872. */
  79873. clone(): Size;
  79874. /**
  79875. * True if the current Size and the given one width and height are strictly equal.
  79876. * @param other the other size to compare against
  79877. * @returns True if the current Size and the given one width and height are strictly equal.
  79878. */
  79879. equals(other: Size): boolean;
  79880. /**
  79881. * The surface of the Size : width * height (float).
  79882. */
  79883. readonly surface: number;
  79884. /**
  79885. * Create a new size of zero
  79886. * @returns a new Size set to (0.0, 0.0)
  79887. */
  79888. static Zero(): Size;
  79889. /**
  79890. * Sums the width and height of two sizes
  79891. * @param otherSize size to add to this size
  79892. * @returns a new Size set as the addition result of the current Size and the given one.
  79893. */
  79894. add(otherSize: Size): Size;
  79895. /**
  79896. * Subtracts the width and height of two
  79897. * @param otherSize size to subtract to this size
  79898. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79899. */
  79900. subtract(otherSize: Size): Size;
  79901. /**
  79902. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79903. * @param start starting size to lerp between
  79904. * @param end end size to lerp between
  79905. * @param amount amount to lerp between the start and end values
  79906. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79907. */
  79908. static Lerp(start: Size, end: Size, amount: number): Size;
  79909. }
  79910. }
  79911. declare module BABYLON {
  79912. /**
  79913. * Defines a runtime animation
  79914. */
  79915. export class RuntimeAnimation {
  79916. private _events;
  79917. /**
  79918. * The current frame of the runtime animation
  79919. */
  79920. private _currentFrame;
  79921. /**
  79922. * The animation used by the runtime animation
  79923. */
  79924. private _animation;
  79925. /**
  79926. * The target of the runtime animation
  79927. */
  79928. private _target;
  79929. /**
  79930. * The initiating animatable
  79931. */
  79932. private _host;
  79933. /**
  79934. * The original value of the runtime animation
  79935. */
  79936. private _originalValue;
  79937. /**
  79938. * The original blend value of the runtime animation
  79939. */
  79940. private _originalBlendValue;
  79941. /**
  79942. * The offsets cache of the runtime animation
  79943. */
  79944. private _offsetsCache;
  79945. /**
  79946. * The high limits cache of the runtime animation
  79947. */
  79948. private _highLimitsCache;
  79949. /**
  79950. * Specifies if the runtime animation has been stopped
  79951. */
  79952. private _stopped;
  79953. /**
  79954. * The blending factor of the runtime animation
  79955. */
  79956. private _blendingFactor;
  79957. /**
  79958. * The BabylonJS scene
  79959. */
  79960. private _scene;
  79961. /**
  79962. * The current value of the runtime animation
  79963. */
  79964. private _currentValue;
  79965. /** @hidden */
  79966. _animationState: _IAnimationState;
  79967. /**
  79968. * The active target of the runtime animation
  79969. */
  79970. private _activeTargets;
  79971. private _currentActiveTarget;
  79972. private _directTarget;
  79973. /**
  79974. * The target path of the runtime animation
  79975. */
  79976. private _targetPath;
  79977. /**
  79978. * The weight of the runtime animation
  79979. */
  79980. private _weight;
  79981. /**
  79982. * The ratio offset of the runtime animation
  79983. */
  79984. private _ratioOffset;
  79985. /**
  79986. * The previous delay of the runtime animation
  79987. */
  79988. private _previousDelay;
  79989. /**
  79990. * The previous ratio of the runtime animation
  79991. */
  79992. private _previousRatio;
  79993. private _enableBlending;
  79994. private _keys;
  79995. private _minFrame;
  79996. private _maxFrame;
  79997. private _minValue;
  79998. private _maxValue;
  79999. private _targetIsArray;
  80000. /**
  80001. * Gets the current frame of the runtime animation
  80002. */
  80003. readonly currentFrame: number;
  80004. /**
  80005. * Gets the weight of the runtime animation
  80006. */
  80007. readonly weight: number;
  80008. /**
  80009. * Gets the current value of the runtime animation
  80010. */
  80011. readonly currentValue: any;
  80012. /**
  80013. * Gets the target path of the runtime animation
  80014. */
  80015. readonly targetPath: string;
  80016. /**
  80017. * Gets the actual target of the runtime animation
  80018. */
  80019. readonly target: any;
  80020. /** @hidden */
  80021. _onLoop: () => void;
  80022. /**
  80023. * Create a new RuntimeAnimation object
  80024. * @param target defines the target of the animation
  80025. * @param animation defines the source animation object
  80026. * @param scene defines the hosting scene
  80027. * @param host defines the initiating Animatable
  80028. */
  80029. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80030. private _preparePath;
  80031. /**
  80032. * Gets the animation from the runtime animation
  80033. */
  80034. readonly animation: Animation;
  80035. /**
  80036. * Resets the runtime animation to the beginning
  80037. * @param restoreOriginal defines whether to restore the target property to the original value
  80038. */
  80039. reset(restoreOriginal?: boolean): void;
  80040. /**
  80041. * Specifies if the runtime animation is stopped
  80042. * @returns Boolean specifying if the runtime animation is stopped
  80043. */
  80044. isStopped(): boolean;
  80045. /**
  80046. * Disposes of the runtime animation
  80047. */
  80048. dispose(): void;
  80049. /**
  80050. * Apply the interpolated value to the target
  80051. * @param currentValue defines the value computed by the animation
  80052. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80053. */
  80054. setValue(currentValue: any, weight: number): void;
  80055. private _getOriginalValues;
  80056. private _setValue;
  80057. /**
  80058. * Gets the loop pmode of the runtime animation
  80059. * @returns Loop Mode
  80060. */
  80061. private _getCorrectLoopMode;
  80062. /**
  80063. * Move the current animation to a given frame
  80064. * @param frame defines the frame to move to
  80065. */
  80066. goToFrame(frame: number): void;
  80067. /**
  80068. * @hidden Internal use only
  80069. */
  80070. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80071. /**
  80072. * Execute the current animation
  80073. * @param delay defines the delay to add to the current frame
  80074. * @param from defines the lower bound of the animation range
  80075. * @param to defines the upper bound of the animation range
  80076. * @param loop defines if the current animation must loop
  80077. * @param speedRatio defines the current speed ratio
  80078. * @param weight defines the weight of the animation (default is -1 so no weight)
  80079. * @param onLoop optional callback called when animation loops
  80080. * @returns a boolean indicating if the animation is running
  80081. */
  80082. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80083. }
  80084. }
  80085. declare module BABYLON {
  80086. /**
  80087. * Class used to store an actual running animation
  80088. */
  80089. export class Animatable {
  80090. /** defines the target object */
  80091. target: any;
  80092. /** defines the starting frame number (default is 0) */
  80093. fromFrame: number;
  80094. /** defines the ending frame number (default is 100) */
  80095. toFrame: number;
  80096. /** defines if the animation must loop (default is false) */
  80097. loopAnimation: boolean;
  80098. /** defines a callback to call when animation ends if it is not looping */
  80099. onAnimationEnd?: (() => void) | null | undefined;
  80100. /** defines a callback to call when animation loops */
  80101. onAnimationLoop?: (() => void) | null | undefined;
  80102. private _localDelayOffset;
  80103. private _pausedDelay;
  80104. private _runtimeAnimations;
  80105. private _paused;
  80106. private _scene;
  80107. private _speedRatio;
  80108. private _weight;
  80109. private _syncRoot;
  80110. /**
  80111. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80112. * This will only apply for non looping animation (default is true)
  80113. */
  80114. disposeOnEnd: boolean;
  80115. /**
  80116. * Gets a boolean indicating if the animation has started
  80117. */
  80118. animationStarted: boolean;
  80119. /**
  80120. * Observer raised when the animation ends
  80121. */
  80122. onAnimationEndObservable: Observable<Animatable>;
  80123. /**
  80124. * Observer raised when the animation loops
  80125. */
  80126. onAnimationLoopObservable: Observable<Animatable>;
  80127. /**
  80128. * Gets the root Animatable used to synchronize and normalize animations
  80129. */
  80130. readonly syncRoot: Nullable<Animatable>;
  80131. /**
  80132. * Gets the current frame of the first RuntimeAnimation
  80133. * Used to synchronize Animatables
  80134. */
  80135. readonly masterFrame: number;
  80136. /**
  80137. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80138. */
  80139. weight: number;
  80140. /**
  80141. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80142. */
  80143. speedRatio: number;
  80144. /**
  80145. * Creates a new Animatable
  80146. * @param scene defines the hosting scene
  80147. * @param target defines the target object
  80148. * @param fromFrame defines the starting frame number (default is 0)
  80149. * @param toFrame defines the ending frame number (default is 100)
  80150. * @param loopAnimation defines if the animation must loop (default is false)
  80151. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80152. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80153. * @param animations defines a group of animation to add to the new Animatable
  80154. * @param onAnimationLoop defines a callback to call when animation loops
  80155. */
  80156. constructor(scene: Scene,
  80157. /** defines the target object */
  80158. target: any,
  80159. /** defines the starting frame number (default is 0) */
  80160. fromFrame?: number,
  80161. /** defines the ending frame number (default is 100) */
  80162. toFrame?: number,
  80163. /** defines if the animation must loop (default is false) */
  80164. loopAnimation?: boolean, speedRatio?: number,
  80165. /** defines a callback to call when animation ends if it is not looping */
  80166. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80167. /** defines a callback to call when animation loops */
  80168. onAnimationLoop?: (() => void) | null | undefined);
  80169. /**
  80170. * Synchronize and normalize current Animatable with a source Animatable
  80171. * This is useful when using animation weights and when animations are not of the same length
  80172. * @param root defines the root Animatable to synchronize with
  80173. * @returns the current Animatable
  80174. */
  80175. syncWith(root: Animatable): Animatable;
  80176. /**
  80177. * Gets the list of runtime animations
  80178. * @returns an array of RuntimeAnimation
  80179. */
  80180. getAnimations(): RuntimeAnimation[];
  80181. /**
  80182. * Adds more animations to the current animatable
  80183. * @param target defines the target of the animations
  80184. * @param animations defines the new animations to add
  80185. */
  80186. appendAnimations(target: any, animations: Animation[]): void;
  80187. /**
  80188. * Gets the source animation for a specific property
  80189. * @param property defines the propertyu to look for
  80190. * @returns null or the source animation for the given property
  80191. */
  80192. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80193. /**
  80194. * Gets the runtime animation for a specific property
  80195. * @param property defines the propertyu to look for
  80196. * @returns null or the runtime animation for the given property
  80197. */
  80198. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80199. /**
  80200. * Resets the animatable to its original state
  80201. */
  80202. reset(): void;
  80203. /**
  80204. * Allows the animatable to blend with current running animations
  80205. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80206. * @param blendingSpeed defines the blending speed to use
  80207. */
  80208. enableBlending(blendingSpeed: number): void;
  80209. /**
  80210. * Disable animation blending
  80211. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80212. */
  80213. disableBlending(): void;
  80214. /**
  80215. * Jump directly to a given frame
  80216. * @param frame defines the frame to jump to
  80217. */
  80218. goToFrame(frame: number): void;
  80219. /**
  80220. * Pause the animation
  80221. */
  80222. pause(): void;
  80223. /**
  80224. * Restart the animation
  80225. */
  80226. restart(): void;
  80227. private _raiseOnAnimationEnd;
  80228. /**
  80229. * Stop and delete the current animation
  80230. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80231. * @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)
  80232. */
  80233. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80234. /**
  80235. * Wait asynchronously for the animation to end
  80236. * @returns a promise which will be fullfilled when the animation ends
  80237. */
  80238. waitAsync(): Promise<Animatable>;
  80239. /** @hidden */
  80240. _animate(delay: number): boolean;
  80241. }
  80242. interface Scene {
  80243. /** @hidden */
  80244. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80245. /** @hidden */
  80246. _processLateAnimationBindingsForMatrices(holder: {
  80247. totalWeight: number;
  80248. animations: RuntimeAnimation[];
  80249. originalValue: Matrix;
  80250. }): any;
  80251. /** @hidden */
  80252. _processLateAnimationBindingsForQuaternions(holder: {
  80253. totalWeight: number;
  80254. animations: RuntimeAnimation[];
  80255. originalValue: Quaternion;
  80256. }, refQuaternion: Quaternion): Quaternion;
  80257. /** @hidden */
  80258. _processLateAnimationBindings(): void;
  80259. /**
  80260. * Will start the animation sequence of a given target
  80261. * @param target defines the target
  80262. * @param from defines from which frame should animation start
  80263. * @param to defines until which frame should animation run.
  80264. * @param weight defines the weight to apply to the animation (1.0 by default)
  80265. * @param loop defines if the animation loops
  80266. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80267. * @param onAnimationEnd defines the function to be executed when the animation ends
  80268. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80269. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80270. * @param onAnimationLoop defines the callback to call when an animation loops
  80271. * @returns the animatable object created for this animation
  80272. */
  80273. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80274. /**
  80275. * Will start the animation sequence of a given target
  80276. * @param target defines the target
  80277. * @param from defines from which frame should animation start
  80278. * @param to defines until which frame should animation run.
  80279. * @param loop defines if the animation loops
  80280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80281. * @param onAnimationEnd defines the function to be executed when the animation ends
  80282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80283. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80284. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80285. * @param onAnimationLoop defines the callback to call when an animation loops
  80286. * @returns the animatable object created for this animation
  80287. */
  80288. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80289. /**
  80290. * Will start the animation sequence of a given target and its hierarchy
  80291. * @param target defines the target
  80292. * @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.
  80293. * @param from defines from which frame should animation start
  80294. * @param to defines until which frame should animation run.
  80295. * @param loop defines if the animation loops
  80296. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80297. * @param onAnimationEnd defines the function to be executed when the animation ends
  80298. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80299. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80300. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80301. * @param onAnimationLoop defines the callback to call when an animation loops
  80302. * @returns the list of created animatables
  80303. */
  80304. 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[];
  80305. /**
  80306. * Begin a new animation on a given node
  80307. * @param target defines the target where the animation will take place
  80308. * @param animations defines the list of animations to start
  80309. * @param from defines the initial value
  80310. * @param to defines the final value
  80311. * @param loop defines if you want animation to loop (off by default)
  80312. * @param speedRatio defines the speed ratio to apply to all animations
  80313. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80314. * @param onAnimationLoop defines the callback to call when an animation loops
  80315. * @returns the list of created animatables
  80316. */
  80317. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80318. /**
  80319. * Begin a new animation on a given node and its hierarchy
  80320. * @param target defines the root node where the animation will take place
  80321. * @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.
  80322. * @param animations defines the list of animations to start
  80323. * @param from defines the initial value
  80324. * @param to defines the final value
  80325. * @param loop defines if you want animation to loop (off by default)
  80326. * @param speedRatio defines the speed ratio to apply to all animations
  80327. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80328. * @param onAnimationLoop defines the callback to call when an animation loops
  80329. * @returns the list of animatables created for all nodes
  80330. */
  80331. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80332. /**
  80333. * Gets the animatable associated with a specific target
  80334. * @param target defines the target of the animatable
  80335. * @returns the required animatable if found
  80336. */
  80337. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80338. /**
  80339. * Gets all animatables associated with a given target
  80340. * @param target defines the target to look animatables for
  80341. * @returns an array of Animatables
  80342. */
  80343. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80344. /**
  80345. * Stops and removes all animations that have been applied to the scene
  80346. */
  80347. stopAllAnimations(): void;
  80348. /**
  80349. * Gets the current delta time used by animation engine
  80350. */
  80351. deltaTime: number;
  80352. }
  80353. interface Bone {
  80354. /**
  80355. * Copy an animation range from another bone
  80356. * @param source defines the source bone
  80357. * @param rangeName defines the range name to copy
  80358. * @param frameOffset defines the frame offset
  80359. * @param rescaleAsRequired defines if rescaling must be applied if required
  80360. * @param skelDimensionsRatio defines the scaling ratio
  80361. * @returns true if operation was successful
  80362. */
  80363. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80364. }
  80365. }
  80366. declare module BABYLON {
  80367. /**
  80368. * Class used to override all child animations of a given target
  80369. */
  80370. export class AnimationPropertiesOverride {
  80371. /**
  80372. * Gets or sets a value indicating if animation blending must be used
  80373. */
  80374. enableBlending: boolean;
  80375. /**
  80376. * Gets or sets the blending speed to use when enableBlending is true
  80377. */
  80378. blendingSpeed: number;
  80379. /**
  80380. * Gets or sets the default loop mode to use
  80381. */
  80382. loopMode: number;
  80383. }
  80384. }
  80385. declare module BABYLON {
  80386. /**
  80387. * Class used to handle skinning animations
  80388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80389. */
  80390. export class Skeleton implements IAnimatable {
  80391. /** defines the skeleton name */
  80392. name: string;
  80393. /** defines the skeleton Id */
  80394. id: string;
  80395. /**
  80396. * Defines the list of child bones
  80397. */
  80398. bones: Bone[];
  80399. /**
  80400. * Defines an estimate of the dimension of the skeleton at rest
  80401. */
  80402. dimensionsAtRest: Vector3;
  80403. /**
  80404. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80405. */
  80406. needInitialSkinMatrix: boolean;
  80407. /**
  80408. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80409. */
  80410. overrideMesh: Nullable<AbstractMesh>;
  80411. /**
  80412. * Gets the list of animations attached to this skeleton
  80413. */
  80414. animations: Array<Animation>;
  80415. private _scene;
  80416. private _isDirty;
  80417. private _transformMatrices;
  80418. private _transformMatrixTexture;
  80419. private _meshesWithPoseMatrix;
  80420. private _animatables;
  80421. private _identity;
  80422. private _synchronizedWithMesh;
  80423. private _ranges;
  80424. private _lastAbsoluteTransformsUpdateId;
  80425. private _canUseTextureForBones;
  80426. private _uniqueId;
  80427. /** @hidden */
  80428. _numBonesWithLinkedTransformNode: number;
  80429. /** @hidden */
  80430. _hasWaitingData: Nullable<boolean>;
  80431. /**
  80432. * Specifies if the skeleton should be serialized
  80433. */
  80434. doNotSerialize: boolean;
  80435. private _useTextureToStoreBoneMatrices;
  80436. /**
  80437. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80438. * Please note that this option is not available if the hardware does not support it
  80439. */
  80440. useTextureToStoreBoneMatrices: boolean;
  80441. private _animationPropertiesOverride;
  80442. /**
  80443. * Gets or sets the animation properties override
  80444. */
  80445. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80446. /**
  80447. * List of inspectable custom properties (used by the Inspector)
  80448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80449. */
  80450. inspectableCustomProperties: IInspectable[];
  80451. /**
  80452. * An observable triggered before computing the skeleton's matrices
  80453. */
  80454. onBeforeComputeObservable: Observable<Skeleton>;
  80455. /**
  80456. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80457. */
  80458. readonly isUsingTextureForMatrices: boolean;
  80459. /**
  80460. * Gets the unique ID of this skeleton
  80461. */
  80462. readonly uniqueId: number;
  80463. /**
  80464. * Creates a new skeleton
  80465. * @param name defines the skeleton name
  80466. * @param id defines the skeleton Id
  80467. * @param scene defines the hosting scene
  80468. */
  80469. constructor(
  80470. /** defines the skeleton name */
  80471. name: string,
  80472. /** defines the skeleton Id */
  80473. id: string, scene: Scene);
  80474. /**
  80475. * Gets the current object class name.
  80476. * @return the class name
  80477. */
  80478. getClassName(): string;
  80479. /**
  80480. * Returns an array containing the root bones
  80481. * @returns an array containing the root bones
  80482. */
  80483. getChildren(): Array<Bone>;
  80484. /**
  80485. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80486. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80487. * @returns a Float32Array containing matrices data
  80488. */
  80489. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80490. /**
  80491. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80493. * @returns a raw texture containing the data
  80494. */
  80495. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80496. /**
  80497. * Gets the current hosting scene
  80498. * @returns a scene object
  80499. */
  80500. getScene(): Scene;
  80501. /**
  80502. * Gets a string representing the current skeleton data
  80503. * @param fullDetails defines a boolean indicating if we want a verbose version
  80504. * @returns a string representing the current skeleton data
  80505. */
  80506. toString(fullDetails?: boolean): string;
  80507. /**
  80508. * Get bone's index searching by name
  80509. * @param name defines bone's name to search for
  80510. * @return the indice of the bone. Returns -1 if not found
  80511. */
  80512. getBoneIndexByName(name: string): number;
  80513. /**
  80514. * Creater a new animation range
  80515. * @param name defines the name of the range
  80516. * @param from defines the start key
  80517. * @param to defines the end key
  80518. */
  80519. createAnimationRange(name: string, from: number, to: number): void;
  80520. /**
  80521. * Delete a specific animation range
  80522. * @param name defines the name of the range
  80523. * @param deleteFrames defines if frames must be removed as well
  80524. */
  80525. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80526. /**
  80527. * Gets a specific animation range
  80528. * @param name defines the name of the range to look for
  80529. * @returns the requested animation range or null if not found
  80530. */
  80531. getAnimationRange(name: string): Nullable<AnimationRange>;
  80532. /**
  80533. * Gets the list of all animation ranges defined on this skeleton
  80534. * @returns an array
  80535. */
  80536. getAnimationRanges(): Nullable<AnimationRange>[];
  80537. /**
  80538. * Copy animation range from a source skeleton.
  80539. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80540. * @param source defines the source skeleton
  80541. * @param name defines the name of the range to copy
  80542. * @param rescaleAsRequired defines if rescaling must be applied if required
  80543. * @returns true if operation was successful
  80544. */
  80545. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80546. /**
  80547. * Forces the skeleton to go to rest pose
  80548. */
  80549. returnToRest(): void;
  80550. private _getHighestAnimationFrame;
  80551. /**
  80552. * Begin a specific animation range
  80553. * @param name defines the name of the range to start
  80554. * @param loop defines if looping must be turned on (false by default)
  80555. * @param speedRatio defines the speed ratio to apply (1 by default)
  80556. * @param onAnimationEnd defines a callback which will be called when animation will end
  80557. * @returns a new animatable
  80558. */
  80559. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80560. /** @hidden */
  80561. _markAsDirty(): void;
  80562. /** @hidden */
  80563. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80564. /** @hidden */
  80565. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80566. private _computeTransformMatrices;
  80567. /**
  80568. * Build all resources required to render a skeleton
  80569. */
  80570. prepare(): void;
  80571. /**
  80572. * Gets the list of animatables currently running for this skeleton
  80573. * @returns an array of animatables
  80574. */
  80575. getAnimatables(): IAnimatable[];
  80576. /**
  80577. * Clone the current skeleton
  80578. * @param name defines the name of the new skeleton
  80579. * @param id defines the id of the new skeleton
  80580. * @returns the new skeleton
  80581. */
  80582. clone(name: string, id: string): Skeleton;
  80583. /**
  80584. * Enable animation blending for this skeleton
  80585. * @param blendingSpeed defines the blending speed to apply
  80586. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80587. */
  80588. enableBlending(blendingSpeed?: number): void;
  80589. /**
  80590. * Releases all resources associated with the current skeleton
  80591. */
  80592. dispose(): void;
  80593. /**
  80594. * Serialize the skeleton in a JSON object
  80595. * @returns a JSON object
  80596. */
  80597. serialize(): any;
  80598. /**
  80599. * Creates a new skeleton from serialized data
  80600. * @param parsedSkeleton defines the serialized data
  80601. * @param scene defines the hosting scene
  80602. * @returns a new skeleton
  80603. */
  80604. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80605. /**
  80606. * Compute all node absolute transforms
  80607. * @param forceUpdate defines if computation must be done even if cache is up to date
  80608. */
  80609. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80610. /**
  80611. * Gets the root pose matrix
  80612. * @returns a matrix
  80613. */
  80614. getPoseMatrix(): Nullable<Matrix>;
  80615. /**
  80616. * Sorts bones per internal index
  80617. */
  80618. sortBones(): void;
  80619. private _sortBones;
  80620. }
  80621. }
  80622. declare module BABYLON {
  80623. /**
  80624. * Class used to store bone information
  80625. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80626. */
  80627. export class Bone extends Node {
  80628. /**
  80629. * defines the bone name
  80630. */
  80631. name: string;
  80632. private static _tmpVecs;
  80633. private static _tmpQuat;
  80634. private static _tmpMats;
  80635. /**
  80636. * Gets the list of child bones
  80637. */
  80638. children: Bone[];
  80639. /** Gets the animations associated with this bone */
  80640. animations: Animation[];
  80641. /**
  80642. * Gets or sets bone length
  80643. */
  80644. length: number;
  80645. /**
  80646. * @hidden Internal only
  80647. * Set this value to map this bone to a different index in the transform matrices
  80648. * Set this value to -1 to exclude the bone from the transform matrices
  80649. */
  80650. _index: Nullable<number>;
  80651. private _skeleton;
  80652. private _localMatrix;
  80653. private _restPose;
  80654. private _baseMatrix;
  80655. private _absoluteTransform;
  80656. private _invertedAbsoluteTransform;
  80657. private _parent;
  80658. private _scalingDeterminant;
  80659. private _worldTransform;
  80660. private _localScaling;
  80661. private _localRotation;
  80662. private _localPosition;
  80663. private _needToDecompose;
  80664. private _needToCompose;
  80665. /** @hidden */
  80666. _linkedTransformNode: Nullable<TransformNode>;
  80667. /** @hidden */
  80668. _waitingTransformNodeId: Nullable<string>;
  80669. /** @hidden */
  80670. /** @hidden */
  80671. _matrix: Matrix;
  80672. /**
  80673. * Create a new bone
  80674. * @param name defines the bone name
  80675. * @param skeleton defines the parent skeleton
  80676. * @param parentBone defines the parent (can be null if the bone is the root)
  80677. * @param localMatrix defines the local matrix
  80678. * @param restPose defines the rest pose matrix
  80679. * @param baseMatrix defines the base matrix
  80680. * @param index defines index of the bone in the hiearchy
  80681. */
  80682. constructor(
  80683. /**
  80684. * defines the bone name
  80685. */
  80686. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80687. /**
  80688. * Gets the current object class name.
  80689. * @return the class name
  80690. */
  80691. getClassName(): string;
  80692. /**
  80693. * Gets the parent skeleton
  80694. * @returns a skeleton
  80695. */
  80696. getSkeleton(): Skeleton;
  80697. /**
  80698. * Gets parent bone
  80699. * @returns a bone or null if the bone is the root of the bone hierarchy
  80700. */
  80701. getParent(): Nullable<Bone>;
  80702. /**
  80703. * Returns an array containing the root bones
  80704. * @returns an array containing the root bones
  80705. */
  80706. getChildren(): Array<Bone>;
  80707. /**
  80708. * Sets the parent bone
  80709. * @param parent defines the parent (can be null if the bone is the root)
  80710. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80711. */
  80712. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80713. /**
  80714. * Gets the local matrix
  80715. * @returns a matrix
  80716. */
  80717. getLocalMatrix(): Matrix;
  80718. /**
  80719. * Gets the base matrix (initial matrix which remains unchanged)
  80720. * @returns a matrix
  80721. */
  80722. getBaseMatrix(): Matrix;
  80723. /**
  80724. * Gets the rest pose matrix
  80725. * @returns a matrix
  80726. */
  80727. getRestPose(): Matrix;
  80728. /**
  80729. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80730. */
  80731. getWorldMatrix(): Matrix;
  80732. /**
  80733. * Sets the local matrix to rest pose matrix
  80734. */
  80735. returnToRest(): void;
  80736. /**
  80737. * Gets the inverse of the absolute transform matrix.
  80738. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80739. * @returns a matrix
  80740. */
  80741. getInvertedAbsoluteTransform(): Matrix;
  80742. /**
  80743. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80744. * @returns a matrix
  80745. */
  80746. getAbsoluteTransform(): Matrix;
  80747. /**
  80748. * Links with the given transform node.
  80749. * The local matrix of this bone is copied from the transform node every frame.
  80750. * @param transformNode defines the transform node to link to
  80751. */
  80752. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80753. /**
  80754. * Gets the node used to drive the bone's transformation
  80755. * @returns a transform node or null
  80756. */
  80757. getTransformNode(): Nullable<TransformNode>;
  80758. /** Gets or sets current position (in local space) */
  80759. position: Vector3;
  80760. /** Gets or sets current rotation (in local space) */
  80761. rotation: Vector3;
  80762. /** Gets or sets current rotation quaternion (in local space) */
  80763. rotationQuaternion: Quaternion;
  80764. /** Gets or sets current scaling (in local space) */
  80765. scaling: Vector3;
  80766. /**
  80767. * Gets the animation properties override
  80768. */
  80769. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80770. private _decompose;
  80771. private _compose;
  80772. /**
  80773. * Update the base and local matrices
  80774. * @param matrix defines the new base or local matrix
  80775. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80776. * @param updateLocalMatrix defines if the local matrix should be updated
  80777. */
  80778. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80779. /** @hidden */
  80780. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80781. /**
  80782. * Flag the bone as dirty (Forcing it to update everything)
  80783. */
  80784. markAsDirty(): void;
  80785. /** @hidden */
  80786. _markAsDirtyAndCompose(): void;
  80787. private _markAsDirtyAndDecompose;
  80788. /**
  80789. * Translate the bone in local or world space
  80790. * @param vec The amount to translate the bone
  80791. * @param space The space that the translation is in
  80792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80793. */
  80794. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80795. /**
  80796. * Set the postion of the bone in local or world space
  80797. * @param position The position to set the bone
  80798. * @param space The space that the position is in
  80799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80800. */
  80801. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80802. /**
  80803. * Set the absolute position of the bone (world space)
  80804. * @param position The position to set the bone
  80805. * @param mesh The mesh that this bone is attached to
  80806. */
  80807. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80808. /**
  80809. * Scale the bone on the x, y and z axes (in local space)
  80810. * @param x The amount to scale the bone on the x axis
  80811. * @param y The amount to scale the bone on the y axis
  80812. * @param z The amount to scale the bone on the z axis
  80813. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80814. */
  80815. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80816. /**
  80817. * Set the bone scaling in local space
  80818. * @param scale defines the scaling vector
  80819. */
  80820. setScale(scale: Vector3): void;
  80821. /**
  80822. * Gets the current scaling in local space
  80823. * @returns the current scaling vector
  80824. */
  80825. getScale(): Vector3;
  80826. /**
  80827. * Gets the current scaling in local space and stores it in a target vector
  80828. * @param result defines the target vector
  80829. */
  80830. getScaleToRef(result: Vector3): void;
  80831. /**
  80832. * Set the yaw, pitch, and roll of the bone in local or world space
  80833. * @param yaw The rotation of the bone on the y axis
  80834. * @param pitch The rotation of the bone on the x axis
  80835. * @param roll The rotation of the bone on the z axis
  80836. * @param space The space that the axes of rotation are in
  80837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80838. */
  80839. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80840. /**
  80841. * Add a rotation to the bone on an axis in local or world space
  80842. * @param axis The axis to rotate the bone on
  80843. * @param amount The amount to rotate the bone
  80844. * @param space The space that the axis is in
  80845. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80846. */
  80847. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80848. /**
  80849. * Set the rotation of the bone to a particular axis angle in local or world space
  80850. * @param axis The axis to rotate the bone on
  80851. * @param angle The angle that the bone should be rotated to
  80852. * @param space The space that the axis is in
  80853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80854. */
  80855. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80856. /**
  80857. * Set the euler rotation of the bone in local of world space
  80858. * @param rotation The euler rotation that the bone should be set to
  80859. * @param space The space that the rotation is in
  80860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80861. */
  80862. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80863. /**
  80864. * Set the quaternion rotation of the bone in local of world space
  80865. * @param quat The quaternion rotation that the bone should be set to
  80866. * @param space The space that the rotation is in
  80867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80868. */
  80869. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80870. /**
  80871. * Set the rotation matrix of the bone in local of world space
  80872. * @param rotMat The rotation matrix that the bone should be set to
  80873. * @param space The space that the rotation is in
  80874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80875. */
  80876. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80877. private _rotateWithMatrix;
  80878. private _getNegativeRotationToRef;
  80879. /**
  80880. * Get the position of the bone in local or world space
  80881. * @param space The space that the returned position is in
  80882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80883. * @returns The position of the bone
  80884. */
  80885. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80886. /**
  80887. * Copy the position of the bone to a vector3 in local or world space
  80888. * @param space The space that the returned position is in
  80889. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80890. * @param result The vector3 to copy the position to
  80891. */
  80892. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80893. /**
  80894. * Get the absolute position of the bone (world space)
  80895. * @param mesh The mesh that this bone is attached to
  80896. * @returns The absolute position of the bone
  80897. */
  80898. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80899. /**
  80900. * Copy the absolute position of the bone (world space) to the result param
  80901. * @param mesh The mesh that this bone is attached to
  80902. * @param result The vector3 to copy the absolute position to
  80903. */
  80904. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80905. /**
  80906. * Compute the absolute transforms of this bone and its children
  80907. */
  80908. computeAbsoluteTransforms(): void;
  80909. /**
  80910. * Get the world direction from an axis that is in the local space of the bone
  80911. * @param localAxis The local direction that is used to compute the world direction
  80912. * @param mesh The mesh that this bone is attached to
  80913. * @returns The world direction
  80914. */
  80915. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80916. /**
  80917. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80918. * @param localAxis The local direction that is used to compute the world direction
  80919. * @param mesh The mesh that this bone is attached to
  80920. * @param result The vector3 that the world direction will be copied to
  80921. */
  80922. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80923. /**
  80924. * Get the euler rotation of the bone in local or world space
  80925. * @param space The space that the rotation should be in
  80926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80927. * @returns The euler rotation
  80928. */
  80929. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80930. /**
  80931. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80932. * @param space The space that the rotation should be in
  80933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80934. * @param result The vector3 that the rotation should be copied to
  80935. */
  80936. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80937. /**
  80938. * Get the quaternion rotation of the bone in either local or world space
  80939. * @param space The space that the rotation should be in
  80940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80941. * @returns The quaternion rotation
  80942. */
  80943. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80944. /**
  80945. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80946. * @param space The space that the rotation should be in
  80947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80948. * @param result The quaternion that the rotation should be copied to
  80949. */
  80950. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80951. /**
  80952. * Get the rotation matrix of the bone in local or world space
  80953. * @param space The space that the rotation should be in
  80954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80955. * @returns The rotation matrix
  80956. */
  80957. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80958. /**
  80959. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80960. * @param space The space that the rotation should be in
  80961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80962. * @param result The quaternion that the rotation should be copied to
  80963. */
  80964. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80965. /**
  80966. * Get the world position of a point that is in the local space of the bone
  80967. * @param position The local position
  80968. * @param mesh The mesh that this bone is attached to
  80969. * @returns The world position
  80970. */
  80971. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80972. /**
  80973. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80974. * @param position The local position
  80975. * @param mesh The mesh that this bone is attached to
  80976. * @param result The vector3 that the world position should be copied to
  80977. */
  80978. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80979. /**
  80980. * Get the local position of a point that is in world space
  80981. * @param position The world position
  80982. * @param mesh The mesh that this bone is attached to
  80983. * @returns The local position
  80984. */
  80985. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80986. /**
  80987. * Get the local position of a point that is in world space and copy it to the result param
  80988. * @param position The world position
  80989. * @param mesh The mesh that this bone is attached to
  80990. * @param result The vector3 that the local position should be copied to
  80991. */
  80992. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80993. }
  80994. }
  80995. declare module BABYLON {
  80996. /**
  80997. * 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.
  80998. * @see https://doc.babylonjs.com/how_to/transformnode
  80999. */
  81000. export class TransformNode extends Node {
  81001. /**
  81002. * Object will not rotate to face the camera
  81003. */
  81004. static BILLBOARDMODE_NONE: number;
  81005. /**
  81006. * Object will rotate to face the camera but only on the x axis
  81007. */
  81008. static BILLBOARDMODE_X: number;
  81009. /**
  81010. * Object will rotate to face the camera but only on the y axis
  81011. */
  81012. static BILLBOARDMODE_Y: number;
  81013. /**
  81014. * Object will rotate to face the camera but only on the z axis
  81015. */
  81016. static BILLBOARDMODE_Z: number;
  81017. /**
  81018. * Object will rotate to face the camera
  81019. */
  81020. static BILLBOARDMODE_ALL: number;
  81021. /**
  81022. * Object will rotate to face the camera's position instead of orientation
  81023. */
  81024. static BILLBOARDMODE_USE_POSITION: number;
  81025. private _forward;
  81026. private _forwardInverted;
  81027. private _up;
  81028. private _right;
  81029. private _rightInverted;
  81030. private _position;
  81031. private _rotation;
  81032. private _rotationQuaternion;
  81033. protected _scaling: Vector3;
  81034. protected _isDirty: boolean;
  81035. private _transformToBoneReferal;
  81036. private _isAbsoluteSynced;
  81037. private _billboardMode;
  81038. /**
  81039. * Gets or sets the billboard mode. Default is 0.
  81040. *
  81041. * | Value | Type | Description |
  81042. * | --- | --- | --- |
  81043. * | 0 | BILLBOARDMODE_NONE | |
  81044. * | 1 | BILLBOARDMODE_X | |
  81045. * | 2 | BILLBOARDMODE_Y | |
  81046. * | 4 | BILLBOARDMODE_Z | |
  81047. * | 7 | BILLBOARDMODE_ALL | |
  81048. *
  81049. */
  81050. billboardMode: number;
  81051. private _preserveParentRotationForBillboard;
  81052. /**
  81053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81055. */
  81056. preserveParentRotationForBillboard: boolean;
  81057. /**
  81058. * 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
  81059. */
  81060. scalingDeterminant: number;
  81061. private _infiniteDistance;
  81062. /**
  81063. * Gets or sets the distance of the object to max, often used by skybox
  81064. */
  81065. infiniteDistance: boolean;
  81066. /**
  81067. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81068. * By default the system will update normals to compensate
  81069. */
  81070. ignoreNonUniformScaling: boolean;
  81071. /**
  81072. * 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
  81073. */
  81074. reIntegrateRotationIntoRotationQuaternion: boolean;
  81075. /** @hidden */
  81076. _poseMatrix: Nullable<Matrix>;
  81077. /** @hidden */
  81078. _localMatrix: Matrix;
  81079. private _usePivotMatrix;
  81080. private _absolutePosition;
  81081. private _absoluteScaling;
  81082. private _absoluteRotationQuaternion;
  81083. private _pivotMatrix;
  81084. private _pivotMatrixInverse;
  81085. protected _postMultiplyPivotMatrix: boolean;
  81086. protected _isWorldMatrixFrozen: boolean;
  81087. /** @hidden */
  81088. _indexInSceneTransformNodesArray: number;
  81089. /**
  81090. * An event triggered after the world matrix is updated
  81091. */
  81092. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81093. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81094. /**
  81095. * Gets a string identifying the name of the class
  81096. * @returns "TransformNode" string
  81097. */
  81098. getClassName(): string;
  81099. /**
  81100. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81101. */
  81102. position: Vector3;
  81103. /**
  81104. * 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)).
  81105. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81106. */
  81107. rotation: Vector3;
  81108. /**
  81109. * 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)).
  81110. */
  81111. scaling: Vector3;
  81112. /**
  81113. * 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).
  81114. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81115. */
  81116. rotationQuaternion: Nullable<Quaternion>;
  81117. /**
  81118. * The forward direction of that transform in world space.
  81119. */
  81120. readonly forward: Vector3;
  81121. /**
  81122. * The up direction of that transform in world space.
  81123. */
  81124. readonly up: Vector3;
  81125. /**
  81126. * The right direction of that transform in world space.
  81127. */
  81128. readonly right: Vector3;
  81129. /**
  81130. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81131. * @param matrix the matrix to copy the pose from
  81132. * @returns this TransformNode.
  81133. */
  81134. updatePoseMatrix(matrix: Matrix): TransformNode;
  81135. /**
  81136. * Returns the mesh Pose matrix.
  81137. * @returns the pose matrix
  81138. */
  81139. getPoseMatrix(): Matrix;
  81140. /** @hidden */
  81141. _isSynchronized(): boolean;
  81142. /** @hidden */
  81143. _initCache(): void;
  81144. /**
  81145. * Flag the transform node as dirty (Forcing it to update everything)
  81146. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81147. * @returns this transform node
  81148. */
  81149. markAsDirty(property: string): TransformNode;
  81150. /**
  81151. * Returns the current mesh absolute position.
  81152. * Returns a Vector3.
  81153. */
  81154. readonly absolutePosition: Vector3;
  81155. /**
  81156. * Returns the current mesh absolute scaling.
  81157. * Returns a Vector3.
  81158. */
  81159. readonly absoluteScaling: Vector3;
  81160. /**
  81161. * Returns the current mesh absolute rotation.
  81162. * Returns a Quaternion.
  81163. */
  81164. readonly absoluteRotationQuaternion: Quaternion;
  81165. /**
  81166. * Sets a new matrix to apply before all other transformation
  81167. * @param matrix defines the transform matrix
  81168. * @returns the current TransformNode
  81169. */
  81170. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81171. /**
  81172. * Sets a new pivot matrix to the current node
  81173. * @param matrix defines the new pivot matrix to use
  81174. * @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
  81175. * @returns the current TransformNode
  81176. */
  81177. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81178. /**
  81179. * Returns the mesh pivot matrix.
  81180. * Default : Identity.
  81181. * @returns the matrix
  81182. */
  81183. getPivotMatrix(): Matrix;
  81184. /**
  81185. * Instantiate (when possible) or clone that node with its hierarchy
  81186. * @param newParent defines the new parent to use for the instance (or clone)
  81187. * @returns an instance (or a clone) of the current node with its hiearchy
  81188. */
  81189. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  81190. /**
  81191. * Prevents the World matrix to be computed any longer
  81192. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81193. * @returns the TransformNode.
  81194. */
  81195. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81196. /**
  81197. * Allows back the World matrix computation.
  81198. * @returns the TransformNode.
  81199. */
  81200. unfreezeWorldMatrix(): this;
  81201. /**
  81202. * True if the World matrix has been frozen.
  81203. */
  81204. readonly isWorldMatrixFrozen: boolean;
  81205. /**
  81206. * Retuns the mesh absolute position in the World.
  81207. * @returns a Vector3.
  81208. */
  81209. getAbsolutePosition(): Vector3;
  81210. /**
  81211. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81212. * @param absolutePosition the absolute position to set
  81213. * @returns the TransformNode.
  81214. */
  81215. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81216. /**
  81217. * Sets the mesh position in its local space.
  81218. * @param vector3 the position to set in localspace
  81219. * @returns the TransformNode.
  81220. */
  81221. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81222. /**
  81223. * Returns the mesh position in the local space from the current World matrix values.
  81224. * @returns a new Vector3.
  81225. */
  81226. getPositionExpressedInLocalSpace(): Vector3;
  81227. /**
  81228. * Translates the mesh along the passed Vector3 in its local space.
  81229. * @param vector3 the distance to translate in localspace
  81230. * @returns the TransformNode.
  81231. */
  81232. locallyTranslate(vector3: Vector3): TransformNode;
  81233. private static _lookAtVectorCache;
  81234. /**
  81235. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81236. * @param targetPoint the position (must be in same space as current mesh) to look at
  81237. * @param yawCor optional yaw (y-axis) correction in radians
  81238. * @param pitchCor optional pitch (x-axis) correction in radians
  81239. * @param rollCor optional roll (z-axis) correction in radians
  81240. * @param space the choosen space of the target
  81241. * @returns the TransformNode.
  81242. */
  81243. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81244. /**
  81245. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81246. * This Vector3 is expressed in the World space.
  81247. * @param localAxis axis to rotate
  81248. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81249. */
  81250. getDirection(localAxis: Vector3): Vector3;
  81251. /**
  81252. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81253. * localAxis is expressed in the mesh local space.
  81254. * result is computed in the Wordl space from the mesh World matrix.
  81255. * @param localAxis axis to rotate
  81256. * @param result the resulting transformnode
  81257. * @returns this TransformNode.
  81258. */
  81259. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81260. /**
  81261. * Sets this transform node rotation to the given local axis.
  81262. * @param localAxis the axis in local space
  81263. * @param yawCor optional yaw (y-axis) correction in radians
  81264. * @param pitchCor optional pitch (x-axis) correction in radians
  81265. * @param rollCor optional roll (z-axis) correction in radians
  81266. * @returns this TransformNode
  81267. */
  81268. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81269. /**
  81270. * Sets a new pivot point to the current node
  81271. * @param point defines the new pivot point to use
  81272. * @param space defines if the point is in world or local space (local by default)
  81273. * @returns the current TransformNode
  81274. */
  81275. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81276. /**
  81277. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81278. * @returns the pivot point
  81279. */
  81280. getPivotPoint(): Vector3;
  81281. /**
  81282. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81283. * @param result the vector3 to store the result
  81284. * @returns this TransformNode.
  81285. */
  81286. getPivotPointToRef(result: Vector3): TransformNode;
  81287. /**
  81288. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81289. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81290. */
  81291. getAbsolutePivotPoint(): Vector3;
  81292. /**
  81293. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81294. * @param result vector3 to store the result
  81295. * @returns this TransformNode.
  81296. */
  81297. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81298. /**
  81299. * Defines the passed node as the parent of the current node.
  81300. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81301. * @see https://doc.babylonjs.com/how_to/parenting
  81302. * @param node the node ot set as the parent
  81303. * @returns this TransformNode.
  81304. */
  81305. setParent(node: Nullable<Node>): TransformNode;
  81306. private _nonUniformScaling;
  81307. /**
  81308. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81309. */
  81310. readonly nonUniformScaling: boolean;
  81311. /** @hidden */
  81312. _updateNonUniformScalingState(value: boolean): boolean;
  81313. /**
  81314. * Attach the current TransformNode to another TransformNode associated with a bone
  81315. * @param bone Bone affecting the TransformNode
  81316. * @param affectedTransformNode TransformNode associated with the bone
  81317. * @returns this object
  81318. */
  81319. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81320. /**
  81321. * Detach the transform node if its associated with a bone
  81322. * @returns this object
  81323. */
  81324. detachFromBone(): TransformNode;
  81325. private static _rotationAxisCache;
  81326. /**
  81327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81328. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81329. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81330. * The passed axis is also normalized.
  81331. * @param axis the axis to rotate around
  81332. * @param amount the amount to rotate in radians
  81333. * @param space Space to rotate in (Default: local)
  81334. * @returns the TransformNode.
  81335. */
  81336. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81337. /**
  81338. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81339. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81340. * The passed axis is also normalized. .
  81341. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81342. * @param point the point to rotate around
  81343. * @param axis the axis to rotate around
  81344. * @param amount the amount to rotate in radians
  81345. * @returns the TransformNode
  81346. */
  81347. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81348. /**
  81349. * Translates the mesh along the axis vector for the passed distance in the given space.
  81350. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81351. * @param axis the axis to translate in
  81352. * @param distance the distance to translate
  81353. * @param space Space to rotate in (Default: local)
  81354. * @returns the TransformNode.
  81355. */
  81356. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81357. /**
  81358. * Adds a rotation step to the mesh current rotation.
  81359. * x, y, z are Euler angles expressed in radians.
  81360. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81361. * This means this rotation is made in the mesh local space only.
  81362. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81363. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81364. * ```javascript
  81365. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81366. * ```
  81367. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81368. * 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.
  81369. * @param x Rotation to add
  81370. * @param y Rotation to add
  81371. * @param z Rotation to add
  81372. * @returns the TransformNode.
  81373. */
  81374. addRotation(x: number, y: number, z: number): TransformNode;
  81375. /**
  81376. * @hidden
  81377. */
  81378. protected _getEffectiveParent(): Nullable<Node>;
  81379. /**
  81380. * Computes the world matrix of the node
  81381. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81382. * @returns the world matrix
  81383. */
  81384. computeWorldMatrix(force?: boolean): Matrix;
  81385. protected _afterComputeWorldMatrix(): void;
  81386. /**
  81387. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81388. * @param func callback function to add
  81389. *
  81390. * @returns the TransformNode.
  81391. */
  81392. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81393. /**
  81394. * Removes a registered callback function.
  81395. * @param func callback function to remove
  81396. * @returns the TransformNode.
  81397. */
  81398. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81399. /**
  81400. * Gets the position of the current mesh in camera space
  81401. * @param camera defines the camera to use
  81402. * @returns a position
  81403. */
  81404. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81405. /**
  81406. * Returns the distance from the mesh to the active camera
  81407. * @param camera defines the camera to use
  81408. * @returns the distance
  81409. */
  81410. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81411. /**
  81412. * Clone the current transform node
  81413. * @param name Name of the new clone
  81414. * @param newParent New parent for the clone
  81415. * @param doNotCloneChildren Do not clone children hierarchy
  81416. * @returns the new transform node
  81417. */
  81418. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81419. /**
  81420. * Serializes the objects information.
  81421. * @param currentSerializationObject defines the object to serialize in
  81422. * @returns the serialized object
  81423. */
  81424. serialize(currentSerializationObject?: any): any;
  81425. /**
  81426. * Returns a new TransformNode object parsed from the source provided.
  81427. * @param parsedTransformNode is the source.
  81428. * @param scene the scne the object belongs to
  81429. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81430. * @returns a new TransformNode object parsed from the source provided.
  81431. */
  81432. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81433. /**
  81434. * Get all child-transformNodes of this node
  81435. * @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
  81436. * @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
  81437. * @returns an array of TransformNode
  81438. */
  81439. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81440. /**
  81441. * Releases resources associated with this transform node.
  81442. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81443. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81444. */
  81445. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81446. /**
  81447. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81448. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81449. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81450. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81451. * @returns the current mesh
  81452. */
  81453. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81454. private _syncAbsoluteScalingAndRotation;
  81455. }
  81456. }
  81457. declare module BABYLON {
  81458. /**
  81459. * Defines the types of pose enabled controllers that are supported
  81460. */
  81461. export enum PoseEnabledControllerType {
  81462. /**
  81463. * HTC Vive
  81464. */
  81465. VIVE = 0,
  81466. /**
  81467. * Oculus Rift
  81468. */
  81469. OCULUS = 1,
  81470. /**
  81471. * Windows mixed reality
  81472. */
  81473. WINDOWS = 2,
  81474. /**
  81475. * Samsung gear VR
  81476. */
  81477. GEAR_VR = 3,
  81478. /**
  81479. * Google Daydream
  81480. */
  81481. DAYDREAM = 4,
  81482. /**
  81483. * Generic
  81484. */
  81485. GENERIC = 5
  81486. }
  81487. /**
  81488. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81489. */
  81490. export interface MutableGamepadButton {
  81491. /**
  81492. * Value of the button/trigger
  81493. */
  81494. value: number;
  81495. /**
  81496. * If the button/trigger is currently touched
  81497. */
  81498. touched: boolean;
  81499. /**
  81500. * If the button/trigger is currently pressed
  81501. */
  81502. pressed: boolean;
  81503. }
  81504. /**
  81505. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81506. * @hidden
  81507. */
  81508. export interface ExtendedGamepadButton extends GamepadButton {
  81509. /**
  81510. * If the button/trigger is currently pressed
  81511. */
  81512. readonly pressed: boolean;
  81513. /**
  81514. * If the button/trigger is currently touched
  81515. */
  81516. readonly touched: boolean;
  81517. /**
  81518. * Value of the button/trigger
  81519. */
  81520. readonly value: number;
  81521. }
  81522. /** @hidden */
  81523. export interface _GamePadFactory {
  81524. /**
  81525. * Returns wether or not the current gamepad can be created for this type of controller.
  81526. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81527. * @returns true if it can be created, otherwise false
  81528. */
  81529. canCreate(gamepadInfo: any): boolean;
  81530. /**
  81531. * Creates a new instance of the Gamepad.
  81532. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81533. * @returns the new gamepad instance
  81534. */
  81535. create(gamepadInfo: any): Gamepad;
  81536. }
  81537. /**
  81538. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81539. */
  81540. export class PoseEnabledControllerHelper {
  81541. /** @hidden */
  81542. static _ControllerFactories: _GamePadFactory[];
  81543. /** @hidden */
  81544. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81545. /**
  81546. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81547. * @param vrGamepad the gamepad to initialized
  81548. * @returns a vr controller of the type the gamepad identified as
  81549. */
  81550. static InitiateController(vrGamepad: any): Gamepad;
  81551. }
  81552. /**
  81553. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81554. */
  81555. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81556. /**
  81557. * If the controller is used in a webXR session
  81558. */
  81559. isXR: boolean;
  81560. private _deviceRoomPosition;
  81561. private _deviceRoomRotationQuaternion;
  81562. /**
  81563. * The device position in babylon space
  81564. */
  81565. devicePosition: Vector3;
  81566. /**
  81567. * The device rotation in babylon space
  81568. */
  81569. deviceRotationQuaternion: Quaternion;
  81570. /**
  81571. * The scale factor of the device in babylon space
  81572. */
  81573. deviceScaleFactor: number;
  81574. /**
  81575. * (Likely devicePosition should be used instead) The device position in its room space
  81576. */
  81577. position: Vector3;
  81578. /**
  81579. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81580. */
  81581. rotationQuaternion: Quaternion;
  81582. /**
  81583. * The type of controller (Eg. Windows mixed reality)
  81584. */
  81585. controllerType: PoseEnabledControllerType;
  81586. protected _calculatedPosition: Vector3;
  81587. private _calculatedRotation;
  81588. /**
  81589. * The raw pose from the device
  81590. */
  81591. rawPose: DevicePose;
  81592. private _trackPosition;
  81593. private _maxRotationDistFromHeadset;
  81594. private _draggedRoomRotation;
  81595. /**
  81596. * @hidden
  81597. */
  81598. _disableTrackPosition(fixedPosition: Vector3): void;
  81599. /**
  81600. * Internal, the mesh attached to the controller
  81601. * @hidden
  81602. */
  81603. _mesh: Nullable<AbstractMesh>;
  81604. private _poseControlledCamera;
  81605. private _leftHandSystemQuaternion;
  81606. /**
  81607. * Internal, matrix used to convert room space to babylon space
  81608. * @hidden
  81609. */
  81610. _deviceToWorld: Matrix;
  81611. /**
  81612. * Node to be used when casting a ray from the controller
  81613. * @hidden
  81614. */
  81615. _pointingPoseNode: Nullable<TransformNode>;
  81616. /**
  81617. * Name of the child mesh that can be used to cast a ray from the controller
  81618. */
  81619. static readonly POINTING_POSE: string;
  81620. /**
  81621. * Creates a new PoseEnabledController from a gamepad
  81622. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81623. */
  81624. constructor(browserGamepad: any);
  81625. private _workingMatrix;
  81626. /**
  81627. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81628. */
  81629. update(): void;
  81630. /**
  81631. * Updates only the pose device and mesh without doing any button event checking
  81632. */
  81633. protected _updatePoseAndMesh(): void;
  81634. /**
  81635. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81636. * @param poseData raw pose fromthe device
  81637. */
  81638. updateFromDevice(poseData: DevicePose): void;
  81639. /**
  81640. * @hidden
  81641. */
  81642. _meshAttachedObservable: Observable<AbstractMesh>;
  81643. /**
  81644. * Attaches a mesh to the controller
  81645. * @param mesh the mesh to be attached
  81646. */
  81647. attachToMesh(mesh: AbstractMesh): void;
  81648. /**
  81649. * Attaches the controllers mesh to a camera
  81650. * @param camera the camera the mesh should be attached to
  81651. */
  81652. attachToPoseControlledCamera(camera: TargetCamera): void;
  81653. /**
  81654. * Disposes of the controller
  81655. */
  81656. dispose(): void;
  81657. /**
  81658. * The mesh that is attached to the controller
  81659. */
  81660. readonly mesh: Nullable<AbstractMesh>;
  81661. /**
  81662. * Gets the ray of the controller in the direction the controller is pointing
  81663. * @param length the length the resulting ray should be
  81664. * @returns a ray in the direction the controller is pointing
  81665. */
  81666. getForwardRay(length?: number): Ray;
  81667. }
  81668. }
  81669. declare module BABYLON {
  81670. /**
  81671. * Defines the WebVRController object that represents controllers tracked in 3D space
  81672. */
  81673. export abstract class WebVRController extends PoseEnabledController {
  81674. /**
  81675. * Internal, the default controller model for the controller
  81676. */
  81677. protected _defaultModel: Nullable<AbstractMesh>;
  81678. /**
  81679. * Fired when the trigger state has changed
  81680. */
  81681. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81682. /**
  81683. * Fired when the main button state has changed
  81684. */
  81685. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81686. /**
  81687. * Fired when the secondary button state has changed
  81688. */
  81689. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81690. /**
  81691. * Fired when the pad state has changed
  81692. */
  81693. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81694. /**
  81695. * Fired when controllers stick values have changed
  81696. */
  81697. onPadValuesChangedObservable: Observable<StickValues>;
  81698. /**
  81699. * Array of button availible on the controller
  81700. */
  81701. protected _buttons: Array<MutableGamepadButton>;
  81702. private _onButtonStateChange;
  81703. /**
  81704. * Fired when a controller button's state has changed
  81705. * @param callback the callback containing the button that was modified
  81706. */
  81707. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81708. /**
  81709. * X and Y axis corresponding to the controllers joystick
  81710. */
  81711. pad: StickValues;
  81712. /**
  81713. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81714. */
  81715. hand: string;
  81716. /**
  81717. * The default controller model for the controller
  81718. */
  81719. readonly defaultModel: Nullable<AbstractMesh>;
  81720. /**
  81721. * Creates a new WebVRController from a gamepad
  81722. * @param vrGamepad the gamepad that the WebVRController should be created from
  81723. */
  81724. constructor(vrGamepad: any);
  81725. /**
  81726. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81727. */
  81728. update(): void;
  81729. /**
  81730. * Function to be called when a button is modified
  81731. */
  81732. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81733. /**
  81734. * Loads a mesh and attaches it to the controller
  81735. * @param scene the scene the mesh should be added to
  81736. * @param meshLoaded callback for when the mesh has been loaded
  81737. */
  81738. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81739. private _setButtonValue;
  81740. private _changes;
  81741. private _checkChanges;
  81742. /**
  81743. * Disposes of th webVRCOntroller
  81744. */
  81745. dispose(): void;
  81746. }
  81747. }
  81748. declare module BABYLON {
  81749. /**
  81750. * The HemisphericLight simulates the ambient environment light,
  81751. * so the passed direction is the light reflection direction, not the incoming direction.
  81752. */
  81753. export class HemisphericLight extends Light {
  81754. /**
  81755. * The groundColor is the light in the opposite direction to the one specified during creation.
  81756. * 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.
  81757. */
  81758. groundColor: Color3;
  81759. /**
  81760. * The light reflection direction, not the incoming direction.
  81761. */
  81762. direction: Vector3;
  81763. /**
  81764. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81765. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81766. * The HemisphericLight can't cast shadows.
  81767. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81768. * @param name The friendly name of the light
  81769. * @param direction The direction of the light reflection
  81770. * @param scene The scene the light belongs to
  81771. */
  81772. constructor(name: string, direction: Vector3, scene: Scene);
  81773. protected _buildUniformLayout(): void;
  81774. /**
  81775. * Returns the string "HemisphericLight".
  81776. * @return The class name
  81777. */
  81778. getClassName(): string;
  81779. /**
  81780. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81781. * Returns the updated direction.
  81782. * @param target The target the direction should point to
  81783. * @return The computed direction
  81784. */
  81785. setDirectionToTarget(target: Vector3): Vector3;
  81786. /**
  81787. * Returns the shadow generator associated to the light.
  81788. * @returns Always null for hemispheric lights because it does not support shadows.
  81789. */
  81790. getShadowGenerator(): Nullable<IShadowGenerator>;
  81791. /**
  81792. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81793. * @param effect The effect to update
  81794. * @param lightIndex The index of the light in the effect to update
  81795. * @returns The hemispheric light
  81796. */
  81797. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81798. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81799. /**
  81800. * Computes the world matrix of the node
  81801. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81802. * @param useWasUpdatedFlag defines a reserved property
  81803. * @returns the world matrix
  81804. */
  81805. computeWorldMatrix(): Matrix;
  81806. /**
  81807. * Returns the integer 3.
  81808. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81809. */
  81810. getTypeID(): number;
  81811. /**
  81812. * Prepares the list of defines specific to the light type.
  81813. * @param defines the list of defines
  81814. * @param lightIndex defines the index of the light for the effect
  81815. */
  81816. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81817. }
  81818. }
  81819. declare module BABYLON {
  81820. /** @hidden */
  81821. export var vrMultiviewToSingleviewPixelShader: {
  81822. name: string;
  81823. shader: string;
  81824. };
  81825. }
  81826. declare module BABYLON {
  81827. /**
  81828. * Renders to multiple views with a single draw call
  81829. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81830. */
  81831. export class MultiviewRenderTarget extends RenderTargetTexture {
  81832. /**
  81833. * Creates a multiview render target
  81834. * @param scene scene used with the render target
  81835. * @param size the size of the render target (used for each view)
  81836. */
  81837. constructor(scene: Scene, size?: number | {
  81838. width: number;
  81839. height: number;
  81840. } | {
  81841. ratio: number;
  81842. });
  81843. /**
  81844. * @hidden
  81845. * @param faceIndex the face index, if its a cube texture
  81846. */
  81847. _bindFrameBuffer(faceIndex?: number): void;
  81848. /**
  81849. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81850. * @returns the view count
  81851. */
  81852. getViewCount(): number;
  81853. }
  81854. }
  81855. declare module BABYLON {
  81856. /**
  81857. * Represents a camera frustum
  81858. */
  81859. export class Frustum {
  81860. /**
  81861. * Gets the planes representing the frustum
  81862. * @param transform matrix to be applied to the returned planes
  81863. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81864. */
  81865. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81866. /**
  81867. * Gets the near frustum plane transformed by the transform matrix
  81868. * @param transform transformation matrix to be applied to the resulting frustum plane
  81869. * @param frustumPlane the resuling frustum plane
  81870. */
  81871. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81872. /**
  81873. * Gets the far frustum plane transformed by the transform matrix
  81874. * @param transform transformation matrix to be applied to the resulting frustum plane
  81875. * @param frustumPlane the resuling frustum plane
  81876. */
  81877. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81878. /**
  81879. * Gets the left frustum plane transformed by the transform matrix
  81880. * @param transform transformation matrix to be applied to the resulting frustum plane
  81881. * @param frustumPlane the resuling frustum plane
  81882. */
  81883. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81884. /**
  81885. * Gets the right frustum plane transformed by the transform matrix
  81886. * @param transform transformation matrix to be applied to the resulting frustum plane
  81887. * @param frustumPlane the resuling frustum plane
  81888. */
  81889. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81890. /**
  81891. * Gets the top frustum plane transformed by the transform matrix
  81892. * @param transform transformation matrix to be applied to the resulting frustum plane
  81893. * @param frustumPlane the resuling frustum plane
  81894. */
  81895. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81896. /**
  81897. * Gets the bottom frustum plane transformed by the transform matrix
  81898. * @param transform transformation matrix to be applied to the resulting frustum plane
  81899. * @param frustumPlane the resuling frustum plane
  81900. */
  81901. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81902. /**
  81903. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81904. * @param transform transformation matrix to be applied to the resulting frustum planes
  81905. * @param frustumPlanes the resuling frustum planes
  81906. */
  81907. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81908. }
  81909. }
  81910. declare module BABYLON {
  81911. interface Engine {
  81912. /**
  81913. * Creates a new multiview render target
  81914. * @param width defines the width of the texture
  81915. * @param height defines the height of the texture
  81916. * @returns the created multiview texture
  81917. */
  81918. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81919. /**
  81920. * Binds a multiview framebuffer to be drawn to
  81921. * @param multiviewTexture texture to bind
  81922. */
  81923. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81924. }
  81925. interface Camera {
  81926. /**
  81927. * @hidden
  81928. * 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)
  81929. */
  81930. _useMultiviewToSingleView: boolean;
  81931. /**
  81932. * @hidden
  81933. * 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)
  81934. */
  81935. _multiviewTexture: Nullable<RenderTargetTexture>;
  81936. /**
  81937. * @hidden
  81938. * ensures the multiview texture of the camera exists and has the specified width/height
  81939. * @param width height to set on the multiview texture
  81940. * @param height width to set on the multiview texture
  81941. */
  81942. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81943. }
  81944. interface Scene {
  81945. /** @hidden */
  81946. _transformMatrixR: Matrix;
  81947. /** @hidden */
  81948. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81949. /** @hidden */
  81950. _createMultiviewUbo(): void;
  81951. /** @hidden */
  81952. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81953. /** @hidden */
  81954. _renderMultiviewToSingleView(camera: Camera): void;
  81955. }
  81956. }
  81957. declare module BABYLON {
  81958. /**
  81959. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81960. * This will not be used for webXR as it supports displaying texture arrays directly
  81961. */
  81962. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81963. /**
  81964. * Initializes a VRMultiviewToSingleview
  81965. * @param name name of the post process
  81966. * @param camera camera to be applied to
  81967. * @param scaleFactor scaling factor to the size of the output texture
  81968. */
  81969. constructor(name: string, camera: Camera, scaleFactor: number);
  81970. }
  81971. }
  81972. declare module BABYLON {
  81973. interface Engine {
  81974. /** @hidden */
  81975. _vrDisplay: any;
  81976. /** @hidden */
  81977. _vrSupported: boolean;
  81978. /** @hidden */
  81979. _oldSize: Size;
  81980. /** @hidden */
  81981. _oldHardwareScaleFactor: number;
  81982. /** @hidden */
  81983. _vrExclusivePointerMode: boolean;
  81984. /** @hidden */
  81985. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81986. /** @hidden */
  81987. _onVRDisplayPointerRestricted: () => void;
  81988. /** @hidden */
  81989. _onVRDisplayPointerUnrestricted: () => void;
  81990. /** @hidden */
  81991. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81992. /** @hidden */
  81993. _onVrDisplayDisconnect: Nullable<() => void>;
  81994. /** @hidden */
  81995. _onVrDisplayPresentChange: Nullable<() => void>;
  81996. /**
  81997. * Observable signaled when VR display mode changes
  81998. */
  81999. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82000. /**
  82001. * Observable signaled when VR request present is complete
  82002. */
  82003. onVRRequestPresentComplete: Observable<boolean>;
  82004. /**
  82005. * Observable signaled when VR request present starts
  82006. */
  82007. onVRRequestPresentStart: Observable<Engine>;
  82008. /**
  82009. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82010. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82011. */
  82012. isInVRExclusivePointerMode: boolean;
  82013. /**
  82014. * Gets a boolean indicating if a webVR device was detected
  82015. * @returns true if a webVR device was detected
  82016. */
  82017. isVRDevicePresent(): boolean;
  82018. /**
  82019. * Gets the current webVR device
  82020. * @returns the current webVR device (or null)
  82021. */
  82022. getVRDevice(): any;
  82023. /**
  82024. * Initializes a webVR display and starts listening to display change events
  82025. * The onVRDisplayChangedObservable will be notified upon these changes
  82026. * @returns A promise containing a VRDisplay and if vr is supported
  82027. */
  82028. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82029. /** @hidden */
  82030. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82031. /**
  82032. * Call this function to switch to webVR mode
  82033. * Will do nothing if webVR is not supported or if there is no webVR device
  82034. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82035. */
  82036. enableVR(): void;
  82037. /** @hidden */
  82038. _onVRFullScreenTriggered(): void;
  82039. }
  82040. }
  82041. declare module BABYLON {
  82042. /**
  82043. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82044. * IMPORTANT!! The data is right-hand data.
  82045. * @export
  82046. * @interface DevicePose
  82047. */
  82048. export interface DevicePose {
  82049. /**
  82050. * The position of the device, values in array are [x,y,z].
  82051. */
  82052. readonly position: Nullable<Float32Array>;
  82053. /**
  82054. * The linearVelocity of the device, values in array are [x,y,z].
  82055. */
  82056. readonly linearVelocity: Nullable<Float32Array>;
  82057. /**
  82058. * The linearAcceleration of the device, values in array are [x,y,z].
  82059. */
  82060. readonly linearAcceleration: Nullable<Float32Array>;
  82061. /**
  82062. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82063. */
  82064. readonly orientation: Nullable<Float32Array>;
  82065. /**
  82066. * The angularVelocity of the device, values in array are [x,y,z].
  82067. */
  82068. readonly angularVelocity: Nullable<Float32Array>;
  82069. /**
  82070. * The angularAcceleration of the device, values in array are [x,y,z].
  82071. */
  82072. readonly angularAcceleration: Nullable<Float32Array>;
  82073. }
  82074. /**
  82075. * Interface representing a pose controlled object in Babylon.
  82076. * A pose controlled object has both regular pose values as well as pose values
  82077. * from an external device such as a VR head mounted display
  82078. */
  82079. export interface PoseControlled {
  82080. /**
  82081. * The position of the object in babylon space.
  82082. */
  82083. position: Vector3;
  82084. /**
  82085. * The rotation quaternion of the object in babylon space.
  82086. */
  82087. rotationQuaternion: Quaternion;
  82088. /**
  82089. * The position of the device in babylon space.
  82090. */
  82091. devicePosition?: Vector3;
  82092. /**
  82093. * The rotation quaternion of the device in babylon space.
  82094. */
  82095. deviceRotationQuaternion: Quaternion;
  82096. /**
  82097. * The raw pose coming from the device.
  82098. */
  82099. rawPose: Nullable<DevicePose>;
  82100. /**
  82101. * The scale of the device to be used when translating from device space to babylon space.
  82102. */
  82103. deviceScaleFactor: number;
  82104. /**
  82105. * Updates the poseControlled values based on the input device pose.
  82106. * @param poseData the pose data to update the object with
  82107. */
  82108. updateFromDevice(poseData: DevicePose): void;
  82109. }
  82110. /**
  82111. * Set of options to customize the webVRCamera
  82112. */
  82113. export interface WebVROptions {
  82114. /**
  82115. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82116. */
  82117. trackPosition?: boolean;
  82118. /**
  82119. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82120. */
  82121. positionScale?: number;
  82122. /**
  82123. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82124. */
  82125. displayName?: string;
  82126. /**
  82127. * Should the native controller meshes be initialized. (default: true)
  82128. */
  82129. controllerMeshes?: boolean;
  82130. /**
  82131. * Creating a default HemiLight only on controllers. (default: true)
  82132. */
  82133. defaultLightingOnControllers?: boolean;
  82134. /**
  82135. * If you don't want to use the default VR button of the helper. (default: false)
  82136. */
  82137. useCustomVRButton?: boolean;
  82138. /**
  82139. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82140. */
  82141. customVRButton?: HTMLButtonElement;
  82142. /**
  82143. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82144. */
  82145. rayLength?: number;
  82146. /**
  82147. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82148. */
  82149. defaultHeight?: number;
  82150. /**
  82151. * If multiview should be used if availible (default: false)
  82152. */
  82153. useMultiview?: boolean;
  82154. }
  82155. /**
  82156. * This represents a WebVR camera.
  82157. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82158. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82159. */
  82160. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82161. private webVROptions;
  82162. /**
  82163. * @hidden
  82164. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82165. */
  82166. _vrDevice: any;
  82167. /**
  82168. * The rawPose of the vrDevice.
  82169. */
  82170. rawPose: Nullable<DevicePose>;
  82171. private _onVREnabled;
  82172. private _specsVersion;
  82173. private _attached;
  82174. private _frameData;
  82175. protected _descendants: Array<Node>;
  82176. private _deviceRoomPosition;
  82177. /** @hidden */
  82178. _deviceRoomRotationQuaternion: Quaternion;
  82179. private _standingMatrix;
  82180. /**
  82181. * Represents device position in babylon space.
  82182. */
  82183. devicePosition: Vector3;
  82184. /**
  82185. * Represents device rotation in babylon space.
  82186. */
  82187. deviceRotationQuaternion: Quaternion;
  82188. /**
  82189. * The scale of the device to be used when translating from device space to babylon space.
  82190. */
  82191. deviceScaleFactor: number;
  82192. private _deviceToWorld;
  82193. private _worldToDevice;
  82194. /**
  82195. * References to the webVR controllers for the vrDevice.
  82196. */
  82197. controllers: Array<WebVRController>;
  82198. /**
  82199. * Emits an event when a controller is attached.
  82200. */
  82201. onControllersAttachedObservable: Observable<WebVRController[]>;
  82202. /**
  82203. * Emits an event when a controller's mesh has been loaded;
  82204. */
  82205. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82206. /**
  82207. * Emits an event when the HMD's pose has been updated.
  82208. */
  82209. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82210. private _poseSet;
  82211. /**
  82212. * If the rig cameras be used as parent instead of this camera.
  82213. */
  82214. rigParenting: boolean;
  82215. private _lightOnControllers;
  82216. private _defaultHeight?;
  82217. /**
  82218. * Instantiates a WebVRFreeCamera.
  82219. * @param name The name of the WebVRFreeCamera
  82220. * @param position The starting anchor position for the camera
  82221. * @param scene The scene the camera belongs to
  82222. * @param webVROptions a set of customizable options for the webVRCamera
  82223. */
  82224. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82225. /**
  82226. * Gets the device distance from the ground in meters.
  82227. * @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.
  82228. */
  82229. deviceDistanceToRoomGround(): number;
  82230. /**
  82231. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82232. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82233. */
  82234. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82235. /**
  82236. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82237. * @returns A promise with a boolean set to if the standing matrix is supported.
  82238. */
  82239. useStandingMatrixAsync(): Promise<boolean>;
  82240. /**
  82241. * Disposes the camera
  82242. */
  82243. dispose(): void;
  82244. /**
  82245. * Gets a vrController by name.
  82246. * @param name The name of the controller to retreive
  82247. * @returns the controller matching the name specified or null if not found
  82248. */
  82249. getControllerByName(name: string): Nullable<WebVRController>;
  82250. private _leftController;
  82251. /**
  82252. * The controller corresponding to the users left hand.
  82253. */
  82254. readonly leftController: Nullable<WebVRController>;
  82255. private _rightController;
  82256. /**
  82257. * The controller corresponding to the users right hand.
  82258. */
  82259. readonly rightController: Nullable<WebVRController>;
  82260. /**
  82261. * Casts a ray forward from the vrCamera's gaze.
  82262. * @param length Length of the ray (default: 100)
  82263. * @returns the ray corresponding to the gaze
  82264. */
  82265. getForwardRay(length?: number): Ray;
  82266. /**
  82267. * @hidden
  82268. * Updates the camera based on device's frame data
  82269. */
  82270. _checkInputs(): void;
  82271. /**
  82272. * Updates the poseControlled values based on the input device pose.
  82273. * @param poseData Pose coming from the device
  82274. */
  82275. updateFromDevice(poseData: DevicePose): void;
  82276. private _htmlElementAttached;
  82277. private _detachIfAttached;
  82278. /**
  82279. * WebVR's attach control will start broadcasting frames to the device.
  82280. * Note that in certain browsers (chrome for example) this function must be called
  82281. * within a user-interaction callback. Example:
  82282. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82283. *
  82284. * @param element html element to attach the vrDevice to
  82285. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82286. */
  82287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82288. /**
  82289. * Detaches the camera from the html element and disables VR
  82290. *
  82291. * @param element html element to detach from
  82292. */
  82293. detachControl(element: HTMLElement): void;
  82294. /**
  82295. * @returns the name of this class
  82296. */
  82297. getClassName(): string;
  82298. /**
  82299. * Calls resetPose on the vrDisplay
  82300. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82301. */
  82302. resetToCurrentRotation(): void;
  82303. /**
  82304. * @hidden
  82305. * Updates the rig cameras (left and right eye)
  82306. */
  82307. _updateRigCameras(): void;
  82308. private _workingVector;
  82309. private _oneVector;
  82310. private _workingMatrix;
  82311. private updateCacheCalled;
  82312. private _correctPositionIfNotTrackPosition;
  82313. /**
  82314. * @hidden
  82315. * Updates the cached values of the camera
  82316. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82317. */
  82318. _updateCache(ignoreParentClass?: boolean): void;
  82319. /**
  82320. * @hidden
  82321. * Get current device position in babylon world
  82322. */
  82323. _computeDevicePosition(): void;
  82324. /**
  82325. * Updates the current device position and rotation in the babylon world
  82326. */
  82327. update(): void;
  82328. /**
  82329. * @hidden
  82330. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82331. * @returns an identity matrix
  82332. */
  82333. _getViewMatrix(): Matrix;
  82334. private _tmpMatrix;
  82335. /**
  82336. * This function is called by the two RIG cameras.
  82337. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82338. * @hidden
  82339. */
  82340. _getWebVRViewMatrix(): Matrix;
  82341. /** @hidden */
  82342. _getWebVRProjectionMatrix(): Matrix;
  82343. private _onGamepadConnectedObserver;
  82344. private _onGamepadDisconnectedObserver;
  82345. private _updateCacheWhenTrackingDisabledObserver;
  82346. /**
  82347. * Initializes the controllers and their meshes
  82348. */
  82349. initControllers(): void;
  82350. }
  82351. }
  82352. declare module BABYLON {
  82353. /**
  82354. * Size options for a post process
  82355. */
  82356. export type PostProcessOptions = {
  82357. width: number;
  82358. height: number;
  82359. };
  82360. /**
  82361. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82362. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82363. */
  82364. export class PostProcess {
  82365. /** Name of the PostProcess. */
  82366. name: string;
  82367. /**
  82368. * Gets or sets the unique id of the post process
  82369. */
  82370. uniqueId: number;
  82371. /**
  82372. * Width of the texture to apply the post process on
  82373. */
  82374. width: number;
  82375. /**
  82376. * Height of the texture to apply the post process on
  82377. */
  82378. height: number;
  82379. /**
  82380. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82381. * @hidden
  82382. */
  82383. _outputTexture: Nullable<InternalTexture>;
  82384. /**
  82385. * Sampling mode used by the shader
  82386. * See https://doc.babylonjs.com/classes/3.1/texture
  82387. */
  82388. renderTargetSamplingMode: number;
  82389. /**
  82390. * Clear color to use when screen clearing
  82391. */
  82392. clearColor: Color4;
  82393. /**
  82394. * If the buffer needs to be cleared before applying the post process. (default: true)
  82395. * Should be set to false if shader will overwrite all previous pixels.
  82396. */
  82397. autoClear: boolean;
  82398. /**
  82399. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82400. */
  82401. alphaMode: number;
  82402. /**
  82403. * Sets the setAlphaBlendConstants of the babylon engine
  82404. */
  82405. alphaConstants: Color4;
  82406. /**
  82407. * Animations to be used for the post processing
  82408. */
  82409. animations: Animation[];
  82410. /**
  82411. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82412. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82413. */
  82414. enablePixelPerfectMode: boolean;
  82415. /**
  82416. * Force the postprocess to be applied without taking in account viewport
  82417. */
  82418. forceFullscreenViewport: boolean;
  82419. /**
  82420. * List of inspectable custom properties (used by the Inspector)
  82421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82422. */
  82423. inspectableCustomProperties: IInspectable[];
  82424. /**
  82425. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82426. *
  82427. * | Value | Type | Description |
  82428. * | ----- | ----------------------------------- | ----------- |
  82429. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82430. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82431. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82432. *
  82433. */
  82434. scaleMode: number;
  82435. /**
  82436. * Force textures to be a power of two (default: false)
  82437. */
  82438. alwaysForcePOT: boolean;
  82439. private _samples;
  82440. /**
  82441. * Number of sample textures (default: 1)
  82442. */
  82443. samples: number;
  82444. /**
  82445. * Modify the scale of the post process to be the same as the viewport (default: false)
  82446. */
  82447. adaptScaleToCurrentViewport: boolean;
  82448. private _camera;
  82449. private _scene;
  82450. private _engine;
  82451. private _options;
  82452. private _reusable;
  82453. private _textureType;
  82454. /**
  82455. * Smart array of input and output textures for the post process.
  82456. * @hidden
  82457. */
  82458. _textures: SmartArray<InternalTexture>;
  82459. /**
  82460. * The index in _textures that corresponds to the output texture.
  82461. * @hidden
  82462. */
  82463. _currentRenderTextureInd: number;
  82464. private _effect;
  82465. private _samplers;
  82466. private _fragmentUrl;
  82467. private _vertexUrl;
  82468. private _parameters;
  82469. private _scaleRatio;
  82470. protected _indexParameters: any;
  82471. private _shareOutputWithPostProcess;
  82472. private _texelSize;
  82473. private _forcedOutputTexture;
  82474. /**
  82475. * Returns the fragment url or shader name used in the post process.
  82476. * @returns the fragment url or name in the shader store.
  82477. */
  82478. getEffectName(): string;
  82479. /**
  82480. * An event triggered when the postprocess is activated.
  82481. */
  82482. onActivateObservable: Observable<Camera>;
  82483. private _onActivateObserver;
  82484. /**
  82485. * A function that is added to the onActivateObservable
  82486. */
  82487. onActivate: Nullable<(camera: Camera) => void>;
  82488. /**
  82489. * An event triggered when the postprocess changes its size.
  82490. */
  82491. onSizeChangedObservable: Observable<PostProcess>;
  82492. private _onSizeChangedObserver;
  82493. /**
  82494. * A function that is added to the onSizeChangedObservable
  82495. */
  82496. onSizeChanged: (postProcess: PostProcess) => void;
  82497. /**
  82498. * An event triggered when the postprocess applies its effect.
  82499. */
  82500. onApplyObservable: Observable<Effect>;
  82501. private _onApplyObserver;
  82502. /**
  82503. * A function that is added to the onApplyObservable
  82504. */
  82505. onApply: (effect: Effect) => void;
  82506. /**
  82507. * An event triggered before rendering the postprocess
  82508. */
  82509. onBeforeRenderObservable: Observable<Effect>;
  82510. private _onBeforeRenderObserver;
  82511. /**
  82512. * A function that is added to the onBeforeRenderObservable
  82513. */
  82514. onBeforeRender: (effect: Effect) => void;
  82515. /**
  82516. * An event triggered after rendering the postprocess
  82517. */
  82518. onAfterRenderObservable: Observable<Effect>;
  82519. private _onAfterRenderObserver;
  82520. /**
  82521. * A function that is added to the onAfterRenderObservable
  82522. */
  82523. onAfterRender: (efect: Effect) => void;
  82524. /**
  82525. * 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
  82526. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82527. */
  82528. inputTexture: InternalTexture;
  82529. /**
  82530. * Gets the camera which post process is applied to.
  82531. * @returns The camera the post process is applied to.
  82532. */
  82533. getCamera(): Camera;
  82534. /**
  82535. * Gets the texel size of the postprocess.
  82536. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82537. */
  82538. readonly texelSize: Vector2;
  82539. /**
  82540. * Creates a new instance PostProcess
  82541. * @param name The name of the PostProcess.
  82542. * @param fragmentUrl The url of the fragment shader to be used.
  82543. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82544. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82545. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82546. * @param camera The camera to apply the render pass to.
  82547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82548. * @param engine The engine which the post process will be applied. (default: current engine)
  82549. * @param reusable If the post process can be reused on the same frame. (default: false)
  82550. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82551. * @param textureType Type of textures used when performing the post process. (default: 0)
  82552. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82553. * @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
  82554. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82555. */
  82556. constructor(
  82557. /** Name of the PostProcess. */
  82558. 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);
  82559. /**
  82560. * Gets a string idenfifying the name of the class
  82561. * @returns "PostProcess" string
  82562. */
  82563. getClassName(): string;
  82564. /**
  82565. * Gets the engine which this post process belongs to.
  82566. * @returns The engine the post process was enabled with.
  82567. */
  82568. getEngine(): Engine;
  82569. /**
  82570. * The effect that is created when initializing the post process.
  82571. * @returns The created effect corresponding the the postprocess.
  82572. */
  82573. getEffect(): Effect;
  82574. /**
  82575. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82576. * @param postProcess The post process to share the output with.
  82577. * @returns This post process.
  82578. */
  82579. shareOutputWith(postProcess: PostProcess): PostProcess;
  82580. /**
  82581. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82582. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82583. */
  82584. useOwnOutput(): void;
  82585. /**
  82586. * Updates the effect with the current post process compile time values and recompiles the shader.
  82587. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82588. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82589. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82590. * @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
  82591. * @param onCompiled Called when the shader has been compiled.
  82592. * @param onError Called if there is an error when compiling a shader.
  82593. */
  82594. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82595. /**
  82596. * The post process is reusable if it can be used multiple times within one frame.
  82597. * @returns If the post process is reusable
  82598. */
  82599. isReusable(): boolean;
  82600. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82601. markTextureDirty(): void;
  82602. /**
  82603. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82604. * 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.
  82605. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82606. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82607. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82608. * @returns The target texture that was bound to be written to.
  82609. */
  82610. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82611. /**
  82612. * If the post process is supported.
  82613. */
  82614. readonly isSupported: boolean;
  82615. /**
  82616. * The aspect ratio of the output texture.
  82617. */
  82618. readonly aspectRatio: number;
  82619. /**
  82620. * Get a value indicating if the post-process is ready to be used
  82621. * @returns true if the post-process is ready (shader is compiled)
  82622. */
  82623. isReady(): boolean;
  82624. /**
  82625. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82626. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82627. */
  82628. apply(): Nullable<Effect>;
  82629. private _disposeTextures;
  82630. /**
  82631. * Disposes the post process.
  82632. * @param camera The camera to dispose the post process on.
  82633. */
  82634. dispose(camera?: Camera): void;
  82635. }
  82636. }
  82637. declare module BABYLON {
  82638. /** @hidden */
  82639. export var kernelBlurVaryingDeclaration: {
  82640. name: string;
  82641. shader: string;
  82642. };
  82643. }
  82644. declare module BABYLON {
  82645. /** @hidden */
  82646. export var kernelBlurFragment: {
  82647. name: string;
  82648. shader: string;
  82649. };
  82650. }
  82651. declare module BABYLON {
  82652. /** @hidden */
  82653. export var kernelBlurFragment2: {
  82654. name: string;
  82655. shader: string;
  82656. };
  82657. }
  82658. declare module BABYLON {
  82659. /** @hidden */
  82660. export var kernelBlurPixelShader: {
  82661. name: string;
  82662. shader: string;
  82663. };
  82664. }
  82665. declare module BABYLON {
  82666. /** @hidden */
  82667. export var kernelBlurVertex: {
  82668. name: string;
  82669. shader: string;
  82670. };
  82671. }
  82672. declare module BABYLON {
  82673. /** @hidden */
  82674. export var kernelBlurVertexShader: {
  82675. name: string;
  82676. shader: string;
  82677. };
  82678. }
  82679. declare module BABYLON {
  82680. /**
  82681. * The Blur Post Process which blurs an image based on a kernel and direction.
  82682. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82683. */
  82684. export class BlurPostProcess extends PostProcess {
  82685. /** The direction in which to blur the image. */
  82686. direction: Vector2;
  82687. private blockCompilation;
  82688. protected _kernel: number;
  82689. protected _idealKernel: number;
  82690. protected _packedFloat: boolean;
  82691. private _staticDefines;
  82692. /**
  82693. * Sets the length in pixels of the blur sample region
  82694. */
  82695. /**
  82696. * Gets the length in pixels of the blur sample region
  82697. */
  82698. kernel: number;
  82699. /**
  82700. * Sets wether or not the blur needs to unpack/repack floats
  82701. */
  82702. /**
  82703. * Gets wether or not the blur is unpacking/repacking floats
  82704. */
  82705. packedFloat: boolean;
  82706. /**
  82707. * Creates a new instance BlurPostProcess
  82708. * @param name The name of the effect.
  82709. * @param direction The direction in which to blur the image.
  82710. * @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.
  82711. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82712. * @param camera The camera to apply the render pass to.
  82713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82714. * @param engine The engine which the post process will be applied. (default: current engine)
  82715. * @param reusable If the post process can be reused on the same frame. (default: false)
  82716. * @param textureType Type of textures used when performing the post process. (default: 0)
  82717. * @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)
  82718. */
  82719. constructor(name: string,
  82720. /** The direction in which to blur the image. */
  82721. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82722. /**
  82723. * Updates the effect with the current post process compile time values and recompiles the shader.
  82724. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82725. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82726. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82727. * @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
  82728. * @param onCompiled Called when the shader has been compiled.
  82729. * @param onError Called if there is an error when compiling a shader.
  82730. */
  82731. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82732. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82733. /**
  82734. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82735. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82736. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82737. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82738. * The gaps between physical kernels are compensated for in the weighting of the samples
  82739. * @param idealKernel Ideal blur kernel.
  82740. * @return Nearest best kernel.
  82741. */
  82742. protected _nearestBestKernel(idealKernel: number): number;
  82743. /**
  82744. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82745. * @param x The point on the Gaussian distribution to sample.
  82746. * @return the value of the Gaussian function at x.
  82747. */
  82748. protected _gaussianWeight(x: number): number;
  82749. /**
  82750. * Generates a string that can be used as a floating point number in GLSL.
  82751. * @param x Value to print.
  82752. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82753. * @return GLSL float string.
  82754. */
  82755. protected _glslFloat(x: number, decimalFigures?: number): string;
  82756. }
  82757. }
  82758. declare module BABYLON {
  82759. /**
  82760. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82761. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82762. * You can then easily use it as a reflectionTexture on a flat surface.
  82763. * In case the surface is not a plane, please consider relying on reflection probes.
  82764. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82765. */
  82766. export class MirrorTexture extends RenderTargetTexture {
  82767. private scene;
  82768. /**
  82769. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82770. * 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.
  82771. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82772. */
  82773. mirrorPlane: Plane;
  82774. /**
  82775. * Define the blur ratio used to blur the reflection if needed.
  82776. */
  82777. blurRatio: number;
  82778. /**
  82779. * Define the adaptive blur kernel used to blur the reflection if needed.
  82780. * This will autocompute the closest best match for the `blurKernel`
  82781. */
  82782. adaptiveBlurKernel: number;
  82783. /**
  82784. * Define the blur kernel used to blur the reflection if needed.
  82785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82786. */
  82787. blurKernel: number;
  82788. /**
  82789. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82790. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82791. */
  82792. blurKernelX: number;
  82793. /**
  82794. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82795. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82796. */
  82797. blurKernelY: number;
  82798. private _autoComputeBlurKernel;
  82799. protected _onRatioRescale(): void;
  82800. private _updateGammaSpace;
  82801. private _imageProcessingConfigChangeObserver;
  82802. private _transformMatrix;
  82803. private _mirrorMatrix;
  82804. private _savedViewMatrix;
  82805. private _blurX;
  82806. private _blurY;
  82807. private _adaptiveBlurKernel;
  82808. private _blurKernelX;
  82809. private _blurKernelY;
  82810. private _blurRatio;
  82811. /**
  82812. * Instantiates a Mirror Texture.
  82813. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82814. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82815. * You can then easily use it as a reflectionTexture on a flat surface.
  82816. * In case the surface is not a plane, please consider relying on reflection probes.
  82817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82818. * @param name
  82819. * @param size
  82820. * @param scene
  82821. * @param generateMipMaps
  82822. * @param type
  82823. * @param samplingMode
  82824. * @param generateDepthBuffer
  82825. */
  82826. constructor(name: string, size: number | {
  82827. width: number;
  82828. height: number;
  82829. } | {
  82830. ratio: number;
  82831. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82832. private _preparePostProcesses;
  82833. /**
  82834. * Clone the mirror texture.
  82835. * @returns the cloned texture
  82836. */
  82837. clone(): MirrorTexture;
  82838. /**
  82839. * Serialize the texture to a JSON representation you could use in Parse later on
  82840. * @returns the serialized JSON representation
  82841. */
  82842. serialize(): any;
  82843. /**
  82844. * Dispose the texture and release its associated resources.
  82845. */
  82846. dispose(): void;
  82847. }
  82848. }
  82849. declare module BABYLON {
  82850. /**
  82851. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82852. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82853. */
  82854. export class Texture extends BaseTexture {
  82855. /**
  82856. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82857. */
  82858. static SerializeBuffers: boolean;
  82859. /** @hidden */
  82860. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82861. /** @hidden */
  82862. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82863. /** @hidden */
  82864. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82865. /** nearest is mag = nearest and min = nearest and mip = linear */
  82866. static readonly NEAREST_SAMPLINGMODE: number;
  82867. /** nearest is mag = nearest and min = nearest and mip = linear */
  82868. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82870. static readonly BILINEAR_SAMPLINGMODE: number;
  82871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82872. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82873. /** Trilinear is mag = linear and min = linear and mip = linear */
  82874. static readonly TRILINEAR_SAMPLINGMODE: number;
  82875. /** Trilinear is mag = linear and min = linear and mip = linear */
  82876. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82877. /** mag = nearest and min = nearest and mip = nearest */
  82878. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82879. /** mag = nearest and min = linear and mip = nearest */
  82880. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82881. /** mag = nearest and min = linear and mip = linear */
  82882. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82883. /** mag = nearest and min = linear and mip = none */
  82884. static readonly NEAREST_LINEAR: number;
  82885. /** mag = nearest and min = nearest and mip = none */
  82886. static readonly NEAREST_NEAREST: number;
  82887. /** mag = linear and min = nearest and mip = nearest */
  82888. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82889. /** mag = linear and min = nearest and mip = linear */
  82890. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82891. /** mag = linear and min = linear and mip = none */
  82892. static readonly LINEAR_LINEAR: number;
  82893. /** mag = linear and min = nearest and mip = none */
  82894. static readonly LINEAR_NEAREST: number;
  82895. /** Explicit coordinates mode */
  82896. static readonly EXPLICIT_MODE: number;
  82897. /** Spherical coordinates mode */
  82898. static readonly SPHERICAL_MODE: number;
  82899. /** Planar coordinates mode */
  82900. static readonly PLANAR_MODE: number;
  82901. /** Cubic coordinates mode */
  82902. static readonly CUBIC_MODE: number;
  82903. /** Projection coordinates mode */
  82904. static readonly PROJECTION_MODE: number;
  82905. /** Inverse Cubic coordinates mode */
  82906. static readonly SKYBOX_MODE: number;
  82907. /** Inverse Cubic coordinates mode */
  82908. static readonly INVCUBIC_MODE: number;
  82909. /** Equirectangular coordinates mode */
  82910. static readonly EQUIRECTANGULAR_MODE: number;
  82911. /** Equirectangular Fixed coordinates mode */
  82912. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82913. /** Equirectangular Fixed Mirrored coordinates mode */
  82914. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82915. /** Texture is not repeating outside of 0..1 UVs */
  82916. static readonly CLAMP_ADDRESSMODE: number;
  82917. /** Texture is repeating outside of 0..1 UVs */
  82918. static readonly WRAP_ADDRESSMODE: number;
  82919. /** Texture is repeating and mirrored */
  82920. static readonly MIRROR_ADDRESSMODE: number;
  82921. /**
  82922. * 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
  82923. */
  82924. static UseSerializedUrlIfAny: boolean;
  82925. /**
  82926. * Define the url of the texture.
  82927. */
  82928. url: Nullable<string>;
  82929. /**
  82930. * Define an offset on the texture to offset the u coordinates of the UVs
  82931. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82932. */
  82933. uOffset: number;
  82934. /**
  82935. * Define an offset on the texture to offset the v coordinates of the UVs
  82936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82937. */
  82938. vOffset: number;
  82939. /**
  82940. * Define an offset on the texture to scale the u coordinates of the UVs
  82941. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82942. */
  82943. uScale: number;
  82944. /**
  82945. * Define an offset on the texture to scale the v coordinates of the UVs
  82946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82947. */
  82948. vScale: number;
  82949. /**
  82950. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82951. * @see http://doc.babylonjs.com/how_to/more_materials
  82952. */
  82953. uAng: number;
  82954. /**
  82955. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82956. * @see http://doc.babylonjs.com/how_to/more_materials
  82957. */
  82958. vAng: number;
  82959. /**
  82960. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82961. * @see http://doc.babylonjs.com/how_to/more_materials
  82962. */
  82963. wAng: number;
  82964. /**
  82965. * Defines the center of rotation (U)
  82966. */
  82967. uRotationCenter: number;
  82968. /**
  82969. * Defines the center of rotation (V)
  82970. */
  82971. vRotationCenter: number;
  82972. /**
  82973. * Defines the center of rotation (W)
  82974. */
  82975. wRotationCenter: number;
  82976. /**
  82977. * Are mip maps generated for this texture or not.
  82978. */
  82979. readonly noMipmap: boolean;
  82980. /**
  82981. * List of inspectable custom properties (used by the Inspector)
  82982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82983. */
  82984. inspectableCustomProperties: Nullable<IInspectable[]>;
  82985. private _noMipmap;
  82986. /** @hidden */
  82987. _invertY: boolean;
  82988. private _rowGenerationMatrix;
  82989. private _cachedTextureMatrix;
  82990. private _projectionModeMatrix;
  82991. private _t0;
  82992. private _t1;
  82993. private _t2;
  82994. private _cachedUOffset;
  82995. private _cachedVOffset;
  82996. private _cachedUScale;
  82997. private _cachedVScale;
  82998. private _cachedUAng;
  82999. private _cachedVAng;
  83000. private _cachedWAng;
  83001. private _cachedProjectionMatrixId;
  83002. private _cachedCoordinatesMode;
  83003. /** @hidden */
  83004. protected _initialSamplingMode: number;
  83005. /** @hidden */
  83006. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83007. private _deleteBuffer;
  83008. protected _format: Nullable<number>;
  83009. private _delayedOnLoad;
  83010. private _delayedOnError;
  83011. private _mimeType?;
  83012. /**
  83013. * Observable triggered once the texture has been loaded.
  83014. */
  83015. onLoadObservable: Observable<Texture>;
  83016. protected _isBlocking: boolean;
  83017. /**
  83018. * Is the texture preventing material to render while loading.
  83019. * If false, a default texture will be used instead of the loading one during the preparation step.
  83020. */
  83021. isBlocking: boolean;
  83022. /**
  83023. * Get the current sampling mode associated with the texture.
  83024. */
  83025. readonly samplingMode: number;
  83026. /**
  83027. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83028. */
  83029. readonly invertY: boolean;
  83030. /**
  83031. * Instantiates a new texture.
  83032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83033. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83034. * @param url defines the url of the picture to load as a texture
  83035. * @param scene defines the scene or engine the texture will belong to
  83036. * @param noMipmap defines if the texture will require mip maps or not
  83037. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83038. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83039. * @param onLoad defines a callback triggered when the texture has been loaded
  83040. * @param onError defines a callback triggered when an error occurred during the loading session
  83041. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83042. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83043. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83044. * @param mimeType defines an optional mime type information
  83045. */
  83046. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83047. /**
  83048. * Update the url (and optional buffer) of this texture if url was null during construction.
  83049. * @param url the url of the texture
  83050. * @param buffer the buffer of the texture (defaults to null)
  83051. * @param onLoad callback called when the texture is loaded (defaults to null)
  83052. */
  83053. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83054. /**
  83055. * Finish the loading sequence of a texture flagged as delayed load.
  83056. * @hidden
  83057. */
  83058. delayLoad(): void;
  83059. private _prepareRowForTextureGeneration;
  83060. /**
  83061. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83062. * @returns the transform matrix of the texture.
  83063. */
  83064. getTextureMatrix(): Matrix;
  83065. /**
  83066. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83067. * @returns The reflection texture transform
  83068. */
  83069. getReflectionTextureMatrix(): Matrix;
  83070. /**
  83071. * Clones the texture.
  83072. * @returns the cloned texture
  83073. */
  83074. clone(): Texture;
  83075. /**
  83076. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83077. * @returns The JSON representation of the texture
  83078. */
  83079. serialize(): any;
  83080. /**
  83081. * Get the current class name of the texture useful for serialization or dynamic coding.
  83082. * @returns "Texture"
  83083. */
  83084. getClassName(): string;
  83085. /**
  83086. * Dispose the texture and release its associated resources.
  83087. */
  83088. dispose(): void;
  83089. /**
  83090. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83091. * @param parsedTexture Define the JSON representation of the texture
  83092. * @param scene Define the scene the parsed texture should be instantiated in
  83093. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83094. * @returns The parsed texture if successful
  83095. */
  83096. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83097. /**
  83098. * Creates a texture from its base 64 representation.
  83099. * @param data Define the base64 payload without the data: prefix
  83100. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83101. * @param scene Define the scene the texture should belong to
  83102. * @param noMipmap Forces the texture to not create mip map information if true
  83103. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83104. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83105. * @param onLoad define a callback triggered when the texture has been loaded
  83106. * @param onError define a callback triggered when an error occurred during the loading session
  83107. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83108. * @returns the created texture
  83109. */
  83110. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83111. /**
  83112. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83113. * @param data Define the base64 payload without the data: prefix
  83114. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83115. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83116. * @param scene Define the scene the texture should belong to
  83117. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83118. * @param noMipmap Forces the texture to not create mip map information if true
  83119. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83120. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83121. * @param onLoad define a callback triggered when the texture has been loaded
  83122. * @param onError define a callback triggered when an error occurred during the loading session
  83123. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83124. * @returns the created texture
  83125. */
  83126. 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;
  83127. }
  83128. }
  83129. declare module BABYLON {
  83130. /**
  83131. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83132. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83133. */
  83134. export class PostProcessManager {
  83135. private _scene;
  83136. private _indexBuffer;
  83137. private _vertexBuffers;
  83138. /**
  83139. * Creates a new instance PostProcess
  83140. * @param scene The scene that the post process is associated with.
  83141. */
  83142. constructor(scene: Scene);
  83143. private _prepareBuffers;
  83144. private _buildIndexBuffer;
  83145. /**
  83146. * Rebuilds the vertex buffers of the manager.
  83147. * @hidden
  83148. */
  83149. _rebuild(): void;
  83150. /**
  83151. * Prepares a frame to be run through a post process.
  83152. * @param sourceTexture The input texture to the post procesess. (default: null)
  83153. * @param postProcesses An array of post processes to be run. (default: null)
  83154. * @returns True if the post processes were able to be run.
  83155. * @hidden
  83156. */
  83157. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83158. /**
  83159. * Manually render a set of post processes to a texture.
  83160. * @param postProcesses An array of post processes to be run.
  83161. * @param targetTexture The target texture to render to.
  83162. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83163. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83164. * @param lodLevel defines which lod of the texture to render to
  83165. */
  83166. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83167. /**
  83168. * Finalize the result of the output of the postprocesses.
  83169. * @param doNotPresent If true the result will not be displayed to the screen.
  83170. * @param targetTexture The target texture to render to.
  83171. * @param faceIndex The index of the face to bind the target texture to.
  83172. * @param postProcesses The array of post processes to render.
  83173. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83174. * @hidden
  83175. */
  83176. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83177. /**
  83178. * Disposes of the post process manager.
  83179. */
  83180. dispose(): void;
  83181. }
  83182. }
  83183. declare module BABYLON {
  83184. /** Interface used by value gradients (color, factor, ...) */
  83185. export interface IValueGradient {
  83186. /**
  83187. * Gets or sets the gradient value (between 0 and 1)
  83188. */
  83189. gradient: number;
  83190. }
  83191. /** Class used to store color4 gradient */
  83192. export class ColorGradient implements IValueGradient {
  83193. /**
  83194. * Gets or sets the gradient value (between 0 and 1)
  83195. */
  83196. gradient: number;
  83197. /**
  83198. * Gets or sets first associated color
  83199. */
  83200. color1: Color4;
  83201. /**
  83202. * Gets or sets second associated color
  83203. */
  83204. color2?: Color4;
  83205. /**
  83206. * Will get a color picked randomly between color1 and color2.
  83207. * If color2 is undefined then color1 will be used
  83208. * @param result defines the target Color4 to store the result in
  83209. */
  83210. getColorToRef(result: Color4): void;
  83211. }
  83212. /** Class used to store color 3 gradient */
  83213. export class Color3Gradient implements IValueGradient {
  83214. /**
  83215. * Gets or sets the gradient value (between 0 and 1)
  83216. */
  83217. gradient: number;
  83218. /**
  83219. * Gets or sets the associated color
  83220. */
  83221. color: Color3;
  83222. }
  83223. /** Class used to store factor gradient */
  83224. export class FactorGradient implements IValueGradient {
  83225. /**
  83226. * Gets or sets the gradient value (between 0 and 1)
  83227. */
  83228. gradient: number;
  83229. /**
  83230. * Gets or sets first associated factor
  83231. */
  83232. factor1: number;
  83233. /**
  83234. * Gets or sets second associated factor
  83235. */
  83236. factor2?: number;
  83237. /**
  83238. * Will get a number picked randomly between factor1 and factor2.
  83239. * If factor2 is undefined then factor1 will be used
  83240. * @returns the picked number
  83241. */
  83242. getFactor(): number;
  83243. }
  83244. /**
  83245. * Helper used to simplify some generic gradient tasks
  83246. */
  83247. export class GradientHelper {
  83248. /**
  83249. * Gets the current gradient from an array of IValueGradient
  83250. * @param ratio defines the current ratio to get
  83251. * @param gradients defines the array of IValueGradient
  83252. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83253. */
  83254. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83255. }
  83256. }
  83257. declare module BABYLON {
  83258. interface ThinEngine {
  83259. /**
  83260. * Creates a dynamic texture
  83261. * @param width defines the width of the texture
  83262. * @param height defines the height of the texture
  83263. * @param generateMipMaps defines if the engine should generate the mip levels
  83264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83265. * @returns the dynamic texture inside an InternalTexture
  83266. */
  83267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83268. /**
  83269. * Update the content of a dynamic texture
  83270. * @param texture defines the texture to update
  83271. * @param canvas defines the canvas containing the source
  83272. * @param invertY defines if data must be stored with Y axis inverted
  83273. * @param premulAlpha defines if alpha is stored as premultiplied
  83274. * @param format defines the format of the data
  83275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83276. */
  83277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83278. }
  83279. }
  83280. declare module BABYLON {
  83281. /**
  83282. * Helper class used to generate a canvas to manipulate images
  83283. */
  83284. export class CanvasGenerator {
  83285. /**
  83286. * Create a new canvas (or offscreen canvas depending on the context)
  83287. * @param width defines the expected width
  83288. * @param height defines the expected height
  83289. * @return a new canvas or offscreen canvas
  83290. */
  83291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83292. }
  83293. }
  83294. declare module BABYLON {
  83295. /**
  83296. * A class extending Texture allowing drawing on a texture
  83297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83298. */
  83299. export class DynamicTexture extends Texture {
  83300. private _generateMipMaps;
  83301. private _canvas;
  83302. private _context;
  83303. private _engine;
  83304. /**
  83305. * Creates a DynamicTexture
  83306. * @param name defines the name of the texture
  83307. * @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
  83308. * @param scene defines the scene where you want the texture
  83309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83312. */
  83313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83314. /**
  83315. * Get the current class name of the texture useful for serialization or dynamic coding.
  83316. * @returns "DynamicTexture"
  83317. */
  83318. getClassName(): string;
  83319. /**
  83320. * Gets the current state of canRescale
  83321. */
  83322. readonly canRescale: boolean;
  83323. private _recreate;
  83324. /**
  83325. * Scales the texture
  83326. * @param ratio the scale factor to apply to both width and height
  83327. */
  83328. scale(ratio: number): void;
  83329. /**
  83330. * Resizes the texture
  83331. * @param width the new width
  83332. * @param height the new height
  83333. */
  83334. scaleTo(width: number, height: number): void;
  83335. /**
  83336. * Gets the context of the canvas used by the texture
  83337. * @returns the canvas context of the dynamic texture
  83338. */
  83339. getContext(): CanvasRenderingContext2D;
  83340. /**
  83341. * Clears the texture
  83342. */
  83343. clear(): void;
  83344. /**
  83345. * Updates the texture
  83346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83348. */
  83349. update(invertY?: boolean, premulAlpha?: boolean): void;
  83350. /**
  83351. * Draws text onto the texture
  83352. * @param text defines the text to be drawn
  83353. * @param x defines the placement of the text from the left
  83354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83355. * @param font defines the font to be used with font-style, font-size, font-name
  83356. * @param color defines the color used for the text
  83357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83359. * @param update defines whether texture is immediately update (default is true)
  83360. */
  83361. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83362. /**
  83363. * Clones the texture
  83364. * @returns the clone of the texture.
  83365. */
  83366. clone(): DynamicTexture;
  83367. /**
  83368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83369. * @returns a serialized dynamic texture object
  83370. */
  83371. serialize(): any;
  83372. /** @hidden */
  83373. _rebuild(): void;
  83374. }
  83375. }
  83376. declare module BABYLON {
  83377. interface AbstractScene {
  83378. /**
  83379. * The list of procedural textures added to the scene
  83380. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83381. */
  83382. proceduralTextures: Array<ProceduralTexture>;
  83383. }
  83384. /**
  83385. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83386. * in a given scene.
  83387. */
  83388. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83389. /**
  83390. * The component name helpfull to identify the component in the list of scene components.
  83391. */
  83392. readonly name: string;
  83393. /**
  83394. * The scene the component belongs to.
  83395. */
  83396. scene: Scene;
  83397. /**
  83398. * Creates a new instance of the component for the given scene
  83399. * @param scene Defines the scene to register the component in
  83400. */
  83401. constructor(scene: Scene);
  83402. /**
  83403. * Registers the component in a given scene
  83404. */
  83405. register(): void;
  83406. /**
  83407. * Rebuilds the elements related to this component in case of
  83408. * context lost for instance.
  83409. */
  83410. rebuild(): void;
  83411. /**
  83412. * Disposes the component and the associated ressources.
  83413. */
  83414. dispose(): void;
  83415. private _beforeClear;
  83416. }
  83417. }
  83418. declare module BABYLON {
  83419. interface ThinEngine {
  83420. /**
  83421. * Creates a new render target cube texture
  83422. * @param size defines the size of the texture
  83423. * @param options defines the options used to create the texture
  83424. * @returns a new render target cube texture stored in an InternalTexture
  83425. */
  83426. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83427. }
  83428. }
  83429. declare module BABYLON {
  83430. /** @hidden */
  83431. export var proceduralVertexShader: {
  83432. name: string;
  83433. shader: string;
  83434. };
  83435. }
  83436. declare module BABYLON {
  83437. /**
  83438. * 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.
  83439. * This is the base class of any Procedural texture and contains most of the shareable code.
  83440. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83441. */
  83442. export class ProceduralTexture extends Texture {
  83443. isCube: boolean;
  83444. /**
  83445. * Define if the texture is enabled or not (disabled texture will not render)
  83446. */
  83447. isEnabled: boolean;
  83448. /**
  83449. * Define if the texture must be cleared before rendering (default is true)
  83450. */
  83451. autoClear: boolean;
  83452. /**
  83453. * Callback called when the texture is generated
  83454. */
  83455. onGenerated: () => void;
  83456. /**
  83457. * Event raised when the texture is generated
  83458. */
  83459. onGeneratedObservable: Observable<ProceduralTexture>;
  83460. /** @hidden */
  83461. _generateMipMaps: boolean;
  83462. /** @hidden **/
  83463. _effect: Effect;
  83464. /** @hidden */
  83465. _textures: {
  83466. [key: string]: Texture;
  83467. };
  83468. private _size;
  83469. private _currentRefreshId;
  83470. private _refreshRate;
  83471. private _vertexBuffers;
  83472. private _indexBuffer;
  83473. private _uniforms;
  83474. private _samplers;
  83475. private _fragment;
  83476. private _floats;
  83477. private _ints;
  83478. private _floatsArrays;
  83479. private _colors3;
  83480. private _colors4;
  83481. private _vectors2;
  83482. private _vectors3;
  83483. private _matrices;
  83484. private _fallbackTexture;
  83485. private _fallbackTextureUsed;
  83486. private _engine;
  83487. private _cachedDefines;
  83488. private _contentUpdateId;
  83489. private _contentData;
  83490. /**
  83491. * Instantiates a new procedural texture.
  83492. * 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.
  83493. * This is the base class of any Procedural texture and contains most of the shareable code.
  83494. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83495. * @param name Define the name of the texture
  83496. * @param size Define the size of the texture to create
  83497. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83498. * @param scene Define the scene the texture belongs to
  83499. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83500. * @param generateMipMaps Define if the texture should creates mip maps or not
  83501. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83502. */
  83503. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83504. /**
  83505. * The effect that is created when initializing the post process.
  83506. * @returns The created effect corresponding the the postprocess.
  83507. */
  83508. getEffect(): Effect;
  83509. /**
  83510. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83511. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83512. */
  83513. getContent(): Nullable<ArrayBufferView>;
  83514. private _createIndexBuffer;
  83515. /** @hidden */
  83516. _rebuild(): void;
  83517. /**
  83518. * Resets the texture in order to recreate its associated resources.
  83519. * This can be called in case of context loss
  83520. */
  83521. reset(): void;
  83522. protected _getDefines(): string;
  83523. /**
  83524. * Is the texture ready to be used ? (rendered at least once)
  83525. * @returns true if ready, otherwise, false.
  83526. */
  83527. isReady(): boolean;
  83528. /**
  83529. * Resets the refresh counter of the texture and start bak from scratch.
  83530. * Could be useful to regenerate the texture if it is setup to render only once.
  83531. */
  83532. resetRefreshCounter(): void;
  83533. /**
  83534. * Set the fragment shader to use in order to render the texture.
  83535. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83536. */
  83537. setFragment(fragment: any): void;
  83538. /**
  83539. * Define the refresh rate of the texture or the rendering frequency.
  83540. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83541. */
  83542. refreshRate: number;
  83543. /** @hidden */
  83544. _shouldRender(): boolean;
  83545. /**
  83546. * Get the size the texture is rendering at.
  83547. * @returns the size (texture is always squared)
  83548. */
  83549. getRenderSize(): number;
  83550. /**
  83551. * Resize the texture to new value.
  83552. * @param size Define the new size the texture should have
  83553. * @param generateMipMaps Define whether the new texture should create mip maps
  83554. */
  83555. resize(size: number, generateMipMaps: boolean): void;
  83556. private _checkUniform;
  83557. /**
  83558. * Set a texture in the shader program used to render.
  83559. * @param name Define the name of the uniform samplers as defined in the shader
  83560. * @param texture Define the texture to bind to this sampler
  83561. * @return the texture itself allowing "fluent" like uniform updates
  83562. */
  83563. setTexture(name: string, texture: Texture): ProceduralTexture;
  83564. /**
  83565. * Set a float in the shader.
  83566. * @param name Define the name of the uniform as defined in the shader
  83567. * @param value Define the value to give to the uniform
  83568. * @return the texture itself allowing "fluent" like uniform updates
  83569. */
  83570. setFloat(name: string, value: number): ProceduralTexture;
  83571. /**
  83572. * Set a int in the shader.
  83573. * @param name Define the name of the uniform as defined in the shader
  83574. * @param value Define the value to give to the uniform
  83575. * @return the texture itself allowing "fluent" like uniform updates
  83576. */
  83577. setInt(name: string, value: number): ProceduralTexture;
  83578. /**
  83579. * Set an array of floats in the shader.
  83580. * @param name Define the name of the uniform as defined in the shader
  83581. * @param value Define the value to give to the uniform
  83582. * @return the texture itself allowing "fluent" like uniform updates
  83583. */
  83584. setFloats(name: string, value: number[]): ProceduralTexture;
  83585. /**
  83586. * Set a vec3 in the shader from a Color3.
  83587. * @param name Define the name of the uniform as defined in the shader
  83588. * @param value Define the value to give to the uniform
  83589. * @return the texture itself allowing "fluent" like uniform updates
  83590. */
  83591. setColor3(name: string, value: Color3): ProceduralTexture;
  83592. /**
  83593. * Set a vec4 in the shader from a Color4.
  83594. * @param name Define the name of the uniform as defined in the shader
  83595. * @param value Define the value to give to the uniform
  83596. * @return the texture itself allowing "fluent" like uniform updates
  83597. */
  83598. setColor4(name: string, value: Color4): ProceduralTexture;
  83599. /**
  83600. * Set a vec2 in the shader from a Vector2.
  83601. * @param name Define the name of the uniform as defined in the shader
  83602. * @param value Define the value to give to the uniform
  83603. * @return the texture itself allowing "fluent" like uniform updates
  83604. */
  83605. setVector2(name: string, value: Vector2): ProceduralTexture;
  83606. /**
  83607. * Set a vec3 in the shader from a Vector3.
  83608. * @param name Define the name of the uniform as defined in the shader
  83609. * @param value Define the value to give to the uniform
  83610. * @return the texture itself allowing "fluent" like uniform updates
  83611. */
  83612. setVector3(name: string, value: Vector3): ProceduralTexture;
  83613. /**
  83614. * Set a mat4 in the shader from a MAtrix.
  83615. * @param name Define the name of the uniform as defined in the shader
  83616. * @param value Define the value to give to the uniform
  83617. * @return the texture itself allowing "fluent" like uniform updates
  83618. */
  83619. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83620. /**
  83621. * Render the texture to its associated render target.
  83622. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83623. */
  83624. render(useCameraPostProcess?: boolean): void;
  83625. /**
  83626. * Clone the texture.
  83627. * @returns the cloned texture
  83628. */
  83629. clone(): ProceduralTexture;
  83630. /**
  83631. * Dispose the texture and release its asoociated resources.
  83632. */
  83633. dispose(): void;
  83634. }
  83635. }
  83636. declare module BABYLON {
  83637. /**
  83638. * This represents the base class for particle system in Babylon.
  83639. * 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.
  83640. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83641. * @example https://doc.babylonjs.com/babylon101/particles
  83642. */
  83643. export class BaseParticleSystem {
  83644. /**
  83645. * Source color is added to the destination color without alpha affecting the result
  83646. */
  83647. static BLENDMODE_ONEONE: number;
  83648. /**
  83649. * Blend current color and particle color using particle’s alpha
  83650. */
  83651. static BLENDMODE_STANDARD: number;
  83652. /**
  83653. * Add current color and particle color multiplied by particle’s alpha
  83654. */
  83655. static BLENDMODE_ADD: number;
  83656. /**
  83657. * Multiply current color with particle color
  83658. */
  83659. static BLENDMODE_MULTIPLY: number;
  83660. /**
  83661. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83662. */
  83663. static BLENDMODE_MULTIPLYADD: number;
  83664. /**
  83665. * List of animations used by the particle system.
  83666. */
  83667. animations: Animation[];
  83668. /**
  83669. * The id of the Particle system.
  83670. */
  83671. id: string;
  83672. /**
  83673. * The friendly name of the Particle system.
  83674. */
  83675. name: string;
  83676. /**
  83677. * The rendering group used by the Particle system to chose when to render.
  83678. */
  83679. renderingGroupId: number;
  83680. /**
  83681. * The emitter represents the Mesh or position we are attaching the particle system to.
  83682. */
  83683. emitter: Nullable<AbstractMesh | Vector3>;
  83684. /**
  83685. * The maximum number of particles to emit per frame
  83686. */
  83687. emitRate: number;
  83688. /**
  83689. * If you want to launch only a few particles at once, that can be done, as well.
  83690. */
  83691. manualEmitCount: number;
  83692. /**
  83693. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83694. */
  83695. updateSpeed: number;
  83696. /**
  83697. * The amount of time the particle system is running (depends of the overall update speed).
  83698. */
  83699. targetStopDuration: number;
  83700. /**
  83701. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83702. */
  83703. disposeOnStop: boolean;
  83704. /**
  83705. * Minimum power of emitting particles.
  83706. */
  83707. minEmitPower: number;
  83708. /**
  83709. * Maximum power of emitting particles.
  83710. */
  83711. maxEmitPower: number;
  83712. /**
  83713. * Minimum life time of emitting particles.
  83714. */
  83715. minLifeTime: number;
  83716. /**
  83717. * Maximum life time of emitting particles.
  83718. */
  83719. maxLifeTime: number;
  83720. /**
  83721. * Minimum Size of emitting particles.
  83722. */
  83723. minSize: number;
  83724. /**
  83725. * Maximum Size of emitting particles.
  83726. */
  83727. maxSize: number;
  83728. /**
  83729. * Minimum scale of emitting particles on X axis.
  83730. */
  83731. minScaleX: number;
  83732. /**
  83733. * Maximum scale of emitting particles on X axis.
  83734. */
  83735. maxScaleX: number;
  83736. /**
  83737. * Minimum scale of emitting particles on Y axis.
  83738. */
  83739. minScaleY: number;
  83740. /**
  83741. * Maximum scale of emitting particles on Y axis.
  83742. */
  83743. maxScaleY: number;
  83744. /**
  83745. * Gets or sets the minimal initial rotation in radians.
  83746. */
  83747. minInitialRotation: number;
  83748. /**
  83749. * Gets or sets the maximal initial rotation in radians.
  83750. */
  83751. maxInitialRotation: number;
  83752. /**
  83753. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83754. */
  83755. minAngularSpeed: number;
  83756. /**
  83757. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83758. */
  83759. maxAngularSpeed: number;
  83760. /**
  83761. * The texture used to render each particle. (this can be a spritesheet)
  83762. */
  83763. particleTexture: Nullable<Texture>;
  83764. /**
  83765. * The layer mask we are rendering the particles through.
  83766. */
  83767. layerMask: number;
  83768. /**
  83769. * This can help using your own shader to render the particle system.
  83770. * The according effect will be created
  83771. */
  83772. customShader: any;
  83773. /**
  83774. * By default particle system starts as soon as they are created. This prevents the
  83775. * automatic start to happen and let you decide when to start emitting particles.
  83776. */
  83777. preventAutoStart: boolean;
  83778. private _noiseTexture;
  83779. /**
  83780. * Gets or sets a texture used to add random noise to particle positions
  83781. */
  83782. noiseTexture: Nullable<ProceduralTexture>;
  83783. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83784. noiseStrength: Vector3;
  83785. /**
  83786. * Callback triggered when the particle animation is ending.
  83787. */
  83788. onAnimationEnd: Nullable<() => void>;
  83789. /**
  83790. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83791. */
  83792. blendMode: number;
  83793. /**
  83794. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83795. * to override the particles.
  83796. */
  83797. forceDepthWrite: boolean;
  83798. /** 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 */
  83799. preWarmCycles: number;
  83800. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83801. preWarmStepOffset: number;
  83802. /**
  83803. * 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)
  83804. */
  83805. spriteCellChangeSpeed: number;
  83806. /**
  83807. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83808. */
  83809. startSpriteCellID: number;
  83810. /**
  83811. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83812. */
  83813. endSpriteCellID: number;
  83814. /**
  83815. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83816. */
  83817. spriteCellWidth: number;
  83818. /**
  83819. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83820. */
  83821. spriteCellHeight: number;
  83822. /**
  83823. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83824. */
  83825. spriteRandomStartCell: boolean;
  83826. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83827. translationPivot: Vector2;
  83828. /** @hidden */
  83829. protected _isAnimationSheetEnabled: boolean;
  83830. /**
  83831. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83832. */
  83833. beginAnimationOnStart: boolean;
  83834. /**
  83835. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83836. */
  83837. beginAnimationFrom: number;
  83838. /**
  83839. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83840. */
  83841. beginAnimationTo: number;
  83842. /**
  83843. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83844. */
  83845. beginAnimationLoop: boolean;
  83846. /**
  83847. * Gets or sets a world offset applied to all particles
  83848. */
  83849. worldOffset: Vector3;
  83850. /**
  83851. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83852. */
  83853. isAnimationSheetEnabled: boolean;
  83854. /**
  83855. * Get hosting scene
  83856. * @returns the scene
  83857. */
  83858. getScene(): Scene;
  83859. /**
  83860. * You can use gravity if you want to give an orientation to your particles.
  83861. */
  83862. gravity: Vector3;
  83863. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83864. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83865. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83866. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83867. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83868. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83869. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83870. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83871. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83872. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83873. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83874. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83875. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83876. /**
  83877. * Defines the delay in milliseconds before starting the system (0 by default)
  83878. */
  83879. startDelay: number;
  83880. /**
  83881. * Gets the current list of drag gradients.
  83882. * You must use addDragGradient and removeDragGradient to udpate this list
  83883. * @returns the list of drag gradients
  83884. */
  83885. getDragGradients(): Nullable<Array<FactorGradient>>;
  83886. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83887. limitVelocityDamping: number;
  83888. /**
  83889. * Gets the current list of limit velocity gradients.
  83890. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83891. * @returns the list of limit velocity gradients
  83892. */
  83893. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83894. /**
  83895. * Gets the current list of color gradients.
  83896. * You must use addColorGradient and removeColorGradient to udpate this list
  83897. * @returns the list of color gradients
  83898. */
  83899. getColorGradients(): Nullable<Array<ColorGradient>>;
  83900. /**
  83901. * Gets the current list of size gradients.
  83902. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83903. * @returns the list of size gradients
  83904. */
  83905. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83906. /**
  83907. * Gets the current list of color remap gradients.
  83908. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83909. * @returns the list of color remap gradients
  83910. */
  83911. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83912. /**
  83913. * Gets the current list of alpha remap gradients.
  83914. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83915. * @returns the list of alpha remap gradients
  83916. */
  83917. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83918. /**
  83919. * Gets the current list of life time gradients.
  83920. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83921. * @returns the list of life time gradients
  83922. */
  83923. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83924. /**
  83925. * Gets the current list of angular speed gradients.
  83926. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83927. * @returns the list of angular speed gradients
  83928. */
  83929. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83930. /**
  83931. * Gets the current list of velocity gradients.
  83932. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83933. * @returns the list of velocity gradients
  83934. */
  83935. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83936. /**
  83937. * Gets the current list of start size gradients.
  83938. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83939. * @returns the list of start size gradients
  83940. */
  83941. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83942. /**
  83943. * Gets the current list of emit rate gradients.
  83944. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83945. * @returns the list of emit rate gradients
  83946. */
  83947. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83948. /**
  83949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83950. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83951. */
  83952. direction1: Vector3;
  83953. /**
  83954. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83955. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83956. */
  83957. direction2: Vector3;
  83958. /**
  83959. * 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.
  83960. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83961. */
  83962. minEmitBox: Vector3;
  83963. /**
  83964. * 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.
  83965. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83966. */
  83967. maxEmitBox: Vector3;
  83968. /**
  83969. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83970. */
  83971. color1: Color4;
  83972. /**
  83973. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83974. */
  83975. color2: Color4;
  83976. /**
  83977. * Color the particle will have at the end of its lifetime
  83978. */
  83979. colorDead: Color4;
  83980. /**
  83981. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83982. */
  83983. textureMask: Color4;
  83984. /**
  83985. * The particle emitter type defines the emitter used by the particle system.
  83986. * It can be for example box, sphere, or cone...
  83987. */
  83988. particleEmitterType: IParticleEmitterType;
  83989. /** @hidden */
  83990. _isSubEmitter: boolean;
  83991. /**
  83992. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83993. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83994. */
  83995. billboardMode: number;
  83996. protected _isBillboardBased: boolean;
  83997. /**
  83998. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83999. */
  84000. isBillboardBased: boolean;
  84001. /**
  84002. * The scene the particle system belongs to.
  84003. */
  84004. protected _scene: Scene;
  84005. /**
  84006. * Local cache of defines for image processing.
  84007. */
  84008. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84009. /**
  84010. * Default configuration related to image processing available in the standard Material.
  84011. */
  84012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84013. /**
  84014. * Gets the image processing configuration used either in this material.
  84015. */
  84016. /**
  84017. * Sets the Default image processing configuration used either in the this material.
  84018. *
  84019. * If sets to null, the scene one is in use.
  84020. */
  84021. imageProcessingConfiguration: ImageProcessingConfiguration;
  84022. /**
  84023. * Attaches a new image processing configuration to the Standard Material.
  84024. * @param configuration
  84025. */
  84026. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84027. /** @hidden */
  84028. protected _reset(): void;
  84029. /** @hidden */
  84030. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84031. /**
  84032. * Instantiates a particle system.
  84033. * 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.
  84034. * @param name The name of the particle system
  84035. */
  84036. constructor(name: string);
  84037. /**
  84038. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84039. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84040. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84041. * @returns the emitter
  84042. */
  84043. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84044. /**
  84045. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84046. * @param radius The radius of the hemisphere to emit from
  84047. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84048. * @returns the emitter
  84049. */
  84050. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84051. /**
  84052. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84053. * @param radius The radius of the sphere to emit from
  84054. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84055. * @returns the emitter
  84056. */
  84057. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84058. /**
  84059. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84060. * @param radius The radius of the sphere to emit from
  84061. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84062. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84063. * @returns the emitter
  84064. */
  84065. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84066. /**
  84067. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84068. * @param radius The radius of the emission cylinder
  84069. * @param height The height of the emission cylinder
  84070. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84071. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84072. * @returns the emitter
  84073. */
  84074. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84075. /**
  84076. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84077. * @param radius The radius of the cylinder to emit from
  84078. * @param height The height of the emission cylinder
  84079. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84080. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84081. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84082. * @returns the emitter
  84083. */
  84084. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84085. /**
  84086. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84087. * @param radius The radius of the cone to emit from
  84088. * @param angle The base angle of the cone
  84089. * @returns the emitter
  84090. */
  84091. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84092. /**
  84093. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84094. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84095. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84096. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84097. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84098. * @returns the emitter
  84099. */
  84100. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84101. }
  84102. }
  84103. declare module BABYLON {
  84104. /**
  84105. * Type of sub emitter
  84106. */
  84107. export enum SubEmitterType {
  84108. /**
  84109. * Attached to the particle over it's lifetime
  84110. */
  84111. ATTACHED = 0,
  84112. /**
  84113. * Created when the particle dies
  84114. */
  84115. END = 1
  84116. }
  84117. /**
  84118. * Sub emitter class used to emit particles from an existing particle
  84119. */
  84120. export class SubEmitter {
  84121. /**
  84122. * the particle system to be used by the sub emitter
  84123. */
  84124. particleSystem: ParticleSystem;
  84125. /**
  84126. * Type of the submitter (Default: END)
  84127. */
  84128. type: SubEmitterType;
  84129. /**
  84130. * 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)
  84131. * Note: This only is supported when using an emitter of type Mesh
  84132. */
  84133. inheritDirection: boolean;
  84134. /**
  84135. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84136. */
  84137. inheritedVelocityAmount: number;
  84138. /**
  84139. * Creates a sub emitter
  84140. * @param particleSystem the particle system to be used by the sub emitter
  84141. */
  84142. constructor(
  84143. /**
  84144. * the particle system to be used by the sub emitter
  84145. */
  84146. particleSystem: ParticleSystem);
  84147. /**
  84148. * Clones the sub emitter
  84149. * @returns the cloned sub emitter
  84150. */
  84151. clone(): SubEmitter;
  84152. /**
  84153. * Serialize current object to a JSON object
  84154. * @returns the serialized object
  84155. */
  84156. serialize(): any;
  84157. /** @hidden */
  84158. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84159. /**
  84160. * Creates a new SubEmitter from a serialized JSON version
  84161. * @param serializationObject defines the JSON object to read from
  84162. * @param scene defines the hosting scene
  84163. * @param rootUrl defines the rootUrl for data loading
  84164. * @returns a new SubEmitter
  84165. */
  84166. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84167. /** Release associated resources */
  84168. dispose(): void;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /** @hidden */
  84173. export var clipPlaneFragmentDeclaration: {
  84174. name: string;
  84175. shader: string;
  84176. };
  84177. }
  84178. declare module BABYLON {
  84179. /** @hidden */
  84180. export var imageProcessingDeclaration: {
  84181. name: string;
  84182. shader: string;
  84183. };
  84184. }
  84185. declare module BABYLON {
  84186. /** @hidden */
  84187. export var imageProcessingFunctions: {
  84188. name: string;
  84189. shader: string;
  84190. };
  84191. }
  84192. declare module BABYLON {
  84193. /** @hidden */
  84194. export var clipPlaneFragment: {
  84195. name: string;
  84196. shader: string;
  84197. };
  84198. }
  84199. declare module BABYLON {
  84200. /** @hidden */
  84201. export var particlesPixelShader: {
  84202. name: string;
  84203. shader: string;
  84204. };
  84205. }
  84206. declare module BABYLON {
  84207. /** @hidden */
  84208. export var clipPlaneVertexDeclaration: {
  84209. name: string;
  84210. shader: string;
  84211. };
  84212. }
  84213. declare module BABYLON {
  84214. /** @hidden */
  84215. export var clipPlaneVertex: {
  84216. name: string;
  84217. shader: string;
  84218. };
  84219. }
  84220. declare module BABYLON {
  84221. /** @hidden */
  84222. export var particlesVertexShader: {
  84223. name: string;
  84224. shader: string;
  84225. };
  84226. }
  84227. declare module BABYLON {
  84228. /**
  84229. * This represents a particle system in Babylon.
  84230. * 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.
  84231. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84232. * @example https://doc.babylonjs.com/babylon101/particles
  84233. */
  84234. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84235. /**
  84236. * Billboard mode will only apply to Y axis
  84237. */
  84238. static readonly BILLBOARDMODE_Y: number;
  84239. /**
  84240. * Billboard mode will apply to all axes
  84241. */
  84242. static readonly BILLBOARDMODE_ALL: number;
  84243. /**
  84244. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84245. */
  84246. static readonly BILLBOARDMODE_STRETCHED: number;
  84247. /**
  84248. * This function can be defined to provide custom update for active particles.
  84249. * This function will be called instead of regular update (age, position, color, etc.).
  84250. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84251. */
  84252. updateFunction: (particles: Particle[]) => void;
  84253. private _emitterWorldMatrix;
  84254. /**
  84255. * This function can be defined to specify initial direction for every new particle.
  84256. * It by default use the emitterType defined function
  84257. */
  84258. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84259. /**
  84260. * This function can be defined to specify initial position for every new particle.
  84261. * It by default use the emitterType defined function
  84262. */
  84263. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84264. /**
  84265. * @hidden
  84266. */
  84267. _inheritedVelocityOffset: Vector3;
  84268. /**
  84269. * An event triggered when the system is disposed
  84270. */
  84271. onDisposeObservable: Observable<ParticleSystem>;
  84272. private _onDisposeObserver;
  84273. /**
  84274. * Sets a callback that will be triggered when the system is disposed
  84275. */
  84276. onDispose: () => void;
  84277. private _particles;
  84278. private _epsilon;
  84279. private _capacity;
  84280. private _stockParticles;
  84281. private _newPartsExcess;
  84282. private _vertexData;
  84283. private _vertexBuffer;
  84284. private _vertexBuffers;
  84285. private _spriteBuffer;
  84286. private _indexBuffer;
  84287. private _effect;
  84288. private _customEffect;
  84289. private _cachedDefines;
  84290. private _scaledColorStep;
  84291. private _colorDiff;
  84292. private _scaledDirection;
  84293. private _scaledGravity;
  84294. private _currentRenderId;
  84295. private _alive;
  84296. private _useInstancing;
  84297. private _started;
  84298. private _stopped;
  84299. private _actualFrame;
  84300. private _scaledUpdateSpeed;
  84301. private _vertexBufferSize;
  84302. /** @hidden */
  84303. _currentEmitRateGradient: Nullable<FactorGradient>;
  84304. /** @hidden */
  84305. _currentEmitRate1: number;
  84306. /** @hidden */
  84307. _currentEmitRate2: number;
  84308. /** @hidden */
  84309. _currentStartSizeGradient: Nullable<FactorGradient>;
  84310. /** @hidden */
  84311. _currentStartSize1: number;
  84312. /** @hidden */
  84313. _currentStartSize2: number;
  84314. private readonly _rawTextureWidth;
  84315. private _rampGradientsTexture;
  84316. private _useRampGradients;
  84317. /** Gets or sets a boolean indicating that ramp gradients must be used
  84318. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84319. */
  84320. useRampGradients: boolean;
  84321. /**
  84322. * 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.
  84323. * 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: [])
  84324. */
  84325. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84326. private _subEmitters;
  84327. /**
  84328. * @hidden
  84329. * If the particle systems emitter should be disposed when the particle system is disposed
  84330. */
  84331. _disposeEmitterOnDispose: boolean;
  84332. /**
  84333. * The current active Sub-systems, this property is used by the root particle system only.
  84334. */
  84335. activeSubSystems: Array<ParticleSystem>;
  84336. private _rootParticleSystem;
  84337. /**
  84338. * Gets the current list of active particles
  84339. */
  84340. readonly particles: Particle[];
  84341. /**
  84342. * Returns the string "ParticleSystem"
  84343. * @returns a string containing the class name
  84344. */
  84345. getClassName(): string;
  84346. /**
  84347. * Instantiates a particle system.
  84348. * 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.
  84349. * @param name The name of the particle system
  84350. * @param capacity The max number of particles alive at the same time
  84351. * @param scene The scene the particle system belongs to
  84352. * @param customEffect a custom effect used to change the way particles are rendered by default
  84353. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84354. * @param epsilon Offset used to render the particles
  84355. */
  84356. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84357. private _addFactorGradient;
  84358. private _removeFactorGradient;
  84359. /**
  84360. * Adds a new life time gradient
  84361. * @param gradient defines the gradient to use (between 0 and 1)
  84362. * @param factor defines the life time factor to affect to the specified gradient
  84363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84364. * @returns the current particle system
  84365. */
  84366. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84367. /**
  84368. * Remove a specific life time gradient
  84369. * @param gradient defines the gradient to remove
  84370. * @returns the current particle system
  84371. */
  84372. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84373. /**
  84374. * Adds a new size gradient
  84375. * @param gradient defines the gradient to use (between 0 and 1)
  84376. * @param factor defines the size factor to affect to the specified gradient
  84377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84378. * @returns the current particle system
  84379. */
  84380. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84381. /**
  84382. * Remove a specific size gradient
  84383. * @param gradient defines the gradient to remove
  84384. * @returns the current particle system
  84385. */
  84386. removeSizeGradient(gradient: number): IParticleSystem;
  84387. /**
  84388. * Adds a new color remap gradient
  84389. * @param gradient defines the gradient to use (between 0 and 1)
  84390. * @param min defines the color remap minimal range
  84391. * @param max defines the color remap maximal range
  84392. * @returns the current particle system
  84393. */
  84394. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84395. /**
  84396. * Remove a specific color remap gradient
  84397. * @param gradient defines the gradient to remove
  84398. * @returns the current particle system
  84399. */
  84400. removeColorRemapGradient(gradient: number): IParticleSystem;
  84401. /**
  84402. * Adds a new alpha remap gradient
  84403. * @param gradient defines the gradient to use (between 0 and 1)
  84404. * @param min defines the alpha remap minimal range
  84405. * @param max defines the alpha remap maximal range
  84406. * @returns the current particle system
  84407. */
  84408. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84409. /**
  84410. * Remove a specific alpha remap gradient
  84411. * @param gradient defines the gradient to remove
  84412. * @returns the current particle system
  84413. */
  84414. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84415. /**
  84416. * Adds a new angular speed gradient
  84417. * @param gradient defines the gradient to use (between 0 and 1)
  84418. * @param factor defines the angular speed to affect to the specified gradient
  84419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84420. * @returns the current particle system
  84421. */
  84422. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84423. /**
  84424. * Remove a specific angular speed gradient
  84425. * @param gradient defines the gradient to remove
  84426. * @returns the current particle system
  84427. */
  84428. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84429. /**
  84430. * Adds a new velocity gradient
  84431. * @param gradient defines the gradient to use (between 0 and 1)
  84432. * @param factor defines the velocity to affect to the specified gradient
  84433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84434. * @returns the current particle system
  84435. */
  84436. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84437. /**
  84438. * Remove a specific velocity gradient
  84439. * @param gradient defines the gradient to remove
  84440. * @returns the current particle system
  84441. */
  84442. removeVelocityGradient(gradient: number): IParticleSystem;
  84443. /**
  84444. * Adds a new limit velocity gradient
  84445. * @param gradient defines the gradient to use (between 0 and 1)
  84446. * @param factor defines the limit velocity value to affect to the specified gradient
  84447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84448. * @returns the current particle system
  84449. */
  84450. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84451. /**
  84452. * Remove a specific limit velocity gradient
  84453. * @param gradient defines the gradient to remove
  84454. * @returns the current particle system
  84455. */
  84456. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84457. /**
  84458. * Adds a new drag gradient
  84459. * @param gradient defines the gradient to use (between 0 and 1)
  84460. * @param factor defines the drag value to affect to the specified gradient
  84461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84462. * @returns the current particle system
  84463. */
  84464. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84465. /**
  84466. * Remove a specific drag gradient
  84467. * @param gradient defines the gradient to remove
  84468. * @returns the current particle system
  84469. */
  84470. removeDragGradient(gradient: number): IParticleSystem;
  84471. /**
  84472. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84473. * @param gradient defines the gradient to use (between 0 and 1)
  84474. * @param factor defines the emit rate value to affect to the specified gradient
  84475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84476. * @returns the current particle system
  84477. */
  84478. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84479. /**
  84480. * Remove a specific emit rate gradient
  84481. * @param gradient defines the gradient to remove
  84482. * @returns the current particle system
  84483. */
  84484. removeEmitRateGradient(gradient: number): IParticleSystem;
  84485. /**
  84486. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84487. * @param gradient defines the gradient to use (between 0 and 1)
  84488. * @param factor defines the start size value to affect to the specified gradient
  84489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84490. * @returns the current particle system
  84491. */
  84492. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84493. /**
  84494. * Remove a specific start size gradient
  84495. * @param gradient defines the gradient to remove
  84496. * @returns the current particle system
  84497. */
  84498. removeStartSizeGradient(gradient: number): IParticleSystem;
  84499. private _createRampGradientTexture;
  84500. /**
  84501. * Gets the current list of ramp gradients.
  84502. * You must use addRampGradient and removeRampGradient to udpate this list
  84503. * @returns the list of ramp gradients
  84504. */
  84505. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84506. /**
  84507. * Adds a new ramp gradient used to remap particle colors
  84508. * @param gradient defines the gradient to use (between 0 and 1)
  84509. * @param color defines the color to affect to the specified gradient
  84510. * @returns the current particle system
  84511. */
  84512. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84513. /**
  84514. * Remove a specific ramp gradient
  84515. * @param gradient defines the gradient to remove
  84516. * @returns the current particle system
  84517. */
  84518. removeRampGradient(gradient: number): ParticleSystem;
  84519. /**
  84520. * Adds a new color gradient
  84521. * @param gradient defines the gradient to use (between 0 and 1)
  84522. * @param color1 defines the color to affect to the specified gradient
  84523. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84524. * @returns this particle system
  84525. */
  84526. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84527. /**
  84528. * Remove a specific color gradient
  84529. * @param gradient defines the gradient to remove
  84530. * @returns this particle system
  84531. */
  84532. removeColorGradient(gradient: number): IParticleSystem;
  84533. private _fetchR;
  84534. protected _reset(): void;
  84535. private _resetEffect;
  84536. private _createVertexBuffers;
  84537. private _createIndexBuffer;
  84538. /**
  84539. * Gets the maximum number of particles active at the same time.
  84540. * @returns The max number of active particles.
  84541. */
  84542. getCapacity(): number;
  84543. /**
  84544. * Gets whether there are still active particles in the system.
  84545. * @returns True if it is alive, otherwise false.
  84546. */
  84547. isAlive(): boolean;
  84548. /**
  84549. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84550. * @returns True if it has been started, otherwise false.
  84551. */
  84552. isStarted(): boolean;
  84553. private _prepareSubEmitterInternalArray;
  84554. /**
  84555. * Starts the particle system and begins to emit
  84556. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84557. */
  84558. start(delay?: number): void;
  84559. /**
  84560. * Stops the particle system.
  84561. * @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.
  84562. */
  84563. stop(stopSubEmitters?: boolean): void;
  84564. /**
  84565. * Remove all active particles
  84566. */
  84567. reset(): void;
  84568. /**
  84569. * @hidden (for internal use only)
  84570. */
  84571. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84572. /**
  84573. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84574. * Its lifetime will start back at 0.
  84575. */
  84576. recycleParticle: (particle: Particle) => void;
  84577. private _stopSubEmitters;
  84578. private _createParticle;
  84579. private _removeFromRoot;
  84580. private _emitFromParticle;
  84581. private _update;
  84582. /** @hidden */
  84583. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84584. /** @hidden */
  84585. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84586. /** @hidden */
  84587. private _getEffect;
  84588. /**
  84589. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84590. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84591. */
  84592. animate(preWarmOnly?: boolean): void;
  84593. private _appendParticleVertices;
  84594. /**
  84595. * Rebuilds the particle system.
  84596. */
  84597. rebuild(): void;
  84598. /**
  84599. * Is this system ready to be used/rendered
  84600. * @return true if the system is ready
  84601. */
  84602. isReady(): boolean;
  84603. private _render;
  84604. /**
  84605. * Renders the particle system in its current state.
  84606. * @returns the current number of particles
  84607. */
  84608. render(): number;
  84609. /**
  84610. * Disposes the particle system and free the associated resources
  84611. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84612. */
  84613. dispose(disposeTexture?: boolean): void;
  84614. /**
  84615. * Clones the particle system.
  84616. * @param name The name of the cloned object
  84617. * @param newEmitter The new emitter to use
  84618. * @returns the cloned particle system
  84619. */
  84620. clone(name: string, newEmitter: any): ParticleSystem;
  84621. /**
  84622. * Serializes the particle system to a JSON object.
  84623. * @returns the JSON object
  84624. */
  84625. serialize(): any;
  84626. /** @hidden */
  84627. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84628. /** @hidden */
  84629. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84630. /**
  84631. * Parses a JSON object to create a particle system.
  84632. * @param parsedParticleSystem The JSON object to parse
  84633. * @param scene The scene to create the particle system in
  84634. * @param rootUrl The root url to use to load external dependencies like texture
  84635. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84636. * @returns the Parsed particle system
  84637. */
  84638. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. /**
  84643. * A particle represents one of the element emitted by a particle system.
  84644. * This is mainly define by its coordinates, direction, velocity and age.
  84645. */
  84646. export class Particle {
  84647. /**
  84648. * The particle system the particle belongs to.
  84649. */
  84650. particleSystem: ParticleSystem;
  84651. private static _Count;
  84652. /**
  84653. * Unique ID of the particle
  84654. */
  84655. id: number;
  84656. /**
  84657. * The world position of the particle in the scene.
  84658. */
  84659. position: Vector3;
  84660. /**
  84661. * The world direction of the particle in the scene.
  84662. */
  84663. direction: Vector3;
  84664. /**
  84665. * The color of the particle.
  84666. */
  84667. color: Color4;
  84668. /**
  84669. * The color change of the particle per step.
  84670. */
  84671. colorStep: Color4;
  84672. /**
  84673. * Defines how long will the life of the particle be.
  84674. */
  84675. lifeTime: number;
  84676. /**
  84677. * The current age of the particle.
  84678. */
  84679. age: number;
  84680. /**
  84681. * The current size of the particle.
  84682. */
  84683. size: number;
  84684. /**
  84685. * The current scale of the particle.
  84686. */
  84687. scale: Vector2;
  84688. /**
  84689. * The current angle of the particle.
  84690. */
  84691. angle: number;
  84692. /**
  84693. * Defines how fast is the angle changing.
  84694. */
  84695. angularSpeed: number;
  84696. /**
  84697. * Defines the cell index used by the particle to be rendered from a sprite.
  84698. */
  84699. cellIndex: number;
  84700. /**
  84701. * The information required to support color remapping
  84702. */
  84703. remapData: Vector4;
  84704. /** @hidden */
  84705. _randomCellOffset?: number;
  84706. /** @hidden */
  84707. _initialDirection: Nullable<Vector3>;
  84708. /** @hidden */
  84709. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84710. /** @hidden */
  84711. _initialStartSpriteCellID: number;
  84712. /** @hidden */
  84713. _initialEndSpriteCellID: number;
  84714. /** @hidden */
  84715. _currentColorGradient: Nullable<ColorGradient>;
  84716. /** @hidden */
  84717. _currentColor1: Color4;
  84718. /** @hidden */
  84719. _currentColor2: Color4;
  84720. /** @hidden */
  84721. _currentSizeGradient: Nullable<FactorGradient>;
  84722. /** @hidden */
  84723. _currentSize1: number;
  84724. /** @hidden */
  84725. _currentSize2: number;
  84726. /** @hidden */
  84727. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84728. /** @hidden */
  84729. _currentAngularSpeed1: number;
  84730. /** @hidden */
  84731. _currentAngularSpeed2: number;
  84732. /** @hidden */
  84733. _currentVelocityGradient: Nullable<FactorGradient>;
  84734. /** @hidden */
  84735. _currentVelocity1: number;
  84736. /** @hidden */
  84737. _currentVelocity2: number;
  84738. /** @hidden */
  84739. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84740. /** @hidden */
  84741. _currentLimitVelocity1: number;
  84742. /** @hidden */
  84743. _currentLimitVelocity2: number;
  84744. /** @hidden */
  84745. _currentDragGradient: Nullable<FactorGradient>;
  84746. /** @hidden */
  84747. _currentDrag1: number;
  84748. /** @hidden */
  84749. _currentDrag2: number;
  84750. /** @hidden */
  84751. _randomNoiseCoordinates1: Vector3;
  84752. /** @hidden */
  84753. _randomNoiseCoordinates2: Vector3;
  84754. /**
  84755. * Creates a new instance Particle
  84756. * @param particleSystem the particle system the particle belongs to
  84757. */
  84758. constructor(
  84759. /**
  84760. * The particle system the particle belongs to.
  84761. */
  84762. particleSystem: ParticleSystem);
  84763. private updateCellInfoFromSystem;
  84764. /**
  84765. * Defines how the sprite cell index is updated for the particle
  84766. */
  84767. updateCellIndex(): void;
  84768. /** @hidden */
  84769. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84770. /** @hidden */
  84771. _inheritParticleInfoToSubEmitters(): void;
  84772. /** @hidden */
  84773. _reset(): void;
  84774. /**
  84775. * Copy the properties of particle to another one.
  84776. * @param other the particle to copy the information to.
  84777. */
  84778. copyTo(other: Particle): void;
  84779. }
  84780. }
  84781. declare module BABYLON {
  84782. /**
  84783. * Particle emitter represents a volume emitting particles.
  84784. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84785. */
  84786. export interface IParticleEmitterType {
  84787. /**
  84788. * Called by the particle System when the direction is computed for the created particle.
  84789. * @param worldMatrix is the world matrix of the particle system
  84790. * @param directionToUpdate is the direction vector to update with the result
  84791. * @param particle is the particle we are computed the direction for
  84792. */
  84793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84794. /**
  84795. * Called by the particle System when the position is computed for the created particle.
  84796. * @param worldMatrix is the world matrix of the particle system
  84797. * @param positionToUpdate is the position vector to update with the result
  84798. * @param particle is the particle we are computed the position for
  84799. */
  84800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84801. /**
  84802. * Clones the current emitter and returns a copy of it
  84803. * @returns the new emitter
  84804. */
  84805. clone(): IParticleEmitterType;
  84806. /**
  84807. * Called by the GPUParticleSystem to setup the update shader
  84808. * @param effect defines the update shader
  84809. */
  84810. applyToShader(effect: Effect): void;
  84811. /**
  84812. * Returns a string to use to update the GPU particles update shader
  84813. * @returns the effect defines string
  84814. */
  84815. getEffectDefines(): string;
  84816. /**
  84817. * Returns a string representing the class name
  84818. * @returns a string containing the class name
  84819. */
  84820. getClassName(): string;
  84821. /**
  84822. * Serializes the particle system to a JSON object.
  84823. * @returns the JSON object
  84824. */
  84825. serialize(): any;
  84826. /**
  84827. * Parse properties from a JSON object
  84828. * @param serializationObject defines the JSON object
  84829. */
  84830. parse(serializationObject: any): void;
  84831. }
  84832. }
  84833. declare module BABYLON {
  84834. /**
  84835. * Particle emitter emitting particles from the inside of a box.
  84836. * It emits the particles randomly between 2 given directions.
  84837. */
  84838. export class BoxParticleEmitter implements IParticleEmitterType {
  84839. /**
  84840. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84841. */
  84842. direction1: Vector3;
  84843. /**
  84844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84845. */
  84846. direction2: Vector3;
  84847. /**
  84848. * 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.
  84849. */
  84850. minEmitBox: Vector3;
  84851. /**
  84852. * 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.
  84853. */
  84854. maxEmitBox: Vector3;
  84855. /**
  84856. * Creates a new instance BoxParticleEmitter
  84857. */
  84858. constructor();
  84859. /**
  84860. * Called by the particle System when the direction is computed for the created particle.
  84861. * @param worldMatrix is the world matrix of the particle system
  84862. * @param directionToUpdate is the direction vector to update with the result
  84863. * @param particle is the particle we are computed the direction for
  84864. */
  84865. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84866. /**
  84867. * Called by the particle System when the position is computed for the created particle.
  84868. * @param worldMatrix is the world matrix of the particle system
  84869. * @param positionToUpdate is the position vector to update with the result
  84870. * @param particle is the particle we are computed the position for
  84871. */
  84872. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84873. /**
  84874. * Clones the current emitter and returns a copy of it
  84875. * @returns the new emitter
  84876. */
  84877. clone(): BoxParticleEmitter;
  84878. /**
  84879. * Called by the GPUParticleSystem to setup the update shader
  84880. * @param effect defines the update shader
  84881. */
  84882. applyToShader(effect: Effect): void;
  84883. /**
  84884. * Returns a string to use to update the GPU particles update shader
  84885. * @returns a string containng the defines string
  84886. */
  84887. getEffectDefines(): string;
  84888. /**
  84889. * Returns the string "BoxParticleEmitter"
  84890. * @returns a string containing the class name
  84891. */
  84892. getClassName(): string;
  84893. /**
  84894. * Serializes the particle system to a JSON object.
  84895. * @returns the JSON object
  84896. */
  84897. serialize(): any;
  84898. /**
  84899. * Parse properties from a JSON object
  84900. * @param serializationObject defines the JSON object
  84901. */
  84902. parse(serializationObject: any): void;
  84903. }
  84904. }
  84905. declare module BABYLON {
  84906. /**
  84907. * Particle emitter emitting particles from the inside of a cone.
  84908. * It emits the particles alongside the cone volume from the base to the particle.
  84909. * The emission direction might be randomized.
  84910. */
  84911. export class ConeParticleEmitter implements IParticleEmitterType {
  84912. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84913. directionRandomizer: number;
  84914. private _radius;
  84915. private _angle;
  84916. private _height;
  84917. /**
  84918. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84919. */
  84920. radiusRange: number;
  84921. /**
  84922. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84923. */
  84924. heightRange: number;
  84925. /**
  84926. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84927. */
  84928. emitFromSpawnPointOnly: boolean;
  84929. /**
  84930. * Gets or sets the radius of the emission cone
  84931. */
  84932. radius: number;
  84933. /**
  84934. * Gets or sets the angle of the emission cone
  84935. */
  84936. angle: number;
  84937. private _buildHeight;
  84938. /**
  84939. * Creates a new instance ConeParticleEmitter
  84940. * @param radius the radius of the emission cone (1 by default)
  84941. * @param angle the cone base angle (PI by default)
  84942. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84943. */
  84944. constructor(radius?: number, angle?: number,
  84945. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84946. directionRandomizer?: number);
  84947. /**
  84948. * Called by the particle System when the direction is computed for the created particle.
  84949. * @param worldMatrix is the world matrix of the particle system
  84950. * @param directionToUpdate is the direction vector to update with the result
  84951. * @param particle is the particle we are computed the direction for
  84952. */
  84953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84954. /**
  84955. * Called by the particle System when the position is computed for the created particle.
  84956. * @param worldMatrix is the world matrix of the particle system
  84957. * @param positionToUpdate is the position vector to update with the result
  84958. * @param particle is the particle we are computed the position for
  84959. */
  84960. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84961. /**
  84962. * Clones the current emitter and returns a copy of it
  84963. * @returns the new emitter
  84964. */
  84965. clone(): ConeParticleEmitter;
  84966. /**
  84967. * Called by the GPUParticleSystem to setup the update shader
  84968. * @param effect defines the update shader
  84969. */
  84970. applyToShader(effect: Effect): void;
  84971. /**
  84972. * Returns a string to use to update the GPU particles update shader
  84973. * @returns a string containng the defines string
  84974. */
  84975. getEffectDefines(): string;
  84976. /**
  84977. * Returns the string "ConeParticleEmitter"
  84978. * @returns a string containing the class name
  84979. */
  84980. getClassName(): string;
  84981. /**
  84982. * Serializes the particle system to a JSON object.
  84983. * @returns the JSON object
  84984. */
  84985. serialize(): any;
  84986. /**
  84987. * Parse properties from a JSON object
  84988. * @param serializationObject defines the JSON object
  84989. */
  84990. parse(serializationObject: any): void;
  84991. }
  84992. }
  84993. declare module BABYLON {
  84994. /**
  84995. * Particle emitter emitting particles from the inside of a cylinder.
  84996. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84997. */
  84998. export class CylinderParticleEmitter implements IParticleEmitterType {
  84999. /**
  85000. * The radius of the emission cylinder.
  85001. */
  85002. radius: number;
  85003. /**
  85004. * The height of the emission cylinder.
  85005. */
  85006. height: number;
  85007. /**
  85008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85009. */
  85010. radiusRange: number;
  85011. /**
  85012. * How much to randomize the particle direction [0-1].
  85013. */
  85014. directionRandomizer: number;
  85015. /**
  85016. * Creates a new instance CylinderParticleEmitter
  85017. * @param radius the radius of the emission cylinder (1 by default)
  85018. * @param height the height of the emission cylinder (1 by default)
  85019. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85020. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85021. */
  85022. constructor(
  85023. /**
  85024. * The radius of the emission cylinder.
  85025. */
  85026. radius?: number,
  85027. /**
  85028. * The height of the emission cylinder.
  85029. */
  85030. height?: number,
  85031. /**
  85032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85033. */
  85034. radiusRange?: number,
  85035. /**
  85036. * How much to randomize the particle direction [0-1].
  85037. */
  85038. directionRandomizer?: number);
  85039. /**
  85040. * Called by the particle System when the direction is computed for the created particle.
  85041. * @param worldMatrix is the world matrix of the particle system
  85042. * @param directionToUpdate is the direction vector to update with the result
  85043. * @param particle is the particle we are computed the direction for
  85044. */
  85045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85046. /**
  85047. * Called by the particle System when the position is computed for the created particle.
  85048. * @param worldMatrix is the world matrix of the particle system
  85049. * @param positionToUpdate is the position vector to update with the result
  85050. * @param particle is the particle we are computed the position for
  85051. */
  85052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85053. /**
  85054. * Clones the current emitter and returns a copy of it
  85055. * @returns the new emitter
  85056. */
  85057. clone(): CylinderParticleEmitter;
  85058. /**
  85059. * Called by the GPUParticleSystem to setup the update shader
  85060. * @param effect defines the update shader
  85061. */
  85062. applyToShader(effect: Effect): void;
  85063. /**
  85064. * Returns a string to use to update the GPU particles update shader
  85065. * @returns a string containng the defines string
  85066. */
  85067. getEffectDefines(): string;
  85068. /**
  85069. * Returns the string "CylinderParticleEmitter"
  85070. * @returns a string containing the class name
  85071. */
  85072. getClassName(): string;
  85073. /**
  85074. * Serializes the particle system to a JSON object.
  85075. * @returns the JSON object
  85076. */
  85077. serialize(): any;
  85078. /**
  85079. * Parse properties from a JSON object
  85080. * @param serializationObject defines the JSON object
  85081. */
  85082. parse(serializationObject: any): void;
  85083. }
  85084. /**
  85085. * Particle emitter emitting particles from the inside of a cylinder.
  85086. * It emits the particles randomly between two vectors.
  85087. */
  85088. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85089. /**
  85090. * The min limit of the emission direction.
  85091. */
  85092. direction1: Vector3;
  85093. /**
  85094. * The max limit of the emission direction.
  85095. */
  85096. direction2: Vector3;
  85097. /**
  85098. * Creates a new instance CylinderDirectedParticleEmitter
  85099. * @param radius the radius of the emission cylinder (1 by default)
  85100. * @param height the height of the emission cylinder (1 by default)
  85101. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85102. * @param direction1 the min limit of the emission direction (up vector by default)
  85103. * @param direction2 the max limit of the emission direction (up vector by default)
  85104. */
  85105. constructor(radius?: number, height?: number, radiusRange?: number,
  85106. /**
  85107. * The min limit of the emission direction.
  85108. */
  85109. direction1?: Vector3,
  85110. /**
  85111. * The max limit of the emission direction.
  85112. */
  85113. direction2?: Vector3);
  85114. /**
  85115. * Called by the particle System when the direction is computed for the created particle.
  85116. * @param worldMatrix is the world matrix of the particle system
  85117. * @param directionToUpdate is the direction vector to update with the result
  85118. * @param particle is the particle we are computed the direction for
  85119. */
  85120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85121. /**
  85122. * Clones the current emitter and returns a copy of it
  85123. * @returns the new emitter
  85124. */
  85125. clone(): CylinderDirectedParticleEmitter;
  85126. /**
  85127. * Called by the GPUParticleSystem to setup the update shader
  85128. * @param effect defines the update shader
  85129. */
  85130. applyToShader(effect: Effect): void;
  85131. /**
  85132. * Returns a string to use to update the GPU particles update shader
  85133. * @returns a string containng the defines string
  85134. */
  85135. getEffectDefines(): string;
  85136. /**
  85137. * Returns the string "CylinderDirectedParticleEmitter"
  85138. * @returns a string containing the class name
  85139. */
  85140. getClassName(): string;
  85141. /**
  85142. * Serializes the particle system to a JSON object.
  85143. * @returns the JSON object
  85144. */
  85145. serialize(): any;
  85146. /**
  85147. * Parse properties from a JSON object
  85148. * @param serializationObject defines the JSON object
  85149. */
  85150. parse(serializationObject: any): void;
  85151. }
  85152. }
  85153. declare module BABYLON {
  85154. /**
  85155. * Particle emitter emitting particles from the inside of a hemisphere.
  85156. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85157. */
  85158. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85159. /**
  85160. * The radius of the emission hemisphere.
  85161. */
  85162. radius: number;
  85163. /**
  85164. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85165. */
  85166. radiusRange: number;
  85167. /**
  85168. * How much to randomize the particle direction [0-1].
  85169. */
  85170. directionRandomizer: number;
  85171. /**
  85172. * Creates a new instance HemisphericParticleEmitter
  85173. * @param radius the radius of the emission hemisphere (1 by default)
  85174. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85175. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85176. */
  85177. constructor(
  85178. /**
  85179. * The radius of the emission hemisphere.
  85180. */
  85181. radius?: number,
  85182. /**
  85183. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85184. */
  85185. radiusRange?: number,
  85186. /**
  85187. * How much to randomize the particle direction [0-1].
  85188. */
  85189. directionRandomizer?: number);
  85190. /**
  85191. * Called by the particle System when the direction is computed for the created particle.
  85192. * @param worldMatrix is the world matrix of the particle system
  85193. * @param directionToUpdate is the direction vector to update with the result
  85194. * @param particle is the particle we are computed the direction for
  85195. */
  85196. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85197. /**
  85198. * Called by the particle System when the position is computed for the created particle.
  85199. * @param worldMatrix is the world matrix of the particle system
  85200. * @param positionToUpdate is the position vector to update with the result
  85201. * @param particle is the particle we are computed the position for
  85202. */
  85203. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85204. /**
  85205. * Clones the current emitter and returns a copy of it
  85206. * @returns the new emitter
  85207. */
  85208. clone(): HemisphericParticleEmitter;
  85209. /**
  85210. * Called by the GPUParticleSystem to setup the update shader
  85211. * @param effect defines the update shader
  85212. */
  85213. applyToShader(effect: Effect): void;
  85214. /**
  85215. * Returns a string to use to update the GPU particles update shader
  85216. * @returns a string containng the defines string
  85217. */
  85218. getEffectDefines(): string;
  85219. /**
  85220. * Returns the string "HemisphericParticleEmitter"
  85221. * @returns a string containing the class name
  85222. */
  85223. getClassName(): string;
  85224. /**
  85225. * Serializes the particle system to a JSON object.
  85226. * @returns the JSON object
  85227. */
  85228. serialize(): any;
  85229. /**
  85230. * Parse properties from a JSON object
  85231. * @param serializationObject defines the JSON object
  85232. */
  85233. parse(serializationObject: any): void;
  85234. }
  85235. }
  85236. declare module BABYLON {
  85237. /**
  85238. * Particle emitter emitting particles from a point.
  85239. * It emits the particles randomly between 2 given directions.
  85240. */
  85241. export class PointParticleEmitter implements IParticleEmitterType {
  85242. /**
  85243. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85244. */
  85245. direction1: Vector3;
  85246. /**
  85247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85248. */
  85249. direction2: Vector3;
  85250. /**
  85251. * Creates a new instance PointParticleEmitter
  85252. */
  85253. constructor();
  85254. /**
  85255. * Called by the particle System when the direction is computed for the created particle.
  85256. * @param worldMatrix is the world matrix of the particle system
  85257. * @param directionToUpdate is the direction vector to update with the result
  85258. * @param particle is the particle we are computed the direction for
  85259. */
  85260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85261. /**
  85262. * Called by the particle System when the position is computed for the created particle.
  85263. * @param worldMatrix is the world matrix of the particle system
  85264. * @param positionToUpdate is the position vector to update with the result
  85265. * @param particle is the particle we are computed the position for
  85266. */
  85267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85268. /**
  85269. * Clones the current emitter and returns a copy of it
  85270. * @returns the new emitter
  85271. */
  85272. clone(): PointParticleEmitter;
  85273. /**
  85274. * Called by the GPUParticleSystem to setup the update shader
  85275. * @param effect defines the update shader
  85276. */
  85277. applyToShader(effect: Effect): void;
  85278. /**
  85279. * Returns a string to use to update the GPU particles update shader
  85280. * @returns a string containng the defines string
  85281. */
  85282. getEffectDefines(): string;
  85283. /**
  85284. * Returns the string "PointParticleEmitter"
  85285. * @returns a string containing the class name
  85286. */
  85287. getClassName(): string;
  85288. /**
  85289. * Serializes the particle system to a JSON object.
  85290. * @returns the JSON object
  85291. */
  85292. serialize(): any;
  85293. /**
  85294. * Parse properties from a JSON object
  85295. * @param serializationObject defines the JSON object
  85296. */
  85297. parse(serializationObject: any): void;
  85298. }
  85299. }
  85300. declare module BABYLON {
  85301. /**
  85302. * Particle emitter emitting particles from the inside of a sphere.
  85303. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85304. */
  85305. export class SphereParticleEmitter implements IParticleEmitterType {
  85306. /**
  85307. * The radius of the emission sphere.
  85308. */
  85309. radius: number;
  85310. /**
  85311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85312. */
  85313. radiusRange: number;
  85314. /**
  85315. * How much to randomize the particle direction [0-1].
  85316. */
  85317. directionRandomizer: number;
  85318. /**
  85319. * Creates a new instance SphereParticleEmitter
  85320. * @param radius the radius of the emission sphere (1 by default)
  85321. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85322. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85323. */
  85324. constructor(
  85325. /**
  85326. * The radius of the emission sphere.
  85327. */
  85328. radius?: number,
  85329. /**
  85330. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85331. */
  85332. radiusRange?: number,
  85333. /**
  85334. * How much to randomize the particle direction [0-1].
  85335. */
  85336. directionRandomizer?: number);
  85337. /**
  85338. * Called by the particle System when the direction is computed for the created particle.
  85339. * @param worldMatrix is the world matrix of the particle system
  85340. * @param directionToUpdate is the direction vector to update with the result
  85341. * @param particle is the particle we are computed the direction for
  85342. */
  85343. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85344. /**
  85345. * Called by the particle System when the position is computed for the created particle.
  85346. * @param worldMatrix is the world matrix of the particle system
  85347. * @param positionToUpdate is the position vector to update with the result
  85348. * @param particle is the particle we are computed the position for
  85349. */
  85350. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85351. /**
  85352. * Clones the current emitter and returns a copy of it
  85353. * @returns the new emitter
  85354. */
  85355. clone(): SphereParticleEmitter;
  85356. /**
  85357. * Called by the GPUParticleSystem to setup the update shader
  85358. * @param effect defines the update shader
  85359. */
  85360. applyToShader(effect: Effect): void;
  85361. /**
  85362. * Returns a string to use to update the GPU particles update shader
  85363. * @returns a string containng the defines string
  85364. */
  85365. getEffectDefines(): string;
  85366. /**
  85367. * Returns the string "SphereParticleEmitter"
  85368. * @returns a string containing the class name
  85369. */
  85370. getClassName(): string;
  85371. /**
  85372. * Serializes the particle system to a JSON object.
  85373. * @returns the JSON object
  85374. */
  85375. serialize(): any;
  85376. /**
  85377. * Parse properties from a JSON object
  85378. * @param serializationObject defines the JSON object
  85379. */
  85380. parse(serializationObject: any): void;
  85381. }
  85382. /**
  85383. * Particle emitter emitting particles from the inside of a sphere.
  85384. * It emits the particles randomly between two vectors.
  85385. */
  85386. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85387. /**
  85388. * The min limit of the emission direction.
  85389. */
  85390. direction1: Vector3;
  85391. /**
  85392. * The max limit of the emission direction.
  85393. */
  85394. direction2: Vector3;
  85395. /**
  85396. * Creates a new instance SphereDirectedParticleEmitter
  85397. * @param radius the radius of the emission sphere (1 by default)
  85398. * @param direction1 the min limit of the emission direction (up vector by default)
  85399. * @param direction2 the max limit of the emission direction (up vector by default)
  85400. */
  85401. constructor(radius?: number,
  85402. /**
  85403. * The min limit of the emission direction.
  85404. */
  85405. direction1?: Vector3,
  85406. /**
  85407. * The max limit of the emission direction.
  85408. */
  85409. direction2?: Vector3);
  85410. /**
  85411. * Called by the particle System when the direction is computed for the created particle.
  85412. * @param worldMatrix is the world matrix of the particle system
  85413. * @param directionToUpdate is the direction vector to update with the result
  85414. * @param particle is the particle we are computed the direction for
  85415. */
  85416. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85417. /**
  85418. * Clones the current emitter and returns a copy of it
  85419. * @returns the new emitter
  85420. */
  85421. clone(): SphereDirectedParticleEmitter;
  85422. /**
  85423. * Called by the GPUParticleSystem to setup the update shader
  85424. * @param effect defines the update shader
  85425. */
  85426. applyToShader(effect: Effect): void;
  85427. /**
  85428. * Returns a string to use to update the GPU particles update shader
  85429. * @returns a string containng the defines string
  85430. */
  85431. getEffectDefines(): string;
  85432. /**
  85433. * Returns the string "SphereDirectedParticleEmitter"
  85434. * @returns a string containing the class name
  85435. */
  85436. getClassName(): string;
  85437. /**
  85438. * Serializes the particle system to a JSON object.
  85439. * @returns the JSON object
  85440. */
  85441. serialize(): any;
  85442. /**
  85443. * Parse properties from a JSON object
  85444. * @param serializationObject defines the JSON object
  85445. */
  85446. parse(serializationObject: any): void;
  85447. }
  85448. }
  85449. declare module BABYLON {
  85450. /**
  85451. * Interface representing a particle system in Babylon.js.
  85452. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85453. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85454. */
  85455. export interface IParticleSystem {
  85456. /**
  85457. * List of animations used by the particle system.
  85458. */
  85459. animations: Animation[];
  85460. /**
  85461. * The id of the Particle system.
  85462. */
  85463. id: string;
  85464. /**
  85465. * The name of the Particle system.
  85466. */
  85467. name: string;
  85468. /**
  85469. * The emitter represents the Mesh or position we are attaching the particle system to.
  85470. */
  85471. emitter: Nullable<AbstractMesh | Vector3>;
  85472. /**
  85473. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85474. */
  85475. isBillboardBased: boolean;
  85476. /**
  85477. * The rendering group used by the Particle system to chose when to render.
  85478. */
  85479. renderingGroupId: number;
  85480. /**
  85481. * The layer mask we are rendering the particles through.
  85482. */
  85483. layerMask: number;
  85484. /**
  85485. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85486. */
  85487. updateSpeed: number;
  85488. /**
  85489. * The amount of time the particle system is running (depends of the overall update speed).
  85490. */
  85491. targetStopDuration: number;
  85492. /**
  85493. * The texture used to render each particle. (this can be a spritesheet)
  85494. */
  85495. particleTexture: Nullable<Texture>;
  85496. /**
  85497. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85498. */
  85499. blendMode: number;
  85500. /**
  85501. * Minimum life time of emitting particles.
  85502. */
  85503. minLifeTime: number;
  85504. /**
  85505. * Maximum life time of emitting particles.
  85506. */
  85507. maxLifeTime: number;
  85508. /**
  85509. * Minimum Size of emitting particles.
  85510. */
  85511. minSize: number;
  85512. /**
  85513. * Maximum Size of emitting particles.
  85514. */
  85515. maxSize: number;
  85516. /**
  85517. * Minimum scale of emitting particles on X axis.
  85518. */
  85519. minScaleX: number;
  85520. /**
  85521. * Maximum scale of emitting particles on X axis.
  85522. */
  85523. maxScaleX: number;
  85524. /**
  85525. * Minimum scale of emitting particles on Y axis.
  85526. */
  85527. minScaleY: number;
  85528. /**
  85529. * Maximum scale of emitting particles on Y axis.
  85530. */
  85531. maxScaleY: number;
  85532. /**
  85533. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85534. */
  85535. color1: Color4;
  85536. /**
  85537. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85538. */
  85539. color2: Color4;
  85540. /**
  85541. * Color the particle will have at the end of its lifetime.
  85542. */
  85543. colorDead: Color4;
  85544. /**
  85545. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85546. */
  85547. emitRate: number;
  85548. /**
  85549. * You can use gravity if you want to give an orientation to your particles.
  85550. */
  85551. gravity: Vector3;
  85552. /**
  85553. * Minimum power of emitting particles.
  85554. */
  85555. minEmitPower: number;
  85556. /**
  85557. * Maximum power of emitting particles.
  85558. */
  85559. maxEmitPower: number;
  85560. /**
  85561. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85562. */
  85563. minAngularSpeed: number;
  85564. /**
  85565. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85566. */
  85567. maxAngularSpeed: number;
  85568. /**
  85569. * Gets or sets the minimal initial rotation in radians.
  85570. */
  85571. minInitialRotation: number;
  85572. /**
  85573. * Gets or sets the maximal initial rotation in radians.
  85574. */
  85575. maxInitialRotation: number;
  85576. /**
  85577. * The particle emitter type defines the emitter used by the particle system.
  85578. * It can be for example box, sphere, or cone...
  85579. */
  85580. particleEmitterType: Nullable<IParticleEmitterType>;
  85581. /**
  85582. * Defines the delay in milliseconds before starting the system (0 by default)
  85583. */
  85584. startDelay: number;
  85585. /**
  85586. * 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
  85587. */
  85588. preWarmCycles: number;
  85589. /**
  85590. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85591. */
  85592. preWarmStepOffset: number;
  85593. /**
  85594. * 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)
  85595. */
  85596. spriteCellChangeSpeed: number;
  85597. /**
  85598. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85599. */
  85600. startSpriteCellID: number;
  85601. /**
  85602. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85603. */
  85604. endSpriteCellID: number;
  85605. /**
  85606. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85607. */
  85608. spriteCellWidth: number;
  85609. /**
  85610. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85611. */
  85612. spriteCellHeight: number;
  85613. /**
  85614. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85615. */
  85616. spriteRandomStartCell: boolean;
  85617. /**
  85618. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85619. */
  85620. isAnimationSheetEnabled: boolean;
  85621. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85622. translationPivot: Vector2;
  85623. /**
  85624. * Gets or sets a texture used to add random noise to particle positions
  85625. */
  85626. noiseTexture: Nullable<BaseTexture>;
  85627. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85628. noiseStrength: Vector3;
  85629. /**
  85630. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85631. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85632. */
  85633. billboardMode: number;
  85634. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85635. limitVelocityDamping: number;
  85636. /**
  85637. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85638. */
  85639. beginAnimationOnStart: boolean;
  85640. /**
  85641. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85642. */
  85643. beginAnimationFrom: number;
  85644. /**
  85645. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85646. */
  85647. beginAnimationTo: number;
  85648. /**
  85649. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85650. */
  85651. beginAnimationLoop: boolean;
  85652. /**
  85653. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85654. */
  85655. disposeOnStop: boolean;
  85656. /**
  85657. * Gets the maximum number of particles active at the same time.
  85658. * @returns The max number of active particles.
  85659. */
  85660. getCapacity(): number;
  85661. /**
  85662. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85663. * @returns True if it has been started, otherwise false.
  85664. */
  85665. isStarted(): boolean;
  85666. /**
  85667. * Animates the particle system for this frame.
  85668. */
  85669. animate(): void;
  85670. /**
  85671. * Renders the particle system in its current state.
  85672. * @returns the current number of particles
  85673. */
  85674. render(): number;
  85675. /**
  85676. * Dispose the particle system and frees its associated resources.
  85677. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85678. */
  85679. dispose(disposeTexture?: boolean): void;
  85680. /**
  85681. * Clones the particle system.
  85682. * @param name The name of the cloned object
  85683. * @param newEmitter The new emitter to use
  85684. * @returns the cloned particle system
  85685. */
  85686. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85687. /**
  85688. * Serializes the particle system to a JSON object.
  85689. * @returns the JSON object
  85690. */
  85691. serialize(): any;
  85692. /**
  85693. * Rebuild the particle system
  85694. */
  85695. rebuild(): void;
  85696. /**
  85697. * Starts the particle system and begins to emit
  85698. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85699. */
  85700. start(delay?: number): void;
  85701. /**
  85702. * Stops the particle system.
  85703. */
  85704. stop(): void;
  85705. /**
  85706. * Remove all active particles
  85707. */
  85708. reset(): void;
  85709. /**
  85710. * Is this system ready to be used/rendered
  85711. * @return true if the system is ready
  85712. */
  85713. isReady(): boolean;
  85714. /**
  85715. * Adds a new color gradient
  85716. * @param gradient defines the gradient to use (between 0 and 1)
  85717. * @param color1 defines the color to affect to the specified gradient
  85718. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85719. * @returns the current particle system
  85720. */
  85721. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85722. /**
  85723. * Remove a specific color gradient
  85724. * @param gradient defines the gradient to remove
  85725. * @returns the current particle system
  85726. */
  85727. removeColorGradient(gradient: number): IParticleSystem;
  85728. /**
  85729. * Adds a new size gradient
  85730. * @param gradient defines the gradient to use (between 0 and 1)
  85731. * @param factor defines the size factor to affect to the specified gradient
  85732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85733. * @returns the current particle system
  85734. */
  85735. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85736. /**
  85737. * Remove a specific size gradient
  85738. * @param gradient defines the gradient to remove
  85739. * @returns the current particle system
  85740. */
  85741. removeSizeGradient(gradient: number): IParticleSystem;
  85742. /**
  85743. * Gets the current list of color gradients.
  85744. * You must use addColorGradient and removeColorGradient to udpate this list
  85745. * @returns the list of color gradients
  85746. */
  85747. getColorGradients(): Nullable<Array<ColorGradient>>;
  85748. /**
  85749. * Gets the current list of size gradients.
  85750. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85751. * @returns the list of size gradients
  85752. */
  85753. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85754. /**
  85755. * Gets the current list of angular speed gradients.
  85756. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85757. * @returns the list of angular speed gradients
  85758. */
  85759. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85760. /**
  85761. * Adds a new angular speed gradient
  85762. * @param gradient defines the gradient to use (between 0 and 1)
  85763. * @param factor defines the angular speed to affect to the specified gradient
  85764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85765. * @returns the current particle system
  85766. */
  85767. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85768. /**
  85769. * Remove a specific angular speed gradient
  85770. * @param gradient defines the gradient to remove
  85771. * @returns the current particle system
  85772. */
  85773. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85774. /**
  85775. * Gets the current list of velocity gradients.
  85776. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85777. * @returns the list of velocity gradients
  85778. */
  85779. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85780. /**
  85781. * Adds a new velocity gradient
  85782. * @param gradient defines the gradient to use (between 0 and 1)
  85783. * @param factor defines the velocity to affect to the specified gradient
  85784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85785. * @returns the current particle system
  85786. */
  85787. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85788. /**
  85789. * Remove a specific velocity gradient
  85790. * @param gradient defines the gradient to remove
  85791. * @returns the current particle system
  85792. */
  85793. removeVelocityGradient(gradient: number): IParticleSystem;
  85794. /**
  85795. * Gets the current list of limit velocity gradients.
  85796. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85797. * @returns the list of limit velocity gradients
  85798. */
  85799. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85800. /**
  85801. * Adds a new limit velocity gradient
  85802. * @param gradient defines the gradient to use (between 0 and 1)
  85803. * @param factor defines the limit velocity to affect to the specified gradient
  85804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85805. * @returns the current particle system
  85806. */
  85807. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85808. /**
  85809. * Remove a specific limit velocity gradient
  85810. * @param gradient defines the gradient to remove
  85811. * @returns the current particle system
  85812. */
  85813. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85814. /**
  85815. * Adds a new drag gradient
  85816. * @param gradient defines the gradient to use (between 0 and 1)
  85817. * @param factor defines the drag to affect to the specified gradient
  85818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85819. * @returns the current particle system
  85820. */
  85821. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85822. /**
  85823. * Remove a specific drag gradient
  85824. * @param gradient defines the gradient to remove
  85825. * @returns the current particle system
  85826. */
  85827. removeDragGradient(gradient: number): IParticleSystem;
  85828. /**
  85829. * Gets the current list of drag gradients.
  85830. * You must use addDragGradient and removeDragGradient to udpate this list
  85831. * @returns the list of drag gradients
  85832. */
  85833. getDragGradients(): Nullable<Array<FactorGradient>>;
  85834. /**
  85835. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85836. * @param gradient defines the gradient to use (between 0 and 1)
  85837. * @param factor defines the emit rate to affect to the specified gradient
  85838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85839. * @returns the current particle system
  85840. */
  85841. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85842. /**
  85843. * Remove a specific emit rate gradient
  85844. * @param gradient defines the gradient to remove
  85845. * @returns the current particle system
  85846. */
  85847. removeEmitRateGradient(gradient: number): IParticleSystem;
  85848. /**
  85849. * Gets the current list of emit rate gradients.
  85850. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85851. * @returns the list of emit rate gradients
  85852. */
  85853. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85854. /**
  85855. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85856. * @param gradient defines the gradient to use (between 0 and 1)
  85857. * @param factor defines the start size to affect to the specified gradient
  85858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85859. * @returns the current particle system
  85860. */
  85861. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85862. /**
  85863. * Remove a specific start size gradient
  85864. * @param gradient defines the gradient to remove
  85865. * @returns the current particle system
  85866. */
  85867. removeStartSizeGradient(gradient: number): IParticleSystem;
  85868. /**
  85869. * Gets the current list of start size gradients.
  85870. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85871. * @returns the list of start size gradients
  85872. */
  85873. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85874. /**
  85875. * Adds a new life time gradient
  85876. * @param gradient defines the gradient to use (between 0 and 1)
  85877. * @param factor defines the life time factor to affect to the specified gradient
  85878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85879. * @returns the current particle system
  85880. */
  85881. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85882. /**
  85883. * Remove a specific life time gradient
  85884. * @param gradient defines the gradient to remove
  85885. * @returns the current particle system
  85886. */
  85887. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85888. /**
  85889. * Gets the current list of life time gradients.
  85890. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85891. * @returns the list of life time gradients
  85892. */
  85893. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85894. /**
  85895. * Gets the current list of color gradients.
  85896. * You must use addColorGradient and removeColorGradient to udpate this list
  85897. * @returns the list of color gradients
  85898. */
  85899. getColorGradients(): Nullable<Array<ColorGradient>>;
  85900. /**
  85901. * Adds a new ramp gradient used to remap particle colors
  85902. * @param gradient defines the gradient to use (between 0 and 1)
  85903. * @param color defines the color to affect to the specified gradient
  85904. * @returns the current particle system
  85905. */
  85906. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85907. /**
  85908. * Gets the current list of ramp gradients.
  85909. * You must use addRampGradient and removeRampGradient to udpate this list
  85910. * @returns the list of ramp gradients
  85911. */
  85912. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85913. /** Gets or sets a boolean indicating that ramp gradients must be used
  85914. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85915. */
  85916. useRampGradients: boolean;
  85917. /**
  85918. * Adds a new color remap gradient
  85919. * @param gradient defines the gradient to use (between 0 and 1)
  85920. * @param min defines the color remap minimal range
  85921. * @param max defines the color remap maximal range
  85922. * @returns the current particle system
  85923. */
  85924. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85925. /**
  85926. * Gets the current list of color remap gradients.
  85927. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85928. * @returns the list of color remap gradients
  85929. */
  85930. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85931. /**
  85932. * Adds a new alpha remap gradient
  85933. * @param gradient defines the gradient to use (between 0 and 1)
  85934. * @param min defines the alpha remap minimal range
  85935. * @param max defines the alpha remap maximal range
  85936. * @returns the current particle system
  85937. */
  85938. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85939. /**
  85940. * Gets the current list of alpha remap gradients.
  85941. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85942. * @returns the list of alpha remap gradients
  85943. */
  85944. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85945. /**
  85946. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85947. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85948. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85949. * @returns the emitter
  85950. */
  85951. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85952. /**
  85953. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85954. * @param radius The radius of the hemisphere to emit from
  85955. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85956. * @returns the emitter
  85957. */
  85958. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85959. /**
  85960. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85961. * @param radius The radius of the sphere to emit from
  85962. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85963. * @returns the emitter
  85964. */
  85965. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85966. /**
  85967. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85968. * @param radius The radius of the sphere to emit from
  85969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85971. * @returns the emitter
  85972. */
  85973. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85974. /**
  85975. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85976. * @param radius The radius of the emission cylinder
  85977. * @param height The height of the emission cylinder
  85978. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85979. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85980. * @returns the emitter
  85981. */
  85982. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85983. /**
  85984. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85985. * @param radius The radius of the cylinder to emit from
  85986. * @param height The height of the emission cylinder
  85987. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85988. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85989. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85990. * @returns the emitter
  85991. */
  85992. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85993. /**
  85994. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85995. * @param radius The radius of the cone to emit from
  85996. * @param angle The base angle of the cone
  85997. * @returns the emitter
  85998. */
  85999. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86000. /**
  86001. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86004. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86005. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86006. * @returns the emitter
  86007. */
  86008. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86009. /**
  86010. * Get hosting scene
  86011. * @returns the scene
  86012. */
  86013. getScene(): Scene;
  86014. }
  86015. }
  86016. declare module BABYLON {
  86017. /**
  86018. * Creates an instance based on a source mesh.
  86019. */
  86020. export class InstancedMesh extends AbstractMesh {
  86021. private _sourceMesh;
  86022. private _currentLOD;
  86023. /** @hidden */
  86024. _indexInSourceMeshInstanceArray: number;
  86025. constructor(name: string, source: Mesh);
  86026. /**
  86027. * Returns the string "InstancedMesh".
  86028. */
  86029. getClassName(): string;
  86030. /** Gets the list of lights affecting that mesh */
  86031. readonly lightSources: Light[];
  86032. _resyncLightSources(): void;
  86033. _resyncLighSource(light: Light): void;
  86034. _removeLightSource(light: Light, dispose: boolean): void;
  86035. /**
  86036. * If the source mesh receives shadows
  86037. */
  86038. readonly receiveShadows: boolean;
  86039. /**
  86040. * The material of the source mesh
  86041. */
  86042. readonly material: Nullable<Material>;
  86043. /**
  86044. * Visibility of the source mesh
  86045. */
  86046. readonly visibility: number;
  86047. /**
  86048. * Skeleton of the source mesh
  86049. */
  86050. readonly skeleton: Nullable<Skeleton>;
  86051. /**
  86052. * Rendering ground id of the source mesh
  86053. */
  86054. renderingGroupId: number;
  86055. /**
  86056. * Returns the total number of vertices (integer).
  86057. */
  86058. getTotalVertices(): number;
  86059. /**
  86060. * Returns a positive integer : the total number of indices in this mesh geometry.
  86061. * @returns the numner of indices or zero if the mesh has no geometry.
  86062. */
  86063. getTotalIndices(): number;
  86064. /**
  86065. * The source mesh of the instance
  86066. */
  86067. readonly sourceMesh: Mesh;
  86068. /**
  86069. * Is this node ready to be used/rendered
  86070. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86071. * @return {boolean} is it ready
  86072. */
  86073. isReady(completeCheck?: boolean): boolean;
  86074. /**
  86075. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86076. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86077. * @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.
  86078. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86079. */
  86080. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86081. /**
  86082. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86083. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86084. * The `data` are either a numeric array either a Float32Array.
  86085. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86086. * 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).
  86087. * Note that a new underlying VertexBuffer object is created each call.
  86088. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86089. *
  86090. * Possible `kind` values :
  86091. * - VertexBuffer.PositionKind
  86092. * - VertexBuffer.UVKind
  86093. * - VertexBuffer.UV2Kind
  86094. * - VertexBuffer.UV3Kind
  86095. * - VertexBuffer.UV4Kind
  86096. * - VertexBuffer.UV5Kind
  86097. * - VertexBuffer.UV6Kind
  86098. * - VertexBuffer.ColorKind
  86099. * - VertexBuffer.MatricesIndicesKind
  86100. * - VertexBuffer.MatricesIndicesExtraKind
  86101. * - VertexBuffer.MatricesWeightsKind
  86102. * - VertexBuffer.MatricesWeightsExtraKind
  86103. *
  86104. * Returns the Mesh.
  86105. */
  86106. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86107. /**
  86108. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86109. * If the mesh has no geometry, it is simply returned as it is.
  86110. * The `data` are either a numeric array either a Float32Array.
  86111. * No new underlying VertexBuffer object is created.
  86112. * 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.
  86113. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86114. *
  86115. * Possible `kind` values :
  86116. * - VertexBuffer.PositionKind
  86117. * - VertexBuffer.UVKind
  86118. * - VertexBuffer.UV2Kind
  86119. * - VertexBuffer.UV3Kind
  86120. * - VertexBuffer.UV4Kind
  86121. * - VertexBuffer.UV5Kind
  86122. * - VertexBuffer.UV6Kind
  86123. * - VertexBuffer.ColorKind
  86124. * - VertexBuffer.MatricesIndicesKind
  86125. * - VertexBuffer.MatricesIndicesExtraKind
  86126. * - VertexBuffer.MatricesWeightsKind
  86127. * - VertexBuffer.MatricesWeightsExtraKind
  86128. *
  86129. * Returns the Mesh.
  86130. */
  86131. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86132. /**
  86133. * Sets the mesh indices.
  86134. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86135. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86136. * This method creates a new index buffer each call.
  86137. * Returns the Mesh.
  86138. */
  86139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86140. /**
  86141. * Boolean : True if the mesh owns the requested kind of data.
  86142. */
  86143. isVerticesDataPresent(kind: string): boolean;
  86144. /**
  86145. * Returns an array of indices (IndicesArray).
  86146. */
  86147. getIndices(): Nullable<IndicesArray>;
  86148. readonly _positions: Nullable<Vector3[]>;
  86149. /**
  86150. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86151. * This means the mesh underlying bounding box and sphere are recomputed.
  86152. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86153. * @returns the current mesh
  86154. */
  86155. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86156. /** @hidden */
  86157. _preActivate(): InstancedMesh;
  86158. /** @hidden */
  86159. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86160. /** @hidden */
  86161. _postActivate(): void;
  86162. getWorldMatrix(): Matrix;
  86163. readonly isAnInstance: boolean;
  86164. /**
  86165. * Returns the current associated LOD AbstractMesh.
  86166. */
  86167. getLOD(camera: Camera): AbstractMesh;
  86168. /** @hidden */
  86169. _syncSubMeshes(): InstancedMesh;
  86170. /** @hidden */
  86171. _generatePointsArray(): boolean;
  86172. /**
  86173. * Creates a new InstancedMesh from the current mesh.
  86174. * - name (string) : the cloned mesh name
  86175. * - newParent (optional Node) : the optional Node to parent the clone to.
  86176. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86177. *
  86178. * Returns the clone.
  86179. */
  86180. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86181. /**
  86182. * Disposes the InstancedMesh.
  86183. * Returns nothing.
  86184. */
  86185. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86186. }
  86187. }
  86188. declare module BABYLON {
  86189. /**
  86190. * Defines the options associated with the creation of a shader material.
  86191. */
  86192. export interface IShaderMaterialOptions {
  86193. /**
  86194. * Does the material work in alpha blend mode
  86195. */
  86196. needAlphaBlending: boolean;
  86197. /**
  86198. * Does the material work in alpha test mode
  86199. */
  86200. needAlphaTesting: boolean;
  86201. /**
  86202. * The list of attribute names used in the shader
  86203. */
  86204. attributes: string[];
  86205. /**
  86206. * The list of unifrom names used in the shader
  86207. */
  86208. uniforms: string[];
  86209. /**
  86210. * The list of UBO names used in the shader
  86211. */
  86212. uniformBuffers: string[];
  86213. /**
  86214. * The list of sampler names used in the shader
  86215. */
  86216. samplers: string[];
  86217. /**
  86218. * The list of defines used in the shader
  86219. */
  86220. defines: string[];
  86221. }
  86222. /**
  86223. * 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.
  86224. *
  86225. * This returned material effects how the mesh will look based on the code in the shaders.
  86226. *
  86227. * @see http://doc.babylonjs.com/how_to/shader_material
  86228. */
  86229. export class ShaderMaterial extends Material {
  86230. private _shaderPath;
  86231. private _options;
  86232. private _textures;
  86233. private _textureArrays;
  86234. private _floats;
  86235. private _ints;
  86236. private _floatsArrays;
  86237. private _colors3;
  86238. private _colors3Arrays;
  86239. private _colors4;
  86240. private _colors4Arrays;
  86241. private _vectors2;
  86242. private _vectors3;
  86243. private _vectors4;
  86244. private _matrices;
  86245. private _matrices3x3;
  86246. private _matrices2x2;
  86247. private _vectors2Arrays;
  86248. private _vectors3Arrays;
  86249. private _vectors4Arrays;
  86250. private _cachedWorldViewMatrix;
  86251. private _cachedWorldViewProjectionMatrix;
  86252. private _renderId;
  86253. /**
  86254. * Instantiate a new shader material.
  86255. * 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.
  86256. * This returned material effects how the mesh will look based on the code in the shaders.
  86257. * @see http://doc.babylonjs.com/how_to/shader_material
  86258. * @param name Define the name of the material in the scene
  86259. * @param scene Define the scene the material belongs to
  86260. * @param shaderPath Defines the route to the shader code in one of three ways:
  86261. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86262. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86263. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86264. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86265. * @param options Define the options used to create the shader
  86266. */
  86267. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86268. /**
  86269. * Gets the options used to compile the shader.
  86270. * They can be modified to trigger a new compilation
  86271. */
  86272. readonly options: IShaderMaterialOptions;
  86273. /**
  86274. * Gets the current class name of the material e.g. "ShaderMaterial"
  86275. * Mainly use in serialization.
  86276. * @returns the class name
  86277. */
  86278. getClassName(): string;
  86279. /**
  86280. * Specifies if the material will require alpha blending
  86281. * @returns a boolean specifying if alpha blending is needed
  86282. */
  86283. needAlphaBlending(): boolean;
  86284. /**
  86285. * Specifies if this material should be rendered in alpha test mode
  86286. * @returns a boolean specifying if an alpha test is needed.
  86287. */
  86288. needAlphaTesting(): boolean;
  86289. private _checkUniform;
  86290. /**
  86291. * Set a texture in the shader.
  86292. * @param name Define the name of the uniform samplers as defined in the shader
  86293. * @param texture Define the texture to bind to this sampler
  86294. * @return the material itself allowing "fluent" like uniform updates
  86295. */
  86296. setTexture(name: string, texture: Texture): ShaderMaterial;
  86297. /**
  86298. * Set a texture array in the shader.
  86299. * @param name Define the name of the uniform sampler array as defined in the shader
  86300. * @param textures Define the list of textures to bind to this sampler
  86301. * @return the material itself allowing "fluent" like uniform updates
  86302. */
  86303. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86304. /**
  86305. * Set a float in the shader.
  86306. * @param name Define the name of the uniform as defined in the shader
  86307. * @param value Define the value to give to the uniform
  86308. * @return the material itself allowing "fluent" like uniform updates
  86309. */
  86310. setFloat(name: string, value: number): ShaderMaterial;
  86311. /**
  86312. * Set a int in the shader.
  86313. * @param name Define the name of the uniform as defined in the shader
  86314. * @param value Define the value to give to the uniform
  86315. * @return the material itself allowing "fluent" like uniform updates
  86316. */
  86317. setInt(name: string, value: number): ShaderMaterial;
  86318. /**
  86319. * Set an array of floats in the shader.
  86320. * @param name Define the name of the uniform as defined in the shader
  86321. * @param value Define the value to give to the uniform
  86322. * @return the material itself allowing "fluent" like uniform updates
  86323. */
  86324. setFloats(name: string, value: number[]): ShaderMaterial;
  86325. /**
  86326. * Set a vec3 in the shader from a Color3.
  86327. * @param name Define the name of the uniform as defined in the shader
  86328. * @param value Define the value to give to the uniform
  86329. * @return the material itself allowing "fluent" like uniform updates
  86330. */
  86331. setColor3(name: string, value: Color3): ShaderMaterial;
  86332. /**
  86333. * Set a vec3 array in the shader from a Color3 array.
  86334. * @param name Define the name of the uniform as defined in the shader
  86335. * @param value Define the value to give to the uniform
  86336. * @return the material itself allowing "fluent" like uniform updates
  86337. */
  86338. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86339. /**
  86340. * Set a vec4 in the shader from a Color4.
  86341. * @param name Define the name of the uniform as defined in the shader
  86342. * @param value Define the value to give to the uniform
  86343. * @return the material itself allowing "fluent" like uniform updates
  86344. */
  86345. setColor4(name: string, value: Color4): ShaderMaterial;
  86346. /**
  86347. * Set a vec4 array in the shader from a Color4 array.
  86348. * @param name Define the name of the uniform as defined in the shader
  86349. * @param value Define the value to give to the uniform
  86350. * @return the material itself allowing "fluent" like uniform updates
  86351. */
  86352. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86353. /**
  86354. * Set a vec2 in the shader from a Vector2.
  86355. * @param name Define the name of the uniform as defined in the shader
  86356. * @param value Define the value to give to the uniform
  86357. * @return the material itself allowing "fluent" like uniform updates
  86358. */
  86359. setVector2(name: string, value: Vector2): ShaderMaterial;
  86360. /**
  86361. * Set a vec3 in the shader from a Vector3.
  86362. * @param name Define the name of the uniform as defined in the shader
  86363. * @param value Define the value to give to the uniform
  86364. * @return the material itself allowing "fluent" like uniform updates
  86365. */
  86366. setVector3(name: string, value: Vector3): ShaderMaterial;
  86367. /**
  86368. * Set a vec4 in the shader from a Vector4.
  86369. * @param name Define the name of the uniform as defined in the shader
  86370. * @param value Define the value to give to the uniform
  86371. * @return the material itself allowing "fluent" like uniform updates
  86372. */
  86373. setVector4(name: string, value: Vector4): ShaderMaterial;
  86374. /**
  86375. * Set a mat4 in the shader from a Matrix.
  86376. * @param name Define the name of the uniform as defined in the shader
  86377. * @param value Define the value to give to the uniform
  86378. * @return the material itself allowing "fluent" like uniform updates
  86379. */
  86380. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86381. /**
  86382. * Set a mat3 in the shader from a Float32Array.
  86383. * @param name Define the name of the uniform as defined in the shader
  86384. * @param value Define the value to give to the uniform
  86385. * @return the material itself allowing "fluent" like uniform updates
  86386. */
  86387. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86388. /**
  86389. * Set a mat2 in the shader from a Float32Array.
  86390. * @param name Define the name of the uniform as defined in the shader
  86391. * @param value Define the value to give to the uniform
  86392. * @return the material itself allowing "fluent" like uniform updates
  86393. */
  86394. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86395. /**
  86396. * Set a vec2 array in the shader from a number array.
  86397. * @param name Define the name of the uniform as defined in the shader
  86398. * @param value Define the value to give to the uniform
  86399. * @return the material itself allowing "fluent" like uniform updates
  86400. */
  86401. setArray2(name: string, value: number[]): ShaderMaterial;
  86402. /**
  86403. * Set a vec3 array in the shader from a number array.
  86404. * @param name Define the name of the uniform as defined in the shader
  86405. * @param value Define the value to give to the uniform
  86406. * @return the material itself allowing "fluent" like uniform updates
  86407. */
  86408. setArray3(name: string, value: number[]): ShaderMaterial;
  86409. /**
  86410. * Set a vec4 array in the shader from a number array.
  86411. * @param name Define the name of the uniform as defined in the shader
  86412. * @param value Define the value to give to the uniform
  86413. * @return the material itself allowing "fluent" like uniform updates
  86414. */
  86415. setArray4(name: string, value: number[]): ShaderMaterial;
  86416. private _checkCache;
  86417. /**
  86418. * Specifies that the submesh is ready to be used
  86419. * @param mesh defines the mesh to check
  86420. * @param subMesh defines which submesh to check
  86421. * @param useInstances specifies that instances should be used
  86422. * @returns a boolean indicating that the submesh is ready or not
  86423. */
  86424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86425. /**
  86426. * Checks if the material is ready to render the requested mesh
  86427. * @param mesh Define the mesh to render
  86428. * @param useInstances Define whether or not the material is used with instances
  86429. * @returns true if ready, otherwise false
  86430. */
  86431. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86432. /**
  86433. * Binds the world matrix to the material
  86434. * @param world defines the world transformation matrix
  86435. */
  86436. bindOnlyWorldMatrix(world: Matrix): void;
  86437. /**
  86438. * Binds the material to the mesh
  86439. * @param world defines the world transformation matrix
  86440. * @param mesh defines the mesh to bind the material to
  86441. */
  86442. bind(world: Matrix, mesh?: Mesh): void;
  86443. /**
  86444. * Gets the active textures from the material
  86445. * @returns an array of textures
  86446. */
  86447. getActiveTextures(): BaseTexture[];
  86448. /**
  86449. * Specifies if the material uses a texture
  86450. * @param texture defines the texture to check against the material
  86451. * @returns a boolean specifying if the material uses the texture
  86452. */
  86453. hasTexture(texture: BaseTexture): boolean;
  86454. /**
  86455. * Makes a duplicate of the material, and gives it a new name
  86456. * @param name defines the new name for the duplicated material
  86457. * @returns the cloned material
  86458. */
  86459. clone(name: string): ShaderMaterial;
  86460. /**
  86461. * Disposes the material
  86462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86463. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86464. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86465. */
  86466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86467. /**
  86468. * Serializes this material in a JSON representation
  86469. * @returns the serialized material object
  86470. */
  86471. serialize(): any;
  86472. /**
  86473. * Creates a shader material from parsed shader material data
  86474. * @param source defines the JSON represnetation of the material
  86475. * @param scene defines the hosting scene
  86476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86477. * @returns a new material
  86478. */
  86479. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86480. }
  86481. }
  86482. declare module BABYLON {
  86483. /** @hidden */
  86484. export var colorPixelShader: {
  86485. name: string;
  86486. shader: string;
  86487. };
  86488. }
  86489. declare module BABYLON {
  86490. /** @hidden */
  86491. export var colorVertexShader: {
  86492. name: string;
  86493. shader: string;
  86494. };
  86495. }
  86496. declare module BABYLON {
  86497. /**
  86498. * Line mesh
  86499. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86500. */
  86501. export class LinesMesh extends Mesh {
  86502. /**
  86503. * If vertex color should be applied to the mesh
  86504. */
  86505. readonly useVertexColor?: boolean | undefined;
  86506. /**
  86507. * If vertex alpha should be applied to the mesh
  86508. */
  86509. readonly useVertexAlpha?: boolean | undefined;
  86510. /**
  86511. * Color of the line (Default: White)
  86512. */
  86513. color: Color3;
  86514. /**
  86515. * Alpha of the line (Default: 1)
  86516. */
  86517. alpha: number;
  86518. /**
  86519. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86520. * This margin is expressed in world space coordinates, so its value may vary.
  86521. * Default value is 0.1
  86522. */
  86523. intersectionThreshold: number;
  86524. private _colorShader;
  86525. private color4;
  86526. /**
  86527. * Creates a new LinesMesh
  86528. * @param name defines the name
  86529. * @param scene defines the hosting scene
  86530. * @param parent defines the parent mesh if any
  86531. * @param source defines the optional source LinesMesh used to clone data from
  86532. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86533. * When false, achieved by calling a clone(), also passing False.
  86534. * This will make creation of children, recursive.
  86535. * @param useVertexColor defines if this LinesMesh supports vertex color
  86536. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86537. */
  86538. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86539. /**
  86540. * If vertex color should be applied to the mesh
  86541. */
  86542. useVertexColor?: boolean | undefined,
  86543. /**
  86544. * If vertex alpha should be applied to the mesh
  86545. */
  86546. useVertexAlpha?: boolean | undefined);
  86547. private _addClipPlaneDefine;
  86548. private _removeClipPlaneDefine;
  86549. isReady(): boolean;
  86550. /**
  86551. * Returns the string "LineMesh"
  86552. */
  86553. getClassName(): string;
  86554. /**
  86555. * @hidden
  86556. */
  86557. /**
  86558. * @hidden
  86559. */
  86560. material: Material;
  86561. /**
  86562. * @hidden
  86563. */
  86564. readonly checkCollisions: boolean;
  86565. /** @hidden */
  86566. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86567. /** @hidden */
  86568. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86569. /**
  86570. * Disposes of the line mesh
  86571. * @param doNotRecurse If children should be disposed
  86572. */
  86573. dispose(doNotRecurse?: boolean): void;
  86574. /**
  86575. * Returns a new LineMesh object cloned from the current one.
  86576. */
  86577. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86578. /**
  86579. * Creates a new InstancedLinesMesh object from the mesh model.
  86580. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86581. * @param name defines the name of the new instance
  86582. * @returns a new InstancedLinesMesh
  86583. */
  86584. createInstance(name: string): InstancedLinesMesh;
  86585. }
  86586. /**
  86587. * Creates an instance based on a source LinesMesh
  86588. */
  86589. export class InstancedLinesMesh extends InstancedMesh {
  86590. /**
  86591. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86592. * This margin is expressed in world space coordinates, so its value may vary.
  86593. * Initilized with the intersectionThreshold value of the source LinesMesh
  86594. */
  86595. intersectionThreshold: number;
  86596. constructor(name: string, source: LinesMesh);
  86597. /**
  86598. * Returns the string "InstancedLinesMesh".
  86599. */
  86600. getClassName(): string;
  86601. }
  86602. }
  86603. declare module BABYLON {
  86604. /** @hidden */
  86605. export var linePixelShader: {
  86606. name: string;
  86607. shader: string;
  86608. };
  86609. }
  86610. declare module BABYLON {
  86611. /** @hidden */
  86612. export var lineVertexShader: {
  86613. name: string;
  86614. shader: string;
  86615. };
  86616. }
  86617. declare module BABYLON {
  86618. interface AbstractMesh {
  86619. /**
  86620. * Gets the edgesRenderer associated with the mesh
  86621. */
  86622. edgesRenderer: Nullable<EdgesRenderer>;
  86623. }
  86624. interface LinesMesh {
  86625. /**
  86626. * Enables the edge rendering mode on the mesh.
  86627. * This mode makes the mesh edges visible
  86628. * @param epsilon defines the maximal distance between two angles to detect a face
  86629. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86630. * @returns the currentAbstractMesh
  86631. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86632. */
  86633. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86634. }
  86635. interface InstancedLinesMesh {
  86636. /**
  86637. * Enables the edge rendering mode on the mesh.
  86638. * This mode makes the mesh edges visible
  86639. * @param epsilon defines the maximal distance between two angles to detect a face
  86640. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86641. * @returns the current InstancedLinesMesh
  86642. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86643. */
  86644. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86645. }
  86646. /**
  86647. * Defines the minimum contract an Edges renderer should follow.
  86648. */
  86649. export interface IEdgesRenderer extends IDisposable {
  86650. /**
  86651. * Gets or sets a boolean indicating if the edgesRenderer is active
  86652. */
  86653. isEnabled: boolean;
  86654. /**
  86655. * Renders the edges of the attached mesh,
  86656. */
  86657. render(): void;
  86658. /**
  86659. * Checks wether or not the edges renderer is ready to render.
  86660. * @return true if ready, otherwise false.
  86661. */
  86662. isReady(): boolean;
  86663. }
  86664. /**
  86665. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86666. */
  86667. export class EdgesRenderer implements IEdgesRenderer {
  86668. /**
  86669. * Define the size of the edges with an orthographic camera
  86670. */
  86671. edgesWidthScalerForOrthographic: number;
  86672. /**
  86673. * Define the size of the edges with a perspective camera
  86674. */
  86675. edgesWidthScalerForPerspective: number;
  86676. protected _source: AbstractMesh;
  86677. protected _linesPositions: number[];
  86678. protected _linesNormals: number[];
  86679. protected _linesIndices: number[];
  86680. protected _epsilon: number;
  86681. protected _indicesCount: number;
  86682. protected _lineShader: ShaderMaterial;
  86683. protected _ib: DataBuffer;
  86684. protected _buffers: {
  86685. [key: string]: Nullable<VertexBuffer>;
  86686. };
  86687. protected _checkVerticesInsteadOfIndices: boolean;
  86688. private _meshRebuildObserver;
  86689. private _meshDisposeObserver;
  86690. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86691. isEnabled: boolean;
  86692. /**
  86693. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86694. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86695. * @param source Mesh used to create edges
  86696. * @param epsilon sum of angles in adjacency to check for edge
  86697. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86698. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86699. */
  86700. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86701. protected _prepareRessources(): void;
  86702. /** @hidden */
  86703. _rebuild(): void;
  86704. /**
  86705. * Releases the required resources for the edges renderer
  86706. */
  86707. dispose(): void;
  86708. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86709. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86710. /**
  86711. * Checks if the pair of p0 and p1 is en edge
  86712. * @param faceIndex
  86713. * @param edge
  86714. * @param faceNormals
  86715. * @param p0
  86716. * @param p1
  86717. * @private
  86718. */
  86719. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86720. /**
  86721. * push line into the position, normal and index buffer
  86722. * @protected
  86723. */
  86724. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86725. /**
  86726. * Generates lines edges from adjacencjes
  86727. * @private
  86728. */
  86729. _generateEdgesLines(): void;
  86730. /**
  86731. * Checks wether or not the edges renderer is ready to render.
  86732. * @return true if ready, otherwise false.
  86733. */
  86734. isReady(): boolean;
  86735. /**
  86736. * Renders the edges of the attached mesh,
  86737. */
  86738. render(): void;
  86739. }
  86740. /**
  86741. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86742. */
  86743. export class LineEdgesRenderer extends EdgesRenderer {
  86744. /**
  86745. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86746. * @param source LineMesh used to generate edges
  86747. * @param epsilon not important (specified angle for edge detection)
  86748. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86749. */
  86750. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86751. /**
  86752. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86753. */
  86754. _generateEdgesLines(): void;
  86755. }
  86756. }
  86757. declare module BABYLON {
  86758. /**
  86759. * This represents the object necessary to create a rendering group.
  86760. * This is exclusively used and created by the rendering manager.
  86761. * To modify the behavior, you use the available helpers in your scene or meshes.
  86762. * @hidden
  86763. */
  86764. export class RenderingGroup {
  86765. index: number;
  86766. private static _zeroVector;
  86767. private _scene;
  86768. private _opaqueSubMeshes;
  86769. private _transparentSubMeshes;
  86770. private _alphaTestSubMeshes;
  86771. private _depthOnlySubMeshes;
  86772. private _particleSystems;
  86773. private _spriteManagers;
  86774. private _opaqueSortCompareFn;
  86775. private _alphaTestSortCompareFn;
  86776. private _transparentSortCompareFn;
  86777. private _renderOpaque;
  86778. private _renderAlphaTest;
  86779. private _renderTransparent;
  86780. /** @hidden */
  86781. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86782. onBeforeTransparentRendering: () => void;
  86783. /**
  86784. * Set the opaque sort comparison function.
  86785. * If null the sub meshes will be render in the order they were created
  86786. */
  86787. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86788. /**
  86789. * Set the alpha test sort comparison function.
  86790. * If null the sub meshes will be render in the order they were created
  86791. */
  86792. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86793. /**
  86794. * Set the transparent sort comparison function.
  86795. * If null the sub meshes will be render in the order they were created
  86796. */
  86797. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86798. /**
  86799. * Creates a new rendering group.
  86800. * @param index The rendering group index
  86801. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86802. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86803. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86804. */
  86805. 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>);
  86806. /**
  86807. * Render all the sub meshes contained in the group.
  86808. * @param customRenderFunction Used to override the default render behaviour of the group.
  86809. * @returns true if rendered some submeshes.
  86810. */
  86811. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86812. /**
  86813. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86814. * @param subMeshes The submeshes to render
  86815. */
  86816. private renderOpaqueSorted;
  86817. /**
  86818. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86819. * @param subMeshes The submeshes to render
  86820. */
  86821. private renderAlphaTestSorted;
  86822. /**
  86823. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86824. * @param subMeshes The submeshes to render
  86825. */
  86826. private renderTransparentSorted;
  86827. /**
  86828. * Renders the submeshes in a specified order.
  86829. * @param subMeshes The submeshes to sort before render
  86830. * @param sortCompareFn The comparison function use to sort
  86831. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86832. * @param transparent Specifies to activate blending if true
  86833. */
  86834. private static renderSorted;
  86835. /**
  86836. * Renders the submeshes in the order they were dispatched (no sort applied).
  86837. * @param subMeshes The submeshes to render
  86838. */
  86839. private static renderUnsorted;
  86840. /**
  86841. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86842. * are rendered back to front if in the same alpha index.
  86843. *
  86844. * @param a The first submesh
  86845. * @param b The second submesh
  86846. * @returns The result of the comparison
  86847. */
  86848. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86849. /**
  86850. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86851. * are rendered back to front.
  86852. *
  86853. * @param a The first submesh
  86854. * @param b The second submesh
  86855. * @returns The result of the comparison
  86856. */
  86857. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86858. /**
  86859. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86860. * are rendered front to back (prevent overdraw).
  86861. *
  86862. * @param a The first submesh
  86863. * @param b The second submesh
  86864. * @returns The result of the comparison
  86865. */
  86866. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86867. /**
  86868. * Resets the different lists of submeshes to prepare a new frame.
  86869. */
  86870. prepare(): void;
  86871. dispose(): void;
  86872. /**
  86873. * Inserts the submesh in its correct queue depending on its material.
  86874. * @param subMesh The submesh to dispatch
  86875. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86876. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86877. */
  86878. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86879. dispatchSprites(spriteManager: ISpriteManager): void;
  86880. dispatchParticles(particleSystem: IParticleSystem): void;
  86881. private _renderParticles;
  86882. private _renderSprites;
  86883. }
  86884. }
  86885. declare module BABYLON {
  86886. /**
  86887. * Interface describing the different options available in the rendering manager
  86888. * regarding Auto Clear between groups.
  86889. */
  86890. export interface IRenderingManagerAutoClearSetup {
  86891. /**
  86892. * Defines whether or not autoclear is enable.
  86893. */
  86894. autoClear: boolean;
  86895. /**
  86896. * Defines whether or not to autoclear the depth buffer.
  86897. */
  86898. depth: boolean;
  86899. /**
  86900. * Defines whether or not to autoclear the stencil buffer.
  86901. */
  86902. stencil: boolean;
  86903. }
  86904. /**
  86905. * This class is used by the onRenderingGroupObservable
  86906. */
  86907. export class RenderingGroupInfo {
  86908. /**
  86909. * The Scene that being rendered
  86910. */
  86911. scene: Scene;
  86912. /**
  86913. * The camera currently used for the rendering pass
  86914. */
  86915. camera: Nullable<Camera>;
  86916. /**
  86917. * The ID of the renderingGroup being processed
  86918. */
  86919. renderingGroupId: number;
  86920. }
  86921. /**
  86922. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86923. * It is enable to manage the different groups as well as the different necessary sort functions.
  86924. * This should not be used directly aside of the few static configurations
  86925. */
  86926. export class RenderingManager {
  86927. /**
  86928. * The max id used for rendering groups (not included)
  86929. */
  86930. static MAX_RENDERINGGROUPS: number;
  86931. /**
  86932. * The min id used for rendering groups (included)
  86933. */
  86934. static MIN_RENDERINGGROUPS: number;
  86935. /**
  86936. * Used to globally prevent autoclearing scenes.
  86937. */
  86938. static AUTOCLEAR: boolean;
  86939. /**
  86940. * @hidden
  86941. */
  86942. _useSceneAutoClearSetup: boolean;
  86943. private _scene;
  86944. private _renderingGroups;
  86945. private _depthStencilBufferAlreadyCleaned;
  86946. private _autoClearDepthStencil;
  86947. private _customOpaqueSortCompareFn;
  86948. private _customAlphaTestSortCompareFn;
  86949. private _customTransparentSortCompareFn;
  86950. private _renderingGroupInfo;
  86951. /**
  86952. * Instantiates a new rendering group for a particular scene
  86953. * @param scene Defines the scene the groups belongs to
  86954. */
  86955. constructor(scene: Scene);
  86956. private _clearDepthStencilBuffer;
  86957. /**
  86958. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86959. * @hidden
  86960. */
  86961. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86962. /**
  86963. * Resets the different information of the group to prepare a new frame
  86964. * @hidden
  86965. */
  86966. reset(): void;
  86967. /**
  86968. * Dispose and release the group and its associated resources.
  86969. * @hidden
  86970. */
  86971. dispose(): void;
  86972. /**
  86973. * Clear the info related to rendering groups preventing retention points during dispose.
  86974. */
  86975. freeRenderingGroups(): void;
  86976. private _prepareRenderingGroup;
  86977. /**
  86978. * Add a sprite manager to the rendering manager in order to render it this frame.
  86979. * @param spriteManager Define the sprite manager to render
  86980. */
  86981. dispatchSprites(spriteManager: ISpriteManager): void;
  86982. /**
  86983. * Add a particle system to the rendering manager in order to render it this frame.
  86984. * @param particleSystem Define the particle system to render
  86985. */
  86986. dispatchParticles(particleSystem: IParticleSystem): void;
  86987. /**
  86988. * Add a submesh to the manager in order to render it this frame
  86989. * @param subMesh The submesh to dispatch
  86990. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86991. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86992. */
  86993. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86994. /**
  86995. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86996. * This allowed control for front to back rendering or reversly depending of the special needs.
  86997. *
  86998. * @param renderingGroupId The rendering group id corresponding to its index
  86999. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87000. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87001. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87002. */
  87003. 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;
  87004. /**
  87005. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87006. *
  87007. * @param renderingGroupId The rendering group id corresponding to its index
  87008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87009. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87010. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87011. */
  87012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87013. /**
  87014. * Gets the current auto clear configuration for one rendering group of the rendering
  87015. * manager.
  87016. * @param index the rendering group index to get the information for
  87017. * @returns The auto clear setup for the requested rendering group
  87018. */
  87019. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87020. }
  87021. }
  87022. declare module BABYLON {
  87023. /**
  87024. * This Helps creating a texture that will be created from a camera in your scene.
  87025. * It is basically a dynamic texture that could be used to create special effects for instance.
  87026. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87027. */
  87028. export class RenderTargetTexture extends Texture {
  87029. isCube: boolean;
  87030. /**
  87031. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87032. */
  87033. static readonly REFRESHRATE_RENDER_ONCE: number;
  87034. /**
  87035. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87036. */
  87037. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87038. /**
  87039. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87040. * the central point of your effect and can save a lot of performances.
  87041. */
  87042. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87043. /**
  87044. * Use this predicate to dynamically define the list of mesh you want to render.
  87045. * If set, the renderList property will be overwritten.
  87046. */
  87047. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87048. private _renderList;
  87049. /**
  87050. * Use this list to define the list of mesh you want to render.
  87051. */
  87052. renderList: Nullable<Array<AbstractMesh>>;
  87053. private _hookArray;
  87054. /**
  87055. * Define if particles should be rendered in your texture.
  87056. */
  87057. renderParticles: boolean;
  87058. /**
  87059. * Define if sprites should be rendered in your texture.
  87060. */
  87061. renderSprites: boolean;
  87062. /**
  87063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87064. */
  87065. coordinatesMode: number;
  87066. /**
  87067. * Define the camera used to render the texture.
  87068. */
  87069. activeCamera: Nullable<Camera>;
  87070. /**
  87071. * Override the render function of the texture with your own one.
  87072. */
  87073. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87074. /**
  87075. * Define if camera post processes should be use while rendering the texture.
  87076. */
  87077. useCameraPostProcesses: boolean;
  87078. /**
  87079. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87080. */
  87081. ignoreCameraViewport: boolean;
  87082. private _postProcessManager;
  87083. private _postProcesses;
  87084. private _resizeObserver;
  87085. /**
  87086. * An event triggered when the texture is unbind.
  87087. */
  87088. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87089. /**
  87090. * An event triggered when the texture is unbind.
  87091. */
  87092. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87093. private _onAfterUnbindObserver;
  87094. /**
  87095. * Set a after unbind callback in the texture.
  87096. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87097. */
  87098. onAfterUnbind: () => void;
  87099. /**
  87100. * An event triggered before rendering the texture
  87101. */
  87102. onBeforeRenderObservable: Observable<number>;
  87103. private _onBeforeRenderObserver;
  87104. /**
  87105. * Set a before render callback in the texture.
  87106. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87107. */
  87108. onBeforeRender: (faceIndex: number) => void;
  87109. /**
  87110. * An event triggered after rendering the texture
  87111. */
  87112. onAfterRenderObservable: Observable<number>;
  87113. private _onAfterRenderObserver;
  87114. /**
  87115. * Set a after render callback in the texture.
  87116. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87117. */
  87118. onAfterRender: (faceIndex: number) => void;
  87119. /**
  87120. * An event triggered after the texture clear
  87121. */
  87122. onClearObservable: Observable<Engine>;
  87123. private _onClearObserver;
  87124. /**
  87125. * Set a clear callback in the texture.
  87126. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87127. */
  87128. onClear: (Engine: Engine) => void;
  87129. /**
  87130. * An event triggered when the texture is resized.
  87131. */
  87132. onResizeObservable: Observable<RenderTargetTexture>;
  87133. /**
  87134. * Define the clear color of the Render Target if it should be different from the scene.
  87135. */
  87136. clearColor: Color4;
  87137. protected _size: number | {
  87138. width: number;
  87139. height: number;
  87140. };
  87141. protected _initialSizeParameter: number | {
  87142. width: number;
  87143. height: number;
  87144. } | {
  87145. ratio: number;
  87146. };
  87147. protected _sizeRatio: Nullable<number>;
  87148. /** @hidden */
  87149. _generateMipMaps: boolean;
  87150. protected _renderingManager: RenderingManager;
  87151. /** @hidden */
  87152. _waitingRenderList: string[];
  87153. protected _doNotChangeAspectRatio: boolean;
  87154. protected _currentRefreshId: number;
  87155. protected _refreshRate: number;
  87156. protected _textureMatrix: Matrix;
  87157. protected _samples: number;
  87158. protected _renderTargetOptions: RenderTargetCreationOptions;
  87159. /**
  87160. * Gets render target creation options that were used.
  87161. */
  87162. readonly renderTargetOptions: RenderTargetCreationOptions;
  87163. protected _engine: Engine;
  87164. protected _onRatioRescale(): void;
  87165. /**
  87166. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87167. * It must define where the camera used to render the texture is set
  87168. */
  87169. boundingBoxPosition: Vector3;
  87170. private _boundingBoxSize;
  87171. /**
  87172. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87173. * When defined, the cubemap will switch to local mode
  87174. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87175. * @example https://www.babylonjs-playground.com/#RNASML
  87176. */
  87177. boundingBoxSize: Vector3;
  87178. /**
  87179. * In case the RTT has been created with a depth texture, get the associated
  87180. * depth texture.
  87181. * Otherwise, return null.
  87182. */
  87183. depthStencilTexture: Nullable<InternalTexture>;
  87184. /**
  87185. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87186. * or used a shadow, depth texture...
  87187. * @param name The friendly name of the texture
  87188. * @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)
  87189. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87190. * @param generateMipMaps True if mip maps need to be generated after render.
  87191. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87192. * @param type The type of the buffer in the RTT (int, half float, float...)
  87193. * @param isCube True if a cube texture needs to be created
  87194. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87195. * @param generateDepthBuffer True to generate a depth buffer
  87196. * @param generateStencilBuffer True to generate a stencil buffer
  87197. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87198. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87199. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87200. */
  87201. constructor(name: string, size: number | {
  87202. width: number;
  87203. height: number;
  87204. } | {
  87205. ratio: number;
  87206. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87207. /**
  87208. * Creates a depth stencil texture.
  87209. * This is only available in WebGL 2 or with the depth texture extension available.
  87210. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87211. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87212. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87213. */
  87214. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87215. private _processSizeParameter;
  87216. /**
  87217. * Define the number of samples to use in case of MSAA.
  87218. * It defaults to one meaning no MSAA has been enabled.
  87219. */
  87220. samples: number;
  87221. /**
  87222. * Resets the refresh counter of the texture and start bak from scratch.
  87223. * Could be useful to regenerate the texture if it is setup to render only once.
  87224. */
  87225. resetRefreshCounter(): void;
  87226. /**
  87227. * Define the refresh rate of the texture or the rendering frequency.
  87228. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87229. */
  87230. refreshRate: number;
  87231. /**
  87232. * Adds a post process to the render target rendering passes.
  87233. * @param postProcess define the post process to add
  87234. */
  87235. addPostProcess(postProcess: PostProcess): void;
  87236. /**
  87237. * Clear all the post processes attached to the render target
  87238. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87239. */
  87240. clearPostProcesses(dispose?: boolean): void;
  87241. /**
  87242. * Remove one of the post process from the list of attached post processes to the texture
  87243. * @param postProcess define the post process to remove from the list
  87244. */
  87245. removePostProcess(postProcess: PostProcess): void;
  87246. /** @hidden */
  87247. _shouldRender(): boolean;
  87248. /**
  87249. * Gets the actual render size of the texture.
  87250. * @returns the width of the render size
  87251. */
  87252. getRenderSize(): number;
  87253. /**
  87254. * Gets the actual render width of the texture.
  87255. * @returns the width of the render size
  87256. */
  87257. getRenderWidth(): number;
  87258. /**
  87259. * Gets the actual render height of the texture.
  87260. * @returns the height of the render size
  87261. */
  87262. getRenderHeight(): number;
  87263. /**
  87264. * Get if the texture can be rescaled or not.
  87265. */
  87266. readonly canRescale: boolean;
  87267. /**
  87268. * Resize the texture using a ratio.
  87269. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87270. */
  87271. scale(ratio: number): void;
  87272. /**
  87273. * Get the texture reflection matrix used to rotate/transform the reflection.
  87274. * @returns the reflection matrix
  87275. */
  87276. getReflectionTextureMatrix(): Matrix;
  87277. /**
  87278. * Resize the texture to a new desired size.
  87279. * Be carrefull as it will recreate all the data in the new texture.
  87280. * @param size Define the new size. It can be:
  87281. * - a number for squared texture,
  87282. * - an object containing { width: number, height: number }
  87283. * - or an object containing a ratio { ratio: number }
  87284. */
  87285. resize(size: number | {
  87286. width: number;
  87287. height: number;
  87288. } | {
  87289. ratio: number;
  87290. }): void;
  87291. /**
  87292. * Renders all the objects from the render list into the texture.
  87293. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87294. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87295. */
  87296. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87297. private _bestReflectionRenderTargetDimension;
  87298. /**
  87299. * @hidden
  87300. * @param faceIndex face index to bind to if this is a cubetexture
  87301. */
  87302. _bindFrameBuffer(faceIndex?: number): void;
  87303. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87304. private renderToTarget;
  87305. /**
  87306. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87307. * This allowed control for front to back rendering or reversly depending of the special needs.
  87308. *
  87309. * @param renderingGroupId The rendering group id corresponding to its index
  87310. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87311. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87312. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87313. */
  87314. 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;
  87315. /**
  87316. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87317. *
  87318. * @param renderingGroupId The rendering group id corresponding to its index
  87319. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87320. */
  87321. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87322. /**
  87323. * Clones the texture.
  87324. * @returns the cloned texture
  87325. */
  87326. clone(): RenderTargetTexture;
  87327. /**
  87328. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87329. * @returns The JSON representation of the texture
  87330. */
  87331. serialize(): any;
  87332. /**
  87333. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87334. */
  87335. disposeFramebufferObjects(): void;
  87336. /**
  87337. * Dispose the texture and release its associated resources.
  87338. */
  87339. dispose(): void;
  87340. /** @hidden */
  87341. _rebuild(): void;
  87342. /**
  87343. * Clear the info related to rendering groups preventing retention point in material dispose.
  87344. */
  87345. freeRenderingGroups(): void;
  87346. /**
  87347. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87348. * @returns the view count
  87349. */
  87350. getViewCount(): number;
  87351. }
  87352. }
  87353. declare module BABYLON {
  87354. /**
  87355. * Base class for the main features of a material in Babylon.js
  87356. */
  87357. export class Material implements IAnimatable {
  87358. /**
  87359. * Returns the triangle fill mode
  87360. */
  87361. static readonly TriangleFillMode: number;
  87362. /**
  87363. * Returns the wireframe mode
  87364. */
  87365. static readonly WireFrameFillMode: number;
  87366. /**
  87367. * Returns the point fill mode
  87368. */
  87369. static readonly PointFillMode: number;
  87370. /**
  87371. * Returns the point list draw mode
  87372. */
  87373. static readonly PointListDrawMode: number;
  87374. /**
  87375. * Returns the line list draw mode
  87376. */
  87377. static readonly LineListDrawMode: number;
  87378. /**
  87379. * Returns the line loop draw mode
  87380. */
  87381. static readonly LineLoopDrawMode: number;
  87382. /**
  87383. * Returns the line strip draw mode
  87384. */
  87385. static readonly LineStripDrawMode: number;
  87386. /**
  87387. * Returns the triangle strip draw mode
  87388. */
  87389. static readonly TriangleStripDrawMode: number;
  87390. /**
  87391. * Returns the triangle fan draw mode
  87392. */
  87393. static readonly TriangleFanDrawMode: number;
  87394. /**
  87395. * Stores the clock-wise side orientation
  87396. */
  87397. static readonly ClockWiseSideOrientation: number;
  87398. /**
  87399. * Stores the counter clock-wise side orientation
  87400. */
  87401. static readonly CounterClockWiseSideOrientation: number;
  87402. /**
  87403. * The dirty texture flag value
  87404. */
  87405. static readonly TextureDirtyFlag: number;
  87406. /**
  87407. * The dirty light flag value
  87408. */
  87409. static readonly LightDirtyFlag: number;
  87410. /**
  87411. * The dirty fresnel flag value
  87412. */
  87413. static readonly FresnelDirtyFlag: number;
  87414. /**
  87415. * The dirty attribute flag value
  87416. */
  87417. static readonly AttributesDirtyFlag: number;
  87418. /**
  87419. * The dirty misc flag value
  87420. */
  87421. static readonly MiscDirtyFlag: number;
  87422. /**
  87423. * The all dirty flag value
  87424. */
  87425. static readonly AllDirtyFlag: number;
  87426. /**
  87427. * The ID of the material
  87428. */
  87429. id: string;
  87430. /**
  87431. * Gets or sets the unique id of the material
  87432. */
  87433. uniqueId: number;
  87434. /**
  87435. * The name of the material
  87436. */
  87437. name: string;
  87438. /**
  87439. * Gets or sets user defined metadata
  87440. */
  87441. metadata: any;
  87442. /**
  87443. * For internal use only. Please do not use.
  87444. */
  87445. reservedDataStore: any;
  87446. /**
  87447. * Specifies if the ready state should be checked on each call
  87448. */
  87449. checkReadyOnEveryCall: boolean;
  87450. /**
  87451. * Specifies if the ready state should be checked once
  87452. */
  87453. checkReadyOnlyOnce: boolean;
  87454. /**
  87455. * The state of the material
  87456. */
  87457. state: string;
  87458. /**
  87459. * The alpha value of the material
  87460. */
  87461. protected _alpha: number;
  87462. /**
  87463. * List of inspectable custom properties (used by the Inspector)
  87464. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87465. */
  87466. inspectableCustomProperties: IInspectable[];
  87467. /**
  87468. * Sets the alpha value of the material
  87469. */
  87470. /**
  87471. * Gets the alpha value of the material
  87472. */
  87473. alpha: number;
  87474. /**
  87475. * Specifies if back face culling is enabled
  87476. */
  87477. protected _backFaceCulling: boolean;
  87478. /**
  87479. * Sets the back-face culling state
  87480. */
  87481. /**
  87482. * Gets the back-face culling state
  87483. */
  87484. backFaceCulling: boolean;
  87485. /**
  87486. * Stores the value for side orientation
  87487. */
  87488. sideOrientation: number;
  87489. /**
  87490. * Callback triggered when the material is compiled
  87491. */
  87492. onCompiled: Nullable<(effect: Effect) => void>;
  87493. /**
  87494. * Callback triggered when an error occurs
  87495. */
  87496. onError: Nullable<(effect: Effect, errors: string) => void>;
  87497. /**
  87498. * Callback triggered to get the render target textures
  87499. */
  87500. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87501. /**
  87502. * Gets a boolean indicating that current material needs to register RTT
  87503. */
  87504. readonly hasRenderTargetTextures: boolean;
  87505. /**
  87506. * Specifies if the material should be serialized
  87507. */
  87508. doNotSerialize: boolean;
  87509. /**
  87510. * @hidden
  87511. */
  87512. _storeEffectOnSubMeshes: boolean;
  87513. /**
  87514. * Stores the animations for the material
  87515. */
  87516. animations: Nullable<Array<Animation>>;
  87517. /**
  87518. * An event triggered when the material is disposed
  87519. */
  87520. onDisposeObservable: Observable<Material>;
  87521. /**
  87522. * An observer which watches for dispose events
  87523. */
  87524. private _onDisposeObserver;
  87525. private _onUnBindObservable;
  87526. /**
  87527. * Called during a dispose event
  87528. */
  87529. onDispose: () => void;
  87530. private _onBindObservable;
  87531. /**
  87532. * An event triggered when the material is bound
  87533. */
  87534. readonly onBindObservable: Observable<AbstractMesh>;
  87535. /**
  87536. * An observer which watches for bind events
  87537. */
  87538. private _onBindObserver;
  87539. /**
  87540. * Called during a bind event
  87541. */
  87542. onBind: (Mesh: AbstractMesh) => void;
  87543. /**
  87544. * An event triggered when the material is unbound
  87545. */
  87546. readonly onUnBindObservable: Observable<Material>;
  87547. /**
  87548. * Stores the value of the alpha mode
  87549. */
  87550. private _alphaMode;
  87551. /**
  87552. * Sets the value of the alpha mode.
  87553. *
  87554. * | Value | Type | Description |
  87555. * | --- | --- | --- |
  87556. * | 0 | ALPHA_DISABLE | |
  87557. * | 1 | ALPHA_ADD | |
  87558. * | 2 | ALPHA_COMBINE | |
  87559. * | 3 | ALPHA_SUBTRACT | |
  87560. * | 4 | ALPHA_MULTIPLY | |
  87561. * | 5 | ALPHA_MAXIMIZED | |
  87562. * | 6 | ALPHA_ONEONE | |
  87563. * | 7 | ALPHA_PREMULTIPLIED | |
  87564. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87565. * | 9 | ALPHA_INTERPOLATE | |
  87566. * | 10 | ALPHA_SCREENMODE | |
  87567. *
  87568. */
  87569. /**
  87570. * Gets the value of the alpha mode
  87571. */
  87572. alphaMode: number;
  87573. /**
  87574. * Stores the state of the need depth pre-pass value
  87575. */
  87576. private _needDepthPrePass;
  87577. /**
  87578. * Sets the need depth pre-pass value
  87579. */
  87580. /**
  87581. * Gets the depth pre-pass value
  87582. */
  87583. needDepthPrePass: boolean;
  87584. /**
  87585. * Specifies if depth writing should be disabled
  87586. */
  87587. disableDepthWrite: boolean;
  87588. /**
  87589. * Specifies if depth writing should be forced
  87590. */
  87591. forceDepthWrite: boolean;
  87592. /**
  87593. * Specifies if there should be a separate pass for culling
  87594. */
  87595. separateCullingPass: boolean;
  87596. /**
  87597. * Stores the state specifing if fog should be enabled
  87598. */
  87599. private _fogEnabled;
  87600. /**
  87601. * Sets the state for enabling fog
  87602. */
  87603. /**
  87604. * Gets the value of the fog enabled state
  87605. */
  87606. fogEnabled: boolean;
  87607. /**
  87608. * Stores the size of points
  87609. */
  87610. pointSize: number;
  87611. /**
  87612. * Stores the z offset value
  87613. */
  87614. zOffset: number;
  87615. /**
  87616. * Gets a value specifying if wireframe mode is enabled
  87617. */
  87618. /**
  87619. * Sets the state of wireframe mode
  87620. */
  87621. wireframe: boolean;
  87622. /**
  87623. * Gets the value specifying if point clouds are enabled
  87624. */
  87625. /**
  87626. * Sets the state of point cloud mode
  87627. */
  87628. pointsCloud: boolean;
  87629. /**
  87630. * Gets the material fill mode
  87631. */
  87632. /**
  87633. * Sets the material fill mode
  87634. */
  87635. fillMode: number;
  87636. /**
  87637. * @hidden
  87638. * Stores the effects for the material
  87639. */
  87640. _effect: Nullable<Effect>;
  87641. /**
  87642. * @hidden
  87643. * Specifies if the material was previously ready
  87644. */
  87645. _wasPreviouslyReady: boolean;
  87646. /**
  87647. * Specifies if uniform buffers should be used
  87648. */
  87649. private _useUBO;
  87650. /**
  87651. * Stores a reference to the scene
  87652. */
  87653. private _scene;
  87654. /**
  87655. * Stores the fill mode state
  87656. */
  87657. private _fillMode;
  87658. /**
  87659. * Specifies if the depth write state should be cached
  87660. */
  87661. private _cachedDepthWriteState;
  87662. /**
  87663. * Stores the uniform buffer
  87664. */
  87665. protected _uniformBuffer: UniformBuffer;
  87666. /** @hidden */
  87667. _indexInSceneMaterialArray: number;
  87668. /** @hidden */
  87669. meshMap: Nullable<{
  87670. [id: string]: AbstractMesh | undefined;
  87671. }>;
  87672. /**
  87673. * Creates a material instance
  87674. * @param name defines the name of the material
  87675. * @param scene defines the scene to reference
  87676. * @param doNotAdd specifies if the material should be added to the scene
  87677. */
  87678. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87679. /**
  87680. * Returns a string representation of the current material
  87681. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87682. * @returns a string with material information
  87683. */
  87684. toString(fullDetails?: boolean): string;
  87685. /**
  87686. * Gets the class name of the material
  87687. * @returns a string with the class name of the material
  87688. */
  87689. getClassName(): string;
  87690. /**
  87691. * Specifies if updates for the material been locked
  87692. */
  87693. readonly isFrozen: boolean;
  87694. /**
  87695. * Locks updates for the material
  87696. */
  87697. freeze(): void;
  87698. /**
  87699. * Unlocks updates for the material
  87700. */
  87701. unfreeze(): void;
  87702. /**
  87703. * Specifies if the material is ready to be used
  87704. * @param mesh defines the mesh to check
  87705. * @param useInstances specifies if instances should be used
  87706. * @returns a boolean indicating if the material is ready to be used
  87707. */
  87708. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87709. /**
  87710. * Specifies that the submesh is ready to be used
  87711. * @param mesh defines the mesh to check
  87712. * @param subMesh defines which submesh to check
  87713. * @param useInstances specifies that instances should be used
  87714. * @returns a boolean indicating that the submesh is ready or not
  87715. */
  87716. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87717. /**
  87718. * Returns the material effect
  87719. * @returns the effect associated with the material
  87720. */
  87721. getEffect(): Nullable<Effect>;
  87722. /**
  87723. * Returns the current scene
  87724. * @returns a Scene
  87725. */
  87726. getScene(): Scene;
  87727. /**
  87728. * Specifies if the material will require alpha blending
  87729. * @returns a boolean specifying if alpha blending is needed
  87730. */
  87731. needAlphaBlending(): boolean;
  87732. /**
  87733. * Specifies if the mesh will require alpha blending
  87734. * @param mesh defines the mesh to check
  87735. * @returns a boolean specifying if alpha blending is needed for the mesh
  87736. */
  87737. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87738. /**
  87739. * Specifies if this material should be rendered in alpha test mode
  87740. * @returns a boolean specifying if an alpha test is needed.
  87741. */
  87742. needAlphaTesting(): boolean;
  87743. /**
  87744. * Gets the texture used for the alpha test
  87745. * @returns the texture to use for alpha testing
  87746. */
  87747. getAlphaTestTexture(): Nullable<BaseTexture>;
  87748. /**
  87749. * Marks the material to indicate that it needs to be re-calculated
  87750. */
  87751. markDirty(): void;
  87752. /** @hidden */
  87753. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87754. /**
  87755. * Binds the material to the mesh
  87756. * @param world defines the world transformation matrix
  87757. * @param mesh defines the mesh to bind the material to
  87758. */
  87759. bind(world: Matrix, mesh?: Mesh): void;
  87760. /**
  87761. * Binds the submesh to the material
  87762. * @param world defines the world transformation matrix
  87763. * @param mesh defines the mesh containing the submesh
  87764. * @param subMesh defines the submesh to bind the material to
  87765. */
  87766. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87767. /**
  87768. * Binds the world matrix to the material
  87769. * @param world defines the world transformation matrix
  87770. */
  87771. bindOnlyWorldMatrix(world: Matrix): void;
  87772. /**
  87773. * Binds the scene's uniform buffer to the effect.
  87774. * @param effect defines the effect to bind to the scene uniform buffer
  87775. * @param sceneUbo defines the uniform buffer storing scene data
  87776. */
  87777. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87778. /**
  87779. * Binds the view matrix to the effect
  87780. * @param effect defines the effect to bind the view matrix to
  87781. */
  87782. bindView(effect: Effect): void;
  87783. /**
  87784. * Binds the view projection matrix to the effect
  87785. * @param effect defines the effect to bind the view projection matrix to
  87786. */
  87787. bindViewProjection(effect: Effect): void;
  87788. /**
  87789. * Specifies if material alpha testing should be turned on for the mesh
  87790. * @param mesh defines the mesh to check
  87791. */
  87792. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87793. /**
  87794. * Processes to execute after binding the material to a mesh
  87795. * @param mesh defines the rendered mesh
  87796. */
  87797. protected _afterBind(mesh?: Mesh): void;
  87798. /**
  87799. * Unbinds the material from the mesh
  87800. */
  87801. unbind(): void;
  87802. /**
  87803. * Gets the active textures from the material
  87804. * @returns an array of textures
  87805. */
  87806. getActiveTextures(): BaseTexture[];
  87807. /**
  87808. * Specifies if the material uses a texture
  87809. * @param texture defines the texture to check against the material
  87810. * @returns a boolean specifying if the material uses the texture
  87811. */
  87812. hasTexture(texture: BaseTexture): boolean;
  87813. /**
  87814. * Makes a duplicate of the material, and gives it a new name
  87815. * @param name defines the new name for the duplicated material
  87816. * @returns the cloned material
  87817. */
  87818. clone(name: string): Nullable<Material>;
  87819. /**
  87820. * Gets the meshes bound to the material
  87821. * @returns an array of meshes bound to the material
  87822. */
  87823. getBindedMeshes(): AbstractMesh[];
  87824. /**
  87825. * Force shader compilation
  87826. * @param mesh defines the mesh associated with this material
  87827. * @param onCompiled defines a function to execute once the material is compiled
  87828. * @param options defines the options to configure the compilation
  87829. * @param onError defines a function to execute if the material fails compiling
  87830. */
  87831. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87832. clipPlane: boolean;
  87833. }>, onError?: (reason: string) => void): void;
  87834. /**
  87835. * Force shader compilation
  87836. * @param mesh defines the mesh that will use this material
  87837. * @param options defines additional options for compiling the shaders
  87838. * @returns a promise that resolves when the compilation completes
  87839. */
  87840. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87841. clipPlane: boolean;
  87842. }>): Promise<void>;
  87843. private static readonly _AllDirtyCallBack;
  87844. private static readonly _ImageProcessingDirtyCallBack;
  87845. private static readonly _TextureDirtyCallBack;
  87846. private static readonly _FresnelDirtyCallBack;
  87847. private static readonly _MiscDirtyCallBack;
  87848. private static readonly _LightsDirtyCallBack;
  87849. private static readonly _AttributeDirtyCallBack;
  87850. private static _FresnelAndMiscDirtyCallBack;
  87851. private static _TextureAndMiscDirtyCallBack;
  87852. private static readonly _DirtyCallbackArray;
  87853. private static readonly _RunDirtyCallBacks;
  87854. /**
  87855. * Marks a define in the material to indicate that it needs to be re-computed
  87856. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87857. */
  87858. markAsDirty(flag: number): void;
  87859. /**
  87860. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87861. * @param func defines a function which checks material defines against the submeshes
  87862. */
  87863. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87864. /**
  87865. * Indicates that we need to re-calculated for all submeshes
  87866. */
  87867. protected _markAllSubMeshesAsAllDirty(): void;
  87868. /**
  87869. * Indicates that image processing needs to be re-calculated for all submeshes
  87870. */
  87871. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87872. /**
  87873. * Indicates that textures need to be re-calculated for all submeshes
  87874. */
  87875. protected _markAllSubMeshesAsTexturesDirty(): void;
  87876. /**
  87877. * Indicates that fresnel needs to be re-calculated for all submeshes
  87878. */
  87879. protected _markAllSubMeshesAsFresnelDirty(): void;
  87880. /**
  87881. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87882. */
  87883. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87884. /**
  87885. * Indicates that lights need to be re-calculated for all submeshes
  87886. */
  87887. protected _markAllSubMeshesAsLightsDirty(): void;
  87888. /**
  87889. * Indicates that attributes need to be re-calculated for all submeshes
  87890. */
  87891. protected _markAllSubMeshesAsAttributesDirty(): void;
  87892. /**
  87893. * Indicates that misc needs to be re-calculated for all submeshes
  87894. */
  87895. protected _markAllSubMeshesAsMiscDirty(): void;
  87896. /**
  87897. * Indicates that textures and misc need to be re-calculated for all submeshes
  87898. */
  87899. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87900. /**
  87901. * Disposes the material
  87902. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87903. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87904. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87905. */
  87906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87907. /** @hidden */
  87908. private releaseVertexArrayObject;
  87909. /**
  87910. * Serializes this material
  87911. * @returns the serialized material object
  87912. */
  87913. serialize(): any;
  87914. /**
  87915. * Creates a material from parsed material data
  87916. * @param parsedMaterial defines parsed material data
  87917. * @param scene defines the hosting scene
  87918. * @param rootUrl defines the root URL to use to load textures
  87919. * @returns a new material
  87920. */
  87921. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87922. }
  87923. }
  87924. declare module BABYLON {
  87925. /**
  87926. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87927. * separate meshes. This can be use to improve performances.
  87928. * @see http://doc.babylonjs.com/how_to/multi_materials
  87929. */
  87930. export class MultiMaterial extends Material {
  87931. private _subMaterials;
  87932. /**
  87933. * Gets or Sets the list of Materials used within the multi material.
  87934. * They need to be ordered according to the submeshes order in the associated mesh
  87935. */
  87936. subMaterials: Nullable<Material>[];
  87937. /**
  87938. * Function used to align with Node.getChildren()
  87939. * @returns the list of Materials used within the multi material
  87940. */
  87941. getChildren(): Nullable<Material>[];
  87942. /**
  87943. * Instantiates a new Multi Material
  87944. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87945. * separate meshes. This can be use to improve performances.
  87946. * @see http://doc.babylonjs.com/how_to/multi_materials
  87947. * @param name Define the name in the scene
  87948. * @param scene Define the scene the material belongs to
  87949. */
  87950. constructor(name: string, scene: Scene);
  87951. private _hookArray;
  87952. /**
  87953. * Get one of the submaterial by its index in the submaterials array
  87954. * @param index The index to look the sub material at
  87955. * @returns The Material if the index has been defined
  87956. */
  87957. getSubMaterial(index: number): Nullable<Material>;
  87958. /**
  87959. * Get the list of active textures for the whole sub materials list.
  87960. * @returns All the textures that will be used during the rendering
  87961. */
  87962. getActiveTextures(): BaseTexture[];
  87963. /**
  87964. * Gets the current class name of the material e.g. "MultiMaterial"
  87965. * Mainly use in serialization.
  87966. * @returns the class name
  87967. */
  87968. getClassName(): string;
  87969. /**
  87970. * Checks if the material is ready to render the requested sub mesh
  87971. * @param mesh Define the mesh the submesh belongs to
  87972. * @param subMesh Define the sub mesh to look readyness for
  87973. * @param useInstances Define whether or not the material is used with instances
  87974. * @returns true if ready, otherwise false
  87975. */
  87976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87977. /**
  87978. * Clones the current material and its related sub materials
  87979. * @param name Define the name of the newly cloned material
  87980. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87981. * @returns the cloned material
  87982. */
  87983. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87984. /**
  87985. * Serializes the materials into a JSON representation.
  87986. * @returns the JSON representation
  87987. */
  87988. serialize(): any;
  87989. /**
  87990. * Dispose the material and release its associated resources
  87991. * @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)
  87992. * @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)
  87993. * @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)
  87994. */
  87995. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87996. /**
  87997. * Creates a MultiMaterial from parsed MultiMaterial data.
  87998. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87999. * @param scene defines the hosting scene
  88000. * @returns a new MultiMaterial
  88001. */
  88002. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88003. }
  88004. }
  88005. declare module BABYLON {
  88006. /**
  88007. * Base class for submeshes
  88008. */
  88009. export class BaseSubMesh {
  88010. /** @hidden */
  88011. _materialDefines: Nullable<MaterialDefines>;
  88012. /** @hidden */
  88013. _materialEffect: Nullable<Effect>;
  88014. /**
  88015. * Gets associated effect
  88016. */
  88017. readonly effect: Nullable<Effect>;
  88018. /**
  88019. * Sets associated effect (effect used to render this submesh)
  88020. * @param effect defines the effect to associate with
  88021. * @param defines defines the set of defines used to compile this effect
  88022. */
  88023. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88024. }
  88025. /**
  88026. * Defines a subdivision inside a mesh
  88027. */
  88028. export class SubMesh extends BaseSubMesh implements ICullable {
  88029. /** the material index to use */
  88030. materialIndex: number;
  88031. /** vertex index start */
  88032. verticesStart: number;
  88033. /** vertices count */
  88034. verticesCount: number;
  88035. /** index start */
  88036. indexStart: number;
  88037. /** indices count */
  88038. indexCount: number;
  88039. /** @hidden */
  88040. _linesIndexCount: number;
  88041. private _mesh;
  88042. private _renderingMesh;
  88043. private _boundingInfo;
  88044. private _linesIndexBuffer;
  88045. /** @hidden */
  88046. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88047. /** @hidden */
  88048. _trianglePlanes: Plane[];
  88049. /** @hidden */
  88050. _lastColliderTransformMatrix: Nullable<Matrix>;
  88051. /** @hidden */
  88052. _renderId: number;
  88053. /** @hidden */
  88054. _alphaIndex: number;
  88055. /** @hidden */
  88056. _distanceToCamera: number;
  88057. /** @hidden */
  88058. _id: number;
  88059. private _currentMaterial;
  88060. /**
  88061. * Add a new submesh to a mesh
  88062. * @param materialIndex defines the material index to use
  88063. * @param verticesStart defines vertex index start
  88064. * @param verticesCount defines vertices count
  88065. * @param indexStart defines index start
  88066. * @param indexCount defines indices count
  88067. * @param mesh defines the parent mesh
  88068. * @param renderingMesh defines an optional rendering mesh
  88069. * @param createBoundingBox defines if bounding box should be created for this submesh
  88070. * @returns the new submesh
  88071. */
  88072. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88073. /**
  88074. * Creates a new submesh
  88075. * @param materialIndex defines the material index to use
  88076. * @param verticesStart defines vertex index start
  88077. * @param verticesCount defines vertices count
  88078. * @param indexStart defines index start
  88079. * @param indexCount defines indices count
  88080. * @param mesh defines the parent mesh
  88081. * @param renderingMesh defines an optional rendering mesh
  88082. * @param createBoundingBox defines if bounding box should be created for this submesh
  88083. */
  88084. constructor(
  88085. /** the material index to use */
  88086. materialIndex: number,
  88087. /** vertex index start */
  88088. verticesStart: number,
  88089. /** vertices count */
  88090. verticesCount: number,
  88091. /** index start */
  88092. indexStart: number,
  88093. /** indices count */
  88094. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88095. /**
  88096. * Returns true if this submesh covers the entire parent mesh
  88097. * @ignorenaming
  88098. */
  88099. readonly IsGlobal: boolean;
  88100. /**
  88101. * Returns the submesh BoudingInfo object
  88102. * @returns current bounding info (or mesh's one if the submesh is global)
  88103. */
  88104. getBoundingInfo(): BoundingInfo;
  88105. /**
  88106. * Sets the submesh BoundingInfo
  88107. * @param boundingInfo defines the new bounding info to use
  88108. * @returns the SubMesh
  88109. */
  88110. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88111. /**
  88112. * Returns the mesh of the current submesh
  88113. * @return the parent mesh
  88114. */
  88115. getMesh(): AbstractMesh;
  88116. /**
  88117. * Returns the rendering mesh of the submesh
  88118. * @returns the rendering mesh (could be different from parent mesh)
  88119. */
  88120. getRenderingMesh(): Mesh;
  88121. /**
  88122. * Returns the submesh material
  88123. * @returns null or the current material
  88124. */
  88125. getMaterial(): Nullable<Material>;
  88126. /**
  88127. * Sets a new updated BoundingInfo object to the submesh
  88128. * @param data defines an optional position array to use to determine the bounding info
  88129. * @returns the SubMesh
  88130. */
  88131. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88132. /** @hidden */
  88133. _checkCollision(collider: Collider): boolean;
  88134. /**
  88135. * Updates the submesh BoundingInfo
  88136. * @param world defines the world matrix to use to update the bounding info
  88137. * @returns the submesh
  88138. */
  88139. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88140. /**
  88141. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88142. * @param frustumPlanes defines the frustum planes
  88143. * @returns true if the submesh is intersecting with the frustum
  88144. */
  88145. isInFrustum(frustumPlanes: Plane[]): boolean;
  88146. /**
  88147. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88148. * @param frustumPlanes defines the frustum planes
  88149. * @returns true if the submesh is inside the frustum
  88150. */
  88151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88152. /**
  88153. * Renders the submesh
  88154. * @param enableAlphaMode defines if alpha needs to be used
  88155. * @returns the submesh
  88156. */
  88157. render(enableAlphaMode: boolean): SubMesh;
  88158. /**
  88159. * @hidden
  88160. */
  88161. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88162. /**
  88163. * Checks if the submesh intersects with a ray
  88164. * @param ray defines the ray to test
  88165. * @returns true is the passed ray intersects the submesh bounding box
  88166. */
  88167. canIntersects(ray: Ray): boolean;
  88168. /**
  88169. * Intersects current submesh with a ray
  88170. * @param ray defines the ray to test
  88171. * @param positions defines mesh's positions array
  88172. * @param indices defines mesh's indices array
  88173. * @param fastCheck defines if only bounding info should be used
  88174. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88175. * @returns intersection info or null if no intersection
  88176. */
  88177. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88178. /** @hidden */
  88179. private _intersectLines;
  88180. /** @hidden */
  88181. private _intersectUnIndexedLines;
  88182. /** @hidden */
  88183. private _intersectTriangles;
  88184. /** @hidden */
  88185. private _intersectUnIndexedTriangles;
  88186. /** @hidden */
  88187. _rebuild(): void;
  88188. /**
  88189. * Creates a new submesh from the passed mesh
  88190. * @param newMesh defines the new hosting mesh
  88191. * @param newRenderingMesh defines an optional rendering mesh
  88192. * @returns the new submesh
  88193. */
  88194. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88195. /**
  88196. * Release associated resources
  88197. */
  88198. dispose(): void;
  88199. /**
  88200. * Gets the class name
  88201. * @returns the string "SubMesh".
  88202. */
  88203. getClassName(): string;
  88204. /**
  88205. * Creates a new submesh from indices data
  88206. * @param materialIndex the index of the main mesh material
  88207. * @param startIndex the index where to start the copy in the mesh indices array
  88208. * @param indexCount the number of indices to copy then from the startIndex
  88209. * @param mesh the main mesh to create the submesh from
  88210. * @param renderingMesh the optional rendering mesh
  88211. * @returns a new submesh
  88212. */
  88213. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88214. }
  88215. }
  88216. declare module BABYLON {
  88217. /**
  88218. * Class used to represent data loading progression
  88219. */
  88220. export class SceneLoaderFlags {
  88221. private static _ForceFullSceneLoadingForIncremental;
  88222. private static _ShowLoadingScreen;
  88223. private static _CleanBoneMatrixWeights;
  88224. private static _loggingLevel;
  88225. /**
  88226. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88227. */
  88228. static ForceFullSceneLoadingForIncremental: boolean;
  88229. /**
  88230. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88231. */
  88232. static ShowLoadingScreen: boolean;
  88233. /**
  88234. * Defines the current logging level (while loading the scene)
  88235. * @ignorenaming
  88236. */
  88237. static loggingLevel: number;
  88238. /**
  88239. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88240. */
  88241. static CleanBoneMatrixWeights: boolean;
  88242. }
  88243. }
  88244. declare module BABYLON {
  88245. /**
  88246. * Class used to store geometry data (vertex buffers + index buffer)
  88247. */
  88248. export class Geometry implements IGetSetVerticesData {
  88249. /**
  88250. * Gets or sets the ID of the geometry
  88251. */
  88252. id: string;
  88253. /**
  88254. * Gets or sets the unique ID of the geometry
  88255. */
  88256. uniqueId: number;
  88257. /**
  88258. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88259. */
  88260. delayLoadState: number;
  88261. /**
  88262. * Gets the file containing the data to load when running in delay load state
  88263. */
  88264. delayLoadingFile: Nullable<string>;
  88265. /**
  88266. * Callback called when the geometry is updated
  88267. */
  88268. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88269. private _scene;
  88270. private _engine;
  88271. private _meshes;
  88272. private _totalVertices;
  88273. /** @hidden */
  88274. _indices: IndicesArray;
  88275. /** @hidden */
  88276. _vertexBuffers: {
  88277. [key: string]: VertexBuffer;
  88278. };
  88279. private _isDisposed;
  88280. private _extend;
  88281. private _boundingBias;
  88282. /** @hidden */
  88283. _delayInfo: Array<string>;
  88284. private _indexBuffer;
  88285. private _indexBufferIsUpdatable;
  88286. /** @hidden */
  88287. _boundingInfo: Nullable<BoundingInfo>;
  88288. /** @hidden */
  88289. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88290. /** @hidden */
  88291. _softwareSkinningFrameId: number;
  88292. private _vertexArrayObjects;
  88293. private _updatable;
  88294. /** @hidden */
  88295. _positions: Nullable<Vector3[]>;
  88296. /**
  88297. * 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
  88298. */
  88299. /**
  88300. * 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
  88301. */
  88302. boundingBias: Vector2;
  88303. /**
  88304. * Static function used to attach a new empty geometry to a mesh
  88305. * @param mesh defines the mesh to attach the geometry to
  88306. * @returns the new Geometry
  88307. */
  88308. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88309. /**
  88310. * Creates a new geometry
  88311. * @param id defines the unique ID
  88312. * @param scene defines the hosting scene
  88313. * @param vertexData defines the VertexData used to get geometry data
  88314. * @param updatable defines if geometry must be updatable (false by default)
  88315. * @param mesh defines the mesh that will be associated with the geometry
  88316. */
  88317. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88318. /**
  88319. * Gets the current extend of the geometry
  88320. */
  88321. readonly extend: {
  88322. minimum: Vector3;
  88323. maximum: Vector3;
  88324. };
  88325. /**
  88326. * Gets the hosting scene
  88327. * @returns the hosting Scene
  88328. */
  88329. getScene(): Scene;
  88330. /**
  88331. * Gets the hosting engine
  88332. * @returns the hosting Engine
  88333. */
  88334. getEngine(): Engine;
  88335. /**
  88336. * Defines if the geometry is ready to use
  88337. * @returns true if the geometry is ready to be used
  88338. */
  88339. isReady(): boolean;
  88340. /**
  88341. * Gets a value indicating that the geometry should not be serialized
  88342. */
  88343. readonly doNotSerialize: boolean;
  88344. /** @hidden */
  88345. _rebuild(): void;
  88346. /**
  88347. * Affects all geometry data in one call
  88348. * @param vertexData defines the geometry data
  88349. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88350. */
  88351. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88352. /**
  88353. * Set specific vertex data
  88354. * @param kind defines the data kind (Position, normal, etc...)
  88355. * @param data defines the vertex data to use
  88356. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88357. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88358. */
  88359. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88360. /**
  88361. * Removes a specific vertex data
  88362. * @param kind defines the data kind (Position, normal, etc...)
  88363. */
  88364. removeVerticesData(kind: string): void;
  88365. /**
  88366. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88367. * @param buffer defines the vertex buffer to use
  88368. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88369. */
  88370. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88371. /**
  88372. * Update a specific vertex buffer
  88373. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88374. * It will do nothing if the buffer is not updatable
  88375. * @param kind defines the data kind (Position, normal, etc...)
  88376. * @param data defines the data to use
  88377. * @param offset defines the offset in the target buffer where to store the data
  88378. * @param useBytes set to true if the offset is in bytes
  88379. */
  88380. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88381. /**
  88382. * Update a specific vertex buffer
  88383. * This function will create a new buffer if the current one is not updatable
  88384. * @param kind defines the data kind (Position, normal, etc...)
  88385. * @param data defines the data to use
  88386. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88387. */
  88388. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88389. private _updateBoundingInfo;
  88390. /** @hidden */
  88391. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88392. /**
  88393. * Gets total number of vertices
  88394. * @returns the total number of vertices
  88395. */
  88396. getTotalVertices(): number;
  88397. /**
  88398. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88399. * @param kind defines the data kind (Position, normal, etc...)
  88400. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88401. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88402. * @returns a float array containing vertex data
  88403. */
  88404. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88405. /**
  88406. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88407. * @param kind defines the data kind (Position, normal, etc...)
  88408. * @returns true if the vertex buffer with the specified kind is updatable
  88409. */
  88410. isVertexBufferUpdatable(kind: string): boolean;
  88411. /**
  88412. * Gets a specific vertex buffer
  88413. * @param kind defines the data kind (Position, normal, etc...)
  88414. * @returns a VertexBuffer
  88415. */
  88416. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88417. /**
  88418. * Returns all vertex buffers
  88419. * @return an object holding all vertex buffers indexed by kind
  88420. */
  88421. getVertexBuffers(): Nullable<{
  88422. [key: string]: VertexBuffer;
  88423. }>;
  88424. /**
  88425. * Gets a boolean indicating if specific vertex buffer is present
  88426. * @param kind defines the data kind (Position, normal, etc...)
  88427. * @returns true if data is present
  88428. */
  88429. isVerticesDataPresent(kind: string): boolean;
  88430. /**
  88431. * Gets a list of all attached data kinds (Position, normal, etc...)
  88432. * @returns a list of string containing all kinds
  88433. */
  88434. getVerticesDataKinds(): string[];
  88435. /**
  88436. * Update index buffer
  88437. * @param indices defines the indices to store in the index buffer
  88438. * @param offset defines the offset in the target buffer where to store the data
  88439. * @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)
  88440. */
  88441. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88442. /**
  88443. * Creates a new index buffer
  88444. * @param indices defines the indices to store in the index buffer
  88445. * @param totalVertices defines the total number of vertices (could be null)
  88446. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88447. */
  88448. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88449. /**
  88450. * Return the total number of indices
  88451. * @returns the total number of indices
  88452. */
  88453. getTotalIndices(): number;
  88454. /**
  88455. * Gets the index buffer array
  88456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88458. * @returns the index buffer array
  88459. */
  88460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88461. /**
  88462. * Gets the index buffer
  88463. * @return the index buffer
  88464. */
  88465. getIndexBuffer(): Nullable<DataBuffer>;
  88466. /** @hidden */
  88467. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88468. /**
  88469. * Release the associated resources for a specific mesh
  88470. * @param mesh defines the source mesh
  88471. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88472. */
  88473. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88474. /**
  88475. * Apply current geometry to a given mesh
  88476. * @param mesh defines the mesh to apply geometry to
  88477. */
  88478. applyToMesh(mesh: Mesh): void;
  88479. private _updateExtend;
  88480. private _applyToMesh;
  88481. private notifyUpdate;
  88482. /**
  88483. * Load the geometry if it was flagged as delay loaded
  88484. * @param scene defines the hosting scene
  88485. * @param onLoaded defines a callback called when the geometry is loaded
  88486. */
  88487. load(scene: Scene, onLoaded?: () => void): void;
  88488. private _queueLoad;
  88489. /**
  88490. * Invert the geometry to move from a right handed system to a left handed one.
  88491. */
  88492. toLeftHanded(): void;
  88493. /** @hidden */
  88494. _resetPointsArrayCache(): void;
  88495. /** @hidden */
  88496. _generatePointsArray(): boolean;
  88497. /**
  88498. * Gets a value indicating if the geometry is disposed
  88499. * @returns true if the geometry was disposed
  88500. */
  88501. isDisposed(): boolean;
  88502. private _disposeVertexArrayObjects;
  88503. /**
  88504. * Free all associated resources
  88505. */
  88506. dispose(): void;
  88507. /**
  88508. * Clone the current geometry into a new geometry
  88509. * @param id defines the unique ID of the new geometry
  88510. * @returns a new geometry object
  88511. */
  88512. copy(id: string): Geometry;
  88513. /**
  88514. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88515. * @return a JSON representation of the current geometry data (without the vertices data)
  88516. */
  88517. serialize(): any;
  88518. private toNumberArray;
  88519. /**
  88520. * Serialize all vertices data into a JSON oject
  88521. * @returns a JSON representation of the current geometry data
  88522. */
  88523. serializeVerticeData(): any;
  88524. /**
  88525. * Extracts a clone of a mesh geometry
  88526. * @param mesh defines the source mesh
  88527. * @param id defines the unique ID of the new geometry object
  88528. * @returns the new geometry object
  88529. */
  88530. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88531. /**
  88532. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88533. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88534. * Be aware Math.random() could cause collisions, but:
  88535. * "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"
  88536. * @returns a string containing a new GUID
  88537. */
  88538. static RandomId(): string;
  88539. /** @hidden */
  88540. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88541. private static _CleanMatricesWeights;
  88542. /**
  88543. * Create a new geometry from persisted data (Using .babylon file format)
  88544. * @param parsedVertexData defines the persisted data
  88545. * @param scene defines the hosting scene
  88546. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88547. * @returns the new geometry object
  88548. */
  88549. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88550. }
  88551. }
  88552. declare module BABYLON {
  88553. /**
  88554. * Define an interface for all classes that will get and set the data on vertices
  88555. */
  88556. export interface IGetSetVerticesData {
  88557. /**
  88558. * Gets a boolean indicating if specific vertex data is present
  88559. * @param kind defines the vertex data kind to use
  88560. * @returns true is data kind is present
  88561. */
  88562. isVerticesDataPresent(kind: string): boolean;
  88563. /**
  88564. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88565. * @param kind defines the data kind (Position, normal, etc...)
  88566. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88567. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88568. * @returns a float array containing vertex data
  88569. */
  88570. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88571. /**
  88572. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88573. * @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.
  88574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88575. * @returns the indices array or an empty array if the mesh has no geometry
  88576. */
  88577. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88578. /**
  88579. * Set specific vertex data
  88580. * @param kind defines the data kind (Position, normal, etc...)
  88581. * @param data defines the vertex data to use
  88582. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88583. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88584. */
  88585. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88586. /**
  88587. * Update a specific associated vertex buffer
  88588. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88589. * - VertexBuffer.PositionKind
  88590. * - VertexBuffer.UVKind
  88591. * - VertexBuffer.UV2Kind
  88592. * - VertexBuffer.UV3Kind
  88593. * - VertexBuffer.UV4Kind
  88594. * - VertexBuffer.UV5Kind
  88595. * - VertexBuffer.UV6Kind
  88596. * - VertexBuffer.ColorKind
  88597. * - VertexBuffer.MatricesIndicesKind
  88598. * - VertexBuffer.MatricesIndicesExtraKind
  88599. * - VertexBuffer.MatricesWeightsKind
  88600. * - VertexBuffer.MatricesWeightsExtraKind
  88601. * @param data defines the data source
  88602. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88603. * @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)
  88604. */
  88605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88606. /**
  88607. * Creates a new index buffer
  88608. * @param indices defines the indices to store in the index buffer
  88609. * @param totalVertices defines the total number of vertices (could be null)
  88610. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88611. */
  88612. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88613. }
  88614. /**
  88615. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88616. */
  88617. export class VertexData {
  88618. /**
  88619. * Mesh side orientation : usually the external or front surface
  88620. */
  88621. static readonly FRONTSIDE: number;
  88622. /**
  88623. * Mesh side orientation : usually the internal or back surface
  88624. */
  88625. static readonly BACKSIDE: number;
  88626. /**
  88627. * Mesh side orientation : both internal and external or front and back surfaces
  88628. */
  88629. static readonly DOUBLESIDE: number;
  88630. /**
  88631. * Mesh side orientation : by default, `FRONTSIDE`
  88632. */
  88633. static readonly DEFAULTSIDE: number;
  88634. /**
  88635. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88636. */
  88637. positions: Nullable<FloatArray>;
  88638. /**
  88639. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88640. */
  88641. normals: Nullable<FloatArray>;
  88642. /**
  88643. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88644. */
  88645. tangents: Nullable<FloatArray>;
  88646. /**
  88647. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88648. */
  88649. uvs: Nullable<FloatArray>;
  88650. /**
  88651. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88652. */
  88653. uvs2: Nullable<FloatArray>;
  88654. /**
  88655. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88656. */
  88657. uvs3: Nullable<FloatArray>;
  88658. /**
  88659. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88660. */
  88661. uvs4: Nullable<FloatArray>;
  88662. /**
  88663. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88664. */
  88665. uvs5: Nullable<FloatArray>;
  88666. /**
  88667. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88668. */
  88669. uvs6: Nullable<FloatArray>;
  88670. /**
  88671. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88672. */
  88673. colors: Nullable<FloatArray>;
  88674. /**
  88675. * 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).
  88676. */
  88677. matricesIndices: Nullable<FloatArray>;
  88678. /**
  88679. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88680. */
  88681. matricesWeights: Nullable<FloatArray>;
  88682. /**
  88683. * An array extending the number of possible indices
  88684. */
  88685. matricesIndicesExtra: Nullable<FloatArray>;
  88686. /**
  88687. * An array extending the number of possible weights when the number of indices is extended
  88688. */
  88689. matricesWeightsExtra: Nullable<FloatArray>;
  88690. /**
  88691. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88692. */
  88693. indices: Nullable<IndicesArray>;
  88694. /**
  88695. * Uses the passed data array to set the set the values for the specified kind of data
  88696. * @param data a linear array of floating numbers
  88697. * @param kind the type of data that is being set, eg positions, colors etc
  88698. */
  88699. set(data: FloatArray, kind: string): void;
  88700. /**
  88701. * Associates the vertexData to the passed Mesh.
  88702. * Sets it as updatable or not (default `false`)
  88703. * @param mesh the mesh the vertexData is applied to
  88704. * @param updatable when used and having the value true allows new data to update the vertexData
  88705. * @returns the VertexData
  88706. */
  88707. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88708. /**
  88709. * Associates the vertexData to the passed Geometry.
  88710. * Sets it as updatable or not (default `false`)
  88711. * @param geometry the geometry the vertexData is applied to
  88712. * @param updatable when used and having the value true allows new data to update the vertexData
  88713. * @returns VertexData
  88714. */
  88715. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88716. /**
  88717. * Updates the associated mesh
  88718. * @param mesh the mesh to be updated
  88719. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88720. * @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
  88721. * @returns VertexData
  88722. */
  88723. updateMesh(mesh: Mesh): VertexData;
  88724. /**
  88725. * Updates the associated geometry
  88726. * @param geometry the geometry to be updated
  88727. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88728. * @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
  88729. * @returns VertexData.
  88730. */
  88731. updateGeometry(geometry: Geometry): VertexData;
  88732. private _applyTo;
  88733. private _update;
  88734. /**
  88735. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88736. * @param matrix the transforming matrix
  88737. * @returns the VertexData
  88738. */
  88739. transform(matrix: Matrix): VertexData;
  88740. /**
  88741. * Merges the passed VertexData into the current one
  88742. * @param other the VertexData to be merged into the current one
  88743. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88744. * @returns the modified VertexData
  88745. */
  88746. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88747. private _mergeElement;
  88748. private _validate;
  88749. /**
  88750. * Serializes the VertexData
  88751. * @returns a serialized object
  88752. */
  88753. serialize(): any;
  88754. /**
  88755. * Extracts the vertexData from a mesh
  88756. * @param mesh the mesh from which to extract the VertexData
  88757. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88758. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88759. * @returns the object VertexData associated to the passed mesh
  88760. */
  88761. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88762. /**
  88763. * Extracts the vertexData from the geometry
  88764. * @param geometry the geometry from which to extract the VertexData
  88765. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88766. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88767. * @returns the object VertexData associated to the passed mesh
  88768. */
  88769. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88770. private static _ExtractFrom;
  88771. /**
  88772. * Creates the VertexData for a Ribbon
  88773. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88774. * * pathArray array of paths, each of which an array of successive Vector3
  88775. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88776. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88777. * * 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
  88778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88779. * * 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)
  88780. * * 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)
  88781. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88782. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88783. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88784. * @returns the VertexData of the ribbon
  88785. */
  88786. static CreateRibbon(options: {
  88787. pathArray: Vector3[][];
  88788. closeArray?: boolean;
  88789. closePath?: boolean;
  88790. offset?: number;
  88791. sideOrientation?: number;
  88792. frontUVs?: Vector4;
  88793. backUVs?: Vector4;
  88794. invertUV?: boolean;
  88795. uvs?: Vector2[];
  88796. colors?: Color4[];
  88797. }): VertexData;
  88798. /**
  88799. * Creates the VertexData for a box
  88800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88801. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88802. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88803. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88804. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88805. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88806. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88808. * * 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)
  88809. * * 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)
  88810. * @returns the VertexData of the box
  88811. */
  88812. static CreateBox(options: {
  88813. size?: number;
  88814. width?: number;
  88815. height?: number;
  88816. depth?: number;
  88817. faceUV?: Vector4[];
  88818. faceColors?: Color4[];
  88819. sideOrientation?: number;
  88820. frontUVs?: Vector4;
  88821. backUVs?: Vector4;
  88822. }): VertexData;
  88823. /**
  88824. * Creates the VertexData for a tiled box
  88825. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88826. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88827. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88828. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88830. * @returns the VertexData of the box
  88831. */
  88832. static CreateTiledBox(options: {
  88833. pattern?: number;
  88834. width?: number;
  88835. height?: number;
  88836. depth?: number;
  88837. tileSize?: number;
  88838. tileWidth?: number;
  88839. tileHeight?: number;
  88840. alignHorizontal?: number;
  88841. alignVertical?: number;
  88842. faceUV?: Vector4[];
  88843. faceColors?: Color4[];
  88844. sideOrientation?: number;
  88845. }): VertexData;
  88846. /**
  88847. * Creates the VertexData for a tiled plane
  88848. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88849. * * pattern a limited pattern arrangement depending on the number
  88850. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88851. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88852. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88854. * * 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)
  88855. * * 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)
  88856. * @returns the VertexData of the tiled plane
  88857. */
  88858. static CreateTiledPlane(options: {
  88859. pattern?: number;
  88860. tileSize?: number;
  88861. tileWidth?: number;
  88862. tileHeight?: number;
  88863. size?: number;
  88864. width?: number;
  88865. height?: number;
  88866. alignHorizontal?: number;
  88867. alignVertical?: number;
  88868. sideOrientation?: number;
  88869. frontUVs?: Vector4;
  88870. backUVs?: Vector4;
  88871. }): VertexData;
  88872. /**
  88873. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88874. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88875. * * segments sets the number of horizontal strips optional, default 32
  88876. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88877. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88878. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88879. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88880. * * 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
  88881. * * 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
  88882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88883. * * 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)
  88884. * * 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)
  88885. * @returns the VertexData of the ellipsoid
  88886. */
  88887. static CreateSphere(options: {
  88888. segments?: number;
  88889. diameter?: number;
  88890. diameterX?: number;
  88891. diameterY?: number;
  88892. diameterZ?: number;
  88893. arc?: number;
  88894. slice?: number;
  88895. sideOrientation?: number;
  88896. frontUVs?: Vector4;
  88897. backUVs?: Vector4;
  88898. }): VertexData;
  88899. /**
  88900. * Creates the VertexData for a cylinder, cone or prism
  88901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88902. * * height sets the height (y direction) of the cylinder, optional, default 2
  88903. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88904. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88905. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88906. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88907. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88908. * * 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
  88909. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88910. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88911. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88912. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88914. * * 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)
  88915. * * 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)
  88916. * @returns the VertexData of the cylinder, cone or prism
  88917. */
  88918. static CreateCylinder(options: {
  88919. height?: number;
  88920. diameterTop?: number;
  88921. diameterBottom?: number;
  88922. diameter?: number;
  88923. tessellation?: number;
  88924. subdivisions?: number;
  88925. arc?: number;
  88926. faceColors?: Color4[];
  88927. faceUV?: Vector4[];
  88928. hasRings?: boolean;
  88929. enclose?: boolean;
  88930. sideOrientation?: number;
  88931. frontUVs?: Vector4;
  88932. backUVs?: Vector4;
  88933. }): VertexData;
  88934. /**
  88935. * Creates the VertexData for a torus
  88936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88937. * * diameter the diameter of the torus, optional default 1
  88938. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88939. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88941. * * 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)
  88942. * * 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)
  88943. * @returns the VertexData of the torus
  88944. */
  88945. static CreateTorus(options: {
  88946. diameter?: number;
  88947. thickness?: number;
  88948. tessellation?: number;
  88949. sideOrientation?: number;
  88950. frontUVs?: Vector4;
  88951. backUVs?: Vector4;
  88952. }): VertexData;
  88953. /**
  88954. * Creates the VertexData of the LineSystem
  88955. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88956. * - lines an array of lines, each line being an array of successive Vector3
  88957. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88958. * @returns the VertexData of the LineSystem
  88959. */
  88960. static CreateLineSystem(options: {
  88961. lines: Vector3[][];
  88962. colors?: Nullable<Color4[][]>;
  88963. }): VertexData;
  88964. /**
  88965. * Create the VertexData for a DashedLines
  88966. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88967. * - points an array successive Vector3
  88968. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88969. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88970. * - dashNb the intended total number of dashes, optional, default 200
  88971. * @returns the VertexData for the DashedLines
  88972. */
  88973. static CreateDashedLines(options: {
  88974. points: Vector3[];
  88975. dashSize?: number;
  88976. gapSize?: number;
  88977. dashNb?: number;
  88978. }): VertexData;
  88979. /**
  88980. * Creates the VertexData for a Ground
  88981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88982. * - width the width (x direction) of the ground, optional, default 1
  88983. * - height the height (z direction) of the ground, optional, default 1
  88984. * - subdivisions the number of subdivisions per side, optional, default 1
  88985. * @returns the VertexData of the Ground
  88986. */
  88987. static CreateGround(options: {
  88988. width?: number;
  88989. height?: number;
  88990. subdivisions?: number;
  88991. subdivisionsX?: number;
  88992. subdivisionsY?: number;
  88993. }): VertexData;
  88994. /**
  88995. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88996. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88997. * * xmin the ground minimum X coordinate, optional, default -1
  88998. * * zmin the ground minimum Z coordinate, optional, default -1
  88999. * * xmax the ground maximum X coordinate, optional, default 1
  89000. * * zmax the ground maximum Z coordinate, optional, default 1
  89001. * * 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}
  89002. * * 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}
  89003. * @returns the VertexData of the TiledGround
  89004. */
  89005. static CreateTiledGround(options: {
  89006. xmin: number;
  89007. zmin: number;
  89008. xmax: number;
  89009. zmax: number;
  89010. subdivisions?: {
  89011. w: number;
  89012. h: number;
  89013. };
  89014. precision?: {
  89015. w: number;
  89016. h: number;
  89017. };
  89018. }): VertexData;
  89019. /**
  89020. * Creates the VertexData of the Ground designed from a heightmap
  89021. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89022. * * width the width (x direction) of the ground
  89023. * * height the height (z direction) of the ground
  89024. * * subdivisions the number of subdivisions per side
  89025. * * minHeight the minimum altitude on the ground, optional, default 0
  89026. * * maxHeight the maximum altitude on the ground, optional default 1
  89027. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89028. * * buffer the array holding the image color data
  89029. * * bufferWidth the width of image
  89030. * * bufferHeight the height of image
  89031. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89032. * @returns the VertexData of the Ground designed from a heightmap
  89033. */
  89034. static CreateGroundFromHeightMap(options: {
  89035. width: number;
  89036. height: number;
  89037. subdivisions: number;
  89038. minHeight: number;
  89039. maxHeight: number;
  89040. colorFilter: Color3;
  89041. buffer: Uint8Array;
  89042. bufferWidth: number;
  89043. bufferHeight: number;
  89044. alphaFilter: number;
  89045. }): VertexData;
  89046. /**
  89047. * Creates the VertexData for a Plane
  89048. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89049. * * size sets the width and height of the plane to the value of size, optional default 1
  89050. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89051. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89053. * * 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)
  89054. * * 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)
  89055. * @returns the VertexData of the box
  89056. */
  89057. static CreatePlane(options: {
  89058. size?: number;
  89059. width?: number;
  89060. height?: number;
  89061. sideOrientation?: number;
  89062. frontUVs?: Vector4;
  89063. backUVs?: Vector4;
  89064. }): VertexData;
  89065. /**
  89066. * Creates the VertexData of the Disc or regular Polygon
  89067. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89068. * * radius the radius of the disc, optional default 0.5
  89069. * * tessellation the number of polygon sides, optional, default 64
  89070. * * 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
  89071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89072. * * 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)
  89073. * * 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)
  89074. * @returns the VertexData of the box
  89075. */
  89076. static CreateDisc(options: {
  89077. radius?: number;
  89078. tessellation?: number;
  89079. arc?: number;
  89080. sideOrientation?: number;
  89081. frontUVs?: Vector4;
  89082. backUVs?: Vector4;
  89083. }): VertexData;
  89084. /**
  89085. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89086. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89087. * @param polygon a mesh built from polygonTriangulation.build()
  89088. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89089. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89090. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89091. * @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)
  89092. * @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)
  89093. * @returns the VertexData of the Polygon
  89094. */
  89095. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89096. /**
  89097. * Creates the VertexData of the IcoSphere
  89098. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89099. * * radius the radius of the IcoSphere, optional default 1
  89100. * * radiusX allows stretching in the x direction, optional, default radius
  89101. * * radiusY allows stretching in the y direction, optional, default radius
  89102. * * radiusZ allows stretching in the z direction, optional, default radius
  89103. * * flat when true creates a flat shaded mesh, optional, default true
  89104. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89106. * * 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)
  89107. * * 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)
  89108. * @returns the VertexData of the IcoSphere
  89109. */
  89110. static CreateIcoSphere(options: {
  89111. radius?: number;
  89112. radiusX?: number;
  89113. radiusY?: number;
  89114. radiusZ?: number;
  89115. flat?: boolean;
  89116. subdivisions?: number;
  89117. sideOrientation?: number;
  89118. frontUVs?: Vector4;
  89119. backUVs?: Vector4;
  89120. }): VertexData;
  89121. /**
  89122. * Creates the VertexData for a Polyhedron
  89123. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89124. * * type provided types are:
  89125. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89126. * * 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)
  89127. * * size the size of the IcoSphere, optional default 1
  89128. * * sizeX allows stretching in the x direction, optional, default size
  89129. * * sizeY allows stretching in the y direction, optional, default size
  89130. * * sizeZ allows stretching in the z direction, optional, default size
  89131. * * 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
  89132. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89133. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89134. * * flat when true creates a flat shaded mesh, optional, default true
  89135. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89137. * * 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)
  89138. * * 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)
  89139. * @returns the VertexData of the Polyhedron
  89140. */
  89141. static CreatePolyhedron(options: {
  89142. type?: number;
  89143. size?: number;
  89144. sizeX?: number;
  89145. sizeY?: number;
  89146. sizeZ?: number;
  89147. custom?: any;
  89148. faceUV?: Vector4[];
  89149. faceColors?: Color4[];
  89150. flat?: boolean;
  89151. sideOrientation?: number;
  89152. frontUVs?: Vector4;
  89153. backUVs?: Vector4;
  89154. }): VertexData;
  89155. /**
  89156. * Creates the VertexData for a TorusKnot
  89157. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89158. * * radius the radius of the torus knot, optional, default 2
  89159. * * tube the thickness of the tube, optional, default 0.5
  89160. * * radialSegments the number of sides on each tube segments, optional, default 32
  89161. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89162. * * p the number of windings around the z axis, optional, default 2
  89163. * * q the number of windings around the x axis, optional, default 3
  89164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89165. * * 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)
  89166. * * 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)
  89167. * @returns the VertexData of the Torus Knot
  89168. */
  89169. static CreateTorusKnot(options: {
  89170. radius?: number;
  89171. tube?: number;
  89172. radialSegments?: number;
  89173. tubularSegments?: number;
  89174. p?: number;
  89175. q?: number;
  89176. sideOrientation?: number;
  89177. frontUVs?: Vector4;
  89178. backUVs?: Vector4;
  89179. }): VertexData;
  89180. /**
  89181. * Compute normals for given positions and indices
  89182. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89183. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89184. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89185. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89186. * * facetNormals : optional array of facet normals (vector3)
  89187. * * facetPositions : optional array of facet positions (vector3)
  89188. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89189. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89190. * * bInfo : optional bounding info, required for facetPartitioning computation
  89191. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89192. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89193. * * useRightHandedSystem: optional boolean to for right handed system computation
  89194. * * depthSort : optional boolean to enable the facet depth sort computation
  89195. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89196. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89197. */
  89198. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89199. facetNormals?: any;
  89200. facetPositions?: any;
  89201. facetPartitioning?: any;
  89202. ratio?: number;
  89203. bInfo?: any;
  89204. bbSize?: Vector3;
  89205. subDiv?: any;
  89206. useRightHandedSystem?: boolean;
  89207. depthSort?: boolean;
  89208. distanceTo?: Vector3;
  89209. depthSortedFacets?: any;
  89210. }): void;
  89211. /** @hidden */
  89212. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89213. /**
  89214. * Applies VertexData created from the imported parameters to the geometry
  89215. * @param parsedVertexData the parsed data from an imported file
  89216. * @param geometry the geometry to apply the VertexData to
  89217. */
  89218. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89219. }
  89220. }
  89221. declare module BABYLON {
  89222. /**
  89223. * Defines a target to use with MorphTargetManager
  89224. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89225. */
  89226. export class MorphTarget implements IAnimatable {
  89227. /** defines the name of the target */
  89228. name: string;
  89229. /**
  89230. * Gets or sets the list of animations
  89231. */
  89232. animations: Animation[];
  89233. private _scene;
  89234. private _positions;
  89235. private _normals;
  89236. private _tangents;
  89237. private _uvs;
  89238. private _influence;
  89239. /**
  89240. * Observable raised when the influence changes
  89241. */
  89242. onInfluenceChanged: Observable<boolean>;
  89243. /** @hidden */
  89244. _onDataLayoutChanged: Observable<void>;
  89245. /**
  89246. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89247. */
  89248. influence: number;
  89249. /**
  89250. * Gets or sets the id of the morph Target
  89251. */
  89252. id: string;
  89253. private _animationPropertiesOverride;
  89254. /**
  89255. * Gets or sets the animation properties override
  89256. */
  89257. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89258. /**
  89259. * Creates a new MorphTarget
  89260. * @param name defines the name of the target
  89261. * @param influence defines the influence to use
  89262. * @param scene defines the scene the morphtarget belongs to
  89263. */
  89264. constructor(
  89265. /** defines the name of the target */
  89266. name: string, influence?: number, scene?: Nullable<Scene>);
  89267. /**
  89268. * Gets a boolean defining if the target contains position data
  89269. */
  89270. readonly hasPositions: boolean;
  89271. /**
  89272. * Gets a boolean defining if the target contains normal data
  89273. */
  89274. readonly hasNormals: boolean;
  89275. /**
  89276. * Gets a boolean defining if the target contains tangent data
  89277. */
  89278. readonly hasTangents: boolean;
  89279. /**
  89280. * Gets a boolean defining if the target contains texture coordinates data
  89281. */
  89282. readonly hasUVs: boolean;
  89283. /**
  89284. * Affects position data to this target
  89285. * @param data defines the position data to use
  89286. */
  89287. setPositions(data: Nullable<FloatArray>): void;
  89288. /**
  89289. * Gets the position data stored in this target
  89290. * @returns a FloatArray containing the position data (or null if not present)
  89291. */
  89292. getPositions(): Nullable<FloatArray>;
  89293. /**
  89294. * Affects normal data to this target
  89295. * @param data defines the normal data to use
  89296. */
  89297. setNormals(data: Nullable<FloatArray>): void;
  89298. /**
  89299. * Gets the normal data stored in this target
  89300. * @returns a FloatArray containing the normal data (or null if not present)
  89301. */
  89302. getNormals(): Nullable<FloatArray>;
  89303. /**
  89304. * Affects tangent data to this target
  89305. * @param data defines the tangent data to use
  89306. */
  89307. setTangents(data: Nullable<FloatArray>): void;
  89308. /**
  89309. * Gets the tangent data stored in this target
  89310. * @returns a FloatArray containing the tangent data (or null if not present)
  89311. */
  89312. getTangents(): Nullable<FloatArray>;
  89313. /**
  89314. * Affects texture coordinates data to this target
  89315. * @param data defines the texture coordinates data to use
  89316. */
  89317. setUVs(data: Nullable<FloatArray>): void;
  89318. /**
  89319. * Gets the texture coordinates data stored in this target
  89320. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89321. */
  89322. getUVs(): Nullable<FloatArray>;
  89323. /**
  89324. * Serializes the current target into a Serialization object
  89325. * @returns the serialized object
  89326. */
  89327. serialize(): any;
  89328. /**
  89329. * Returns the string "MorphTarget"
  89330. * @returns "MorphTarget"
  89331. */
  89332. getClassName(): string;
  89333. /**
  89334. * Creates a new target from serialized data
  89335. * @param serializationObject defines the serialized data to use
  89336. * @returns a new MorphTarget
  89337. */
  89338. static Parse(serializationObject: any): MorphTarget;
  89339. /**
  89340. * Creates a MorphTarget from mesh data
  89341. * @param mesh defines the source mesh
  89342. * @param name defines the name to use for the new target
  89343. * @param influence defines the influence to attach to the target
  89344. * @returns a new MorphTarget
  89345. */
  89346. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89347. }
  89348. }
  89349. declare module BABYLON {
  89350. /**
  89351. * This class is used to deform meshes using morphing between different targets
  89352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89353. */
  89354. export class MorphTargetManager {
  89355. private _targets;
  89356. private _targetInfluenceChangedObservers;
  89357. private _targetDataLayoutChangedObservers;
  89358. private _activeTargets;
  89359. private _scene;
  89360. private _influences;
  89361. private _supportsNormals;
  89362. private _supportsTangents;
  89363. private _supportsUVs;
  89364. private _vertexCount;
  89365. private _uniqueId;
  89366. private _tempInfluences;
  89367. /**
  89368. * Gets or sets a boolean indicating if normals must be morphed
  89369. */
  89370. enableNormalMorphing: boolean;
  89371. /**
  89372. * Gets or sets a boolean indicating if tangents must be morphed
  89373. */
  89374. enableTangentMorphing: boolean;
  89375. /**
  89376. * Gets or sets a boolean indicating if UV must be morphed
  89377. */
  89378. enableUVMorphing: boolean;
  89379. /**
  89380. * Creates a new MorphTargetManager
  89381. * @param scene defines the current scene
  89382. */
  89383. constructor(scene?: Nullable<Scene>);
  89384. /**
  89385. * Gets the unique ID of this manager
  89386. */
  89387. readonly uniqueId: number;
  89388. /**
  89389. * Gets the number of vertices handled by this manager
  89390. */
  89391. readonly vertexCount: number;
  89392. /**
  89393. * Gets a boolean indicating if this manager supports morphing of normals
  89394. */
  89395. readonly supportsNormals: boolean;
  89396. /**
  89397. * Gets a boolean indicating if this manager supports morphing of tangents
  89398. */
  89399. readonly supportsTangents: boolean;
  89400. /**
  89401. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89402. */
  89403. readonly supportsUVs: boolean;
  89404. /**
  89405. * Gets the number of targets stored in this manager
  89406. */
  89407. readonly numTargets: number;
  89408. /**
  89409. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89410. */
  89411. readonly numInfluencers: number;
  89412. /**
  89413. * Gets the list of influences (one per target)
  89414. */
  89415. readonly influences: Float32Array;
  89416. /**
  89417. * Gets the active target at specified index. An active target is a target with an influence > 0
  89418. * @param index defines the index to check
  89419. * @returns the requested target
  89420. */
  89421. getActiveTarget(index: number): MorphTarget;
  89422. /**
  89423. * Gets the target at specified index
  89424. * @param index defines the index to check
  89425. * @returns the requested target
  89426. */
  89427. getTarget(index: number): MorphTarget;
  89428. /**
  89429. * Add a new target to this manager
  89430. * @param target defines the target to add
  89431. */
  89432. addTarget(target: MorphTarget): void;
  89433. /**
  89434. * Removes a target from the manager
  89435. * @param target defines the target to remove
  89436. */
  89437. removeTarget(target: MorphTarget): void;
  89438. /**
  89439. * Serializes the current manager into a Serialization object
  89440. * @returns the serialized object
  89441. */
  89442. serialize(): any;
  89443. private _syncActiveTargets;
  89444. /**
  89445. * Syncrhonize the targets with all the meshes using this morph target manager
  89446. */
  89447. synchronize(): void;
  89448. /**
  89449. * Creates a new MorphTargetManager from serialized data
  89450. * @param serializationObject defines the serialized data
  89451. * @param scene defines the hosting scene
  89452. * @returns the new MorphTargetManager
  89453. */
  89454. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89455. }
  89456. }
  89457. declare module BABYLON {
  89458. /**
  89459. * Class used to represent a specific level of detail of a mesh
  89460. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89461. */
  89462. export class MeshLODLevel {
  89463. /** Defines the distance where this level should start being displayed */
  89464. distance: number;
  89465. /** Defines the mesh to use to render this level */
  89466. mesh: Nullable<Mesh>;
  89467. /**
  89468. * Creates a new LOD level
  89469. * @param distance defines the distance where this level should star being displayed
  89470. * @param mesh defines the mesh to use to render this level
  89471. */
  89472. constructor(
  89473. /** Defines the distance where this level should start being displayed */
  89474. distance: number,
  89475. /** Defines the mesh to use to render this level */
  89476. mesh: Nullable<Mesh>);
  89477. }
  89478. }
  89479. declare module BABYLON {
  89480. /**
  89481. * Mesh representing the gorund
  89482. */
  89483. export class GroundMesh extends Mesh {
  89484. /** If octree should be generated */
  89485. generateOctree: boolean;
  89486. private _heightQuads;
  89487. /** @hidden */
  89488. _subdivisionsX: number;
  89489. /** @hidden */
  89490. _subdivisionsY: number;
  89491. /** @hidden */
  89492. _width: number;
  89493. /** @hidden */
  89494. _height: number;
  89495. /** @hidden */
  89496. _minX: number;
  89497. /** @hidden */
  89498. _maxX: number;
  89499. /** @hidden */
  89500. _minZ: number;
  89501. /** @hidden */
  89502. _maxZ: number;
  89503. constructor(name: string, scene: Scene);
  89504. /**
  89505. * "GroundMesh"
  89506. * @returns "GroundMesh"
  89507. */
  89508. getClassName(): string;
  89509. /**
  89510. * The minimum of x and y subdivisions
  89511. */
  89512. readonly subdivisions: number;
  89513. /**
  89514. * X subdivisions
  89515. */
  89516. readonly subdivisionsX: number;
  89517. /**
  89518. * Y subdivisions
  89519. */
  89520. readonly subdivisionsY: number;
  89521. /**
  89522. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89523. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89524. * @param chunksCount the number of subdivisions for x and y
  89525. * @param octreeBlocksSize (Default: 32)
  89526. */
  89527. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89528. /**
  89529. * Returns a height (y) value in the Worl system :
  89530. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89531. * @param x x coordinate
  89532. * @param z z coordinate
  89533. * @returns the ground y position if (x, z) are outside the ground surface.
  89534. */
  89535. getHeightAtCoordinates(x: number, z: number): number;
  89536. /**
  89537. * Returns a normalized vector (Vector3) orthogonal to the ground
  89538. * at the ground coordinates (x, z) expressed in the World system.
  89539. * @param x x coordinate
  89540. * @param z z coordinate
  89541. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89542. */
  89543. getNormalAtCoordinates(x: number, z: number): Vector3;
  89544. /**
  89545. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89546. * at the ground coordinates (x, z) expressed in the World system.
  89547. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89548. * @param x x coordinate
  89549. * @param z z coordinate
  89550. * @param ref vector to store the result
  89551. * @returns the GroundMesh.
  89552. */
  89553. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89554. /**
  89555. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89556. * if the ground has been updated.
  89557. * This can be used in the render loop.
  89558. * @returns the GroundMesh.
  89559. */
  89560. updateCoordinateHeights(): GroundMesh;
  89561. private _getFacetAt;
  89562. private _initHeightQuads;
  89563. private _computeHeightQuads;
  89564. /**
  89565. * Serializes this ground mesh
  89566. * @param serializationObject object to write serialization to
  89567. */
  89568. serialize(serializationObject: any): void;
  89569. /**
  89570. * Parses a serialized ground mesh
  89571. * @param parsedMesh the serialized mesh
  89572. * @param scene the scene to create the ground mesh in
  89573. * @returns the created ground mesh
  89574. */
  89575. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89576. }
  89577. }
  89578. declare module BABYLON {
  89579. /**
  89580. * Interface for Physics-Joint data
  89581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89582. */
  89583. export interface PhysicsJointData {
  89584. /**
  89585. * The main pivot of the joint
  89586. */
  89587. mainPivot?: Vector3;
  89588. /**
  89589. * The connected pivot of the joint
  89590. */
  89591. connectedPivot?: Vector3;
  89592. /**
  89593. * The main axis of the joint
  89594. */
  89595. mainAxis?: Vector3;
  89596. /**
  89597. * The connected axis of the joint
  89598. */
  89599. connectedAxis?: Vector3;
  89600. /**
  89601. * The collision of the joint
  89602. */
  89603. collision?: boolean;
  89604. /**
  89605. * Native Oimo/Cannon/Energy data
  89606. */
  89607. nativeParams?: any;
  89608. }
  89609. /**
  89610. * This is a holder class for the physics joint created by the physics plugin
  89611. * It holds a set of functions to control the underlying joint
  89612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89613. */
  89614. export class PhysicsJoint {
  89615. /**
  89616. * The type of the physics joint
  89617. */
  89618. type: number;
  89619. /**
  89620. * The data for the physics joint
  89621. */
  89622. jointData: PhysicsJointData;
  89623. private _physicsJoint;
  89624. protected _physicsPlugin: IPhysicsEnginePlugin;
  89625. /**
  89626. * Initializes the physics joint
  89627. * @param type The type of the physics joint
  89628. * @param jointData The data for the physics joint
  89629. */
  89630. constructor(
  89631. /**
  89632. * The type of the physics joint
  89633. */
  89634. type: number,
  89635. /**
  89636. * The data for the physics joint
  89637. */
  89638. jointData: PhysicsJointData);
  89639. /**
  89640. * Gets the physics joint
  89641. */
  89642. /**
  89643. * Sets the physics joint
  89644. */
  89645. physicsJoint: any;
  89646. /**
  89647. * Sets the physics plugin
  89648. */
  89649. physicsPlugin: IPhysicsEnginePlugin;
  89650. /**
  89651. * Execute a function that is physics-plugin specific.
  89652. * @param {Function} func the function that will be executed.
  89653. * It accepts two parameters: the physics world and the physics joint
  89654. */
  89655. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89656. /**
  89657. * Distance-Joint type
  89658. */
  89659. static DistanceJoint: number;
  89660. /**
  89661. * Hinge-Joint type
  89662. */
  89663. static HingeJoint: number;
  89664. /**
  89665. * Ball-and-Socket joint type
  89666. */
  89667. static BallAndSocketJoint: number;
  89668. /**
  89669. * Wheel-Joint type
  89670. */
  89671. static WheelJoint: number;
  89672. /**
  89673. * Slider-Joint type
  89674. */
  89675. static SliderJoint: number;
  89676. /**
  89677. * Prismatic-Joint type
  89678. */
  89679. static PrismaticJoint: number;
  89680. /**
  89681. * Universal-Joint type
  89682. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89683. */
  89684. static UniversalJoint: number;
  89685. /**
  89686. * Hinge-Joint 2 type
  89687. */
  89688. static Hinge2Joint: number;
  89689. /**
  89690. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89691. */
  89692. static PointToPointJoint: number;
  89693. /**
  89694. * Spring-Joint type
  89695. */
  89696. static SpringJoint: number;
  89697. /**
  89698. * Lock-Joint type
  89699. */
  89700. static LockJoint: number;
  89701. }
  89702. /**
  89703. * A class representing a physics distance joint
  89704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89705. */
  89706. export class DistanceJoint extends PhysicsJoint {
  89707. /**
  89708. *
  89709. * @param jointData The data for the Distance-Joint
  89710. */
  89711. constructor(jointData: DistanceJointData);
  89712. /**
  89713. * Update the predefined distance.
  89714. * @param maxDistance The maximum preferred distance
  89715. * @param minDistance The minimum preferred distance
  89716. */
  89717. updateDistance(maxDistance: number, minDistance?: number): void;
  89718. }
  89719. /**
  89720. * Represents a Motor-Enabled Joint
  89721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89722. */
  89723. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89724. /**
  89725. * Initializes the Motor-Enabled Joint
  89726. * @param type The type of the joint
  89727. * @param jointData The physica joint data for the joint
  89728. */
  89729. constructor(type: number, jointData: PhysicsJointData);
  89730. /**
  89731. * Set the motor values.
  89732. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89733. * @param force the force to apply
  89734. * @param maxForce max force for this motor.
  89735. */
  89736. setMotor(force?: number, maxForce?: number): void;
  89737. /**
  89738. * Set the motor's limits.
  89739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89740. * @param upperLimit The upper limit of the motor
  89741. * @param lowerLimit The lower limit of the motor
  89742. */
  89743. setLimit(upperLimit: number, lowerLimit?: number): void;
  89744. }
  89745. /**
  89746. * This class represents a single physics Hinge-Joint
  89747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89748. */
  89749. export class HingeJoint extends MotorEnabledJoint {
  89750. /**
  89751. * Initializes the Hinge-Joint
  89752. * @param jointData The joint data for the Hinge-Joint
  89753. */
  89754. constructor(jointData: PhysicsJointData);
  89755. /**
  89756. * Set the motor values.
  89757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89758. * @param {number} force the force to apply
  89759. * @param {number} maxForce max force for this motor.
  89760. */
  89761. setMotor(force?: number, maxForce?: number): void;
  89762. /**
  89763. * Set the motor's limits.
  89764. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89765. * @param upperLimit The upper limit of the motor
  89766. * @param lowerLimit The lower limit of the motor
  89767. */
  89768. setLimit(upperLimit: number, lowerLimit?: number): void;
  89769. }
  89770. /**
  89771. * This class represents a dual hinge physics joint (same as wheel joint)
  89772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89773. */
  89774. export class Hinge2Joint extends MotorEnabledJoint {
  89775. /**
  89776. * Initializes the Hinge2-Joint
  89777. * @param jointData The joint data for the Hinge2-Joint
  89778. */
  89779. constructor(jointData: PhysicsJointData);
  89780. /**
  89781. * Set the motor values.
  89782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89783. * @param {number} targetSpeed the speed the motor is to reach
  89784. * @param {number} maxForce max force for this motor.
  89785. * @param {motorIndex} the motor's index, 0 or 1.
  89786. */
  89787. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89788. /**
  89789. * Set the motor limits.
  89790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89791. * @param {number} upperLimit the upper limit
  89792. * @param {number} lowerLimit lower limit
  89793. * @param {motorIndex} the motor's index, 0 or 1.
  89794. */
  89795. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89796. }
  89797. /**
  89798. * Interface for a motor enabled joint
  89799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89800. */
  89801. export interface IMotorEnabledJoint {
  89802. /**
  89803. * Physics joint
  89804. */
  89805. physicsJoint: any;
  89806. /**
  89807. * Sets the motor of the motor-enabled joint
  89808. * @param force The force of the motor
  89809. * @param maxForce The maximum force of the motor
  89810. * @param motorIndex The index of the motor
  89811. */
  89812. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89813. /**
  89814. * Sets the limit of the motor
  89815. * @param upperLimit The upper limit of the motor
  89816. * @param lowerLimit The lower limit of the motor
  89817. * @param motorIndex The index of the motor
  89818. */
  89819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89820. }
  89821. /**
  89822. * Joint data for a Distance-Joint
  89823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89824. */
  89825. export interface DistanceJointData extends PhysicsJointData {
  89826. /**
  89827. * Max distance the 2 joint objects can be apart
  89828. */
  89829. maxDistance: number;
  89830. }
  89831. /**
  89832. * Joint data from a spring joint
  89833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89834. */
  89835. export interface SpringJointData extends PhysicsJointData {
  89836. /**
  89837. * Length of the spring
  89838. */
  89839. length: number;
  89840. /**
  89841. * Stiffness of the spring
  89842. */
  89843. stiffness: number;
  89844. /**
  89845. * Damping of the spring
  89846. */
  89847. damping: number;
  89848. /** this callback will be called when applying the force to the impostors. */
  89849. forceApplicationCallback: () => void;
  89850. }
  89851. }
  89852. declare module BABYLON {
  89853. /**
  89854. * Holds the data for the raycast result
  89855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89856. */
  89857. export class PhysicsRaycastResult {
  89858. private _hasHit;
  89859. private _hitDistance;
  89860. private _hitNormalWorld;
  89861. private _hitPointWorld;
  89862. private _rayFromWorld;
  89863. private _rayToWorld;
  89864. /**
  89865. * Gets if there was a hit
  89866. */
  89867. readonly hasHit: boolean;
  89868. /**
  89869. * Gets the distance from the hit
  89870. */
  89871. readonly hitDistance: number;
  89872. /**
  89873. * Gets the hit normal/direction in the world
  89874. */
  89875. readonly hitNormalWorld: Vector3;
  89876. /**
  89877. * Gets the hit point in the world
  89878. */
  89879. readonly hitPointWorld: Vector3;
  89880. /**
  89881. * Gets the ray "start point" of the ray in the world
  89882. */
  89883. readonly rayFromWorld: Vector3;
  89884. /**
  89885. * Gets the ray "end point" of the ray in the world
  89886. */
  89887. readonly rayToWorld: Vector3;
  89888. /**
  89889. * Sets the hit data (normal & point in world space)
  89890. * @param hitNormalWorld defines the normal in world space
  89891. * @param hitPointWorld defines the point in world space
  89892. */
  89893. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89894. /**
  89895. * Sets the distance from the start point to the hit point
  89896. * @param distance
  89897. */
  89898. setHitDistance(distance: number): void;
  89899. /**
  89900. * Calculates the distance manually
  89901. */
  89902. calculateHitDistance(): void;
  89903. /**
  89904. * Resets all the values to default
  89905. * @param from The from point on world space
  89906. * @param to The to point on world space
  89907. */
  89908. reset(from?: Vector3, to?: Vector3): void;
  89909. }
  89910. /**
  89911. * Interface for the size containing width and height
  89912. */
  89913. interface IXYZ {
  89914. /**
  89915. * X
  89916. */
  89917. x: number;
  89918. /**
  89919. * Y
  89920. */
  89921. y: number;
  89922. /**
  89923. * Z
  89924. */
  89925. z: number;
  89926. }
  89927. }
  89928. declare module BABYLON {
  89929. /**
  89930. * Interface used to describe a physics joint
  89931. */
  89932. export interface PhysicsImpostorJoint {
  89933. /** Defines the main impostor to which the joint is linked */
  89934. mainImpostor: PhysicsImpostor;
  89935. /** Defines the impostor that is connected to the main impostor using this joint */
  89936. connectedImpostor: PhysicsImpostor;
  89937. /** Defines the joint itself */
  89938. joint: PhysicsJoint;
  89939. }
  89940. /** @hidden */
  89941. export interface IPhysicsEnginePlugin {
  89942. world: any;
  89943. name: string;
  89944. setGravity(gravity: Vector3): void;
  89945. setTimeStep(timeStep: number): void;
  89946. getTimeStep(): number;
  89947. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89948. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89949. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89950. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89951. removePhysicsBody(impostor: PhysicsImpostor): void;
  89952. generateJoint(joint: PhysicsImpostorJoint): void;
  89953. removeJoint(joint: PhysicsImpostorJoint): void;
  89954. isSupported(): boolean;
  89955. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89958. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89959. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89960. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89962. getBodyMass(impostor: PhysicsImpostor): number;
  89963. getBodyFriction(impostor: PhysicsImpostor): number;
  89964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89965. getBodyRestitution(impostor: PhysicsImpostor): number;
  89966. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89967. getBodyPressure?(impostor: PhysicsImpostor): number;
  89968. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89969. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89970. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89971. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89972. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89973. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89974. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89975. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89976. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89977. sleepBody(impostor: PhysicsImpostor): void;
  89978. wakeUpBody(impostor: PhysicsImpostor): void;
  89979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89980. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89981. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89982. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89983. getRadius(impostor: PhysicsImpostor): number;
  89984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89986. dispose(): void;
  89987. }
  89988. /**
  89989. * Interface used to define a physics engine
  89990. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89991. */
  89992. export interface IPhysicsEngine {
  89993. /**
  89994. * Gets the gravity vector used by the simulation
  89995. */
  89996. gravity: Vector3;
  89997. /**
  89998. * Sets the gravity vector used by the simulation
  89999. * @param gravity defines the gravity vector to use
  90000. */
  90001. setGravity(gravity: Vector3): void;
  90002. /**
  90003. * Set the time step of the physics engine.
  90004. * Default is 1/60.
  90005. * To slow it down, enter 1/600 for example.
  90006. * To speed it up, 1/30
  90007. * @param newTimeStep the new timestep to apply to this world.
  90008. */
  90009. setTimeStep(newTimeStep: number): void;
  90010. /**
  90011. * Get the time step of the physics engine.
  90012. * @returns the current time step
  90013. */
  90014. getTimeStep(): number;
  90015. /**
  90016. * Release all resources
  90017. */
  90018. dispose(): void;
  90019. /**
  90020. * Gets the name of the current physics plugin
  90021. * @returns the name of the plugin
  90022. */
  90023. getPhysicsPluginName(): string;
  90024. /**
  90025. * Adding a new impostor for the impostor tracking.
  90026. * This will be done by the impostor itself.
  90027. * @param impostor the impostor to add
  90028. */
  90029. addImpostor(impostor: PhysicsImpostor): void;
  90030. /**
  90031. * Remove an impostor from the engine.
  90032. * This impostor and its mesh will not longer be updated by the physics engine.
  90033. * @param impostor the impostor to remove
  90034. */
  90035. removeImpostor(impostor: PhysicsImpostor): void;
  90036. /**
  90037. * Add a joint to the physics engine
  90038. * @param mainImpostor defines the main impostor to which the joint is added.
  90039. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90040. * @param joint defines the joint that will connect both impostors.
  90041. */
  90042. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90043. /**
  90044. * Removes a joint from the simulation
  90045. * @param mainImpostor defines the impostor used with the joint
  90046. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90047. * @param joint defines the joint to remove
  90048. */
  90049. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90050. /**
  90051. * Gets the current plugin used to run the simulation
  90052. * @returns current plugin
  90053. */
  90054. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90055. /**
  90056. * Gets the list of physic impostors
  90057. * @returns an array of PhysicsImpostor
  90058. */
  90059. getImpostors(): Array<PhysicsImpostor>;
  90060. /**
  90061. * Gets the impostor for a physics enabled object
  90062. * @param object defines the object impersonated by the impostor
  90063. * @returns the PhysicsImpostor or null if not found
  90064. */
  90065. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90066. /**
  90067. * Gets the impostor for a physics body object
  90068. * @param body defines physics body used by the impostor
  90069. * @returns the PhysicsImpostor or null if not found
  90070. */
  90071. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90072. /**
  90073. * Does a raycast in the physics world
  90074. * @param from when should the ray start?
  90075. * @param to when should the ray end?
  90076. * @returns PhysicsRaycastResult
  90077. */
  90078. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90079. /**
  90080. * Called by the scene. No need to call it.
  90081. * @param delta defines the timespam between frames
  90082. */
  90083. _step(delta: number): void;
  90084. }
  90085. }
  90086. declare module BABYLON {
  90087. /**
  90088. * The interface for the physics imposter parameters
  90089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90090. */
  90091. export interface PhysicsImpostorParameters {
  90092. /**
  90093. * The mass of the physics imposter
  90094. */
  90095. mass: number;
  90096. /**
  90097. * The friction of the physics imposter
  90098. */
  90099. friction?: number;
  90100. /**
  90101. * The coefficient of restitution of the physics imposter
  90102. */
  90103. restitution?: number;
  90104. /**
  90105. * The native options of the physics imposter
  90106. */
  90107. nativeOptions?: any;
  90108. /**
  90109. * Specifies if the parent should be ignored
  90110. */
  90111. ignoreParent?: boolean;
  90112. /**
  90113. * Specifies if bi-directional transformations should be disabled
  90114. */
  90115. disableBidirectionalTransformation?: boolean;
  90116. /**
  90117. * The pressure inside the physics imposter, soft object only
  90118. */
  90119. pressure?: number;
  90120. /**
  90121. * The stiffness the physics imposter, soft object only
  90122. */
  90123. stiffness?: number;
  90124. /**
  90125. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90126. */
  90127. velocityIterations?: number;
  90128. /**
  90129. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90130. */
  90131. positionIterations?: number;
  90132. /**
  90133. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90134. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90135. * Add to fix multiple points
  90136. */
  90137. fixedPoints?: number;
  90138. /**
  90139. * The collision margin around a soft object
  90140. */
  90141. margin?: number;
  90142. /**
  90143. * The collision margin around a soft object
  90144. */
  90145. damping?: number;
  90146. /**
  90147. * The path for a rope based on an extrusion
  90148. */
  90149. path?: any;
  90150. /**
  90151. * The shape of an extrusion used for a rope based on an extrusion
  90152. */
  90153. shape?: any;
  90154. }
  90155. /**
  90156. * Interface for a physics-enabled object
  90157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90158. */
  90159. export interface IPhysicsEnabledObject {
  90160. /**
  90161. * The position of the physics-enabled object
  90162. */
  90163. position: Vector3;
  90164. /**
  90165. * The rotation of the physics-enabled object
  90166. */
  90167. rotationQuaternion: Nullable<Quaternion>;
  90168. /**
  90169. * The scale of the physics-enabled object
  90170. */
  90171. scaling: Vector3;
  90172. /**
  90173. * The rotation of the physics-enabled object
  90174. */
  90175. rotation?: Vector3;
  90176. /**
  90177. * The parent of the physics-enabled object
  90178. */
  90179. parent?: any;
  90180. /**
  90181. * The bounding info of the physics-enabled object
  90182. * @returns The bounding info of the physics-enabled object
  90183. */
  90184. getBoundingInfo(): BoundingInfo;
  90185. /**
  90186. * Computes the world matrix
  90187. * @param force Specifies if the world matrix should be computed by force
  90188. * @returns A world matrix
  90189. */
  90190. computeWorldMatrix(force: boolean): Matrix;
  90191. /**
  90192. * Gets the world matrix
  90193. * @returns A world matrix
  90194. */
  90195. getWorldMatrix?(): Matrix;
  90196. /**
  90197. * Gets the child meshes
  90198. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90199. * @returns An array of abstract meshes
  90200. */
  90201. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90202. /**
  90203. * Gets the vertex data
  90204. * @param kind The type of vertex data
  90205. * @returns A nullable array of numbers, or a float32 array
  90206. */
  90207. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90208. /**
  90209. * Gets the indices from the mesh
  90210. * @returns A nullable array of index arrays
  90211. */
  90212. getIndices?(): Nullable<IndicesArray>;
  90213. /**
  90214. * Gets the scene from the mesh
  90215. * @returns the indices array or null
  90216. */
  90217. getScene?(): Scene;
  90218. /**
  90219. * Gets the absolute position from the mesh
  90220. * @returns the absolute position
  90221. */
  90222. getAbsolutePosition(): Vector3;
  90223. /**
  90224. * Gets the absolute pivot point from the mesh
  90225. * @returns the absolute pivot point
  90226. */
  90227. getAbsolutePivotPoint(): Vector3;
  90228. /**
  90229. * Rotates the mesh
  90230. * @param axis The axis of rotation
  90231. * @param amount The amount of rotation
  90232. * @param space The space of the rotation
  90233. * @returns The rotation transform node
  90234. */
  90235. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90236. /**
  90237. * Translates the mesh
  90238. * @param axis The axis of translation
  90239. * @param distance The distance of translation
  90240. * @param space The space of the translation
  90241. * @returns The transform node
  90242. */
  90243. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90244. /**
  90245. * Sets the absolute position of the mesh
  90246. * @param absolutePosition The absolute position of the mesh
  90247. * @returns The transform node
  90248. */
  90249. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90250. /**
  90251. * Gets the class name of the mesh
  90252. * @returns The class name
  90253. */
  90254. getClassName(): string;
  90255. }
  90256. /**
  90257. * Represents a physics imposter
  90258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90259. */
  90260. export class PhysicsImpostor {
  90261. /**
  90262. * The physics-enabled object used as the physics imposter
  90263. */
  90264. object: IPhysicsEnabledObject;
  90265. /**
  90266. * The type of the physics imposter
  90267. */
  90268. type: number;
  90269. private _options;
  90270. private _scene?;
  90271. /**
  90272. * The default object size of the imposter
  90273. */
  90274. static DEFAULT_OBJECT_SIZE: Vector3;
  90275. /**
  90276. * The identity quaternion of the imposter
  90277. */
  90278. static IDENTITY_QUATERNION: Quaternion;
  90279. /** @hidden */
  90280. _pluginData: any;
  90281. private _physicsEngine;
  90282. private _physicsBody;
  90283. private _bodyUpdateRequired;
  90284. private _onBeforePhysicsStepCallbacks;
  90285. private _onAfterPhysicsStepCallbacks;
  90286. /** @hidden */
  90287. _onPhysicsCollideCallbacks: Array<{
  90288. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90289. otherImpostors: Array<PhysicsImpostor>;
  90290. }>;
  90291. private _deltaPosition;
  90292. private _deltaRotation;
  90293. private _deltaRotationConjugated;
  90294. /** @hidden */
  90295. _isFromLine: boolean;
  90296. private _parent;
  90297. private _isDisposed;
  90298. private static _tmpVecs;
  90299. private static _tmpQuat;
  90300. /**
  90301. * Specifies if the physics imposter is disposed
  90302. */
  90303. readonly isDisposed: boolean;
  90304. /**
  90305. * Gets the mass of the physics imposter
  90306. */
  90307. mass: number;
  90308. /**
  90309. * Gets the coefficient of friction
  90310. */
  90311. /**
  90312. * Sets the coefficient of friction
  90313. */
  90314. friction: number;
  90315. /**
  90316. * Gets the coefficient of restitution
  90317. */
  90318. /**
  90319. * Sets the coefficient of restitution
  90320. */
  90321. restitution: number;
  90322. /**
  90323. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90324. */
  90325. /**
  90326. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90327. */
  90328. pressure: number;
  90329. /**
  90330. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90331. */
  90332. /**
  90333. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90334. */
  90335. stiffness: number;
  90336. /**
  90337. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90338. */
  90339. /**
  90340. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90341. */
  90342. velocityIterations: number;
  90343. /**
  90344. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90345. */
  90346. /**
  90347. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90348. */
  90349. positionIterations: number;
  90350. /**
  90351. * The unique id of the physics imposter
  90352. * set by the physics engine when adding this impostor to the array
  90353. */
  90354. uniqueId: number;
  90355. /**
  90356. * @hidden
  90357. */
  90358. soft: boolean;
  90359. /**
  90360. * @hidden
  90361. */
  90362. segments: number;
  90363. private _joints;
  90364. /**
  90365. * Initializes the physics imposter
  90366. * @param object The physics-enabled object used as the physics imposter
  90367. * @param type The type of the physics imposter
  90368. * @param _options The options for the physics imposter
  90369. * @param _scene The Babylon scene
  90370. */
  90371. constructor(
  90372. /**
  90373. * The physics-enabled object used as the physics imposter
  90374. */
  90375. object: IPhysicsEnabledObject,
  90376. /**
  90377. * The type of the physics imposter
  90378. */
  90379. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90380. /**
  90381. * This function will completly initialize this impostor.
  90382. * It will create a new body - but only if this mesh has no parent.
  90383. * If it has, this impostor will not be used other than to define the impostor
  90384. * of the child mesh.
  90385. * @hidden
  90386. */
  90387. _init(): void;
  90388. private _getPhysicsParent;
  90389. /**
  90390. * Should a new body be generated.
  90391. * @returns boolean specifying if body initialization is required
  90392. */
  90393. isBodyInitRequired(): boolean;
  90394. /**
  90395. * Sets the updated scaling
  90396. * @param updated Specifies if the scaling is updated
  90397. */
  90398. setScalingUpdated(): void;
  90399. /**
  90400. * Force a regeneration of this or the parent's impostor's body.
  90401. * Use under cautious - This will remove all joints already implemented.
  90402. */
  90403. forceUpdate(): void;
  90404. /**
  90405. * Gets the body that holds this impostor. Either its own, or its parent.
  90406. */
  90407. /**
  90408. * Set the physics body. Used mainly by the physics engine/plugin
  90409. */
  90410. physicsBody: any;
  90411. /**
  90412. * Get the parent of the physics imposter
  90413. * @returns Physics imposter or null
  90414. */
  90415. /**
  90416. * Sets the parent of the physics imposter
  90417. */
  90418. parent: Nullable<PhysicsImpostor>;
  90419. /**
  90420. * Resets the update flags
  90421. */
  90422. resetUpdateFlags(): void;
  90423. /**
  90424. * Gets the object extend size
  90425. * @returns the object extend size
  90426. */
  90427. getObjectExtendSize(): Vector3;
  90428. /**
  90429. * Gets the object center
  90430. * @returns The object center
  90431. */
  90432. getObjectCenter(): Vector3;
  90433. /**
  90434. * Get a specific parametes from the options parameter
  90435. * @param paramName The object parameter name
  90436. * @returns The object parameter
  90437. */
  90438. getParam(paramName: string): any;
  90439. /**
  90440. * Sets a specific parameter in the options given to the physics plugin
  90441. * @param paramName The parameter name
  90442. * @param value The value of the parameter
  90443. */
  90444. setParam(paramName: string, value: number): void;
  90445. /**
  90446. * Specifically change the body's mass option. Won't recreate the physics body object
  90447. * @param mass The mass of the physics imposter
  90448. */
  90449. setMass(mass: number): void;
  90450. /**
  90451. * Gets the linear velocity
  90452. * @returns linear velocity or null
  90453. */
  90454. getLinearVelocity(): Nullable<Vector3>;
  90455. /**
  90456. * Sets the linear velocity
  90457. * @param velocity linear velocity or null
  90458. */
  90459. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90460. /**
  90461. * Gets the angular velocity
  90462. * @returns angular velocity or null
  90463. */
  90464. getAngularVelocity(): Nullable<Vector3>;
  90465. /**
  90466. * Sets the angular velocity
  90467. * @param velocity The velocity or null
  90468. */
  90469. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90470. /**
  90471. * Execute a function with the physics plugin native code
  90472. * Provide a function the will have two variables - the world object and the physics body object
  90473. * @param func The function to execute with the physics plugin native code
  90474. */
  90475. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90476. /**
  90477. * Register a function that will be executed before the physics world is stepping forward
  90478. * @param func The function to execute before the physics world is stepped forward
  90479. */
  90480. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90481. /**
  90482. * Unregister a function that will be executed before the physics world is stepping forward
  90483. * @param func The function to execute before the physics world is stepped forward
  90484. */
  90485. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90486. /**
  90487. * Register a function that will be executed after the physics step
  90488. * @param func The function to execute after physics step
  90489. */
  90490. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90491. /**
  90492. * Unregisters a function that will be executed after the physics step
  90493. * @param func The function to execute after physics step
  90494. */
  90495. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90496. /**
  90497. * register a function that will be executed when this impostor collides against a different body
  90498. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90499. * @param func Callback that is executed on collision
  90500. */
  90501. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90502. /**
  90503. * Unregisters the physics imposter on contact
  90504. * @param collideAgainst The physics object to collide against
  90505. * @param func Callback to execute on collision
  90506. */
  90507. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90508. private _tmpQuat;
  90509. private _tmpQuat2;
  90510. /**
  90511. * Get the parent rotation
  90512. * @returns The parent rotation
  90513. */
  90514. getParentsRotation(): Quaternion;
  90515. /**
  90516. * this function is executed by the physics engine.
  90517. */
  90518. beforeStep: () => void;
  90519. /**
  90520. * this function is executed by the physics engine
  90521. */
  90522. afterStep: () => void;
  90523. /**
  90524. * Legacy collision detection event support
  90525. */
  90526. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90527. /**
  90528. * event and body object due to cannon's event-based architecture.
  90529. */
  90530. onCollide: (e: {
  90531. body: any;
  90532. }) => void;
  90533. /**
  90534. * Apply a force
  90535. * @param force The force to apply
  90536. * @param contactPoint The contact point for the force
  90537. * @returns The physics imposter
  90538. */
  90539. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90540. /**
  90541. * Apply an impulse
  90542. * @param force The impulse force
  90543. * @param contactPoint The contact point for the impulse force
  90544. * @returns The physics imposter
  90545. */
  90546. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90547. /**
  90548. * A help function to create a joint
  90549. * @param otherImpostor A physics imposter used to create a joint
  90550. * @param jointType The type of joint
  90551. * @param jointData The data for the joint
  90552. * @returns The physics imposter
  90553. */
  90554. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90555. /**
  90556. * Add a joint to this impostor with a different impostor
  90557. * @param otherImpostor A physics imposter used to add a joint
  90558. * @param joint The joint to add
  90559. * @returns The physics imposter
  90560. */
  90561. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90562. /**
  90563. * Add an anchor to a cloth impostor
  90564. * @param otherImpostor rigid impostor to anchor to
  90565. * @param width ratio across width from 0 to 1
  90566. * @param height ratio up height from 0 to 1
  90567. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90568. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90569. * @returns impostor the soft imposter
  90570. */
  90571. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90572. /**
  90573. * Add a hook to a rope impostor
  90574. * @param otherImpostor rigid impostor to anchor to
  90575. * @param length ratio across rope from 0 to 1
  90576. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90577. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90578. * @returns impostor the rope imposter
  90579. */
  90580. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90581. /**
  90582. * Will keep this body still, in a sleep mode.
  90583. * @returns the physics imposter
  90584. */
  90585. sleep(): PhysicsImpostor;
  90586. /**
  90587. * Wake the body up.
  90588. * @returns The physics imposter
  90589. */
  90590. wakeUp(): PhysicsImpostor;
  90591. /**
  90592. * Clones the physics imposter
  90593. * @param newObject The physics imposter clones to this physics-enabled object
  90594. * @returns A nullable physics imposter
  90595. */
  90596. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90597. /**
  90598. * Disposes the physics imposter
  90599. */
  90600. dispose(): void;
  90601. /**
  90602. * Sets the delta position
  90603. * @param position The delta position amount
  90604. */
  90605. setDeltaPosition(position: Vector3): void;
  90606. /**
  90607. * Sets the delta rotation
  90608. * @param rotation The delta rotation amount
  90609. */
  90610. setDeltaRotation(rotation: Quaternion): void;
  90611. /**
  90612. * Gets the box size of the physics imposter and stores the result in the input parameter
  90613. * @param result Stores the box size
  90614. * @returns The physics imposter
  90615. */
  90616. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90617. /**
  90618. * Gets the radius of the physics imposter
  90619. * @returns Radius of the physics imposter
  90620. */
  90621. getRadius(): number;
  90622. /**
  90623. * Sync a bone with this impostor
  90624. * @param bone The bone to sync to the impostor.
  90625. * @param boneMesh The mesh that the bone is influencing.
  90626. * @param jointPivot The pivot of the joint / bone in local space.
  90627. * @param distToJoint Optional distance from the impostor to the joint.
  90628. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90629. */
  90630. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90631. /**
  90632. * Sync impostor to a bone
  90633. * @param bone The bone that the impostor will be synced to.
  90634. * @param boneMesh The mesh that the bone is influencing.
  90635. * @param jointPivot The pivot of the joint / bone in local space.
  90636. * @param distToJoint Optional distance from the impostor to the joint.
  90637. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90638. * @param boneAxis Optional vector3 axis the bone is aligned with
  90639. */
  90640. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90641. /**
  90642. * No-Imposter type
  90643. */
  90644. static NoImpostor: number;
  90645. /**
  90646. * Sphere-Imposter type
  90647. */
  90648. static SphereImpostor: number;
  90649. /**
  90650. * Box-Imposter type
  90651. */
  90652. static BoxImpostor: number;
  90653. /**
  90654. * Plane-Imposter type
  90655. */
  90656. static PlaneImpostor: number;
  90657. /**
  90658. * Mesh-imposter type
  90659. */
  90660. static MeshImpostor: number;
  90661. /**
  90662. * Capsule-Impostor type (Ammo.js plugin only)
  90663. */
  90664. static CapsuleImpostor: number;
  90665. /**
  90666. * Cylinder-Imposter type
  90667. */
  90668. static CylinderImpostor: number;
  90669. /**
  90670. * Particle-Imposter type
  90671. */
  90672. static ParticleImpostor: number;
  90673. /**
  90674. * Heightmap-Imposter type
  90675. */
  90676. static HeightmapImpostor: number;
  90677. /**
  90678. * ConvexHull-Impostor type (Ammo.js plugin only)
  90679. */
  90680. static ConvexHullImpostor: number;
  90681. /**
  90682. * Rope-Imposter type
  90683. */
  90684. static RopeImpostor: number;
  90685. /**
  90686. * Cloth-Imposter type
  90687. */
  90688. static ClothImpostor: number;
  90689. /**
  90690. * Softbody-Imposter type
  90691. */
  90692. static SoftbodyImpostor: number;
  90693. }
  90694. }
  90695. declare module BABYLON {
  90696. /**
  90697. * @hidden
  90698. **/
  90699. export class _CreationDataStorage {
  90700. closePath?: boolean;
  90701. closeArray?: boolean;
  90702. idx: number[];
  90703. dashSize: number;
  90704. gapSize: number;
  90705. path3D: Path3D;
  90706. pathArray: Vector3[][];
  90707. arc: number;
  90708. radius: number;
  90709. cap: number;
  90710. tessellation: number;
  90711. }
  90712. /**
  90713. * @hidden
  90714. **/
  90715. class _InstanceDataStorage {
  90716. visibleInstances: any;
  90717. batchCache: _InstancesBatch;
  90718. instancesBufferSize: number;
  90719. instancesBuffer: Nullable<Buffer>;
  90720. instancesData: Float32Array;
  90721. overridenInstanceCount: number;
  90722. isFrozen: boolean;
  90723. previousBatch: Nullable<_InstancesBatch>;
  90724. hardwareInstancedRendering: boolean;
  90725. sideOrientation: number;
  90726. }
  90727. /**
  90728. * @hidden
  90729. **/
  90730. export class _InstancesBatch {
  90731. mustReturn: boolean;
  90732. visibleInstances: Nullable<InstancedMesh[]>[];
  90733. renderSelf: boolean[];
  90734. hardwareInstancedRendering: boolean[];
  90735. }
  90736. /**
  90737. * Class used to represent renderable models
  90738. */
  90739. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90740. /**
  90741. * Mesh side orientation : usually the external or front surface
  90742. */
  90743. static readonly FRONTSIDE: number;
  90744. /**
  90745. * Mesh side orientation : usually the internal or back surface
  90746. */
  90747. static readonly BACKSIDE: number;
  90748. /**
  90749. * Mesh side orientation : both internal and external or front and back surfaces
  90750. */
  90751. static readonly DOUBLESIDE: number;
  90752. /**
  90753. * Mesh side orientation : by default, `FRONTSIDE`
  90754. */
  90755. static readonly DEFAULTSIDE: number;
  90756. /**
  90757. * Mesh cap setting : no cap
  90758. */
  90759. static readonly NO_CAP: number;
  90760. /**
  90761. * Mesh cap setting : one cap at the beginning of the mesh
  90762. */
  90763. static readonly CAP_START: number;
  90764. /**
  90765. * Mesh cap setting : one cap at the end of the mesh
  90766. */
  90767. static readonly CAP_END: number;
  90768. /**
  90769. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90770. */
  90771. static readonly CAP_ALL: number;
  90772. /**
  90773. * Mesh pattern setting : no flip or rotate
  90774. */
  90775. static readonly NO_FLIP: number;
  90776. /**
  90777. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90778. */
  90779. static readonly FLIP_TILE: number;
  90780. /**
  90781. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90782. */
  90783. static readonly ROTATE_TILE: number;
  90784. /**
  90785. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90786. */
  90787. static readonly FLIP_ROW: number;
  90788. /**
  90789. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90790. */
  90791. static readonly ROTATE_ROW: number;
  90792. /**
  90793. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90794. */
  90795. static readonly FLIP_N_ROTATE_TILE: number;
  90796. /**
  90797. * Mesh pattern setting : rotate pattern and rotate
  90798. */
  90799. static readonly FLIP_N_ROTATE_ROW: number;
  90800. /**
  90801. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90802. */
  90803. static readonly CENTER: number;
  90804. /**
  90805. * Mesh tile positioning : part tiles on left
  90806. */
  90807. static readonly LEFT: number;
  90808. /**
  90809. * Mesh tile positioning : part tiles on right
  90810. */
  90811. static readonly RIGHT: number;
  90812. /**
  90813. * Mesh tile positioning : part tiles on top
  90814. */
  90815. static readonly TOP: number;
  90816. /**
  90817. * Mesh tile positioning : part tiles on bottom
  90818. */
  90819. static readonly BOTTOM: number;
  90820. /**
  90821. * Gets the default side orientation.
  90822. * @param orientation the orientation to value to attempt to get
  90823. * @returns the default orientation
  90824. * @hidden
  90825. */
  90826. static _GetDefaultSideOrientation(orientation?: number): number;
  90827. private _internalMeshDataInfo;
  90828. /**
  90829. * An event triggered before rendering the mesh
  90830. */
  90831. readonly onBeforeRenderObservable: Observable<Mesh>;
  90832. /**
  90833. * An event triggered before binding the mesh
  90834. */
  90835. readonly onBeforeBindObservable: Observable<Mesh>;
  90836. /**
  90837. * An event triggered after rendering the mesh
  90838. */
  90839. readonly onAfterRenderObservable: Observable<Mesh>;
  90840. /**
  90841. * An event triggered before drawing the mesh
  90842. */
  90843. readonly onBeforeDrawObservable: Observable<Mesh>;
  90844. private _onBeforeDrawObserver;
  90845. /**
  90846. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90847. */
  90848. onBeforeDraw: () => void;
  90849. readonly hasInstances: boolean;
  90850. /**
  90851. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90852. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90853. */
  90854. delayLoadState: number;
  90855. /**
  90856. * Gets the list of instances created from this mesh
  90857. * it is not supposed to be modified manually.
  90858. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90859. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90860. */
  90861. instances: InstancedMesh[];
  90862. /**
  90863. * Gets the file containing delay loading data for this mesh
  90864. */
  90865. delayLoadingFile: string;
  90866. /** @hidden */
  90867. _binaryInfo: any;
  90868. /**
  90869. * User defined function used to change how LOD level selection is done
  90870. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90871. */
  90872. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90873. /**
  90874. * Gets or sets the morph target manager
  90875. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90876. */
  90877. morphTargetManager: Nullable<MorphTargetManager>;
  90878. /** @hidden */
  90879. _creationDataStorage: Nullable<_CreationDataStorage>;
  90880. /** @hidden */
  90881. _geometry: Nullable<Geometry>;
  90882. /** @hidden */
  90883. _delayInfo: Array<string>;
  90884. /** @hidden */
  90885. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90886. /** @hidden */
  90887. _instanceDataStorage: _InstanceDataStorage;
  90888. private _effectiveMaterial;
  90889. /** @hidden */
  90890. _shouldGenerateFlatShading: boolean;
  90891. /** @hidden */
  90892. _originalBuilderSideOrientation: number;
  90893. /**
  90894. * Use this property to change the original side orientation defined at construction time
  90895. */
  90896. overrideMaterialSideOrientation: Nullable<number>;
  90897. /**
  90898. * Gets the source mesh (the one used to clone this one from)
  90899. */
  90900. readonly source: Nullable<Mesh>;
  90901. /**
  90902. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90903. */
  90904. isUnIndexed: boolean;
  90905. /**
  90906. * @constructor
  90907. * @param name The value used by scene.getMeshByName() to do a lookup.
  90908. * @param scene The scene to add this mesh to.
  90909. * @param parent The parent of this mesh, if it has one
  90910. * @param source An optional Mesh from which geometry is shared, cloned.
  90911. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90912. * When false, achieved by calling a clone(), also passing False.
  90913. * This will make creation of children, recursive.
  90914. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90915. */
  90916. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90917. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90918. /**
  90919. * Gets the class name
  90920. * @returns the string "Mesh".
  90921. */
  90922. getClassName(): string;
  90923. /** @hidden */
  90924. readonly _isMesh: boolean;
  90925. /**
  90926. * Returns a description of this mesh
  90927. * @param fullDetails define if full details about this mesh must be used
  90928. * @returns a descriptive string representing this mesh
  90929. */
  90930. toString(fullDetails?: boolean): string;
  90931. /** @hidden */
  90932. _unBindEffect(): void;
  90933. /**
  90934. * Gets a boolean indicating if this mesh has LOD
  90935. */
  90936. readonly hasLODLevels: boolean;
  90937. /**
  90938. * Gets the list of MeshLODLevel associated with the current mesh
  90939. * @returns an array of MeshLODLevel
  90940. */
  90941. getLODLevels(): MeshLODLevel[];
  90942. private _sortLODLevels;
  90943. /**
  90944. * Add a mesh as LOD level triggered at the given distance.
  90945. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90946. * @param distance The distance from the center of the object to show this level
  90947. * @param mesh The mesh to be added as LOD level (can be null)
  90948. * @return This mesh (for chaining)
  90949. */
  90950. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90951. /**
  90952. * Returns the LOD level mesh at the passed distance or null if not found.
  90953. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90954. * @param distance The distance from the center of the object to show this level
  90955. * @returns a Mesh or `null`
  90956. */
  90957. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90958. /**
  90959. * Remove a mesh from the LOD array
  90960. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90961. * @param mesh defines the mesh to be removed
  90962. * @return This mesh (for chaining)
  90963. */
  90964. removeLODLevel(mesh: Mesh): Mesh;
  90965. /**
  90966. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90968. * @param camera defines the camera to use to compute distance
  90969. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90970. * @return This mesh (for chaining)
  90971. */
  90972. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90973. /**
  90974. * Gets the mesh internal Geometry object
  90975. */
  90976. readonly geometry: Nullable<Geometry>;
  90977. /**
  90978. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90979. * @returns the total number of vertices
  90980. */
  90981. getTotalVertices(): number;
  90982. /**
  90983. * Returns the content of an associated vertex buffer
  90984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90985. * - VertexBuffer.PositionKind
  90986. * - VertexBuffer.UVKind
  90987. * - VertexBuffer.UV2Kind
  90988. * - VertexBuffer.UV3Kind
  90989. * - VertexBuffer.UV4Kind
  90990. * - VertexBuffer.UV5Kind
  90991. * - VertexBuffer.UV6Kind
  90992. * - VertexBuffer.ColorKind
  90993. * - VertexBuffer.MatricesIndicesKind
  90994. * - VertexBuffer.MatricesIndicesExtraKind
  90995. * - VertexBuffer.MatricesWeightsKind
  90996. * - VertexBuffer.MatricesWeightsExtraKind
  90997. * @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
  90998. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90999. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91000. */
  91001. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91002. /**
  91003. * Returns the mesh VertexBuffer object from the requested `kind`
  91004. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91005. * - VertexBuffer.PositionKind
  91006. * - VertexBuffer.NormalKind
  91007. * - VertexBuffer.UVKind
  91008. * - VertexBuffer.UV2Kind
  91009. * - VertexBuffer.UV3Kind
  91010. * - VertexBuffer.UV4Kind
  91011. * - VertexBuffer.UV5Kind
  91012. * - VertexBuffer.UV6Kind
  91013. * - VertexBuffer.ColorKind
  91014. * - VertexBuffer.MatricesIndicesKind
  91015. * - VertexBuffer.MatricesIndicesExtraKind
  91016. * - VertexBuffer.MatricesWeightsKind
  91017. * - VertexBuffer.MatricesWeightsExtraKind
  91018. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91019. */
  91020. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91021. /**
  91022. * Tests if a specific vertex buffer is associated with this mesh
  91023. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91024. * - VertexBuffer.PositionKind
  91025. * - VertexBuffer.NormalKind
  91026. * - VertexBuffer.UVKind
  91027. * - VertexBuffer.UV2Kind
  91028. * - VertexBuffer.UV3Kind
  91029. * - VertexBuffer.UV4Kind
  91030. * - VertexBuffer.UV5Kind
  91031. * - VertexBuffer.UV6Kind
  91032. * - VertexBuffer.ColorKind
  91033. * - VertexBuffer.MatricesIndicesKind
  91034. * - VertexBuffer.MatricesIndicesExtraKind
  91035. * - VertexBuffer.MatricesWeightsKind
  91036. * - VertexBuffer.MatricesWeightsExtraKind
  91037. * @returns a boolean
  91038. */
  91039. isVerticesDataPresent(kind: string): boolean;
  91040. /**
  91041. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91042. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91043. * - VertexBuffer.PositionKind
  91044. * - VertexBuffer.UVKind
  91045. * - VertexBuffer.UV2Kind
  91046. * - VertexBuffer.UV3Kind
  91047. * - VertexBuffer.UV4Kind
  91048. * - VertexBuffer.UV5Kind
  91049. * - VertexBuffer.UV6Kind
  91050. * - VertexBuffer.ColorKind
  91051. * - VertexBuffer.MatricesIndicesKind
  91052. * - VertexBuffer.MatricesIndicesExtraKind
  91053. * - VertexBuffer.MatricesWeightsKind
  91054. * - VertexBuffer.MatricesWeightsExtraKind
  91055. * @returns a boolean
  91056. */
  91057. isVertexBufferUpdatable(kind: string): boolean;
  91058. /**
  91059. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91061. * - VertexBuffer.PositionKind
  91062. * - VertexBuffer.NormalKind
  91063. * - VertexBuffer.UVKind
  91064. * - VertexBuffer.UV2Kind
  91065. * - VertexBuffer.UV3Kind
  91066. * - VertexBuffer.UV4Kind
  91067. * - VertexBuffer.UV5Kind
  91068. * - VertexBuffer.UV6Kind
  91069. * - VertexBuffer.ColorKind
  91070. * - VertexBuffer.MatricesIndicesKind
  91071. * - VertexBuffer.MatricesIndicesExtraKind
  91072. * - VertexBuffer.MatricesWeightsKind
  91073. * - VertexBuffer.MatricesWeightsExtraKind
  91074. * @returns an array of strings
  91075. */
  91076. getVerticesDataKinds(): string[];
  91077. /**
  91078. * Returns a positive integer : the total number of indices in this mesh geometry.
  91079. * @returns the numner of indices or zero if the mesh has no geometry.
  91080. */
  91081. getTotalIndices(): number;
  91082. /**
  91083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91084. * @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.
  91085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91086. * @returns the indices array or an empty array if the mesh has no geometry
  91087. */
  91088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91089. readonly isBlocked: boolean;
  91090. /**
  91091. * Determine if the current mesh is ready to be rendered
  91092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91094. * @returns true if all associated assets are ready (material, textures, shaders)
  91095. */
  91096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91097. /**
  91098. * 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.
  91099. */
  91100. readonly areNormalsFrozen: boolean;
  91101. /**
  91102. * 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.
  91103. * @returns the current mesh
  91104. */
  91105. freezeNormals(): Mesh;
  91106. /**
  91107. * 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
  91108. * @returns the current mesh
  91109. */
  91110. unfreezeNormals(): Mesh;
  91111. /**
  91112. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91113. */
  91114. overridenInstanceCount: number;
  91115. /** @hidden */
  91116. _preActivate(): Mesh;
  91117. /** @hidden */
  91118. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91119. /** @hidden */
  91120. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91121. /**
  91122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91123. * This means the mesh underlying bounding box and sphere are recomputed.
  91124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91125. * @returns the current mesh
  91126. */
  91127. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91128. /** @hidden */
  91129. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91130. /**
  91131. * This function will subdivide the mesh into multiple submeshes
  91132. * @param count defines the expected number of submeshes
  91133. */
  91134. subdivide(count: number): void;
  91135. /**
  91136. * Copy a FloatArray into a specific associated vertex buffer
  91137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91138. * - VertexBuffer.PositionKind
  91139. * - VertexBuffer.UVKind
  91140. * - VertexBuffer.UV2Kind
  91141. * - VertexBuffer.UV3Kind
  91142. * - VertexBuffer.UV4Kind
  91143. * - VertexBuffer.UV5Kind
  91144. * - VertexBuffer.UV6Kind
  91145. * - VertexBuffer.ColorKind
  91146. * - VertexBuffer.MatricesIndicesKind
  91147. * - VertexBuffer.MatricesIndicesExtraKind
  91148. * - VertexBuffer.MatricesWeightsKind
  91149. * - VertexBuffer.MatricesWeightsExtraKind
  91150. * @param data defines the data source
  91151. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91152. * @param stride defines the data stride size (can be null)
  91153. * @returns the current mesh
  91154. */
  91155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91156. /**
  91157. * Flags an associated vertex buffer as updatable
  91158. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91159. * - VertexBuffer.PositionKind
  91160. * - VertexBuffer.UVKind
  91161. * - VertexBuffer.UV2Kind
  91162. * - VertexBuffer.UV3Kind
  91163. * - VertexBuffer.UV4Kind
  91164. * - VertexBuffer.UV5Kind
  91165. * - VertexBuffer.UV6Kind
  91166. * - VertexBuffer.ColorKind
  91167. * - VertexBuffer.MatricesIndicesKind
  91168. * - VertexBuffer.MatricesIndicesExtraKind
  91169. * - VertexBuffer.MatricesWeightsKind
  91170. * - VertexBuffer.MatricesWeightsExtraKind
  91171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91172. */
  91173. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91174. /**
  91175. * Sets the mesh global Vertex Buffer
  91176. * @param buffer defines the buffer to use
  91177. * @returns the current mesh
  91178. */
  91179. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91180. /**
  91181. * Update a specific associated vertex buffer
  91182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91183. * - VertexBuffer.PositionKind
  91184. * - VertexBuffer.UVKind
  91185. * - VertexBuffer.UV2Kind
  91186. * - VertexBuffer.UV3Kind
  91187. * - VertexBuffer.UV4Kind
  91188. * - VertexBuffer.UV5Kind
  91189. * - VertexBuffer.UV6Kind
  91190. * - VertexBuffer.ColorKind
  91191. * - VertexBuffer.MatricesIndicesKind
  91192. * - VertexBuffer.MatricesIndicesExtraKind
  91193. * - VertexBuffer.MatricesWeightsKind
  91194. * - VertexBuffer.MatricesWeightsExtraKind
  91195. * @param data defines the data source
  91196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91197. * @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)
  91198. * @returns the current mesh
  91199. */
  91200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91201. /**
  91202. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91203. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91204. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91205. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91206. * @returns the current mesh
  91207. */
  91208. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91209. /**
  91210. * Creates a un-shared specific occurence of the geometry for the mesh.
  91211. * @returns the current mesh
  91212. */
  91213. makeGeometryUnique(): Mesh;
  91214. /**
  91215. * Set the index buffer of this mesh
  91216. * @param indices defines the source data
  91217. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91218. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91219. * @returns the current mesh
  91220. */
  91221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91222. /**
  91223. * Update the current index buffer
  91224. * @param indices defines the source data
  91225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91226. * @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)
  91227. * @returns the current mesh
  91228. */
  91229. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91230. /**
  91231. * Invert the geometry to move from a right handed system to a left handed one.
  91232. * @returns the current mesh
  91233. */
  91234. toLeftHanded(): Mesh;
  91235. /** @hidden */
  91236. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91237. /** @hidden */
  91238. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91239. /**
  91240. * Registers for this mesh a javascript function called just before the rendering process
  91241. * @param func defines the function to call before rendering this mesh
  91242. * @returns the current mesh
  91243. */
  91244. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91245. /**
  91246. * Disposes a previously registered javascript function called before the rendering
  91247. * @param func defines the function to remove
  91248. * @returns the current mesh
  91249. */
  91250. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91251. /**
  91252. * Registers for this mesh a javascript function called just after the rendering is complete
  91253. * @param func defines the function to call after rendering this mesh
  91254. * @returns the current mesh
  91255. */
  91256. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91257. /**
  91258. * Disposes a previously registered javascript function called after the rendering.
  91259. * @param func defines the function to remove
  91260. * @returns the current mesh
  91261. */
  91262. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91263. /** @hidden */
  91264. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91265. /** @hidden */
  91266. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91267. /** @hidden */
  91268. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91269. /** @hidden */
  91270. _rebuild(): void;
  91271. /** @hidden */
  91272. _freeze(): void;
  91273. /** @hidden */
  91274. _unFreeze(): void;
  91275. /**
  91276. * 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
  91277. * @param subMesh defines the subMesh to render
  91278. * @param enableAlphaMode defines if alpha mode can be changed
  91279. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91280. * @returns the current mesh
  91281. */
  91282. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91283. private _onBeforeDraw;
  91284. /**
  91285. * Renormalize the mesh and patch it up if there are no weights
  91286. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91287. * However in the case of zero weights then we set just a single influence to 1.
  91288. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91289. */
  91290. cleanMatrixWeights(): void;
  91291. private normalizeSkinFourWeights;
  91292. private normalizeSkinWeightsAndExtra;
  91293. /**
  91294. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91295. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91296. * the user know there was an issue with importing the mesh
  91297. * @returns a validation object with skinned, valid and report string
  91298. */
  91299. validateSkinning(): {
  91300. skinned: boolean;
  91301. valid: boolean;
  91302. report: string;
  91303. };
  91304. /** @hidden */
  91305. _checkDelayState(): Mesh;
  91306. private _queueLoad;
  91307. /**
  91308. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91309. * A mesh is in the frustum if its bounding box intersects the frustum
  91310. * @param frustumPlanes defines the frustum to test
  91311. * @returns true if the mesh is in the frustum planes
  91312. */
  91313. isInFrustum(frustumPlanes: Plane[]): boolean;
  91314. /**
  91315. * Sets the mesh material by the material or multiMaterial `id` property
  91316. * @param id is a string identifying the material or the multiMaterial
  91317. * @returns the current mesh
  91318. */
  91319. setMaterialByID(id: string): Mesh;
  91320. /**
  91321. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91322. * @returns an array of IAnimatable
  91323. */
  91324. getAnimatables(): IAnimatable[];
  91325. /**
  91326. * Modifies the mesh geometry according to the passed transformation matrix.
  91327. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91328. * The mesh normals are modified using the same transformation.
  91329. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91330. * @param transform defines the transform matrix to use
  91331. * @see http://doc.babylonjs.com/resources/baking_transformations
  91332. * @returns the current mesh
  91333. */
  91334. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91335. /**
  91336. * Modifies the mesh geometry according to its own current World Matrix.
  91337. * The mesh World Matrix is then reset.
  91338. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91339. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91340. * @see http://doc.babylonjs.com/resources/baking_transformations
  91341. * @returns the current mesh
  91342. */
  91343. bakeCurrentTransformIntoVertices(): Mesh;
  91344. /** @hidden */
  91345. readonly _positions: Nullable<Vector3[]>;
  91346. /** @hidden */
  91347. _resetPointsArrayCache(): Mesh;
  91348. /** @hidden */
  91349. _generatePointsArray(): boolean;
  91350. /**
  91351. * Returns a new Mesh object generated from the current mesh properties.
  91352. * This method must not get confused with createInstance()
  91353. * @param name is a string, the name given to the new mesh
  91354. * @param newParent can be any Node object (default `null`)
  91355. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91356. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91357. * @returns a new mesh
  91358. */
  91359. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91360. /**
  91361. * Releases resources associated with this mesh.
  91362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91364. */
  91365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91366. /**
  91367. * Modifies the mesh geometry according to a displacement map.
  91368. * 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.
  91369. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91370. * @param url is a string, the URL from the image file is to be downloaded.
  91371. * @param minHeight is the lower limit of the displacement.
  91372. * @param maxHeight is the upper limit of the displacement.
  91373. * @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.
  91374. * @param uvOffset is an optional vector2 used to offset UV.
  91375. * @param uvScale is an optional vector2 used to scale UV.
  91376. * @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.
  91377. * @returns the Mesh.
  91378. */
  91379. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91380. /**
  91381. * Modifies the mesh geometry according to a displacementMap buffer.
  91382. * 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.
  91383. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91384. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91385. * @param heightMapWidth is the width of the buffer image.
  91386. * @param heightMapHeight is the height of the buffer image.
  91387. * @param minHeight is the lower limit of the displacement.
  91388. * @param maxHeight is the upper limit of the displacement.
  91389. * @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.
  91390. * @param uvOffset is an optional vector2 used to offset UV.
  91391. * @param uvScale is an optional vector2 used to scale UV.
  91392. * @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.
  91393. * @returns the Mesh.
  91394. */
  91395. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91396. /**
  91397. * Modify the mesh to get a flat shading rendering.
  91398. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91399. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91400. * @returns current mesh
  91401. */
  91402. convertToFlatShadedMesh(): Mesh;
  91403. /**
  91404. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91405. * In other words, more vertices, no more indices and a single bigger VBO.
  91406. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91407. * @returns current mesh
  91408. */
  91409. convertToUnIndexedMesh(): Mesh;
  91410. /**
  91411. * Inverses facet orientations.
  91412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91413. * @param flipNormals will also inverts the normals
  91414. * @returns current mesh
  91415. */
  91416. flipFaces(flipNormals?: boolean): Mesh;
  91417. /**
  91418. * Increase the number of facets and hence vertices in a mesh
  91419. * Vertex normals are interpolated from existing vertex normals
  91420. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91421. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91422. */
  91423. increaseVertices(numberPerEdge: number): void;
  91424. /**
  91425. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91426. * This will undo any application of covertToFlatShadedMesh
  91427. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91428. */
  91429. forceSharedVertices(): void;
  91430. /** @hidden */
  91431. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91432. /** @hidden */
  91433. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91434. /**
  91435. * Creates a new InstancedMesh object from the mesh model.
  91436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91437. * @param name defines the name of the new instance
  91438. * @returns a new InstancedMesh
  91439. */
  91440. createInstance(name: string): InstancedMesh;
  91441. /**
  91442. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91443. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91444. * @returns the current mesh
  91445. */
  91446. synchronizeInstances(): Mesh;
  91447. /**
  91448. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91449. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91450. * This should be used together with the simplification to avoid disappearing triangles.
  91451. * @param successCallback an optional success callback to be called after the optimization finished.
  91452. * @returns the current mesh
  91453. */
  91454. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91455. /**
  91456. * Serialize current mesh
  91457. * @param serializationObject defines the object which will receive the serialization data
  91458. */
  91459. serialize(serializationObject: any): void;
  91460. /** @hidden */
  91461. _syncGeometryWithMorphTargetManager(): void;
  91462. /** @hidden */
  91463. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91464. /**
  91465. * Returns a new Mesh object parsed from the source provided.
  91466. * @param parsedMesh is the source
  91467. * @param scene defines the hosting scene
  91468. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91469. * @returns a new Mesh
  91470. */
  91471. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91472. /**
  91473. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91475. * @param name defines the name of the mesh to create
  91476. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91477. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91478. * @param closePath creates a seam between the first and the last points of each path of the path array
  91479. * @param offset is taken in account only if the `pathArray` is containing a single path
  91480. * @param scene defines the hosting scene
  91481. * @param updatable defines if the mesh must be flagged as updatable
  91482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91483. * @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)
  91484. * @returns a new Mesh
  91485. */
  91486. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91487. /**
  91488. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91489. * @param name defines the name of the mesh to create
  91490. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91491. * @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
  91492. * @param scene defines the hosting scene
  91493. * @param updatable defines if the mesh must be flagged as updatable
  91494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91495. * @returns a new Mesh
  91496. */
  91497. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91498. /**
  91499. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91500. * @param name defines the name of the mesh to create
  91501. * @param size sets the size (float) of each box side (default 1)
  91502. * @param scene defines the hosting scene
  91503. * @param updatable defines if the mesh must be flagged as updatable
  91504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91505. * @returns a new Mesh
  91506. */
  91507. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91508. /**
  91509. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91510. * @param name defines the name of the mesh to create
  91511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91513. * @param scene defines the hosting scene
  91514. * @param updatable defines if the mesh must be flagged as updatable
  91515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91516. * @returns a new Mesh
  91517. */
  91518. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91519. /**
  91520. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91521. * @param name defines the name of the mesh to create
  91522. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91523. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91524. * @param scene defines the hosting scene
  91525. * @returns a new Mesh
  91526. */
  91527. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91528. /**
  91529. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91530. * @param name defines the name of the mesh to create
  91531. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91532. * @param diameterTop set the top cap diameter (floats, default 1)
  91533. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91534. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91535. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91536. * @param scene defines the hosting scene
  91537. * @param updatable defines if the mesh must be flagged as updatable
  91538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91539. * @returns a new Mesh
  91540. */
  91541. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91542. /**
  91543. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91544. * @param name defines the name of the mesh to create
  91545. * @param diameter sets the diameter size (float) of the torus (default 1)
  91546. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91547. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91548. * @param scene defines the hosting scene
  91549. * @param updatable defines if the mesh must be flagged as updatable
  91550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91551. * @returns a new Mesh
  91552. */
  91553. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91554. /**
  91555. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91556. * @param name defines the name of the mesh to create
  91557. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91558. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91559. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91560. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91561. * @param p the number of windings on X axis (positive integers, default 2)
  91562. * @param q the number of windings on Y axis (positive integers, default 3)
  91563. * @param scene defines the hosting scene
  91564. * @param updatable defines if the mesh must be flagged as updatable
  91565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91566. * @returns a new Mesh
  91567. */
  91568. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91569. /**
  91570. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91571. * @param name defines the name of the mesh to create
  91572. * @param points is an array successive Vector3
  91573. * @param scene defines the hosting scene
  91574. * @param updatable defines if the mesh must be flagged as updatable
  91575. * @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).
  91576. * @returns a new Mesh
  91577. */
  91578. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91579. /**
  91580. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91581. * @param name defines the name of the mesh to create
  91582. * @param points is an array successive Vector3
  91583. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91584. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91585. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91586. * @param scene defines the hosting scene
  91587. * @param updatable defines if the mesh must be flagged as updatable
  91588. * @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)
  91589. * @returns a new Mesh
  91590. */
  91591. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91592. /**
  91593. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91595. * 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.
  91596. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91598. * Remember you can only change the shape positions, not their number when updating a polygon.
  91599. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91600. * @param name defines the name of the mesh to create
  91601. * @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
  91602. * @param scene defines the hosting scene
  91603. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91604. * @param updatable defines if the mesh must be flagged as updatable
  91605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91606. * @param earcutInjection can be used to inject your own earcut reference
  91607. * @returns a new Mesh
  91608. */
  91609. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91610. /**
  91611. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91612. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91613. * @param name defines the name of the mesh to create
  91614. * @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
  91615. * @param depth defines the height of extrusion
  91616. * @param scene defines the hosting scene
  91617. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91618. * @param updatable defines if the mesh must be flagged as updatable
  91619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91620. * @param earcutInjection can be used to inject your own earcut reference
  91621. * @returns a new Mesh
  91622. */
  91623. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91624. /**
  91625. * Creates an extruded shape mesh.
  91626. * 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
  91627. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91628. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91629. * @param name defines the name of the mesh to create
  91630. * @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
  91631. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91632. * @param scale is the value to scale the shape
  91633. * @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
  91634. * @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
  91635. * @param scene defines the hosting scene
  91636. * @param updatable defines if the mesh must be flagged as updatable
  91637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91638. * @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)
  91639. * @returns a new Mesh
  91640. */
  91641. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91642. /**
  91643. * Creates an custom extruded shape mesh.
  91644. * The custom extrusion is a parametric shape.
  91645. * It has no predefined shape. Its final shape will depend on the input parameters.
  91646. * Please consider using the same method from the MeshBuilder class instead
  91647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91648. * @param name defines the name of the mesh to create
  91649. * @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
  91650. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91651. * @param scaleFunction is a custom Javascript function called on each path point
  91652. * @param rotationFunction is a custom Javascript function called on each path point
  91653. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91654. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91655. * @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
  91656. * @param scene defines the hosting scene
  91657. * @param updatable defines if the mesh must be flagged as updatable
  91658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91659. * @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)
  91660. * @returns a new Mesh
  91661. */
  91662. 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;
  91663. /**
  91664. * Creates lathe mesh.
  91665. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91666. * Please consider using the same method from the MeshBuilder class instead
  91667. * @param name defines the name of the mesh to create
  91668. * @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
  91669. * @param radius is the radius value of the lathe
  91670. * @param tessellation is the side number of the lathe.
  91671. * @param scene defines the hosting scene
  91672. * @param updatable defines if the mesh must be flagged as updatable
  91673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91674. * @returns a new Mesh
  91675. */
  91676. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91677. /**
  91678. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91679. * @param name defines the name of the mesh to create
  91680. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91681. * @param scene defines the hosting scene
  91682. * @param updatable defines if the mesh must be flagged as updatable
  91683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91684. * @returns a new Mesh
  91685. */
  91686. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91687. /**
  91688. * Creates a ground mesh.
  91689. * Please consider using the same method from the MeshBuilder class instead
  91690. * @param name defines the name of the mesh to create
  91691. * @param width set the width of the ground
  91692. * @param height set the height of the ground
  91693. * @param subdivisions sets the number of subdivisions per side
  91694. * @param scene defines the hosting scene
  91695. * @param updatable defines if the mesh must be flagged as updatable
  91696. * @returns a new Mesh
  91697. */
  91698. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91699. /**
  91700. * Creates a tiled ground mesh.
  91701. * Please consider using the same method from the MeshBuilder class instead
  91702. * @param name defines the name of the mesh to create
  91703. * @param xmin set the ground minimum X coordinate
  91704. * @param zmin set the ground minimum Y coordinate
  91705. * @param xmax set the ground maximum X coordinate
  91706. * @param zmax set the ground maximum Z coordinate
  91707. * @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
  91708. * @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
  91709. * @param scene defines the hosting scene
  91710. * @param updatable defines if the mesh must be flagged as updatable
  91711. * @returns a new Mesh
  91712. */
  91713. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91714. w: number;
  91715. h: number;
  91716. }, precision: {
  91717. w: number;
  91718. h: number;
  91719. }, scene: Scene, updatable?: boolean): Mesh;
  91720. /**
  91721. * Creates a ground mesh from a height map.
  91722. * Please consider using the same method from the MeshBuilder class instead
  91723. * @see http://doc.babylonjs.com/babylon101/height_map
  91724. * @param name defines the name of the mesh to create
  91725. * @param url sets the URL of the height map image resource
  91726. * @param width set the ground width size
  91727. * @param height set the ground height size
  91728. * @param subdivisions sets the number of subdivision per side
  91729. * @param minHeight is the minimum altitude on the ground
  91730. * @param maxHeight is the maximum altitude on the ground
  91731. * @param scene defines the hosting scene
  91732. * @param updatable defines if the mesh must be flagged as updatable
  91733. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91734. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91735. * @returns a new Mesh
  91736. */
  91737. 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;
  91738. /**
  91739. * Creates a tube mesh.
  91740. * The tube is a parametric shape.
  91741. * It has no predefined shape. Its final shape will depend on the input parameters.
  91742. * Please consider using the same method from the MeshBuilder class instead
  91743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91744. * @param name defines the name of the mesh to create
  91745. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91746. * @param radius sets the tube radius size
  91747. * @param tessellation is the number of sides on the tubular surface
  91748. * @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
  91749. * @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
  91750. * @param scene defines the hosting scene
  91751. * @param updatable defines if the mesh must be flagged as updatable
  91752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91753. * @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)
  91754. * @returns a new Mesh
  91755. */
  91756. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91757. (i: number, distance: number): number;
  91758. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91759. /**
  91760. * Creates a polyhedron mesh.
  91761. * Please consider using the same method from the MeshBuilder class instead.
  91762. * * 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
  91763. * * The parameter `size` (positive float, default 1) sets the polygon size
  91764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91765. * * 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`
  91766. * * 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
  91767. * * 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)`)
  91768. * * 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
  91769. * * 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
  91770. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91771. * * If you create a double-sided mesh, you can choose what parts of 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
  91772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91773. * @param name defines the name of the mesh to create
  91774. * @param options defines the options used to create the mesh
  91775. * @param scene defines the hosting scene
  91776. * @returns a new Mesh
  91777. */
  91778. static CreatePolyhedron(name: string, options: {
  91779. type?: number;
  91780. size?: number;
  91781. sizeX?: number;
  91782. sizeY?: number;
  91783. sizeZ?: number;
  91784. custom?: any;
  91785. faceUV?: Vector4[];
  91786. faceColors?: Color4[];
  91787. updatable?: boolean;
  91788. sideOrientation?: number;
  91789. }, scene: Scene): Mesh;
  91790. /**
  91791. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91792. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91793. * * 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`)
  91794. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91795. * * 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
  91796. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91797. * * If you create a double-sided mesh, you can choose what parts of 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
  91798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91799. * @param name defines the name of the mesh
  91800. * @param options defines the options used to create the mesh
  91801. * @param scene defines the hosting scene
  91802. * @returns a new Mesh
  91803. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91804. */
  91805. static CreateIcoSphere(name: string, options: {
  91806. radius?: number;
  91807. flat?: boolean;
  91808. subdivisions?: number;
  91809. sideOrientation?: number;
  91810. updatable?: boolean;
  91811. }, scene: Scene): Mesh;
  91812. /**
  91813. * Creates a decal mesh.
  91814. * Please consider using the same method from the MeshBuilder class instead.
  91815. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91816. * @param name defines the name of the mesh
  91817. * @param sourceMesh defines the mesh receiving the decal
  91818. * @param position sets the position of the decal in world coordinates
  91819. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91820. * @param size sets the decal scaling
  91821. * @param angle sets the angle to rotate the decal
  91822. * @returns a new Mesh
  91823. */
  91824. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91825. /**
  91826. * Prepare internal position array for software CPU skinning
  91827. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91828. */
  91829. setPositionsForCPUSkinning(): Float32Array;
  91830. /**
  91831. * Prepare internal normal array for software CPU skinning
  91832. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91833. */
  91834. setNormalsForCPUSkinning(): Float32Array;
  91835. /**
  91836. * Updates the vertex buffer by applying transformation from the bones
  91837. * @param skeleton defines the skeleton to apply to current mesh
  91838. * @returns the current mesh
  91839. */
  91840. applySkeleton(skeleton: Skeleton): Mesh;
  91841. /**
  91842. * 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
  91843. * @param meshes defines the list of meshes to scan
  91844. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91845. */
  91846. static MinMax(meshes: AbstractMesh[]): {
  91847. min: Vector3;
  91848. max: Vector3;
  91849. };
  91850. /**
  91851. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91852. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91853. * @returns a vector3
  91854. */
  91855. static Center(meshesOrMinMaxVector: {
  91856. min: Vector3;
  91857. max: Vector3;
  91858. } | AbstractMesh[]): Vector3;
  91859. /**
  91860. * Merge the array of meshes into a single mesh for performance reasons.
  91861. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91862. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91863. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91864. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91865. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91866. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91867. * @returns a new mesh
  91868. */
  91869. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91870. /** @hidden */
  91871. addInstance(instance: InstancedMesh): void;
  91872. /** @hidden */
  91873. removeInstance(instance: InstancedMesh): void;
  91874. }
  91875. }
  91876. declare module BABYLON {
  91877. /**
  91878. * This is the base class of all the camera used in the application.
  91879. * @see http://doc.babylonjs.com/features/cameras
  91880. */
  91881. export class Camera extends Node {
  91882. /** @hidden */
  91883. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91884. /**
  91885. * This is the default projection mode used by the cameras.
  91886. * It helps recreating a feeling of perspective and better appreciate depth.
  91887. * This is the best way to simulate real life cameras.
  91888. */
  91889. static readonly PERSPECTIVE_CAMERA: number;
  91890. /**
  91891. * This helps creating camera with an orthographic mode.
  91892. * 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.
  91893. */
  91894. static readonly ORTHOGRAPHIC_CAMERA: number;
  91895. /**
  91896. * This is the default FOV mode for perspective cameras.
  91897. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91898. */
  91899. static readonly FOVMODE_VERTICAL_FIXED: number;
  91900. /**
  91901. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91902. */
  91903. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91904. /**
  91905. * This specifies ther is no need for a camera rig.
  91906. * Basically only one eye is rendered corresponding to the camera.
  91907. */
  91908. static readonly RIG_MODE_NONE: number;
  91909. /**
  91910. * Simulates a camera Rig with one blue eye and one red eye.
  91911. * This can be use with 3d blue and red glasses.
  91912. */
  91913. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91914. /**
  91915. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91916. */
  91917. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91918. /**
  91919. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91920. */
  91921. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91922. /**
  91923. * Defines that both eyes of the camera will be rendered over under each other.
  91924. */
  91925. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91926. /**
  91927. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91928. */
  91929. static readonly RIG_MODE_VR: number;
  91930. /**
  91931. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91932. */
  91933. static readonly RIG_MODE_WEBVR: number;
  91934. /**
  91935. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91936. */
  91937. static readonly RIG_MODE_CUSTOM: number;
  91938. /**
  91939. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91940. */
  91941. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91942. /**
  91943. * Define the input manager associated with the camera.
  91944. */
  91945. inputs: CameraInputsManager<Camera>;
  91946. /** @hidden */
  91947. _position: Vector3;
  91948. /**
  91949. * Define the current local position of the camera in the scene
  91950. */
  91951. position: Vector3;
  91952. /**
  91953. * The vector the camera should consider as up.
  91954. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91955. */
  91956. upVector: Vector3;
  91957. /**
  91958. * Define the current limit on the left side for an orthographic camera
  91959. * In scene unit
  91960. */
  91961. orthoLeft: Nullable<number>;
  91962. /**
  91963. * Define the current limit on the right side for an orthographic camera
  91964. * In scene unit
  91965. */
  91966. orthoRight: Nullable<number>;
  91967. /**
  91968. * Define the current limit on the bottom side for an orthographic camera
  91969. * In scene unit
  91970. */
  91971. orthoBottom: Nullable<number>;
  91972. /**
  91973. * Define the current limit on the top side for an orthographic camera
  91974. * In scene unit
  91975. */
  91976. orthoTop: Nullable<number>;
  91977. /**
  91978. * Field Of View is set in Radians. (default is 0.8)
  91979. */
  91980. fov: number;
  91981. /**
  91982. * Define the minimum distance the camera can see from.
  91983. * This is important to note that the depth buffer are not infinite and the closer it starts
  91984. * the more your scene might encounter depth fighting issue.
  91985. */
  91986. minZ: number;
  91987. /**
  91988. * Define the maximum distance the camera can see to.
  91989. * This is important to note that the depth buffer are not infinite and the further it end
  91990. * the more your scene might encounter depth fighting issue.
  91991. */
  91992. maxZ: number;
  91993. /**
  91994. * Define the default inertia of the camera.
  91995. * This helps giving a smooth feeling to the camera movement.
  91996. */
  91997. inertia: number;
  91998. /**
  91999. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92000. */
  92001. mode: number;
  92002. /**
  92003. * Define wether the camera is intermediate.
  92004. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92005. */
  92006. isIntermediate: boolean;
  92007. /**
  92008. * Define the viewport of the camera.
  92009. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92010. */
  92011. viewport: Viewport;
  92012. /**
  92013. * Restricts the camera to viewing objects with the same layerMask.
  92014. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92015. */
  92016. layerMask: number;
  92017. /**
  92018. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92019. */
  92020. fovMode: number;
  92021. /**
  92022. * Rig mode of the camera.
  92023. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92024. * This is normally controlled byt the camera themselves as internal use.
  92025. */
  92026. cameraRigMode: number;
  92027. /**
  92028. * Defines the distance between both "eyes" in case of a RIG
  92029. */
  92030. interaxialDistance: number;
  92031. /**
  92032. * Defines if stereoscopic rendering is done side by side or over under.
  92033. */
  92034. isStereoscopicSideBySide: boolean;
  92035. /**
  92036. * 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
  92037. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92038. * else in the scene. (Eg. security camera)
  92039. *
  92040. * 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)
  92041. */
  92042. customRenderTargets: RenderTargetTexture[];
  92043. /**
  92044. * When set, the camera will render to this render target instead of the default canvas
  92045. *
  92046. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92047. */
  92048. outputRenderTarget: Nullable<RenderTargetTexture>;
  92049. /**
  92050. * Observable triggered when the camera view matrix has changed.
  92051. */
  92052. onViewMatrixChangedObservable: Observable<Camera>;
  92053. /**
  92054. * Observable triggered when the camera Projection matrix has changed.
  92055. */
  92056. onProjectionMatrixChangedObservable: Observable<Camera>;
  92057. /**
  92058. * Observable triggered when the inputs have been processed.
  92059. */
  92060. onAfterCheckInputsObservable: Observable<Camera>;
  92061. /**
  92062. * Observable triggered when reset has been called and applied to the camera.
  92063. */
  92064. onRestoreStateObservable: Observable<Camera>;
  92065. /** @hidden */
  92066. _cameraRigParams: any;
  92067. /** @hidden */
  92068. _rigCameras: Camera[];
  92069. /** @hidden */
  92070. _rigPostProcess: Nullable<PostProcess>;
  92071. protected _webvrViewMatrix: Matrix;
  92072. /** @hidden */
  92073. _skipRendering: boolean;
  92074. /** @hidden */
  92075. _projectionMatrix: Matrix;
  92076. /** @hidden */
  92077. _postProcesses: Nullable<PostProcess>[];
  92078. /** @hidden */
  92079. _activeMeshes: SmartArray<AbstractMesh>;
  92080. protected _globalPosition: Vector3;
  92081. /** @hidden */
  92082. _computedViewMatrix: Matrix;
  92083. private _doNotComputeProjectionMatrix;
  92084. private _transformMatrix;
  92085. private _frustumPlanes;
  92086. private _refreshFrustumPlanes;
  92087. private _storedFov;
  92088. private _stateStored;
  92089. /**
  92090. * Instantiates a new camera object.
  92091. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92092. * @see http://doc.babylonjs.com/features/cameras
  92093. * @param name Defines the name of the camera in the scene
  92094. * @param position Defines the position of the camera
  92095. * @param scene Defines the scene the camera belongs too
  92096. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92097. */
  92098. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92099. /**
  92100. * Store current camera state (fov, position, etc..)
  92101. * @returns the camera
  92102. */
  92103. storeState(): Camera;
  92104. /**
  92105. * Restores the camera state values if it has been stored. You must call storeState() first
  92106. */
  92107. protected _restoreStateValues(): boolean;
  92108. /**
  92109. * Restored camera state. You must call storeState() first.
  92110. * @returns true if restored and false otherwise
  92111. */
  92112. restoreState(): boolean;
  92113. /**
  92114. * Gets the class name of the camera.
  92115. * @returns the class name
  92116. */
  92117. getClassName(): string;
  92118. /** @hidden */
  92119. readonly _isCamera: boolean;
  92120. /**
  92121. * Gets a string representation of the camera useful for debug purpose.
  92122. * @param fullDetails Defines that a more verboe level of logging is required
  92123. * @returns the string representation
  92124. */
  92125. toString(fullDetails?: boolean): string;
  92126. /**
  92127. * Gets the current world space position of the camera.
  92128. */
  92129. readonly globalPosition: Vector3;
  92130. /**
  92131. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92132. * @returns the active meshe list
  92133. */
  92134. getActiveMeshes(): SmartArray<AbstractMesh>;
  92135. /**
  92136. * Check wether a mesh is part of the current active mesh list of the camera
  92137. * @param mesh Defines the mesh to check
  92138. * @returns true if active, false otherwise
  92139. */
  92140. isActiveMesh(mesh: Mesh): boolean;
  92141. /**
  92142. * Is this camera ready to be used/rendered
  92143. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92144. * @return true if the camera is ready
  92145. */
  92146. isReady(completeCheck?: boolean): boolean;
  92147. /** @hidden */
  92148. _initCache(): void;
  92149. /** @hidden */
  92150. _updateCache(ignoreParentClass?: boolean): void;
  92151. /** @hidden */
  92152. _isSynchronized(): boolean;
  92153. /** @hidden */
  92154. _isSynchronizedViewMatrix(): boolean;
  92155. /** @hidden */
  92156. _isSynchronizedProjectionMatrix(): boolean;
  92157. /**
  92158. * Attach the input controls to a specific dom element to get the input from.
  92159. * @param element Defines the element the controls should be listened from
  92160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92161. */
  92162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92163. /**
  92164. * Detach the current controls from the specified dom element.
  92165. * @param element Defines the element to stop listening the inputs from
  92166. */
  92167. detachControl(element: HTMLElement): void;
  92168. /**
  92169. * Update the camera state according to the different inputs gathered during the frame.
  92170. */
  92171. update(): void;
  92172. /** @hidden */
  92173. _checkInputs(): void;
  92174. /** @hidden */
  92175. readonly rigCameras: Camera[];
  92176. /**
  92177. * Gets the post process used by the rig cameras
  92178. */
  92179. readonly rigPostProcess: Nullable<PostProcess>;
  92180. /**
  92181. * Internal, gets the first post proces.
  92182. * @returns the first post process to be run on this camera.
  92183. */
  92184. _getFirstPostProcess(): Nullable<PostProcess>;
  92185. private _cascadePostProcessesToRigCams;
  92186. /**
  92187. * Attach a post process to the camera.
  92188. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92189. * @param postProcess The post process to attach to the camera
  92190. * @param insertAt The position of the post process in case several of them are in use in the scene
  92191. * @returns the position the post process has been inserted at
  92192. */
  92193. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92194. /**
  92195. * Detach a post process to the camera.
  92196. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92197. * @param postProcess The post process to detach from the camera
  92198. */
  92199. detachPostProcess(postProcess: PostProcess): void;
  92200. /**
  92201. * Gets the current world matrix of the camera
  92202. */
  92203. getWorldMatrix(): Matrix;
  92204. /** @hidden */
  92205. _getViewMatrix(): Matrix;
  92206. /**
  92207. * Gets the current view matrix of the camera.
  92208. * @param force forces the camera to recompute the matrix without looking at the cached state
  92209. * @returns the view matrix
  92210. */
  92211. getViewMatrix(force?: boolean): Matrix;
  92212. /**
  92213. * Freeze the projection matrix.
  92214. * It will prevent the cache check of the camera projection compute and can speed up perf
  92215. * if no parameter of the camera are meant to change
  92216. * @param projection Defines manually a projection if necessary
  92217. */
  92218. freezeProjectionMatrix(projection?: Matrix): void;
  92219. /**
  92220. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92221. */
  92222. unfreezeProjectionMatrix(): void;
  92223. /**
  92224. * Gets the current projection matrix of the camera.
  92225. * @param force forces the camera to recompute the matrix without looking at the cached state
  92226. * @returns the projection matrix
  92227. */
  92228. getProjectionMatrix(force?: boolean): Matrix;
  92229. /**
  92230. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92231. * @returns a Matrix
  92232. */
  92233. getTransformationMatrix(): Matrix;
  92234. private _updateFrustumPlanes;
  92235. /**
  92236. * Checks if a cullable object (mesh...) is in the camera frustum
  92237. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92238. * @param target The object to check
  92239. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92240. * @returns true if the object is in frustum otherwise false
  92241. */
  92242. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92243. /**
  92244. * Checks if a cullable object (mesh...) is in the camera frustum
  92245. * Unlike isInFrustum this cheks the full bounding box
  92246. * @param target The object to check
  92247. * @returns true if the object is in frustum otherwise false
  92248. */
  92249. isCompletelyInFrustum(target: ICullable): boolean;
  92250. /**
  92251. * Gets a ray in the forward direction from the camera.
  92252. * @param length Defines the length of the ray to create
  92253. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92254. * @param origin Defines the start point of the ray which defaults to the camera position
  92255. * @returns the forward ray
  92256. */
  92257. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92258. /**
  92259. * Releases resources associated with this node.
  92260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92262. */
  92263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92264. /** @hidden */
  92265. _isLeftCamera: boolean;
  92266. /**
  92267. * Gets the left camera of a rig setup in case of Rigged Camera
  92268. */
  92269. readonly isLeftCamera: boolean;
  92270. /** @hidden */
  92271. _isRightCamera: boolean;
  92272. /**
  92273. * Gets the right camera of a rig setup in case of Rigged Camera
  92274. */
  92275. readonly isRightCamera: boolean;
  92276. /**
  92277. * Gets the left camera of a rig setup in case of Rigged Camera
  92278. */
  92279. readonly leftCamera: Nullable<FreeCamera>;
  92280. /**
  92281. * Gets the right camera of a rig setup in case of Rigged Camera
  92282. */
  92283. readonly rightCamera: Nullable<FreeCamera>;
  92284. /**
  92285. * Gets the left camera target of a rig setup in case of Rigged Camera
  92286. * @returns the target position
  92287. */
  92288. getLeftTarget(): Nullable<Vector3>;
  92289. /**
  92290. * Gets the right camera target of a rig setup in case of Rigged Camera
  92291. * @returns the target position
  92292. */
  92293. getRightTarget(): Nullable<Vector3>;
  92294. /**
  92295. * @hidden
  92296. */
  92297. setCameraRigMode(mode: number, rigParams: any): void;
  92298. /** @hidden */
  92299. static _setStereoscopicRigMode(camera: Camera): void;
  92300. /** @hidden */
  92301. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92302. /** @hidden */
  92303. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92304. /** @hidden */
  92305. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92306. /** @hidden */
  92307. _getVRProjectionMatrix(): Matrix;
  92308. protected _updateCameraRotationMatrix(): void;
  92309. protected _updateWebVRCameraRotationMatrix(): void;
  92310. /**
  92311. * This function MUST be overwritten by the different WebVR cameras available.
  92312. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92313. * @hidden
  92314. */
  92315. _getWebVRProjectionMatrix(): Matrix;
  92316. /**
  92317. * This function MUST be overwritten by the different WebVR cameras available.
  92318. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92319. * @hidden
  92320. */
  92321. _getWebVRViewMatrix(): Matrix;
  92322. /** @hidden */
  92323. setCameraRigParameter(name: string, value: any): void;
  92324. /**
  92325. * needs to be overridden by children so sub has required properties to be copied
  92326. * @hidden
  92327. */
  92328. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92329. /**
  92330. * May need to be overridden by children
  92331. * @hidden
  92332. */
  92333. _updateRigCameras(): void;
  92334. /** @hidden */
  92335. _setupInputs(): void;
  92336. /**
  92337. * Serialiaze the camera setup to a json represention
  92338. * @returns the JSON representation
  92339. */
  92340. serialize(): any;
  92341. /**
  92342. * Clones the current camera.
  92343. * @param name The cloned camera name
  92344. * @returns the cloned camera
  92345. */
  92346. clone(name: string): Camera;
  92347. /**
  92348. * Gets the direction of the camera relative to a given local axis.
  92349. * @param localAxis Defines the reference axis to provide a relative direction.
  92350. * @return the direction
  92351. */
  92352. getDirection(localAxis: Vector3): Vector3;
  92353. /**
  92354. * Returns the current camera absolute rotation
  92355. */
  92356. readonly absoluteRotation: Quaternion;
  92357. /**
  92358. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92359. * @param localAxis Defines the reference axis to provide a relative direction.
  92360. * @param result Defines the vector to store the result in
  92361. */
  92362. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92363. /**
  92364. * Gets a camera constructor for a given camera type
  92365. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92366. * @param name The name of the camera the result will be able to instantiate
  92367. * @param scene The scene the result will construct the camera in
  92368. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92369. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92370. * @returns a factory method to construc the camera
  92371. */
  92372. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92373. /**
  92374. * Compute the world matrix of the camera.
  92375. * @returns the camera workd matrix
  92376. */
  92377. computeWorldMatrix(): Matrix;
  92378. /**
  92379. * Parse a JSON and creates the camera from the parsed information
  92380. * @param parsedCamera The JSON to parse
  92381. * @param scene The scene to instantiate the camera in
  92382. * @returns the newly constructed camera
  92383. */
  92384. static Parse(parsedCamera: any, scene: Scene): Camera;
  92385. }
  92386. }
  92387. declare module BABYLON {
  92388. /**
  92389. * Class containing static functions to help procedurally build meshes
  92390. */
  92391. export class DiscBuilder {
  92392. /**
  92393. * Creates a plane polygonal mesh. By default, this is a disc
  92394. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92395. * * 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
  92396. * * 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
  92397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92400. * @param name defines the name of the mesh
  92401. * @param options defines the options used to create the mesh
  92402. * @param scene defines the hosting scene
  92403. * @returns the plane polygonal mesh
  92404. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92405. */
  92406. static CreateDisc(name: string, options: {
  92407. radius?: number;
  92408. tessellation?: number;
  92409. arc?: number;
  92410. updatable?: boolean;
  92411. sideOrientation?: number;
  92412. frontUVs?: Vector4;
  92413. backUVs?: Vector4;
  92414. }, scene?: Nullable<Scene>): Mesh;
  92415. }
  92416. }
  92417. declare module BABYLON {
  92418. /**
  92419. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92420. *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.
  92421. * The SPS is also a particle system. It provides some methods to manage the particles.
  92422. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92423. *
  92424. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92425. */
  92426. export class SolidParticleSystem implements IDisposable {
  92427. /**
  92428. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92429. * Example : var p = SPS.particles[i];
  92430. */
  92431. particles: SolidParticle[];
  92432. /**
  92433. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92434. */
  92435. nbParticles: number;
  92436. /**
  92437. * If the particles must ever face the camera (default false). Useful for planar particles.
  92438. */
  92439. billboard: boolean;
  92440. /**
  92441. * Recompute normals when adding a shape
  92442. */
  92443. recomputeNormals: boolean;
  92444. /**
  92445. * This a counter ofr your own usage. It's not set by any SPS functions.
  92446. */
  92447. counter: number;
  92448. /**
  92449. * The SPS name. This name is also given to the underlying mesh.
  92450. */
  92451. name: string;
  92452. /**
  92453. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92454. */
  92455. mesh: Mesh;
  92456. /**
  92457. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92458. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92459. */
  92460. vars: any;
  92461. /**
  92462. * This array is populated when the SPS is set as 'pickable'.
  92463. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92464. * Each element of this array is an object `{idx: int, faceId: int}`.
  92465. * `idx` is the picked particle index in the `SPS.particles` array
  92466. * `faceId` is the picked face index counted within this particle.
  92467. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92468. */
  92469. pickedParticles: {
  92470. idx: number;
  92471. faceId: number;
  92472. }[];
  92473. /**
  92474. * This array is populated when `enableDepthSort` is set to true.
  92475. * Each element of this array is an instance of the class DepthSortedParticle.
  92476. */
  92477. depthSortedParticles: DepthSortedParticle[];
  92478. /**
  92479. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92480. * @hidden
  92481. */
  92482. _bSphereOnly: boolean;
  92483. /**
  92484. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92485. * @hidden
  92486. */
  92487. _bSphereRadiusFactor: number;
  92488. private _scene;
  92489. private _positions;
  92490. private _indices;
  92491. private _normals;
  92492. private _colors;
  92493. private _uvs;
  92494. private _indices32;
  92495. private _positions32;
  92496. private _normals32;
  92497. private _fixedNormal32;
  92498. private _colors32;
  92499. private _uvs32;
  92500. private _index;
  92501. private _updatable;
  92502. private _pickable;
  92503. private _isVisibilityBoxLocked;
  92504. private _alwaysVisible;
  92505. private _depthSort;
  92506. private _expandable;
  92507. private _shapeCounter;
  92508. private _copy;
  92509. private _color;
  92510. private _computeParticleColor;
  92511. private _computeParticleTexture;
  92512. private _computeParticleRotation;
  92513. private _computeParticleVertex;
  92514. private _computeBoundingBox;
  92515. private _depthSortParticles;
  92516. private _camera;
  92517. private _mustUnrotateFixedNormals;
  92518. private _particlesIntersect;
  92519. private _needs32Bits;
  92520. /**
  92521. * Creates a SPS (Solid Particle System) object.
  92522. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92523. * @param scene (Scene) is the scene in which the SPS is added.
  92524. * @param options defines the options of the sps e.g.
  92525. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92526. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92527. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92528. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92529. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92530. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92531. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92532. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92533. */
  92534. constructor(name: string, scene: Scene, options?: {
  92535. updatable?: boolean;
  92536. isPickable?: boolean;
  92537. enableDepthSort?: boolean;
  92538. particleIntersection?: boolean;
  92539. boundingSphereOnly?: boolean;
  92540. bSphereRadiusFactor?: number;
  92541. expandable?: boolean;
  92542. });
  92543. /**
  92544. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92545. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92546. * @returns the created mesh
  92547. */
  92548. buildMesh(): Mesh;
  92549. /**
  92550. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92551. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92552. * Thus the particles generated from `digest()` have their property `position` set yet.
  92553. * @param mesh ( Mesh ) is the mesh to be digested
  92554. * @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
  92555. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92556. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92557. * @returns the current SPS
  92558. */
  92559. digest(mesh: Mesh, options?: {
  92560. facetNb?: number;
  92561. number?: number;
  92562. delta?: number;
  92563. }): SolidParticleSystem;
  92564. private _unrotateFixedNormals;
  92565. private _resetCopy;
  92566. private _meshBuilder;
  92567. private _posToShape;
  92568. private _uvsToShapeUV;
  92569. private _addParticle;
  92570. /**
  92571. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92572. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92573. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92574. * @param nb (positive integer) the number of particles to be created from this model
  92575. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92576. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92577. * @returns the number of shapes in the system
  92578. */
  92579. addShape(mesh: Mesh, nb: number, options?: {
  92580. positionFunction?: any;
  92581. vertexFunction?: any;
  92582. }): number;
  92583. private _rebuildParticle;
  92584. /**
  92585. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92586. * @returns the SPS.
  92587. */
  92588. rebuildMesh(): SolidParticleSystem;
  92589. /**
  92590. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92591. * This method calls `updateParticle()` for each particle of the SPS.
  92592. * For an animated SPS, it is usually called within the render loop.
  92593. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92594. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92595. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92596. * @returns the SPS.
  92597. */
  92598. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92599. /**
  92600. * Disposes the SPS.
  92601. */
  92602. dispose(): void;
  92603. /**
  92604. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92605. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92606. * @returns the SPS.
  92607. */
  92608. refreshVisibleSize(): SolidParticleSystem;
  92609. /**
  92610. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92611. * @param size the size (float) of the visibility box
  92612. * note : this doesn't lock the SPS mesh bounding box.
  92613. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92614. */
  92615. setVisibilityBox(size: number): void;
  92616. /**
  92617. * Gets whether the SPS as always visible or not
  92618. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92619. */
  92620. /**
  92621. * Sets the SPS as always visible or not
  92622. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92623. */
  92624. isAlwaysVisible: boolean;
  92625. /**
  92626. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92628. */
  92629. /**
  92630. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92631. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92632. */
  92633. isVisibilityBoxLocked: boolean;
  92634. /**
  92635. * Tells to `setParticles()` to compute the particle rotations or not.
  92636. * Default value : true. The SPS is faster when it's set to false.
  92637. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92638. */
  92639. /**
  92640. * Gets if `setParticles()` computes the particle rotations or not.
  92641. * Default value : true. The SPS is faster when it's set to false.
  92642. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92643. */
  92644. computeParticleRotation: boolean;
  92645. /**
  92646. * Tells to `setParticles()` to compute the particle colors or not.
  92647. * Default value : true. The SPS is faster when it's set to false.
  92648. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92649. */
  92650. /**
  92651. * Gets if `setParticles()` computes the particle colors or not.
  92652. * Default value : true. The SPS is faster when it's set to false.
  92653. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92654. */
  92655. computeParticleColor: boolean;
  92656. /**
  92657. * Gets if `setParticles()` computes the particle textures or not.
  92658. * Default value : true. The SPS is faster when it's set to false.
  92659. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92660. */
  92661. computeParticleTexture: boolean;
  92662. /**
  92663. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92664. * Default value : false. The SPS is faster when it's set to false.
  92665. * Note : the particle custom vertex positions aren't stored values.
  92666. */
  92667. /**
  92668. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92669. * Default value : false. The SPS is faster when it's set to false.
  92670. * Note : the particle custom vertex positions aren't stored values.
  92671. */
  92672. computeParticleVertex: boolean;
  92673. /**
  92674. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92675. */
  92676. /**
  92677. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92678. */
  92679. computeBoundingBox: boolean;
  92680. /**
  92681. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92682. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92683. * Default : `true`
  92684. */
  92685. /**
  92686. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92687. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92688. * Default : `true`
  92689. */
  92690. depthSortParticles: boolean;
  92691. /**
  92692. * Gets if the SPS is created as expandable at construction time.
  92693. * Default : `false`
  92694. */
  92695. readonly expandable: boolean;
  92696. /**
  92697. * This function does nothing. It may be overwritten to set all the particle first values.
  92698. * The SPS doesn't call this function, you may have to call it by your own.
  92699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92700. */
  92701. initParticles(): void;
  92702. /**
  92703. * This function does nothing. It may be overwritten to recycle a particle.
  92704. * The SPS doesn't call this function, you may have to call it by your own.
  92705. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92706. * @param particle The particle to recycle
  92707. * @returns the recycled particle
  92708. */
  92709. recycleParticle(particle: SolidParticle): SolidParticle;
  92710. /**
  92711. * Updates a particle : this function should be overwritten by the user.
  92712. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92713. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92714. * @example : just set a particle position or velocity and recycle conditions
  92715. * @param particle The particle to update
  92716. * @returns the updated particle
  92717. */
  92718. updateParticle(particle: SolidParticle): SolidParticle;
  92719. /**
  92720. * Updates a vertex of a particle : it can be overwritten by the user.
  92721. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92722. * @param particle the current particle
  92723. * @param vertex the current index of the current particle
  92724. * @param pt the index of the current vertex in the particle shape
  92725. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92726. * @example : just set a vertex particle position
  92727. * @returns the updated vertex
  92728. */
  92729. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92730. /**
  92731. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92732. * This does nothing and may be overwritten by the user.
  92733. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92734. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92735. * @param update the boolean update value actually passed to setParticles()
  92736. */
  92737. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92738. /**
  92739. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92740. * This will be passed three parameters.
  92741. * This does nothing and may be overwritten by the user.
  92742. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92743. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92744. * @param update the boolean update value actually passed to setParticles()
  92745. */
  92746. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92747. }
  92748. }
  92749. declare module BABYLON {
  92750. /**
  92751. * Represents one particle of a solid particle system.
  92752. */
  92753. export class SolidParticle {
  92754. /**
  92755. * particle global index
  92756. */
  92757. idx: number;
  92758. /**
  92759. * The color of the particle
  92760. */
  92761. color: Nullable<Color4>;
  92762. /**
  92763. * The world space position of the particle.
  92764. */
  92765. position: Vector3;
  92766. /**
  92767. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92768. */
  92769. rotation: Vector3;
  92770. /**
  92771. * The world space rotation quaternion of the particle.
  92772. */
  92773. rotationQuaternion: Nullable<Quaternion>;
  92774. /**
  92775. * The scaling of the particle.
  92776. */
  92777. scaling: Vector3;
  92778. /**
  92779. * The uvs of the particle.
  92780. */
  92781. uvs: Vector4;
  92782. /**
  92783. * The current speed of the particle.
  92784. */
  92785. velocity: Vector3;
  92786. /**
  92787. * The pivot point in the particle local space.
  92788. */
  92789. pivot: Vector3;
  92790. /**
  92791. * Must the particle be translated from its pivot point in its local space ?
  92792. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92793. * Default : false
  92794. */
  92795. translateFromPivot: boolean;
  92796. /**
  92797. * Is the particle active or not ?
  92798. */
  92799. alive: boolean;
  92800. /**
  92801. * Is the particle visible or not ?
  92802. */
  92803. isVisible: boolean;
  92804. /**
  92805. * Index of this particle in the global "positions" array (Internal use)
  92806. * @hidden
  92807. */
  92808. _pos: number;
  92809. /**
  92810. * @hidden Index of this particle in the global "indices" array (Internal use)
  92811. */
  92812. _ind: number;
  92813. /**
  92814. * @hidden ModelShape of this particle (Internal use)
  92815. */
  92816. _model: ModelShape;
  92817. /**
  92818. * ModelShape id of this particle
  92819. */
  92820. shapeId: number;
  92821. /**
  92822. * Index of the particle in its shape id
  92823. */
  92824. idxInShape: number;
  92825. /**
  92826. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92827. */
  92828. _modelBoundingInfo: BoundingInfo;
  92829. /**
  92830. * @hidden Particle BoundingInfo object (Internal use)
  92831. */
  92832. _boundingInfo: BoundingInfo;
  92833. /**
  92834. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92835. */
  92836. _sps: SolidParticleSystem;
  92837. /**
  92838. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92839. */
  92840. _stillInvisible: boolean;
  92841. /**
  92842. * @hidden Last computed particle rotation matrix
  92843. */
  92844. _rotationMatrix: number[];
  92845. /**
  92846. * Parent particle Id, if any.
  92847. * Default null.
  92848. */
  92849. parentId: Nullable<number>;
  92850. /**
  92851. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92852. * The possible values are :
  92853. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92854. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92855. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92856. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92857. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92858. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92859. * */
  92860. cullingStrategy: number;
  92861. /**
  92862. * @hidden Internal global position in the SPS.
  92863. */
  92864. _globalPosition: Vector3;
  92865. /**
  92866. * Creates a Solid Particle object.
  92867. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92868. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92869. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92870. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92871. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92872. * @param shapeId (integer) is the model shape identifier in the SPS.
  92873. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92874. * @param sps defines the sps it is associated to
  92875. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92876. */
  92877. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92878. /**
  92879. * Legacy support, changed scale to scaling
  92880. */
  92881. /**
  92882. * Legacy support, changed scale to scaling
  92883. */
  92884. scale: Vector3;
  92885. /**
  92886. * Legacy support, changed quaternion to rotationQuaternion
  92887. */
  92888. /**
  92889. * Legacy support, changed quaternion to rotationQuaternion
  92890. */
  92891. quaternion: Nullable<Quaternion>;
  92892. /**
  92893. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92894. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92895. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92896. * @returns true if it intersects
  92897. */
  92898. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92899. /**
  92900. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92901. * A particle is in the frustum if its bounding box intersects the frustum
  92902. * @param frustumPlanes defines the frustum to test
  92903. * @returns true if the particle is in the frustum planes
  92904. */
  92905. isInFrustum(frustumPlanes: Plane[]): boolean;
  92906. /**
  92907. * get the rotation matrix of the particle
  92908. * @hidden
  92909. */
  92910. getRotationMatrix(m: Matrix): void;
  92911. }
  92912. /**
  92913. * Represents the shape of the model used by one particle of a solid particle system.
  92914. * SPS internal tool, don't use it manually.
  92915. */
  92916. export class ModelShape {
  92917. /**
  92918. * The shape id
  92919. * @hidden
  92920. */
  92921. shapeID: number;
  92922. /**
  92923. * flat array of model positions (internal use)
  92924. * @hidden
  92925. */
  92926. _shape: Vector3[];
  92927. /**
  92928. * flat array of model UVs (internal use)
  92929. * @hidden
  92930. */
  92931. _shapeUV: number[];
  92932. /**
  92933. * length of the shape in the model indices array (internal use)
  92934. * @hidden
  92935. */
  92936. _indicesLength: number;
  92937. /**
  92938. * Custom position function (internal use)
  92939. * @hidden
  92940. */
  92941. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92942. /**
  92943. * Custom vertex function (internal use)
  92944. * @hidden
  92945. */
  92946. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92947. /**
  92948. * 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.
  92949. * SPS internal tool, don't use it manually.
  92950. * @hidden
  92951. */
  92952. 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>);
  92953. }
  92954. /**
  92955. * Represents a Depth Sorted Particle in the solid particle system.
  92956. */
  92957. export class DepthSortedParticle {
  92958. /**
  92959. * Index of the particle in the "indices" array
  92960. */
  92961. ind: number;
  92962. /**
  92963. * Length of the particle shape in the "indices" array
  92964. */
  92965. indicesLength: number;
  92966. /**
  92967. * Squared distance from the particle to the camera
  92968. */
  92969. sqDistance: number;
  92970. }
  92971. }
  92972. declare module BABYLON {
  92973. /**
  92974. * @hidden
  92975. */
  92976. export class _MeshCollisionData {
  92977. _checkCollisions: boolean;
  92978. _collisionMask: number;
  92979. _collisionGroup: number;
  92980. _collider: Nullable<Collider>;
  92981. _oldPositionForCollisions: Vector3;
  92982. _diffPositionForCollisions: Vector3;
  92983. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92984. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92985. }
  92986. }
  92987. declare module BABYLON {
  92988. /** @hidden */
  92989. class _FacetDataStorage {
  92990. facetPositions: Vector3[];
  92991. facetNormals: Vector3[];
  92992. facetPartitioning: number[][];
  92993. facetNb: number;
  92994. partitioningSubdivisions: number;
  92995. partitioningBBoxRatio: number;
  92996. facetDataEnabled: boolean;
  92997. facetParameters: any;
  92998. bbSize: Vector3;
  92999. subDiv: {
  93000. max: number;
  93001. X: number;
  93002. Y: number;
  93003. Z: number;
  93004. };
  93005. facetDepthSort: boolean;
  93006. facetDepthSortEnabled: boolean;
  93007. depthSortedIndices: IndicesArray;
  93008. depthSortedFacets: {
  93009. ind: number;
  93010. sqDistance: number;
  93011. }[];
  93012. facetDepthSortFunction: (f1: {
  93013. ind: number;
  93014. sqDistance: number;
  93015. }, f2: {
  93016. ind: number;
  93017. sqDistance: number;
  93018. }) => number;
  93019. facetDepthSortFrom: Vector3;
  93020. facetDepthSortOrigin: Vector3;
  93021. invertedMatrix: Matrix;
  93022. }
  93023. /**
  93024. * @hidden
  93025. **/
  93026. class _InternalAbstractMeshDataInfo {
  93027. _hasVertexAlpha: boolean;
  93028. _useVertexColors: boolean;
  93029. _numBoneInfluencers: number;
  93030. _applyFog: boolean;
  93031. _receiveShadows: boolean;
  93032. _facetData: _FacetDataStorage;
  93033. _visibility: number;
  93034. _skeleton: Nullable<Skeleton>;
  93035. _layerMask: number;
  93036. _computeBonesUsingShaders: boolean;
  93037. _isActive: boolean;
  93038. _onlyForInstances: boolean;
  93039. _isActiveIntermediate: boolean;
  93040. _onlyForInstancesIntermediate: boolean;
  93041. _actAsRegularMesh: boolean;
  93042. }
  93043. /**
  93044. * Class used to store all common mesh properties
  93045. */
  93046. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93047. /** No occlusion */
  93048. static OCCLUSION_TYPE_NONE: number;
  93049. /** Occlusion set to optimisitic */
  93050. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93051. /** Occlusion set to strict */
  93052. static OCCLUSION_TYPE_STRICT: number;
  93053. /** Use an accurante occlusion algorithm */
  93054. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93055. /** Use a conservative occlusion algorithm */
  93056. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93057. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93058. * Test order :
  93059. * Is the bounding sphere outside the frustum ?
  93060. * If not, are the bounding box vertices outside the frustum ?
  93061. * It not, then the cullable object is in the frustum.
  93062. */
  93063. static readonly CULLINGSTRATEGY_STANDARD: number;
  93064. /** Culling strategy : Bounding Sphere Only.
  93065. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93066. * It's also less accurate than the standard because some not visible objects can still be selected.
  93067. * Test : is the bounding sphere outside the frustum ?
  93068. * If not, then the cullable object is in the frustum.
  93069. */
  93070. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93071. /** Culling strategy : Optimistic Inclusion.
  93072. * This in an inclusion test first, then the standard exclusion test.
  93073. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93074. * 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.
  93075. * Anyway, it's as accurate as the standard strategy.
  93076. * Test :
  93077. * Is the cullable object bounding sphere center in the frustum ?
  93078. * If not, apply the default culling strategy.
  93079. */
  93080. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93081. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93082. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93083. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93084. * 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.
  93085. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93086. * Test :
  93087. * Is the cullable object bounding sphere center in the frustum ?
  93088. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93089. */
  93090. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93091. /**
  93092. * No billboard
  93093. */
  93094. static readonly BILLBOARDMODE_NONE: number;
  93095. /** Billboard on X axis */
  93096. static readonly BILLBOARDMODE_X: number;
  93097. /** Billboard on Y axis */
  93098. static readonly BILLBOARDMODE_Y: number;
  93099. /** Billboard on Z axis */
  93100. static readonly BILLBOARDMODE_Z: number;
  93101. /** Billboard on all axes */
  93102. static readonly BILLBOARDMODE_ALL: number;
  93103. /** Billboard on using position instead of orientation */
  93104. static readonly BILLBOARDMODE_USE_POSITION: number;
  93105. /** @hidden */
  93106. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93107. /**
  93108. * The culling strategy to use to check whether the mesh must be rendered or not.
  93109. * This value can be changed at any time and will be used on the next render mesh selection.
  93110. * The possible values are :
  93111. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93112. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93114. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93115. * Please read each static variable documentation to get details about the culling process.
  93116. * */
  93117. cullingStrategy: number;
  93118. /**
  93119. * Gets the number of facets in the mesh
  93120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93121. */
  93122. readonly facetNb: number;
  93123. /**
  93124. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93126. */
  93127. partitioningSubdivisions: number;
  93128. /**
  93129. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93130. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93132. */
  93133. partitioningBBoxRatio: number;
  93134. /**
  93135. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93136. * Works only for updatable meshes.
  93137. * Doesn't work with multi-materials
  93138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93139. */
  93140. mustDepthSortFacets: boolean;
  93141. /**
  93142. * The location (Vector3) where the facet depth sort must be computed from.
  93143. * By default, the active camera position.
  93144. * Used only when facet depth sort is enabled
  93145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93146. */
  93147. facetDepthSortFrom: Vector3;
  93148. /**
  93149. * gets a boolean indicating if facetData is enabled
  93150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93151. */
  93152. readonly isFacetDataEnabled: boolean;
  93153. /** @hidden */
  93154. _updateNonUniformScalingState(value: boolean): boolean;
  93155. /**
  93156. * An event triggered when this mesh collides with another one
  93157. */
  93158. onCollideObservable: Observable<AbstractMesh>;
  93159. /** Set a function to call when this mesh collides with another one */
  93160. onCollide: () => void;
  93161. /**
  93162. * An event triggered when the collision's position changes
  93163. */
  93164. onCollisionPositionChangeObservable: Observable<Vector3>;
  93165. /** Set a function to call when the collision's position changes */
  93166. onCollisionPositionChange: () => void;
  93167. /**
  93168. * An event triggered when material is changed
  93169. */
  93170. onMaterialChangedObservable: Observable<AbstractMesh>;
  93171. /**
  93172. * Gets or sets the orientation for POV movement & rotation
  93173. */
  93174. definedFacingForward: boolean;
  93175. /** @hidden */
  93176. _occlusionQuery: Nullable<WebGLQuery>;
  93177. /** @hidden */
  93178. _renderingGroup: Nullable<RenderingGroup>;
  93179. /**
  93180. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93181. */
  93182. /**
  93183. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93184. */
  93185. visibility: number;
  93186. /** Gets or sets the alpha index used to sort transparent meshes
  93187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93188. */
  93189. alphaIndex: number;
  93190. /**
  93191. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93192. */
  93193. isVisible: boolean;
  93194. /**
  93195. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93196. */
  93197. isPickable: boolean;
  93198. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93199. showSubMeshesBoundingBox: boolean;
  93200. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93201. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93202. */
  93203. isBlocker: boolean;
  93204. /**
  93205. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93206. */
  93207. enablePointerMoveEvents: boolean;
  93208. /**
  93209. * Specifies the rendering group id for this mesh (0 by default)
  93210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93211. */
  93212. renderingGroupId: number;
  93213. private _material;
  93214. /** Gets or sets current material */
  93215. material: Nullable<Material>;
  93216. /**
  93217. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93218. * @see http://doc.babylonjs.com/babylon101/shadows
  93219. */
  93220. receiveShadows: boolean;
  93221. /** Defines color to use when rendering outline */
  93222. outlineColor: Color3;
  93223. /** Define width to use when rendering outline */
  93224. outlineWidth: number;
  93225. /** Defines color to use when rendering overlay */
  93226. overlayColor: Color3;
  93227. /** Defines alpha to use when rendering overlay */
  93228. overlayAlpha: number;
  93229. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93230. hasVertexAlpha: boolean;
  93231. /** 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) */
  93232. useVertexColors: boolean;
  93233. /**
  93234. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93235. */
  93236. computeBonesUsingShaders: boolean;
  93237. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93238. numBoneInfluencers: number;
  93239. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93240. applyFog: boolean;
  93241. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93242. useOctreeForRenderingSelection: boolean;
  93243. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93244. useOctreeForPicking: boolean;
  93245. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93246. useOctreeForCollisions: boolean;
  93247. /**
  93248. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93249. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93250. */
  93251. layerMask: number;
  93252. /**
  93253. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93254. */
  93255. alwaysSelectAsActiveMesh: boolean;
  93256. /**
  93257. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93258. */
  93259. doNotSyncBoundingInfo: boolean;
  93260. /**
  93261. * Gets or sets the current action manager
  93262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93263. */
  93264. actionManager: Nullable<AbstractActionManager>;
  93265. private _meshCollisionData;
  93266. /**
  93267. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93268. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93269. */
  93270. ellipsoid: Vector3;
  93271. /**
  93272. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93273. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93274. */
  93275. ellipsoidOffset: Vector3;
  93276. /**
  93277. * Gets or sets a collision mask used to mask collisions (default is -1).
  93278. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93279. */
  93280. collisionMask: number;
  93281. /**
  93282. * Gets or sets the current collision group mask (-1 by default).
  93283. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93284. */
  93285. collisionGroup: number;
  93286. /**
  93287. * Defines edge width used when edgesRenderer is enabled
  93288. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93289. */
  93290. edgesWidth: number;
  93291. /**
  93292. * Defines edge color used when edgesRenderer is enabled
  93293. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93294. */
  93295. edgesColor: Color4;
  93296. /** @hidden */
  93297. _edgesRenderer: Nullable<IEdgesRenderer>;
  93298. /** @hidden */
  93299. _masterMesh: Nullable<AbstractMesh>;
  93300. /** @hidden */
  93301. _boundingInfo: Nullable<BoundingInfo>;
  93302. /** @hidden */
  93303. _renderId: number;
  93304. /**
  93305. * Gets or sets the list of subMeshes
  93306. * @see http://doc.babylonjs.com/how_to/multi_materials
  93307. */
  93308. subMeshes: SubMesh[];
  93309. /** @hidden */
  93310. _intersectionsInProgress: AbstractMesh[];
  93311. /** @hidden */
  93312. _unIndexed: boolean;
  93313. /** @hidden */
  93314. _lightSources: Light[];
  93315. /** Gets the list of lights affecting that mesh */
  93316. readonly lightSources: Light[];
  93317. /** @hidden */
  93318. readonly _positions: Nullable<Vector3[]>;
  93319. /** @hidden */
  93320. _waitingData: {
  93321. lods: Nullable<any>;
  93322. actions: Nullable<any>;
  93323. freezeWorldMatrix: Nullable<boolean>;
  93324. };
  93325. /** @hidden */
  93326. _bonesTransformMatrices: Nullable<Float32Array>;
  93327. /** @hidden */
  93328. _transformMatrixTexture: Nullable<RawTexture>;
  93329. /**
  93330. * Gets or sets a skeleton to apply skining transformations
  93331. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93332. */
  93333. skeleton: Nullable<Skeleton>;
  93334. /**
  93335. * An event triggered when the mesh is rebuilt.
  93336. */
  93337. onRebuildObservable: Observable<AbstractMesh>;
  93338. /**
  93339. * Creates a new AbstractMesh
  93340. * @param name defines the name of the mesh
  93341. * @param scene defines the hosting scene
  93342. */
  93343. constructor(name: string, scene?: Nullable<Scene>);
  93344. /**
  93345. * Returns the string "AbstractMesh"
  93346. * @returns "AbstractMesh"
  93347. */
  93348. getClassName(): string;
  93349. /**
  93350. * Gets a string representation of the current mesh
  93351. * @param fullDetails defines a boolean indicating if full details must be included
  93352. * @returns a string representation of the current mesh
  93353. */
  93354. toString(fullDetails?: boolean): string;
  93355. /**
  93356. * @hidden
  93357. */
  93358. protected _getEffectiveParent(): Nullable<Node>;
  93359. /** @hidden */
  93360. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93361. /** @hidden */
  93362. _rebuild(): void;
  93363. /** @hidden */
  93364. _resyncLightSources(): void;
  93365. /** @hidden */
  93366. _resyncLighSource(light: Light): void;
  93367. /** @hidden */
  93368. _unBindEffect(): void;
  93369. /** @hidden */
  93370. _removeLightSource(light: Light, dispose: boolean): void;
  93371. private _markSubMeshesAsDirty;
  93372. /** @hidden */
  93373. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93374. /** @hidden */
  93375. _markSubMeshesAsAttributesDirty(): void;
  93376. /** @hidden */
  93377. _markSubMeshesAsMiscDirty(): void;
  93378. /**
  93379. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93380. */
  93381. scaling: Vector3;
  93382. /**
  93383. * Returns true if the mesh is blocked. Implemented by child classes
  93384. */
  93385. readonly isBlocked: boolean;
  93386. /**
  93387. * Returns the mesh itself by default. Implemented by child classes
  93388. * @param camera defines the camera to use to pick the right LOD level
  93389. * @returns the currentAbstractMesh
  93390. */
  93391. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93392. /**
  93393. * Returns 0 by default. Implemented by child classes
  93394. * @returns an integer
  93395. */
  93396. getTotalVertices(): number;
  93397. /**
  93398. * Returns a positive integer : the total number of indices in this mesh geometry.
  93399. * @returns the numner of indices or zero if the mesh has no geometry.
  93400. */
  93401. getTotalIndices(): number;
  93402. /**
  93403. * Returns null by default. Implemented by child classes
  93404. * @returns null
  93405. */
  93406. getIndices(): Nullable<IndicesArray>;
  93407. /**
  93408. * Returns the array of the requested vertex data kind. Implemented by child classes
  93409. * @param kind defines the vertex data kind to use
  93410. * @returns null
  93411. */
  93412. getVerticesData(kind: string): Nullable<FloatArray>;
  93413. /**
  93414. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93415. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93416. * Note that a new underlying VertexBuffer object is created each call.
  93417. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93418. * @param kind defines vertex data kind:
  93419. * * VertexBuffer.PositionKind
  93420. * * VertexBuffer.UVKind
  93421. * * VertexBuffer.UV2Kind
  93422. * * VertexBuffer.UV3Kind
  93423. * * VertexBuffer.UV4Kind
  93424. * * VertexBuffer.UV5Kind
  93425. * * VertexBuffer.UV6Kind
  93426. * * VertexBuffer.ColorKind
  93427. * * VertexBuffer.MatricesIndicesKind
  93428. * * VertexBuffer.MatricesIndicesExtraKind
  93429. * * VertexBuffer.MatricesWeightsKind
  93430. * * VertexBuffer.MatricesWeightsExtraKind
  93431. * @param data defines the data source
  93432. * @param updatable defines if the data must be flagged as updatable (or static)
  93433. * @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
  93434. * @returns the current mesh
  93435. */
  93436. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93437. /**
  93438. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93439. * If the mesh has no geometry, it is simply returned as it is.
  93440. * @param kind defines vertex data kind:
  93441. * * VertexBuffer.PositionKind
  93442. * * VertexBuffer.UVKind
  93443. * * VertexBuffer.UV2Kind
  93444. * * VertexBuffer.UV3Kind
  93445. * * VertexBuffer.UV4Kind
  93446. * * VertexBuffer.UV5Kind
  93447. * * VertexBuffer.UV6Kind
  93448. * * VertexBuffer.ColorKind
  93449. * * VertexBuffer.MatricesIndicesKind
  93450. * * VertexBuffer.MatricesIndicesExtraKind
  93451. * * VertexBuffer.MatricesWeightsKind
  93452. * * VertexBuffer.MatricesWeightsExtraKind
  93453. * @param data defines the data source
  93454. * @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
  93455. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93456. * @returns the current mesh
  93457. */
  93458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93459. /**
  93460. * Sets the mesh indices,
  93461. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93462. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93463. * @param totalVertices Defines the total number of vertices
  93464. * @returns the current mesh
  93465. */
  93466. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93467. /**
  93468. * Gets a boolean indicating if specific vertex data is present
  93469. * @param kind defines the vertex data kind to use
  93470. * @returns true is data kind is present
  93471. */
  93472. isVerticesDataPresent(kind: string): boolean;
  93473. /**
  93474. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93475. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93476. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93477. * @returns a BoundingInfo
  93478. */
  93479. getBoundingInfo(): BoundingInfo;
  93480. /**
  93481. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93482. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93483. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93484. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93485. * @returns the current mesh
  93486. */
  93487. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93488. /**
  93489. * Overwrite the current bounding info
  93490. * @param boundingInfo defines the new bounding info
  93491. * @returns the current mesh
  93492. */
  93493. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93494. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93495. readonly useBones: boolean;
  93496. /** @hidden */
  93497. _preActivate(): void;
  93498. /** @hidden */
  93499. _preActivateForIntermediateRendering(renderId: number): void;
  93500. /** @hidden */
  93501. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93502. /** @hidden */
  93503. _postActivate(): void;
  93504. /** @hidden */
  93505. _freeze(): void;
  93506. /** @hidden */
  93507. _unFreeze(): void;
  93508. /**
  93509. * Gets the current world matrix
  93510. * @returns a Matrix
  93511. */
  93512. getWorldMatrix(): Matrix;
  93513. /** @hidden */
  93514. _getWorldMatrixDeterminant(): number;
  93515. /**
  93516. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93517. */
  93518. readonly isAnInstance: boolean;
  93519. /**
  93520. * Gets a boolean indicating if this mesh has instances
  93521. */
  93522. readonly hasInstances: boolean;
  93523. /**
  93524. * Perform relative position change from the point of view of behind the front of the mesh.
  93525. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93526. * Supports definition of mesh facing forward or backward
  93527. * @param amountRight defines the distance on the right axis
  93528. * @param amountUp defines the distance on the up axis
  93529. * @param amountForward defines the distance on the forward axis
  93530. * @returns the current mesh
  93531. */
  93532. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93533. /**
  93534. * Calculate relative position change from the point of view of behind the front of the mesh.
  93535. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93536. * Supports definition of mesh facing forward or backward
  93537. * @param amountRight defines the distance on the right axis
  93538. * @param amountUp defines the distance on the up axis
  93539. * @param amountForward defines the distance on the forward axis
  93540. * @returns the new displacement vector
  93541. */
  93542. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93543. /**
  93544. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93545. * Supports definition of mesh facing forward or backward
  93546. * @param flipBack defines the flip
  93547. * @param twirlClockwise defines the twirl
  93548. * @param tiltRight defines the tilt
  93549. * @returns the current mesh
  93550. */
  93551. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93552. /**
  93553. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93554. * Supports definition of mesh facing forward or backward.
  93555. * @param flipBack defines the flip
  93556. * @param twirlClockwise defines the twirl
  93557. * @param tiltRight defines the tilt
  93558. * @returns the new rotation vector
  93559. */
  93560. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93561. /**
  93562. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93563. * This means the mesh underlying bounding box and sphere are recomputed.
  93564. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93565. * @returns the current mesh
  93566. */
  93567. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93568. /** @hidden */
  93569. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93570. /** @hidden */
  93571. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93572. /** @hidden */
  93573. _updateBoundingInfo(): AbstractMesh;
  93574. /** @hidden */
  93575. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93576. /** @hidden */
  93577. protected _afterComputeWorldMatrix(): void;
  93578. /** @hidden */
  93579. readonly _effectiveMesh: AbstractMesh;
  93580. /**
  93581. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93582. * A mesh is in the frustum if its bounding box intersects the frustum
  93583. * @param frustumPlanes defines the frustum to test
  93584. * @returns true if the mesh is in the frustum planes
  93585. */
  93586. isInFrustum(frustumPlanes: Plane[]): boolean;
  93587. /**
  93588. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93589. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93590. * @param frustumPlanes defines the frustum to test
  93591. * @returns true if the mesh is completely in the frustum planes
  93592. */
  93593. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93594. /**
  93595. * True if the mesh intersects another mesh or a SolidParticle object
  93596. * @param mesh defines a target mesh or SolidParticle to test
  93597. * @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)
  93598. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93599. * @returns true if there is an intersection
  93600. */
  93601. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93602. /**
  93603. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93604. * @param point defines the point to test
  93605. * @returns true if there is an intersection
  93606. */
  93607. intersectsPoint(point: Vector3): boolean;
  93608. /**
  93609. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93610. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93611. */
  93612. checkCollisions: boolean;
  93613. /**
  93614. * Gets Collider object used to compute collisions (not physics)
  93615. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93616. */
  93617. readonly collider: Nullable<Collider>;
  93618. /**
  93619. * Move the mesh using collision engine
  93620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93621. * @param displacement defines the requested displacement vector
  93622. * @returns the current mesh
  93623. */
  93624. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93625. private _onCollisionPositionChange;
  93626. /** @hidden */
  93627. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93628. /** @hidden */
  93629. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93630. /** @hidden */
  93631. _checkCollision(collider: Collider): AbstractMesh;
  93632. /** @hidden */
  93633. _generatePointsArray(): boolean;
  93634. /**
  93635. * Checks if the passed Ray intersects with the mesh
  93636. * @param ray defines the ray to use
  93637. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93639. * @returns the picking info
  93640. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93641. */
  93642. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93643. /**
  93644. * Clones the current mesh
  93645. * @param name defines the mesh name
  93646. * @param newParent defines the new mesh parent
  93647. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93648. * @returns the new mesh
  93649. */
  93650. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93651. /**
  93652. * Disposes all the submeshes of the current meshnp
  93653. * @returns the current mesh
  93654. */
  93655. releaseSubMeshes(): AbstractMesh;
  93656. /**
  93657. * Releases resources associated with this abstract mesh.
  93658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93660. */
  93661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93662. /**
  93663. * Adds the passed mesh as a child to the current mesh
  93664. * @param mesh defines the child mesh
  93665. * @returns the current mesh
  93666. */
  93667. addChild(mesh: AbstractMesh): AbstractMesh;
  93668. /**
  93669. * Removes the passed mesh from the current mesh children list
  93670. * @param mesh defines the child mesh
  93671. * @returns the current mesh
  93672. */
  93673. removeChild(mesh: AbstractMesh): AbstractMesh;
  93674. /** @hidden */
  93675. private _initFacetData;
  93676. /**
  93677. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93678. * This method can be called within the render loop.
  93679. * 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
  93680. * @returns the current mesh
  93681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93682. */
  93683. updateFacetData(): AbstractMesh;
  93684. /**
  93685. * Returns the facetLocalNormals array.
  93686. * The normals are expressed in the mesh local spac
  93687. * @returns an array of Vector3
  93688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93689. */
  93690. getFacetLocalNormals(): Vector3[];
  93691. /**
  93692. * Returns the facetLocalPositions array.
  93693. * The facet positions are expressed in the mesh local space
  93694. * @returns an array of Vector3
  93695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93696. */
  93697. getFacetLocalPositions(): Vector3[];
  93698. /**
  93699. * Returns the facetLocalPartioning array
  93700. * @returns an array of array of numbers
  93701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93702. */
  93703. getFacetLocalPartitioning(): number[][];
  93704. /**
  93705. * Returns the i-th facet position in the world system.
  93706. * This method allocates a new Vector3 per call
  93707. * @param i defines the facet index
  93708. * @returns a new Vector3
  93709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93710. */
  93711. getFacetPosition(i: number): Vector3;
  93712. /**
  93713. * Sets the reference Vector3 with the i-th facet position in the world system
  93714. * @param i defines the facet index
  93715. * @param ref defines the target vector
  93716. * @returns the current mesh
  93717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93718. */
  93719. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93720. /**
  93721. * Returns the i-th facet normal in the world system.
  93722. * This method allocates a new Vector3 per call
  93723. * @param i defines the facet index
  93724. * @returns a new Vector3
  93725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93726. */
  93727. getFacetNormal(i: number): Vector3;
  93728. /**
  93729. * Sets the reference Vector3 with the i-th facet normal in the world system
  93730. * @param i defines the facet index
  93731. * @param ref defines the target vector
  93732. * @returns the current mesh
  93733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93734. */
  93735. getFacetNormalToRef(i: number, ref: Vector3): this;
  93736. /**
  93737. * 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)
  93738. * @param x defines x coordinate
  93739. * @param y defines y coordinate
  93740. * @param z defines z coordinate
  93741. * @returns the array of facet indexes
  93742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93743. */
  93744. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93745. /**
  93746. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93747. * @param projected sets as the (x,y,z) world projection on the facet
  93748. * @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
  93749. * @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
  93750. * @param x defines x coordinate
  93751. * @param y defines y coordinate
  93752. * @param z defines z coordinate
  93753. * @returns the face index if found (or null instead)
  93754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93755. */
  93756. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93757. /**
  93758. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93759. * @param projected sets as the (x,y,z) local projection on the facet
  93760. * @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
  93761. * @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
  93762. * @param x defines x coordinate
  93763. * @param y defines y coordinate
  93764. * @param z defines z coordinate
  93765. * @returns the face index if found (or null instead)
  93766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93767. */
  93768. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93769. /**
  93770. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93771. * @returns the parameters
  93772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93773. */
  93774. getFacetDataParameters(): any;
  93775. /**
  93776. * Disables the feature FacetData and frees the related memory
  93777. * @returns the current mesh
  93778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93779. */
  93780. disableFacetData(): AbstractMesh;
  93781. /**
  93782. * Updates the AbstractMesh indices array
  93783. * @param indices defines the data source
  93784. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93785. * @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)
  93786. * @returns the current mesh
  93787. */
  93788. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93789. /**
  93790. * Creates new normals data for the mesh
  93791. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93792. * @returns the current mesh
  93793. */
  93794. createNormals(updatable: boolean): AbstractMesh;
  93795. /**
  93796. * Align the mesh with a normal
  93797. * @param normal defines the normal to use
  93798. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93799. * @returns the current mesh
  93800. */
  93801. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93802. /** @hidden */
  93803. _checkOcclusionQuery(): boolean;
  93804. /**
  93805. * Disables the mesh edge rendering mode
  93806. * @returns the currentAbstractMesh
  93807. */
  93808. disableEdgesRendering(): AbstractMesh;
  93809. /**
  93810. * Enables the edge rendering mode on the mesh.
  93811. * This mode makes the mesh edges visible
  93812. * @param epsilon defines the maximal distance between two angles to detect a face
  93813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93814. * @returns the currentAbstractMesh
  93815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93816. */
  93817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93818. }
  93819. }
  93820. declare module BABYLON {
  93821. /**
  93822. * Interface used to define ActionEvent
  93823. */
  93824. export interface IActionEvent {
  93825. /** The mesh or sprite that triggered the action */
  93826. source: any;
  93827. /** The X mouse cursor position at the time of the event */
  93828. pointerX: number;
  93829. /** The Y mouse cursor position at the time of the event */
  93830. pointerY: number;
  93831. /** The mesh that is currently pointed at (can be null) */
  93832. meshUnderPointer: Nullable<AbstractMesh>;
  93833. /** the original (browser) event that triggered the ActionEvent */
  93834. sourceEvent?: any;
  93835. /** additional data for the event */
  93836. additionalData?: any;
  93837. }
  93838. /**
  93839. * ActionEvent is the event being sent when an action is triggered.
  93840. */
  93841. export class ActionEvent implements IActionEvent {
  93842. /** The mesh or sprite that triggered the action */
  93843. source: any;
  93844. /** The X mouse cursor position at the time of the event */
  93845. pointerX: number;
  93846. /** The Y mouse cursor position at the time of the event */
  93847. pointerY: number;
  93848. /** The mesh that is currently pointed at (can be null) */
  93849. meshUnderPointer: Nullable<AbstractMesh>;
  93850. /** the original (browser) event that triggered the ActionEvent */
  93851. sourceEvent?: any;
  93852. /** additional data for the event */
  93853. additionalData?: any;
  93854. /**
  93855. * Creates a new ActionEvent
  93856. * @param source The mesh or sprite that triggered the action
  93857. * @param pointerX The X mouse cursor position at the time of the event
  93858. * @param pointerY The Y mouse cursor position at the time of the event
  93859. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93860. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93861. * @param additionalData additional data for the event
  93862. */
  93863. constructor(
  93864. /** The mesh or sprite that triggered the action */
  93865. source: any,
  93866. /** The X mouse cursor position at the time of the event */
  93867. pointerX: number,
  93868. /** The Y mouse cursor position at the time of the event */
  93869. pointerY: number,
  93870. /** The mesh that is currently pointed at (can be null) */
  93871. meshUnderPointer: Nullable<AbstractMesh>,
  93872. /** the original (browser) event that triggered the ActionEvent */
  93873. sourceEvent?: any,
  93874. /** additional data for the event */
  93875. additionalData?: any);
  93876. /**
  93877. * Helper function to auto-create an ActionEvent from a source mesh.
  93878. * @param source The source mesh that triggered the event
  93879. * @param evt The original (browser) event
  93880. * @param additionalData additional data for the event
  93881. * @returns the new ActionEvent
  93882. */
  93883. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93884. /**
  93885. * Helper function to auto-create an ActionEvent from a source sprite
  93886. * @param source The source sprite that triggered the event
  93887. * @param scene Scene associated with the sprite
  93888. * @param evt The original (browser) event
  93889. * @param additionalData additional data for the event
  93890. * @returns the new ActionEvent
  93891. */
  93892. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93893. /**
  93894. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93895. * @param scene the scene where the event occurred
  93896. * @param evt The original (browser) event
  93897. * @returns the new ActionEvent
  93898. */
  93899. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93900. /**
  93901. * Helper function to auto-create an ActionEvent from a primitive
  93902. * @param prim defines the target primitive
  93903. * @param pointerPos defines the pointer position
  93904. * @param evt The original (browser) event
  93905. * @param additionalData additional data for the event
  93906. * @returns the new ActionEvent
  93907. */
  93908. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93909. }
  93910. }
  93911. declare module BABYLON {
  93912. /**
  93913. * Abstract class used to decouple action Manager from scene and meshes.
  93914. * Do not instantiate.
  93915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93916. */
  93917. export abstract class AbstractActionManager implements IDisposable {
  93918. /** Gets the list of active triggers */
  93919. static Triggers: {
  93920. [key: string]: number;
  93921. };
  93922. /** Gets the cursor to use when hovering items */
  93923. hoverCursor: string;
  93924. /** Gets the list of actions */
  93925. actions: IAction[];
  93926. /**
  93927. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93928. */
  93929. isRecursive: boolean;
  93930. /**
  93931. * Releases all associated resources
  93932. */
  93933. abstract dispose(): void;
  93934. /**
  93935. * Does this action manager has pointer triggers
  93936. */
  93937. abstract readonly hasPointerTriggers: boolean;
  93938. /**
  93939. * Does this action manager has pick triggers
  93940. */
  93941. abstract readonly hasPickTriggers: boolean;
  93942. /**
  93943. * Process a specific trigger
  93944. * @param trigger defines the trigger to process
  93945. * @param evt defines the event details to be processed
  93946. */
  93947. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93948. /**
  93949. * Does this action manager handles actions of any of the given triggers
  93950. * @param triggers defines the triggers to be tested
  93951. * @return a boolean indicating whether one (or more) of the triggers is handled
  93952. */
  93953. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93954. /**
  93955. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93956. * speed.
  93957. * @param triggerA defines the trigger to be tested
  93958. * @param triggerB defines the trigger to be tested
  93959. * @return a boolean indicating whether one (or more) of the triggers is handled
  93960. */
  93961. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93962. /**
  93963. * Does this action manager handles actions of a given trigger
  93964. * @param trigger defines the trigger to be tested
  93965. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93966. * @return whether the trigger is handled
  93967. */
  93968. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93969. /**
  93970. * Serialize this manager to a JSON object
  93971. * @param name defines the property name to store this manager
  93972. * @returns a JSON representation of this manager
  93973. */
  93974. abstract serialize(name: string): any;
  93975. /**
  93976. * Registers an action to this action manager
  93977. * @param action defines the action to be registered
  93978. * @return the action amended (prepared) after registration
  93979. */
  93980. abstract registerAction(action: IAction): Nullable<IAction>;
  93981. /**
  93982. * Unregisters an action to this action manager
  93983. * @param action defines the action to be unregistered
  93984. * @return a boolean indicating whether the action has been unregistered
  93985. */
  93986. abstract unregisterAction(action: IAction): Boolean;
  93987. /**
  93988. * Does exist one action manager with at least one trigger
  93989. **/
  93990. static readonly HasTriggers: boolean;
  93991. /**
  93992. * Does exist one action manager with at least one pick trigger
  93993. **/
  93994. static readonly HasPickTriggers: boolean;
  93995. /**
  93996. * Does exist one action manager that handles actions of a given trigger
  93997. * @param trigger defines the trigger to be tested
  93998. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93999. **/
  94000. static HasSpecificTrigger(trigger: number): boolean;
  94001. }
  94002. }
  94003. declare module BABYLON {
  94004. /**
  94005. * Defines how a node can be built from a string name.
  94006. */
  94007. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94008. /**
  94009. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94010. */
  94011. export class Node implements IBehaviorAware<Node> {
  94012. /** @hidden */
  94013. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94014. private static _NodeConstructors;
  94015. /**
  94016. * Add a new node constructor
  94017. * @param type defines the type name of the node to construct
  94018. * @param constructorFunc defines the constructor function
  94019. */
  94020. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94021. /**
  94022. * Returns a node constructor based on type name
  94023. * @param type defines the type name
  94024. * @param name defines the new node name
  94025. * @param scene defines the hosting scene
  94026. * @param options defines optional options to transmit to constructors
  94027. * @returns the new constructor or null
  94028. */
  94029. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94030. /**
  94031. * Gets or sets the name of the node
  94032. */
  94033. name: string;
  94034. /**
  94035. * Gets or sets the id of the node
  94036. */
  94037. id: string;
  94038. /**
  94039. * Gets or sets the unique id of the node
  94040. */
  94041. uniqueId: number;
  94042. /**
  94043. * Gets or sets a string used to store user defined state for the node
  94044. */
  94045. state: string;
  94046. /**
  94047. * Gets or sets an object used to store user defined information for the node
  94048. */
  94049. metadata: any;
  94050. /**
  94051. * For internal use only. Please do not use.
  94052. */
  94053. reservedDataStore: any;
  94054. /**
  94055. * List of inspectable custom properties (used by the Inspector)
  94056. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94057. */
  94058. inspectableCustomProperties: IInspectable[];
  94059. private _doNotSerialize;
  94060. /**
  94061. * Gets or sets a boolean used to define if the node must be serialized
  94062. */
  94063. doNotSerialize: boolean;
  94064. /** @hidden */
  94065. _isDisposed: boolean;
  94066. /**
  94067. * Gets a list of Animations associated with the node
  94068. */
  94069. animations: Animation[];
  94070. protected _ranges: {
  94071. [name: string]: Nullable<AnimationRange>;
  94072. };
  94073. /**
  94074. * Callback raised when the node is ready to be used
  94075. */
  94076. onReady: Nullable<(node: Node) => void>;
  94077. private _isEnabled;
  94078. private _isParentEnabled;
  94079. private _isReady;
  94080. /** @hidden */
  94081. _currentRenderId: number;
  94082. private _parentUpdateId;
  94083. /** @hidden */
  94084. _childUpdateId: number;
  94085. /** @hidden */
  94086. _waitingParentId: Nullable<string>;
  94087. /** @hidden */
  94088. _scene: Scene;
  94089. /** @hidden */
  94090. _cache: any;
  94091. private _parentNode;
  94092. private _children;
  94093. /** @hidden */
  94094. _worldMatrix: Matrix;
  94095. /** @hidden */
  94096. _worldMatrixDeterminant: number;
  94097. /** @hidden */
  94098. _worldMatrixDeterminantIsDirty: boolean;
  94099. /** @hidden */
  94100. private _sceneRootNodesIndex;
  94101. /**
  94102. * Gets a boolean indicating if the node has been disposed
  94103. * @returns true if the node was disposed
  94104. */
  94105. isDisposed(): boolean;
  94106. /**
  94107. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94108. * @see https://doc.babylonjs.com/how_to/parenting
  94109. */
  94110. parent: Nullable<Node>;
  94111. private addToSceneRootNodes;
  94112. private removeFromSceneRootNodes;
  94113. private _animationPropertiesOverride;
  94114. /**
  94115. * Gets or sets the animation properties override
  94116. */
  94117. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94118. /**
  94119. * Gets a string idenfifying the name of the class
  94120. * @returns "Node" string
  94121. */
  94122. getClassName(): string;
  94123. /** @hidden */
  94124. readonly _isNode: boolean;
  94125. /**
  94126. * An event triggered when the mesh is disposed
  94127. */
  94128. onDisposeObservable: Observable<Node>;
  94129. private _onDisposeObserver;
  94130. /**
  94131. * Sets a callback that will be raised when the node will be disposed
  94132. */
  94133. onDispose: () => void;
  94134. /**
  94135. * Creates a new Node
  94136. * @param name the name and id to be given to this node
  94137. * @param scene the scene this node will be added to
  94138. * @param addToRootNodes the node will be added to scene.rootNodes
  94139. */
  94140. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94141. /**
  94142. * Gets the scene of the node
  94143. * @returns a scene
  94144. */
  94145. getScene(): Scene;
  94146. /**
  94147. * Gets the engine of the node
  94148. * @returns a Engine
  94149. */
  94150. getEngine(): Engine;
  94151. private _behaviors;
  94152. /**
  94153. * Attach a behavior to the node
  94154. * @see http://doc.babylonjs.com/features/behaviour
  94155. * @param behavior defines the behavior to attach
  94156. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94157. * @returns the current Node
  94158. */
  94159. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94160. /**
  94161. * Remove an attached behavior
  94162. * @see http://doc.babylonjs.com/features/behaviour
  94163. * @param behavior defines the behavior to attach
  94164. * @returns the current Node
  94165. */
  94166. removeBehavior(behavior: Behavior<Node>): Node;
  94167. /**
  94168. * Gets the list of attached behaviors
  94169. * @see http://doc.babylonjs.com/features/behaviour
  94170. */
  94171. readonly behaviors: Behavior<Node>[];
  94172. /**
  94173. * Gets an attached behavior by name
  94174. * @param name defines the name of the behavior to look for
  94175. * @see http://doc.babylonjs.com/features/behaviour
  94176. * @returns null if behavior was not found else the requested behavior
  94177. */
  94178. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94179. /**
  94180. * Returns the latest update of the World matrix
  94181. * @returns a Matrix
  94182. */
  94183. getWorldMatrix(): Matrix;
  94184. /** @hidden */
  94185. _getWorldMatrixDeterminant(): number;
  94186. /**
  94187. * Returns directly the latest state of the mesh World matrix.
  94188. * A Matrix is returned.
  94189. */
  94190. readonly worldMatrixFromCache: Matrix;
  94191. /** @hidden */
  94192. _initCache(): void;
  94193. /** @hidden */
  94194. updateCache(force?: boolean): void;
  94195. /** @hidden */
  94196. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94197. /** @hidden */
  94198. _updateCache(ignoreParentClass?: boolean): void;
  94199. /** @hidden */
  94200. _isSynchronized(): boolean;
  94201. /** @hidden */
  94202. _markSyncedWithParent(): void;
  94203. /** @hidden */
  94204. isSynchronizedWithParent(): boolean;
  94205. /** @hidden */
  94206. isSynchronized(): boolean;
  94207. /**
  94208. * Is this node ready to be used/rendered
  94209. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94210. * @return true if the node is ready
  94211. */
  94212. isReady(completeCheck?: boolean): boolean;
  94213. /**
  94214. * Is this node enabled?
  94215. * 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
  94216. * @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
  94217. * @return whether this node (and its parent) is enabled
  94218. */
  94219. isEnabled(checkAncestors?: boolean): boolean;
  94220. /** @hidden */
  94221. protected _syncParentEnabledState(): void;
  94222. /**
  94223. * Set the enabled state of this node
  94224. * @param value defines the new enabled state
  94225. */
  94226. setEnabled(value: boolean): void;
  94227. /**
  94228. * Is this node a descendant of the given node?
  94229. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94230. * @param ancestor defines the parent node to inspect
  94231. * @returns a boolean indicating if this node is a descendant of the given node
  94232. */
  94233. isDescendantOf(ancestor: Node): boolean;
  94234. /** @hidden */
  94235. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94236. /**
  94237. * Will return all nodes that have this node as ascendant
  94238. * @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
  94239. * @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
  94240. * @return all children nodes of all types
  94241. */
  94242. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94243. /**
  94244. * Get all child-meshes of this node
  94245. * @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)
  94246. * @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
  94247. * @returns an array of AbstractMesh
  94248. */
  94249. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94250. /**
  94251. * Get all direct children of this node
  94252. * @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
  94253. * @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)
  94254. * @returns an array of Node
  94255. */
  94256. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94257. /** @hidden */
  94258. _setReady(state: boolean): void;
  94259. /**
  94260. * Get an animation by name
  94261. * @param name defines the name of the animation to look for
  94262. * @returns null if not found else the requested animation
  94263. */
  94264. getAnimationByName(name: string): Nullable<Animation>;
  94265. /**
  94266. * Creates an animation range for this node
  94267. * @param name defines the name of the range
  94268. * @param from defines the starting key
  94269. * @param to defines the end key
  94270. */
  94271. createAnimationRange(name: string, from: number, to: number): void;
  94272. /**
  94273. * Delete a specific animation range
  94274. * @param name defines the name of the range to delete
  94275. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94276. */
  94277. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94278. /**
  94279. * Get an animation range by name
  94280. * @param name defines the name of the animation range to look for
  94281. * @returns null if not found else the requested animation range
  94282. */
  94283. getAnimationRange(name: string): Nullable<AnimationRange>;
  94284. /**
  94285. * Gets the list of all animation ranges defined on this node
  94286. * @returns an array
  94287. */
  94288. getAnimationRanges(): Nullable<AnimationRange>[];
  94289. /**
  94290. * Will start the animation sequence
  94291. * @param name defines the range frames for animation sequence
  94292. * @param loop defines if the animation should loop (false by default)
  94293. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94294. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94295. * @returns the object created for this animation. If range does not exist, it will return null
  94296. */
  94297. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94298. /**
  94299. * Serialize animation ranges into a JSON compatible object
  94300. * @returns serialization object
  94301. */
  94302. serializeAnimationRanges(): any;
  94303. /**
  94304. * Computes the world matrix of the node
  94305. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94306. * @returns the world matrix
  94307. */
  94308. computeWorldMatrix(force?: boolean): Matrix;
  94309. /**
  94310. * Releases resources associated with this node.
  94311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94313. */
  94314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94315. /**
  94316. * Parse animation range data from a serialization object and store them into a given node
  94317. * @param node defines where to store the animation ranges
  94318. * @param parsedNode defines the serialization object to read data from
  94319. * @param scene defines the hosting scene
  94320. */
  94321. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94322. /**
  94323. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94324. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94325. * @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
  94326. * @returns the new bounding vectors
  94327. */
  94328. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94329. min: Vector3;
  94330. max: Vector3;
  94331. };
  94332. }
  94333. }
  94334. declare module BABYLON {
  94335. /**
  94336. * @hidden
  94337. */
  94338. export class _IAnimationState {
  94339. key: number;
  94340. repeatCount: number;
  94341. workValue?: any;
  94342. loopMode?: number;
  94343. offsetValue?: any;
  94344. highLimitValue?: any;
  94345. }
  94346. /**
  94347. * Class used to store any kind of animation
  94348. */
  94349. export class Animation {
  94350. /**Name of the animation */
  94351. name: string;
  94352. /**Property to animate */
  94353. targetProperty: string;
  94354. /**The frames per second of the animation */
  94355. framePerSecond: number;
  94356. /**The data type of the animation */
  94357. dataType: number;
  94358. /**The loop mode of the animation */
  94359. loopMode?: number | undefined;
  94360. /**Specifies if blending should be enabled */
  94361. enableBlending?: boolean | undefined;
  94362. /**
  94363. * Use matrix interpolation instead of using direct key value when animating matrices
  94364. */
  94365. static AllowMatricesInterpolation: boolean;
  94366. /**
  94367. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94368. */
  94369. static AllowMatrixDecomposeForInterpolation: boolean;
  94370. /**
  94371. * Stores the key frames of the animation
  94372. */
  94373. private _keys;
  94374. /**
  94375. * Stores the easing function of the animation
  94376. */
  94377. private _easingFunction;
  94378. /**
  94379. * @hidden Internal use only
  94380. */
  94381. _runtimeAnimations: RuntimeAnimation[];
  94382. /**
  94383. * The set of event that will be linked to this animation
  94384. */
  94385. private _events;
  94386. /**
  94387. * Stores an array of target property paths
  94388. */
  94389. targetPropertyPath: string[];
  94390. /**
  94391. * Stores the blending speed of the animation
  94392. */
  94393. blendingSpeed: number;
  94394. /**
  94395. * Stores the animation ranges for the animation
  94396. */
  94397. private _ranges;
  94398. /**
  94399. * @hidden Internal use
  94400. */
  94401. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94402. /**
  94403. * Sets up an animation
  94404. * @param property The property to animate
  94405. * @param animationType The animation type to apply
  94406. * @param framePerSecond The frames per second of the animation
  94407. * @param easingFunction The easing function used in the animation
  94408. * @returns The created animation
  94409. */
  94410. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94411. /**
  94412. * Create and start an animation on a node
  94413. * @param name defines the name of the global animation that will be run on all nodes
  94414. * @param node defines the root node where the animation will take place
  94415. * @param targetProperty defines property to animate
  94416. * @param framePerSecond defines the number of frame per second yo use
  94417. * @param totalFrame defines the number of frames in total
  94418. * @param from defines the initial value
  94419. * @param to defines the final value
  94420. * @param loopMode defines which loop mode you want to use (off by default)
  94421. * @param easingFunction defines the easing function to use (linear by default)
  94422. * @param onAnimationEnd defines the callback to call when animation end
  94423. * @returns the animatable created for this animation
  94424. */
  94425. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94426. /**
  94427. * Create and start an animation on a node and its descendants
  94428. * @param name defines the name of the global animation that will be run on all nodes
  94429. * @param node defines the root node where the animation will take place
  94430. * @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
  94431. * @param targetProperty defines property to animate
  94432. * @param framePerSecond defines the number of frame per second to use
  94433. * @param totalFrame defines the number of frames in total
  94434. * @param from defines the initial value
  94435. * @param to defines the final value
  94436. * @param loopMode defines which loop mode you want to use (off by default)
  94437. * @param easingFunction defines the easing function to use (linear by default)
  94438. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94439. * @returns the list of animatables created for all nodes
  94440. * @example https://www.babylonjs-playground.com/#MH0VLI
  94441. */
  94442. 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[]>;
  94443. /**
  94444. * Creates a new animation, merges it with the existing animations and starts it
  94445. * @param name Name of the animation
  94446. * @param node Node which contains the scene that begins the animations
  94447. * @param targetProperty Specifies which property to animate
  94448. * @param framePerSecond The frames per second of the animation
  94449. * @param totalFrame The total number of frames
  94450. * @param from The frame at the beginning of the animation
  94451. * @param to The frame at the end of the animation
  94452. * @param loopMode Specifies the loop mode of the animation
  94453. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94454. * @param onAnimationEnd Callback to run once the animation is complete
  94455. * @returns Nullable animation
  94456. */
  94457. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94458. /**
  94459. * Transition property of an host to the target Value
  94460. * @param property The property to transition
  94461. * @param targetValue The target Value of the property
  94462. * @param host The object where the property to animate belongs
  94463. * @param scene Scene used to run the animation
  94464. * @param frameRate Framerate (in frame/s) to use
  94465. * @param transition The transition type we want to use
  94466. * @param duration The duration of the animation, in milliseconds
  94467. * @param onAnimationEnd Callback trigger at the end of the animation
  94468. * @returns Nullable animation
  94469. */
  94470. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94471. /**
  94472. * Return the array of runtime animations currently using this animation
  94473. */
  94474. readonly runtimeAnimations: RuntimeAnimation[];
  94475. /**
  94476. * Specifies if any of the runtime animations are currently running
  94477. */
  94478. readonly hasRunningRuntimeAnimations: boolean;
  94479. /**
  94480. * Initializes the animation
  94481. * @param name Name of the animation
  94482. * @param targetProperty Property to animate
  94483. * @param framePerSecond The frames per second of the animation
  94484. * @param dataType The data type of the animation
  94485. * @param loopMode The loop mode of the animation
  94486. * @param enableBlending Specifies if blending should be enabled
  94487. */
  94488. constructor(
  94489. /**Name of the animation */
  94490. name: string,
  94491. /**Property to animate */
  94492. targetProperty: string,
  94493. /**The frames per second of the animation */
  94494. framePerSecond: number,
  94495. /**The data type of the animation */
  94496. dataType: number,
  94497. /**The loop mode of the animation */
  94498. loopMode?: number | undefined,
  94499. /**Specifies if blending should be enabled */
  94500. enableBlending?: boolean | undefined);
  94501. /**
  94502. * Converts the animation to a string
  94503. * @param fullDetails support for multiple levels of logging within scene loading
  94504. * @returns String form of the animation
  94505. */
  94506. toString(fullDetails?: boolean): string;
  94507. /**
  94508. * Add an event to this animation
  94509. * @param event Event to add
  94510. */
  94511. addEvent(event: AnimationEvent): void;
  94512. /**
  94513. * Remove all events found at the given frame
  94514. * @param frame The frame to remove events from
  94515. */
  94516. removeEvents(frame: number): void;
  94517. /**
  94518. * Retrieves all the events from the animation
  94519. * @returns Events from the animation
  94520. */
  94521. getEvents(): AnimationEvent[];
  94522. /**
  94523. * Creates an animation range
  94524. * @param name Name of the animation range
  94525. * @param from Starting frame of the animation range
  94526. * @param to Ending frame of the animation
  94527. */
  94528. createRange(name: string, from: number, to: number): void;
  94529. /**
  94530. * Deletes an animation range by name
  94531. * @param name Name of the animation range to delete
  94532. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94533. */
  94534. deleteRange(name: string, deleteFrames?: boolean): void;
  94535. /**
  94536. * Gets the animation range by name, or null if not defined
  94537. * @param name Name of the animation range
  94538. * @returns Nullable animation range
  94539. */
  94540. getRange(name: string): Nullable<AnimationRange>;
  94541. /**
  94542. * Gets the key frames from the animation
  94543. * @returns The key frames of the animation
  94544. */
  94545. getKeys(): Array<IAnimationKey>;
  94546. /**
  94547. * Gets the highest frame rate of the animation
  94548. * @returns Highest frame rate of the animation
  94549. */
  94550. getHighestFrame(): number;
  94551. /**
  94552. * Gets the easing function of the animation
  94553. * @returns Easing function of the animation
  94554. */
  94555. getEasingFunction(): IEasingFunction;
  94556. /**
  94557. * Sets the easing function of the animation
  94558. * @param easingFunction A custom mathematical formula for animation
  94559. */
  94560. setEasingFunction(easingFunction: EasingFunction): void;
  94561. /**
  94562. * Interpolates a scalar linearly
  94563. * @param startValue Start value of the animation curve
  94564. * @param endValue End value of the animation curve
  94565. * @param gradient Scalar amount to interpolate
  94566. * @returns Interpolated scalar value
  94567. */
  94568. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94569. /**
  94570. * Interpolates a scalar cubically
  94571. * @param startValue Start value of the animation curve
  94572. * @param outTangent End tangent of the animation
  94573. * @param endValue End value of the animation curve
  94574. * @param inTangent Start tangent of the animation curve
  94575. * @param gradient Scalar amount to interpolate
  94576. * @returns Interpolated scalar value
  94577. */
  94578. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94579. /**
  94580. * Interpolates a quaternion using a spherical linear interpolation
  94581. * @param startValue Start value of the animation curve
  94582. * @param endValue End value of the animation curve
  94583. * @param gradient Scalar amount to interpolate
  94584. * @returns Interpolated quaternion value
  94585. */
  94586. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94587. /**
  94588. * Interpolates a quaternion cubically
  94589. * @param startValue Start value of the animation curve
  94590. * @param outTangent End tangent of the animation curve
  94591. * @param endValue End value of the animation curve
  94592. * @param inTangent Start tangent of the animation curve
  94593. * @param gradient Scalar amount to interpolate
  94594. * @returns Interpolated quaternion value
  94595. */
  94596. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94597. /**
  94598. * Interpolates a Vector3 linearl
  94599. * @param startValue Start value of the animation curve
  94600. * @param endValue End value of the animation curve
  94601. * @param gradient Scalar amount to interpolate
  94602. * @returns Interpolated scalar value
  94603. */
  94604. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94605. /**
  94606. * Interpolates a Vector3 cubically
  94607. * @param startValue Start value of the animation curve
  94608. * @param outTangent End tangent of the animation
  94609. * @param endValue End value of the animation curve
  94610. * @param inTangent Start tangent of the animation curve
  94611. * @param gradient Scalar amount to interpolate
  94612. * @returns InterpolatedVector3 value
  94613. */
  94614. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94615. /**
  94616. * Interpolates a Vector2 linearly
  94617. * @param startValue Start value of the animation curve
  94618. * @param endValue End value of the animation curve
  94619. * @param gradient Scalar amount to interpolate
  94620. * @returns Interpolated Vector2 value
  94621. */
  94622. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94623. /**
  94624. * Interpolates a Vector2 cubically
  94625. * @param startValue Start value of the animation curve
  94626. * @param outTangent End tangent of the animation
  94627. * @param endValue End value of the animation curve
  94628. * @param inTangent Start tangent of the animation curve
  94629. * @param gradient Scalar amount to interpolate
  94630. * @returns Interpolated Vector2 value
  94631. */
  94632. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94633. /**
  94634. * Interpolates a size linearly
  94635. * @param startValue Start value of the animation curve
  94636. * @param endValue End value of the animation curve
  94637. * @param gradient Scalar amount to interpolate
  94638. * @returns Interpolated Size value
  94639. */
  94640. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94641. /**
  94642. * Interpolates a Color3 linearly
  94643. * @param startValue Start value of the animation curve
  94644. * @param endValue End value of the animation curve
  94645. * @param gradient Scalar amount to interpolate
  94646. * @returns Interpolated Color3 value
  94647. */
  94648. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94649. /**
  94650. * @hidden Internal use only
  94651. */
  94652. _getKeyValue(value: any): any;
  94653. /**
  94654. * @hidden Internal use only
  94655. */
  94656. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94657. /**
  94658. * Defines the function to use to interpolate matrices
  94659. * @param startValue defines the start matrix
  94660. * @param endValue defines the end matrix
  94661. * @param gradient defines the gradient between both matrices
  94662. * @param result defines an optional target matrix where to store the interpolation
  94663. * @returns the interpolated matrix
  94664. */
  94665. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94666. /**
  94667. * Makes a copy of the animation
  94668. * @returns Cloned animation
  94669. */
  94670. clone(): Animation;
  94671. /**
  94672. * Sets the key frames of the animation
  94673. * @param values The animation key frames to set
  94674. */
  94675. setKeys(values: Array<IAnimationKey>): void;
  94676. /**
  94677. * Serializes the animation to an object
  94678. * @returns Serialized object
  94679. */
  94680. serialize(): any;
  94681. /**
  94682. * Float animation type
  94683. */
  94684. private static _ANIMATIONTYPE_FLOAT;
  94685. /**
  94686. * Vector3 animation type
  94687. */
  94688. private static _ANIMATIONTYPE_VECTOR3;
  94689. /**
  94690. * Quaternion animation type
  94691. */
  94692. private static _ANIMATIONTYPE_QUATERNION;
  94693. /**
  94694. * Matrix animation type
  94695. */
  94696. private static _ANIMATIONTYPE_MATRIX;
  94697. /**
  94698. * Color3 animation type
  94699. */
  94700. private static _ANIMATIONTYPE_COLOR3;
  94701. /**
  94702. * Vector2 animation type
  94703. */
  94704. private static _ANIMATIONTYPE_VECTOR2;
  94705. /**
  94706. * Size animation type
  94707. */
  94708. private static _ANIMATIONTYPE_SIZE;
  94709. /**
  94710. * Relative Loop Mode
  94711. */
  94712. private static _ANIMATIONLOOPMODE_RELATIVE;
  94713. /**
  94714. * Cycle Loop Mode
  94715. */
  94716. private static _ANIMATIONLOOPMODE_CYCLE;
  94717. /**
  94718. * Constant Loop Mode
  94719. */
  94720. private static _ANIMATIONLOOPMODE_CONSTANT;
  94721. /**
  94722. * Get the float animation type
  94723. */
  94724. static readonly ANIMATIONTYPE_FLOAT: number;
  94725. /**
  94726. * Get the Vector3 animation type
  94727. */
  94728. static readonly ANIMATIONTYPE_VECTOR3: number;
  94729. /**
  94730. * Get the Vector2 animation type
  94731. */
  94732. static readonly ANIMATIONTYPE_VECTOR2: number;
  94733. /**
  94734. * Get the Size animation type
  94735. */
  94736. static readonly ANIMATIONTYPE_SIZE: number;
  94737. /**
  94738. * Get the Quaternion animation type
  94739. */
  94740. static readonly ANIMATIONTYPE_QUATERNION: number;
  94741. /**
  94742. * Get the Matrix animation type
  94743. */
  94744. static readonly ANIMATIONTYPE_MATRIX: number;
  94745. /**
  94746. * Get the Color3 animation type
  94747. */
  94748. static readonly ANIMATIONTYPE_COLOR3: number;
  94749. /**
  94750. * Get the Relative Loop Mode
  94751. */
  94752. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94753. /**
  94754. * Get the Cycle Loop Mode
  94755. */
  94756. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94757. /**
  94758. * Get the Constant Loop Mode
  94759. */
  94760. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94761. /** @hidden */
  94762. static _UniversalLerp(left: any, right: any, amount: number): any;
  94763. /**
  94764. * Parses an animation object and creates an animation
  94765. * @param parsedAnimation Parsed animation object
  94766. * @returns Animation object
  94767. */
  94768. static Parse(parsedAnimation: any): Animation;
  94769. /**
  94770. * Appends the serialized animations from the source animations
  94771. * @param source Source containing the animations
  94772. * @param destination Target to store the animations
  94773. */
  94774. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94775. }
  94776. }
  94777. declare module BABYLON {
  94778. /**
  94779. * Interface containing an array of animations
  94780. */
  94781. export interface IAnimatable {
  94782. /**
  94783. * Array of animations
  94784. */
  94785. animations: Nullable<Array<Animation>>;
  94786. }
  94787. }
  94788. declare module BABYLON {
  94789. /**
  94790. * This represents all the required information to add a fresnel effect on a material:
  94791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94792. */
  94793. export class FresnelParameters {
  94794. private _isEnabled;
  94795. /**
  94796. * Define if the fresnel effect is enable or not.
  94797. */
  94798. isEnabled: boolean;
  94799. /**
  94800. * Define the color used on edges (grazing angle)
  94801. */
  94802. leftColor: Color3;
  94803. /**
  94804. * Define the color used on center
  94805. */
  94806. rightColor: Color3;
  94807. /**
  94808. * Define bias applied to computed fresnel term
  94809. */
  94810. bias: number;
  94811. /**
  94812. * Defined the power exponent applied to fresnel term
  94813. */
  94814. power: number;
  94815. /**
  94816. * Clones the current fresnel and its valuues
  94817. * @returns a clone fresnel configuration
  94818. */
  94819. clone(): FresnelParameters;
  94820. /**
  94821. * Serializes the current fresnel parameters to a JSON representation.
  94822. * @return the JSON serialization
  94823. */
  94824. serialize(): any;
  94825. /**
  94826. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94827. * @param parsedFresnelParameters Define the JSON representation
  94828. * @returns the parsed parameters
  94829. */
  94830. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94831. }
  94832. }
  94833. declare module BABYLON {
  94834. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94835. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94836. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94837. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94838. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94839. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94840. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94841. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94842. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94843. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94844. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94845. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94846. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94847. /**
  94848. * Decorator used to define property that can be serialized as reference to a camera
  94849. * @param sourceName defines the name of the property to decorate
  94850. */
  94851. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94852. /**
  94853. * Class used to help serialization objects
  94854. */
  94855. export class SerializationHelper {
  94856. /** @hidden */
  94857. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94858. /** @hidden */
  94859. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94860. /** @hidden */
  94861. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94862. /** @hidden */
  94863. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94864. /**
  94865. * Appends the serialized animations from the source animations
  94866. * @param source Source containing the animations
  94867. * @param destination Target to store the animations
  94868. */
  94869. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94870. /**
  94871. * Static function used to serialized a specific entity
  94872. * @param entity defines the entity to serialize
  94873. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94874. * @returns a JSON compatible object representing the serialization of the entity
  94875. */
  94876. static Serialize<T>(entity: T, serializationObject?: any): any;
  94877. /**
  94878. * Creates a new entity from a serialization data object
  94879. * @param creationFunction defines a function used to instanciated the new entity
  94880. * @param source defines the source serialization data
  94881. * @param scene defines the hosting scene
  94882. * @param rootUrl defines the root url for resources
  94883. * @returns a new entity
  94884. */
  94885. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94886. /**
  94887. * Clones an object
  94888. * @param creationFunction defines the function used to instanciate the new object
  94889. * @param source defines the source object
  94890. * @returns the cloned object
  94891. */
  94892. static Clone<T>(creationFunction: () => T, source: T): T;
  94893. /**
  94894. * Instanciates a new object based on a source one (some data will be shared between both object)
  94895. * @param creationFunction defines the function used to instanciate the new object
  94896. * @param source defines the source object
  94897. * @returns the new object
  94898. */
  94899. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94900. }
  94901. }
  94902. declare module BABYLON {
  94903. /**
  94904. * Class used to manipulate GUIDs
  94905. */
  94906. export class GUID {
  94907. /**
  94908. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94909. * Be aware Math.random() could cause collisions, but:
  94910. * "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"
  94911. * @returns a pseudo random id
  94912. */
  94913. static RandomId(): string;
  94914. }
  94915. }
  94916. declare module BABYLON {
  94917. /**
  94918. * Base class of all the textures in babylon.
  94919. * It groups all the common properties the materials, post process, lights... might need
  94920. * in order to make a correct use of the texture.
  94921. */
  94922. export class BaseTexture implements IAnimatable {
  94923. /**
  94924. * Default anisotropic filtering level for the application.
  94925. * It is set to 4 as a good tradeoff between perf and quality.
  94926. */
  94927. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94928. /**
  94929. * Gets or sets the unique id of the texture
  94930. */
  94931. uniqueId: number;
  94932. /**
  94933. * Define the name of the texture.
  94934. */
  94935. name: string;
  94936. /**
  94937. * Gets or sets an object used to store user defined information.
  94938. */
  94939. metadata: any;
  94940. /**
  94941. * For internal use only. Please do not use.
  94942. */
  94943. reservedDataStore: any;
  94944. private _hasAlpha;
  94945. /**
  94946. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94947. */
  94948. hasAlpha: boolean;
  94949. /**
  94950. * Defines if the alpha value should be determined via the rgb values.
  94951. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94952. */
  94953. getAlphaFromRGB: boolean;
  94954. /**
  94955. * Intensity or strength of the texture.
  94956. * It is commonly used by materials to fine tune the intensity of the texture
  94957. */
  94958. level: number;
  94959. /**
  94960. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94961. * This is part of the texture as textures usually maps to one uv set.
  94962. */
  94963. coordinatesIndex: number;
  94964. private _coordinatesMode;
  94965. /**
  94966. * How a texture is mapped.
  94967. *
  94968. * | Value | Type | Description |
  94969. * | ----- | ----------------------------------- | ----------- |
  94970. * | 0 | EXPLICIT_MODE | |
  94971. * | 1 | SPHERICAL_MODE | |
  94972. * | 2 | PLANAR_MODE | |
  94973. * | 3 | CUBIC_MODE | |
  94974. * | 4 | PROJECTION_MODE | |
  94975. * | 5 | SKYBOX_MODE | |
  94976. * | 6 | INVCUBIC_MODE | |
  94977. * | 7 | EQUIRECTANGULAR_MODE | |
  94978. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94979. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94980. */
  94981. coordinatesMode: number;
  94982. /**
  94983. * | Value | Type | Description |
  94984. * | ----- | ------------------ | ----------- |
  94985. * | 0 | CLAMP_ADDRESSMODE | |
  94986. * | 1 | WRAP_ADDRESSMODE | |
  94987. * | 2 | MIRROR_ADDRESSMODE | |
  94988. */
  94989. wrapU: number;
  94990. /**
  94991. * | Value | Type | Description |
  94992. * | ----- | ------------------ | ----------- |
  94993. * | 0 | CLAMP_ADDRESSMODE | |
  94994. * | 1 | WRAP_ADDRESSMODE | |
  94995. * | 2 | MIRROR_ADDRESSMODE | |
  94996. */
  94997. wrapV: number;
  94998. /**
  94999. * | Value | Type | Description |
  95000. * | ----- | ------------------ | ----------- |
  95001. * | 0 | CLAMP_ADDRESSMODE | |
  95002. * | 1 | WRAP_ADDRESSMODE | |
  95003. * | 2 | MIRROR_ADDRESSMODE | |
  95004. */
  95005. wrapR: number;
  95006. /**
  95007. * With compliant hardware and browser (supporting anisotropic filtering)
  95008. * this defines the level of anisotropic filtering in the texture.
  95009. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95010. */
  95011. anisotropicFilteringLevel: number;
  95012. /**
  95013. * Define if the texture is a cube texture or if false a 2d texture.
  95014. */
  95015. isCube: boolean;
  95016. /**
  95017. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95018. */
  95019. is3D: boolean;
  95020. /**
  95021. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95022. * HDR texture are usually stored in linear space.
  95023. * This only impacts the PBR and Background materials
  95024. */
  95025. gammaSpace: boolean;
  95026. /**
  95027. * Gets or sets whether or not the texture contains RGBD data.
  95028. */
  95029. isRGBD: boolean;
  95030. /**
  95031. * Is Z inverted in the texture (useful in a cube texture).
  95032. */
  95033. invertZ: boolean;
  95034. /**
  95035. * Are mip maps generated for this texture or not.
  95036. */
  95037. readonly noMipmap: boolean;
  95038. /**
  95039. * @hidden
  95040. */
  95041. lodLevelInAlpha: boolean;
  95042. /**
  95043. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95044. */
  95045. lodGenerationOffset: number;
  95046. /**
  95047. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95048. */
  95049. lodGenerationScale: number;
  95050. /**
  95051. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95052. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95053. * average roughness values.
  95054. */
  95055. linearSpecularLOD: boolean;
  95056. /**
  95057. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95058. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95059. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95060. */
  95061. irradianceTexture: Nullable<BaseTexture>;
  95062. /**
  95063. * Define if the texture is a render target.
  95064. */
  95065. isRenderTarget: boolean;
  95066. /**
  95067. * Define the unique id of the texture in the scene.
  95068. */
  95069. readonly uid: string;
  95070. /**
  95071. * Return a string representation of the texture.
  95072. * @returns the texture as a string
  95073. */
  95074. toString(): string;
  95075. /**
  95076. * Get the class name of the texture.
  95077. * @returns "BaseTexture"
  95078. */
  95079. getClassName(): string;
  95080. /**
  95081. * Define the list of animation attached to the texture.
  95082. */
  95083. animations: Animation[];
  95084. /**
  95085. * An event triggered when the texture is disposed.
  95086. */
  95087. onDisposeObservable: Observable<BaseTexture>;
  95088. private _onDisposeObserver;
  95089. /**
  95090. * Callback triggered when the texture has been disposed.
  95091. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95092. */
  95093. onDispose: () => void;
  95094. /**
  95095. * Define the current state of the loading sequence when in delayed load mode.
  95096. */
  95097. delayLoadState: number;
  95098. private _scene;
  95099. /** @hidden */
  95100. _texture: Nullable<InternalTexture>;
  95101. private _uid;
  95102. /**
  95103. * Define if the texture is preventinga material to render or not.
  95104. * If not and the texture is not ready, the engine will use a default black texture instead.
  95105. */
  95106. readonly isBlocking: boolean;
  95107. /**
  95108. * Instantiates a new BaseTexture.
  95109. * Base class of all the textures in babylon.
  95110. * It groups all the common properties the materials, post process, lights... might need
  95111. * in order to make a correct use of the texture.
  95112. * @param scene Define the scene the texture blongs to
  95113. */
  95114. constructor(scene: Nullable<Scene>);
  95115. /**
  95116. * Get the scene the texture belongs to.
  95117. * @returns the scene or null if undefined
  95118. */
  95119. getScene(): Nullable<Scene>;
  95120. /**
  95121. * Get the texture transform matrix used to offset tile the texture for istance.
  95122. * @returns the transformation matrix
  95123. */
  95124. getTextureMatrix(): Matrix;
  95125. /**
  95126. * Get the texture reflection matrix used to rotate/transform the reflection.
  95127. * @returns the reflection matrix
  95128. */
  95129. getReflectionTextureMatrix(): Matrix;
  95130. /**
  95131. * Get the underlying lower level texture from Babylon.
  95132. * @returns the insternal texture
  95133. */
  95134. getInternalTexture(): Nullable<InternalTexture>;
  95135. /**
  95136. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95137. * @returns true if ready or not blocking
  95138. */
  95139. isReadyOrNotBlocking(): boolean;
  95140. /**
  95141. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95142. * @returns true if fully ready
  95143. */
  95144. isReady(): boolean;
  95145. private _cachedSize;
  95146. /**
  95147. * Get the size of the texture.
  95148. * @returns the texture size.
  95149. */
  95150. getSize(): ISize;
  95151. /**
  95152. * Get the base size of the texture.
  95153. * It can be different from the size if the texture has been resized for POT for instance
  95154. * @returns the base size
  95155. */
  95156. getBaseSize(): ISize;
  95157. /**
  95158. * Update the sampling mode of the texture.
  95159. * Default is Trilinear mode.
  95160. *
  95161. * | Value | Type | Description |
  95162. * | ----- | ------------------ | ----------- |
  95163. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95164. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95165. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95166. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95167. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95168. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95169. * | 7 | NEAREST_LINEAR | |
  95170. * | 8 | NEAREST_NEAREST | |
  95171. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95172. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95173. * | 11 | LINEAR_LINEAR | |
  95174. * | 12 | LINEAR_NEAREST | |
  95175. *
  95176. * > _mag_: magnification filter (close to the viewer)
  95177. * > _min_: minification filter (far from the viewer)
  95178. * > _mip_: filter used between mip map levels
  95179. *@param samplingMode Define the new sampling mode of the texture
  95180. */
  95181. updateSamplingMode(samplingMode: number): void;
  95182. /**
  95183. * Scales the texture if is `canRescale()`
  95184. * @param ratio the resize factor we want to use to rescale
  95185. */
  95186. scale(ratio: number): void;
  95187. /**
  95188. * Get if the texture can rescale.
  95189. */
  95190. readonly canRescale: boolean;
  95191. /** @hidden */
  95192. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95193. /** @hidden */
  95194. _rebuild(): void;
  95195. /**
  95196. * Triggers the load sequence in delayed load mode.
  95197. */
  95198. delayLoad(): void;
  95199. /**
  95200. * Clones the texture.
  95201. * @returns the cloned texture
  95202. */
  95203. clone(): Nullable<BaseTexture>;
  95204. /**
  95205. * Get the texture underlying type (INT, FLOAT...)
  95206. */
  95207. readonly textureType: number;
  95208. /**
  95209. * Get the texture underlying format (RGB, RGBA...)
  95210. */
  95211. readonly textureFormat: number;
  95212. /**
  95213. * Indicates that textures need to be re-calculated for all materials
  95214. */
  95215. protected _markAllSubMeshesAsTexturesDirty(): void;
  95216. /**
  95217. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95218. * This will returns an RGBA array buffer containing either in values (0-255) or
  95219. * float values (0-1) depending of the underlying buffer type.
  95220. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95221. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95222. * @param buffer defines a user defined buffer to fill with data (can be null)
  95223. * @returns The Array buffer containing the pixels data.
  95224. */
  95225. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95226. /**
  95227. * Release and destroy the underlying lower level texture aka internalTexture.
  95228. */
  95229. releaseInternalTexture(): void;
  95230. /** @hidden */
  95231. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95232. /** @hidden */
  95233. readonly _lodTextureMid: Nullable<BaseTexture>;
  95234. /** @hidden */
  95235. readonly _lodTextureLow: Nullable<BaseTexture>;
  95236. /**
  95237. * Dispose the texture and release its associated resources.
  95238. */
  95239. dispose(): void;
  95240. /**
  95241. * Serialize the texture into a JSON representation that can be parsed later on.
  95242. * @returns the JSON representation of the texture
  95243. */
  95244. serialize(): any;
  95245. /**
  95246. * Helper function to be called back once a list of texture contains only ready textures.
  95247. * @param textures Define the list of textures to wait for
  95248. * @param callback Define the callback triggered once the entire list will be ready
  95249. */
  95250. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95251. }
  95252. }
  95253. declare module BABYLON {
  95254. /**
  95255. * Options to be used when creating an effect.
  95256. */
  95257. export interface IEffectCreationOptions {
  95258. /**
  95259. * Atrributes that will be used in the shader.
  95260. */
  95261. attributes: string[];
  95262. /**
  95263. * Uniform varible names that will be set in the shader.
  95264. */
  95265. uniformsNames: string[];
  95266. /**
  95267. * Uniform buffer varible names that will be set in the shader.
  95268. */
  95269. uniformBuffersNames: string[];
  95270. /**
  95271. * Sampler texture variable names that will be set in the shader.
  95272. */
  95273. samplers: string[];
  95274. /**
  95275. * Define statements that will be set in the shader.
  95276. */
  95277. defines: any;
  95278. /**
  95279. * Possible fallbacks for this effect to improve performance when needed.
  95280. */
  95281. fallbacks: Nullable<IEffectFallbacks>;
  95282. /**
  95283. * Callback that will be called when the shader is compiled.
  95284. */
  95285. onCompiled: Nullable<(effect: Effect) => void>;
  95286. /**
  95287. * Callback that will be called if an error occurs during shader compilation.
  95288. */
  95289. onError: Nullable<(effect: Effect, errors: string) => void>;
  95290. /**
  95291. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95292. */
  95293. indexParameters?: any;
  95294. /**
  95295. * Max number of lights that can be used in the shader.
  95296. */
  95297. maxSimultaneousLights?: number;
  95298. /**
  95299. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95300. */
  95301. transformFeedbackVaryings?: Nullable<string[]>;
  95302. }
  95303. /**
  95304. * Effect containing vertex and fragment shader that can be executed on an object.
  95305. */
  95306. export class Effect implements IDisposable {
  95307. /**
  95308. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95309. */
  95310. static ShadersRepository: string;
  95311. /**
  95312. * Name of the effect.
  95313. */
  95314. name: any;
  95315. /**
  95316. * String container all the define statements that should be set on the shader.
  95317. */
  95318. defines: string;
  95319. /**
  95320. * Callback that will be called when the shader is compiled.
  95321. */
  95322. onCompiled: Nullable<(effect: Effect) => void>;
  95323. /**
  95324. * Callback that will be called if an error occurs during shader compilation.
  95325. */
  95326. onError: Nullable<(effect: Effect, errors: string) => void>;
  95327. /**
  95328. * Callback that will be called when effect is bound.
  95329. */
  95330. onBind: Nullable<(effect: Effect) => void>;
  95331. /**
  95332. * Unique ID of the effect.
  95333. */
  95334. uniqueId: number;
  95335. /**
  95336. * Observable that will be called when the shader is compiled.
  95337. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95338. */
  95339. onCompileObservable: Observable<Effect>;
  95340. /**
  95341. * Observable that will be called if an error occurs during shader compilation.
  95342. */
  95343. onErrorObservable: Observable<Effect>;
  95344. /** @hidden */
  95345. _onBindObservable: Nullable<Observable<Effect>>;
  95346. /**
  95347. * Observable that will be called when effect is bound.
  95348. */
  95349. readonly onBindObservable: Observable<Effect>;
  95350. /** @hidden */
  95351. _bonesComputationForcedToCPU: boolean;
  95352. private static _uniqueIdSeed;
  95353. private _engine;
  95354. private _uniformBuffersNames;
  95355. private _uniformsNames;
  95356. private _samplerList;
  95357. private _samplers;
  95358. private _isReady;
  95359. private _compilationError;
  95360. private _allFallbacksProcessed;
  95361. private _attributesNames;
  95362. private _attributes;
  95363. private _uniforms;
  95364. /**
  95365. * Key for the effect.
  95366. * @hidden
  95367. */
  95368. _key: string;
  95369. private _indexParameters;
  95370. private _fallbacks;
  95371. private _vertexSourceCode;
  95372. private _fragmentSourceCode;
  95373. private _vertexSourceCodeOverride;
  95374. private _fragmentSourceCodeOverride;
  95375. private _transformFeedbackVaryings;
  95376. /**
  95377. * Compiled shader to webGL program.
  95378. * @hidden
  95379. */
  95380. _pipelineContext: Nullable<IPipelineContext>;
  95381. private _valueCache;
  95382. private static _baseCache;
  95383. /**
  95384. * Instantiates an effect.
  95385. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95386. * @param baseName Name of the effect.
  95387. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95388. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95389. * @param samplers List of sampler variables that will be passed to the shader.
  95390. * @param engine Engine to be used to render the effect
  95391. * @param defines Define statements to be added to the shader.
  95392. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95393. * @param onCompiled Callback that will be called when the shader is compiled.
  95394. * @param onError Callback that will be called if an error occurs during shader compilation.
  95395. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95396. */
  95397. 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);
  95398. private _useFinalCode;
  95399. /**
  95400. * Unique key for this effect
  95401. */
  95402. readonly key: string;
  95403. /**
  95404. * If the effect has been compiled and prepared.
  95405. * @returns if the effect is compiled and prepared.
  95406. */
  95407. isReady(): boolean;
  95408. private _isReadyInternal;
  95409. /**
  95410. * The engine the effect was initialized with.
  95411. * @returns the engine.
  95412. */
  95413. getEngine(): Engine;
  95414. /**
  95415. * The pipeline context for this effect
  95416. * @returns the associated pipeline context
  95417. */
  95418. getPipelineContext(): Nullable<IPipelineContext>;
  95419. /**
  95420. * The set of names of attribute variables for the shader.
  95421. * @returns An array of attribute names.
  95422. */
  95423. getAttributesNames(): string[];
  95424. /**
  95425. * Returns the attribute at the given index.
  95426. * @param index The index of the attribute.
  95427. * @returns The location of the attribute.
  95428. */
  95429. getAttributeLocation(index: number): number;
  95430. /**
  95431. * Returns the attribute based on the name of the variable.
  95432. * @param name of the attribute to look up.
  95433. * @returns the attribute location.
  95434. */
  95435. getAttributeLocationByName(name: string): number;
  95436. /**
  95437. * The number of attributes.
  95438. * @returns the numnber of attributes.
  95439. */
  95440. getAttributesCount(): number;
  95441. /**
  95442. * Gets the index of a uniform variable.
  95443. * @param uniformName of the uniform to look up.
  95444. * @returns the index.
  95445. */
  95446. getUniformIndex(uniformName: string): number;
  95447. /**
  95448. * Returns the attribute based on the name of the variable.
  95449. * @param uniformName of the uniform to look up.
  95450. * @returns the location of the uniform.
  95451. */
  95452. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95453. /**
  95454. * Returns an array of sampler variable names
  95455. * @returns The array of sampler variable neames.
  95456. */
  95457. getSamplers(): string[];
  95458. /**
  95459. * The error from the last compilation.
  95460. * @returns the error string.
  95461. */
  95462. getCompilationError(): string;
  95463. /**
  95464. * Gets a boolean indicating that all fallbacks were used during compilation
  95465. * @returns true if all fallbacks were used
  95466. */
  95467. allFallbacksProcessed(): boolean;
  95468. /**
  95469. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95470. * @param func The callback to be used.
  95471. */
  95472. executeWhenCompiled(func: (effect: Effect) => void): void;
  95473. private _checkIsReady;
  95474. private _loadShader;
  95475. /**
  95476. * Recompiles the webGL program
  95477. * @param vertexSourceCode The source code for the vertex shader.
  95478. * @param fragmentSourceCode The source code for the fragment shader.
  95479. * @param onCompiled Callback called when completed.
  95480. * @param onError Callback called on error.
  95481. * @hidden
  95482. */
  95483. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95484. /**
  95485. * Prepares the effect
  95486. * @hidden
  95487. */
  95488. _prepareEffect(): void;
  95489. private _processCompilationErrors;
  95490. /**
  95491. * Checks if the effect is supported. (Must be called after compilation)
  95492. */
  95493. readonly isSupported: boolean;
  95494. /**
  95495. * Binds a texture to the engine to be used as output of the shader.
  95496. * @param channel Name of the output variable.
  95497. * @param texture Texture to bind.
  95498. * @hidden
  95499. */
  95500. _bindTexture(channel: string, texture: InternalTexture): void;
  95501. /**
  95502. * Sets a texture on the engine to be used in the shader.
  95503. * @param channel Name of the sampler variable.
  95504. * @param texture Texture to set.
  95505. */
  95506. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95507. /**
  95508. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95509. * @param channel Name of the sampler variable.
  95510. * @param texture Texture to set.
  95511. */
  95512. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95513. /**
  95514. * Sets an array of textures on the engine to be used in the shader.
  95515. * @param channel Name of the variable.
  95516. * @param textures Textures to set.
  95517. */
  95518. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95519. /**
  95520. * 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)
  95521. * @param channel Name of the sampler variable.
  95522. * @param postProcess Post process to get the input texture from.
  95523. */
  95524. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95525. /**
  95526. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95527. * 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)
  95528. * @param channel Name of the sampler variable.
  95529. * @param postProcess Post process to get the output texture from.
  95530. */
  95531. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95532. /** @hidden */
  95533. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95534. /** @hidden */
  95535. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95536. /** @hidden */
  95537. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95538. /** @hidden */
  95539. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95540. /**
  95541. * Binds a buffer to a uniform.
  95542. * @param buffer Buffer to bind.
  95543. * @param name Name of the uniform variable to bind to.
  95544. */
  95545. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95546. /**
  95547. * Binds block to a uniform.
  95548. * @param blockName Name of the block to bind.
  95549. * @param index Index to bind.
  95550. */
  95551. bindUniformBlock(blockName: string, index: number): void;
  95552. /**
  95553. * Sets an interger value on a uniform variable.
  95554. * @param uniformName Name of the variable.
  95555. * @param value Value to be set.
  95556. * @returns this effect.
  95557. */
  95558. setInt(uniformName: string, value: number): Effect;
  95559. /**
  95560. * Sets an int array on a uniform variable.
  95561. * @param uniformName Name of the variable.
  95562. * @param array array to be set.
  95563. * @returns this effect.
  95564. */
  95565. setIntArray(uniformName: string, array: Int32Array): Effect;
  95566. /**
  95567. * 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)
  95568. * @param uniformName Name of the variable.
  95569. * @param array array to be set.
  95570. * @returns this effect.
  95571. */
  95572. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95573. /**
  95574. * 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)
  95575. * @param uniformName Name of the variable.
  95576. * @param array array to be set.
  95577. * @returns this effect.
  95578. */
  95579. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95580. /**
  95581. * 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)
  95582. * @param uniformName Name of the variable.
  95583. * @param array array to be set.
  95584. * @returns this effect.
  95585. */
  95586. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95587. /**
  95588. * Sets an float array on a uniform variable.
  95589. * @param uniformName Name of the variable.
  95590. * @param array array to be set.
  95591. * @returns this effect.
  95592. */
  95593. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95594. /**
  95595. * 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)
  95596. * @param uniformName Name of the variable.
  95597. * @param array array to be set.
  95598. * @returns this effect.
  95599. */
  95600. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95601. /**
  95602. * 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)
  95603. * @param uniformName Name of the variable.
  95604. * @param array array to be set.
  95605. * @returns this effect.
  95606. */
  95607. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95608. /**
  95609. * 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)
  95610. * @param uniformName Name of the variable.
  95611. * @param array array to be set.
  95612. * @returns this effect.
  95613. */
  95614. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95615. /**
  95616. * Sets an array on a uniform variable.
  95617. * @param uniformName Name of the variable.
  95618. * @param array array to be set.
  95619. * @returns this effect.
  95620. */
  95621. setArray(uniformName: string, array: number[]): Effect;
  95622. /**
  95623. * 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)
  95624. * @param uniformName Name of the variable.
  95625. * @param array array to be set.
  95626. * @returns this effect.
  95627. */
  95628. setArray2(uniformName: string, array: number[]): Effect;
  95629. /**
  95630. * 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)
  95631. * @param uniformName Name of the variable.
  95632. * @param array array to be set.
  95633. * @returns this effect.
  95634. */
  95635. setArray3(uniformName: string, array: number[]): Effect;
  95636. /**
  95637. * 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)
  95638. * @param uniformName Name of the variable.
  95639. * @param array array to be set.
  95640. * @returns this effect.
  95641. */
  95642. setArray4(uniformName: string, array: number[]): Effect;
  95643. /**
  95644. * Sets matrices on a uniform variable.
  95645. * @param uniformName Name of the variable.
  95646. * @param matrices matrices to be set.
  95647. * @returns this effect.
  95648. */
  95649. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95650. /**
  95651. * Sets matrix on a uniform variable.
  95652. * @param uniformName Name of the variable.
  95653. * @param matrix matrix to be set.
  95654. * @returns this effect.
  95655. */
  95656. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95657. /**
  95658. * 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)
  95659. * @param uniformName Name of the variable.
  95660. * @param matrix matrix to be set.
  95661. * @returns this effect.
  95662. */
  95663. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95664. /**
  95665. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95666. * @param uniformName Name of the variable.
  95667. * @param matrix matrix to be set.
  95668. * @returns this effect.
  95669. */
  95670. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95671. /**
  95672. * Sets a float on a uniform variable.
  95673. * @param uniformName Name of the variable.
  95674. * @param value value to be set.
  95675. * @returns this effect.
  95676. */
  95677. setFloat(uniformName: string, value: number): Effect;
  95678. /**
  95679. * Sets a boolean on a uniform variable.
  95680. * @param uniformName Name of the variable.
  95681. * @param bool value to be set.
  95682. * @returns this effect.
  95683. */
  95684. setBool(uniformName: string, bool: boolean): Effect;
  95685. /**
  95686. * Sets a Vector2 on a uniform variable.
  95687. * @param uniformName Name of the variable.
  95688. * @param vector2 vector2 to be set.
  95689. * @returns this effect.
  95690. */
  95691. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95692. /**
  95693. * Sets a float2 on a uniform variable.
  95694. * @param uniformName Name of the variable.
  95695. * @param x First float in float2.
  95696. * @param y Second float in float2.
  95697. * @returns this effect.
  95698. */
  95699. setFloat2(uniformName: string, x: number, y: number): Effect;
  95700. /**
  95701. * Sets a Vector3 on a uniform variable.
  95702. * @param uniformName Name of the variable.
  95703. * @param vector3 Value to be set.
  95704. * @returns this effect.
  95705. */
  95706. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95707. /**
  95708. * Sets a float3 on a uniform variable.
  95709. * @param uniformName Name of the variable.
  95710. * @param x First float in float3.
  95711. * @param y Second float in float3.
  95712. * @param z Third float in float3.
  95713. * @returns this effect.
  95714. */
  95715. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95716. /**
  95717. * Sets a Vector4 on a uniform variable.
  95718. * @param uniformName Name of the variable.
  95719. * @param vector4 Value to be set.
  95720. * @returns this effect.
  95721. */
  95722. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95723. /**
  95724. * Sets a float4 on a uniform variable.
  95725. * @param uniformName Name of the variable.
  95726. * @param x First float in float4.
  95727. * @param y Second float in float4.
  95728. * @param z Third float in float4.
  95729. * @param w Fourth float in float4.
  95730. * @returns this effect.
  95731. */
  95732. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95733. /**
  95734. * Sets a Color3 on a uniform variable.
  95735. * @param uniformName Name of the variable.
  95736. * @param color3 Value to be set.
  95737. * @returns this effect.
  95738. */
  95739. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95740. /**
  95741. * Sets a Color4 on a uniform variable.
  95742. * @param uniformName Name of the variable.
  95743. * @param color3 Value to be set.
  95744. * @param alpha Alpha value to be set.
  95745. * @returns this effect.
  95746. */
  95747. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95748. /**
  95749. * Sets a Color4 on a uniform variable
  95750. * @param uniformName defines the name of the variable
  95751. * @param color4 defines the value to be set
  95752. * @returns this effect.
  95753. */
  95754. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95755. /** Release all associated resources */
  95756. dispose(): void;
  95757. /**
  95758. * This function will add a new shader to the shader store
  95759. * @param name the name of the shader
  95760. * @param pixelShader optional pixel shader content
  95761. * @param vertexShader optional vertex shader content
  95762. */
  95763. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95764. /**
  95765. * Store of each shader (The can be looked up using effect.key)
  95766. */
  95767. static ShadersStore: {
  95768. [key: string]: string;
  95769. };
  95770. /**
  95771. * Store of each included file for a shader (The can be looked up using effect.key)
  95772. */
  95773. static IncludesShadersStore: {
  95774. [key: string]: string;
  95775. };
  95776. /**
  95777. * Resets the cache of effects.
  95778. */
  95779. static ResetCache(): void;
  95780. }
  95781. }
  95782. declare module BABYLON {
  95783. /**
  95784. * Class used to describe the capabilities of the engine relatively to the current browser
  95785. */
  95786. export class EngineCapabilities {
  95787. /** Maximum textures units per fragment shader */
  95788. maxTexturesImageUnits: number;
  95789. /** Maximum texture units per vertex shader */
  95790. maxVertexTextureImageUnits: number;
  95791. /** Maximum textures units in the entire pipeline */
  95792. maxCombinedTexturesImageUnits: number;
  95793. /** Maximum texture size */
  95794. maxTextureSize: number;
  95795. /** Maximum cube texture size */
  95796. maxCubemapTextureSize: number;
  95797. /** Maximum render texture size */
  95798. maxRenderTextureSize: number;
  95799. /** Maximum number of vertex attributes */
  95800. maxVertexAttribs: number;
  95801. /** Maximum number of varyings */
  95802. maxVaryingVectors: number;
  95803. /** Maximum number of uniforms per vertex shader */
  95804. maxVertexUniformVectors: number;
  95805. /** Maximum number of uniforms per fragment shader */
  95806. maxFragmentUniformVectors: number;
  95807. /** Defines if standard derivates (dx/dy) are supported */
  95808. standardDerivatives: boolean;
  95809. /** Defines if s3tc texture compression is supported */
  95810. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95811. /** Defines if pvrtc texture compression is supported */
  95812. pvrtc: any;
  95813. /** Defines if etc1 texture compression is supported */
  95814. etc1: any;
  95815. /** Defines if etc2 texture compression is supported */
  95816. etc2: any;
  95817. /** Defines if astc texture compression is supported */
  95818. astc: any;
  95819. /** Defines if float textures are supported */
  95820. textureFloat: boolean;
  95821. /** Defines if vertex array objects are supported */
  95822. vertexArrayObject: boolean;
  95823. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95824. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95825. /** Gets the maximum level of anisotropy supported */
  95826. maxAnisotropy: number;
  95827. /** Defines if instancing is supported */
  95828. instancedArrays: boolean;
  95829. /** Defines if 32 bits indices are supported */
  95830. uintIndices: boolean;
  95831. /** Defines if high precision shaders are supported */
  95832. highPrecisionShaderSupported: boolean;
  95833. /** Defines if depth reading in the fragment shader is supported */
  95834. fragmentDepthSupported: boolean;
  95835. /** Defines if float texture linear filtering is supported*/
  95836. textureFloatLinearFiltering: boolean;
  95837. /** Defines if rendering to float textures is supported */
  95838. textureFloatRender: boolean;
  95839. /** Defines if half float textures are supported*/
  95840. textureHalfFloat: boolean;
  95841. /** Defines if half float texture linear filtering is supported*/
  95842. textureHalfFloatLinearFiltering: boolean;
  95843. /** Defines if rendering to half float textures is supported */
  95844. textureHalfFloatRender: boolean;
  95845. /** Defines if textureLOD shader command is supported */
  95846. textureLOD: boolean;
  95847. /** Defines if draw buffers extension is supported */
  95848. drawBuffersExtension: boolean;
  95849. /** Defines if depth textures are supported */
  95850. depthTextureExtension: boolean;
  95851. /** Defines if float color buffer are supported */
  95852. colorBufferFloat: boolean;
  95853. /** Gets disjoint timer query extension (null if not supported) */
  95854. timerQuery: EXT_disjoint_timer_query;
  95855. /** Defines if timestamp can be used with timer query */
  95856. canUseTimestampForTimerQuery: boolean;
  95857. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95858. multiview: any;
  95859. /** Function used to let the system compiles shaders in background */
  95860. parallelShaderCompile: {
  95861. COMPLETION_STATUS_KHR: number;
  95862. };
  95863. /** Max number of texture samples for MSAA */
  95864. maxMSAASamples: number;
  95865. /** Defines if the blend min max extension is supported */
  95866. blendMinMax: boolean;
  95867. }
  95868. }
  95869. declare module BABYLON {
  95870. /**
  95871. * @hidden
  95872. **/
  95873. export class DepthCullingState {
  95874. private _isDepthTestDirty;
  95875. private _isDepthMaskDirty;
  95876. private _isDepthFuncDirty;
  95877. private _isCullFaceDirty;
  95878. private _isCullDirty;
  95879. private _isZOffsetDirty;
  95880. private _isFrontFaceDirty;
  95881. private _depthTest;
  95882. private _depthMask;
  95883. private _depthFunc;
  95884. private _cull;
  95885. private _cullFace;
  95886. private _zOffset;
  95887. private _frontFace;
  95888. /**
  95889. * Initializes the state.
  95890. */
  95891. constructor();
  95892. readonly isDirty: boolean;
  95893. zOffset: number;
  95894. cullFace: Nullable<number>;
  95895. cull: Nullable<boolean>;
  95896. depthFunc: Nullable<number>;
  95897. depthMask: boolean;
  95898. depthTest: boolean;
  95899. frontFace: Nullable<number>;
  95900. reset(): void;
  95901. apply(gl: WebGLRenderingContext): void;
  95902. }
  95903. }
  95904. declare module BABYLON {
  95905. /**
  95906. * @hidden
  95907. **/
  95908. export class StencilState {
  95909. /** 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 */
  95910. static readonly ALWAYS: number;
  95911. /** Passed to stencilOperation to specify that stencil value must be kept */
  95912. static readonly KEEP: number;
  95913. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95914. static readonly REPLACE: number;
  95915. private _isStencilTestDirty;
  95916. private _isStencilMaskDirty;
  95917. private _isStencilFuncDirty;
  95918. private _isStencilOpDirty;
  95919. private _stencilTest;
  95920. private _stencilMask;
  95921. private _stencilFunc;
  95922. private _stencilFuncRef;
  95923. private _stencilFuncMask;
  95924. private _stencilOpStencilFail;
  95925. private _stencilOpDepthFail;
  95926. private _stencilOpStencilDepthPass;
  95927. readonly isDirty: boolean;
  95928. stencilFunc: number;
  95929. stencilFuncRef: number;
  95930. stencilFuncMask: number;
  95931. stencilOpStencilFail: number;
  95932. stencilOpDepthFail: number;
  95933. stencilOpStencilDepthPass: number;
  95934. stencilMask: number;
  95935. stencilTest: boolean;
  95936. constructor();
  95937. reset(): void;
  95938. apply(gl: WebGLRenderingContext): void;
  95939. }
  95940. }
  95941. declare module BABYLON {
  95942. /**
  95943. * @hidden
  95944. **/
  95945. export class AlphaState {
  95946. private _isAlphaBlendDirty;
  95947. private _isBlendFunctionParametersDirty;
  95948. private _isBlendEquationParametersDirty;
  95949. private _isBlendConstantsDirty;
  95950. private _alphaBlend;
  95951. private _blendFunctionParameters;
  95952. private _blendEquationParameters;
  95953. private _blendConstants;
  95954. /**
  95955. * Initializes the state.
  95956. */
  95957. constructor();
  95958. readonly isDirty: boolean;
  95959. alphaBlend: boolean;
  95960. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95961. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95962. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95963. reset(): void;
  95964. apply(gl: WebGLRenderingContext): void;
  95965. }
  95966. }
  95967. declare module BABYLON {
  95968. /** @hidden */
  95969. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95970. attributeProcessor(attribute: string): string;
  95971. varyingProcessor(varying: string, isFragment: boolean): string;
  95972. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95973. }
  95974. }
  95975. declare module BABYLON {
  95976. /**
  95977. * Interface for attribute information associated with buffer instanciation
  95978. */
  95979. export class InstancingAttributeInfo {
  95980. /**
  95981. * Index/offset of the attribute in the vertex shader
  95982. */
  95983. index: number;
  95984. /**
  95985. * size of the attribute, 1, 2, 3 or 4
  95986. */
  95987. attributeSize: number;
  95988. /**
  95989. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95990. * default is FLOAT
  95991. */
  95992. attribyteType: number;
  95993. /**
  95994. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95995. */
  95996. normalized: boolean;
  95997. /**
  95998. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95999. */
  96000. offset: number;
  96001. /**
  96002. * Name of the GLSL attribute, for debugging purpose only
  96003. */
  96004. attributeName: string;
  96005. }
  96006. }
  96007. declare module BABYLON {
  96008. interface ThinEngine {
  96009. /**
  96010. * Update a video texture
  96011. * @param texture defines the texture to update
  96012. * @param video defines the video element to use
  96013. * @param invertY defines if data must be stored with Y axis inverted
  96014. */
  96015. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96016. }
  96017. }
  96018. declare module BABYLON {
  96019. /**
  96020. * Settings for finer control over video usage
  96021. */
  96022. export interface VideoTextureSettings {
  96023. /**
  96024. * Applies `autoplay` to video, if specified
  96025. */
  96026. autoPlay?: boolean;
  96027. /**
  96028. * Applies `loop` to video, if specified
  96029. */
  96030. loop?: boolean;
  96031. /**
  96032. * Automatically updates internal texture from video at every frame in the render loop
  96033. */
  96034. autoUpdateTexture: boolean;
  96035. /**
  96036. * Image src displayed during the video loading or until the user interacts with the video.
  96037. */
  96038. poster?: string;
  96039. }
  96040. /**
  96041. * If you want to display a video in your scene, this is the special texture for that.
  96042. * This special texture works similar to other textures, with the exception of a few parameters.
  96043. * @see https://doc.babylonjs.com/how_to/video_texture
  96044. */
  96045. export class VideoTexture extends Texture {
  96046. /**
  96047. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96048. */
  96049. readonly autoUpdateTexture: boolean;
  96050. /**
  96051. * The video instance used by the texture internally
  96052. */
  96053. readonly video: HTMLVideoElement;
  96054. private _onUserActionRequestedObservable;
  96055. /**
  96056. * Event triggerd when a dom action is required by the user to play the video.
  96057. * This happens due to recent changes in browser policies preventing video to auto start.
  96058. */
  96059. readonly onUserActionRequestedObservable: Observable<Texture>;
  96060. private _generateMipMaps;
  96061. private _engine;
  96062. private _stillImageCaptured;
  96063. private _displayingPosterTexture;
  96064. private _settings;
  96065. private _createInternalTextureOnEvent;
  96066. private _frameId;
  96067. /**
  96068. * Creates a video texture.
  96069. * If you want to display a video in your scene, this is the special texture for that.
  96070. * This special texture works similar to other textures, with the exception of a few parameters.
  96071. * @see https://doc.babylonjs.com/how_to/video_texture
  96072. * @param name optional name, will detect from video source, if not defined
  96073. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96074. * @param scene is obviously the current scene.
  96075. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96076. * @param invertY is false by default but can be used to invert video on Y axis
  96077. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96078. * @param settings allows finer control over video usage
  96079. */
  96080. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96081. private _getName;
  96082. private _getVideo;
  96083. private _createInternalTexture;
  96084. private reset;
  96085. /**
  96086. * @hidden Internal method to initiate `update`.
  96087. */
  96088. _rebuild(): void;
  96089. /**
  96090. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96091. */
  96092. update(): void;
  96093. /**
  96094. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96095. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96096. */
  96097. updateTexture(isVisible: boolean): void;
  96098. protected _updateInternalTexture: () => void;
  96099. /**
  96100. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96101. * @param url New url.
  96102. */
  96103. updateURL(url: string): void;
  96104. /**
  96105. * Dispose the texture and release its associated resources.
  96106. */
  96107. dispose(): void;
  96108. /**
  96109. * Creates a video texture straight from a stream.
  96110. * @param scene Define the scene the texture should be created in
  96111. * @param stream Define the stream the texture should be created from
  96112. * @returns The created video texture as a promise
  96113. */
  96114. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96115. /**
  96116. * Creates a video texture straight from your WebCam video feed.
  96117. * @param scene Define the scene the texture should be created in
  96118. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96119. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96120. * @returns The created video texture as a promise
  96121. */
  96122. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96123. minWidth: number;
  96124. maxWidth: number;
  96125. minHeight: number;
  96126. maxHeight: number;
  96127. deviceId: string;
  96128. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96129. /**
  96130. * Creates a video texture straight from your WebCam video feed.
  96131. * @param scene Define the scene the texture should be created in
  96132. * @param onReady Define a callback to triggered once the texture will be ready
  96133. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96134. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96135. */
  96136. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96137. minWidth: number;
  96138. maxWidth: number;
  96139. minHeight: number;
  96140. maxHeight: number;
  96141. deviceId: string;
  96142. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96143. }
  96144. }
  96145. declare module BABYLON {
  96146. /**
  96147. * Defines the interface used by objects working like Scene
  96148. * @hidden
  96149. */
  96150. interface ISceneLike {
  96151. _addPendingData(data: any): void;
  96152. _removePendingData(data: any): void;
  96153. offlineProvider: IOfflineProvider;
  96154. }
  96155. /** Interface defining initialization parameters for Engine class */
  96156. export interface EngineOptions extends WebGLContextAttributes {
  96157. /**
  96158. * Defines if the engine should no exceed a specified device ratio
  96159. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96160. */
  96161. limitDeviceRatio?: number;
  96162. /**
  96163. * Defines if webvr should be enabled automatically
  96164. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96165. */
  96166. autoEnableWebVR?: boolean;
  96167. /**
  96168. * Defines if webgl2 should be turned off even if supported
  96169. * @see http://doc.babylonjs.com/features/webgl2
  96170. */
  96171. disableWebGL2Support?: boolean;
  96172. /**
  96173. * Defines if webaudio should be initialized as well
  96174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96175. */
  96176. audioEngine?: boolean;
  96177. /**
  96178. * Defines if animations should run using a deterministic lock step
  96179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96180. */
  96181. deterministicLockstep?: boolean;
  96182. /** Defines the maximum steps to use with deterministic lock step mode */
  96183. lockstepMaxSteps?: number;
  96184. /**
  96185. * Defines that engine should ignore context lost events
  96186. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96187. */
  96188. doNotHandleContextLost?: boolean;
  96189. /**
  96190. * Defines that engine should ignore modifying touch action attribute and style
  96191. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96192. */
  96193. doNotHandleTouchAction?: boolean;
  96194. /**
  96195. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96196. */
  96197. useHighPrecisionFloats?: boolean;
  96198. }
  96199. /**
  96200. * The base engine class (root of all engines)
  96201. */
  96202. export class ThinEngine {
  96203. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96204. static ExceptionList: ({
  96205. key: string;
  96206. capture: string;
  96207. captureConstraint: number;
  96208. targets: string[];
  96209. } | {
  96210. key: string;
  96211. capture: null;
  96212. captureConstraint: null;
  96213. targets: string[];
  96214. })[];
  96215. /** @hidden */
  96216. static _TextureLoaders: IInternalTextureLoader[];
  96217. /**
  96218. * Returns the current npm package of the sdk
  96219. */
  96220. static readonly NpmPackage: string;
  96221. /**
  96222. * Returns the current version of the framework
  96223. */
  96224. static readonly Version: string;
  96225. /**
  96226. * Returns a string describing the current engine
  96227. */
  96228. readonly description: string;
  96229. /**
  96230. * Gets or sets the epsilon value used by collision engine
  96231. */
  96232. static CollisionsEpsilon: number;
  96233. /**
  96234. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96235. */
  96236. static ShadersRepository: string;
  96237. /** @hidden */
  96238. _shaderProcessor: IShaderProcessor;
  96239. /**
  96240. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96241. */
  96242. forcePOTTextures: boolean;
  96243. /**
  96244. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96245. */
  96246. isFullscreen: boolean;
  96247. /**
  96248. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96249. */
  96250. cullBackFaces: boolean;
  96251. /**
  96252. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96253. */
  96254. renderEvenInBackground: boolean;
  96255. /**
  96256. * Gets or sets a boolean indicating that cache can be kept between frames
  96257. */
  96258. preventCacheWipeBetweenFrames: boolean;
  96259. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96260. validateShaderPrograms: boolean;
  96261. /**
  96262. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96263. */
  96264. disableUniformBuffers: boolean;
  96265. /** @hidden */
  96266. _uniformBuffers: UniformBuffer[];
  96267. /**
  96268. * Gets a boolean indicating that the engine supports uniform buffers
  96269. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96270. */
  96271. readonly supportsUniformBuffers: boolean;
  96272. /** @hidden */
  96273. _gl: WebGLRenderingContext;
  96274. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96275. protected _windowIsBackground: boolean;
  96276. protected _webGLVersion: number;
  96277. protected _highPrecisionShadersAllowed: boolean;
  96278. /** @hidden */
  96279. readonly _shouldUseHighPrecisionShader: boolean;
  96280. /**
  96281. * Gets a boolean indicating that only power of 2 textures are supported
  96282. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96283. */
  96284. readonly needPOTTextures: boolean;
  96285. /** @hidden */
  96286. _badOS: boolean;
  96287. /** @hidden */
  96288. _badDesktopOS: boolean;
  96289. private _hardwareScalingLevel;
  96290. /** @hidden */
  96291. _caps: EngineCapabilities;
  96292. private _isStencilEnable;
  96293. protected _colorWrite: boolean;
  96294. private _glVersion;
  96295. private _glRenderer;
  96296. private _glVendor;
  96297. /** @hidden */
  96298. _videoTextureSupported: boolean;
  96299. protected _renderingQueueLaunched: boolean;
  96300. protected _activeRenderLoops: (() => void)[];
  96301. /**
  96302. * Observable signaled when a context lost event is raised
  96303. */
  96304. onContextLostObservable: Observable<ThinEngine>;
  96305. /**
  96306. * Observable signaled when a context restored event is raised
  96307. */
  96308. onContextRestoredObservable: Observable<ThinEngine>;
  96309. private _onContextLost;
  96310. private _onContextRestored;
  96311. protected _contextWasLost: boolean;
  96312. /** @hidden */
  96313. _doNotHandleContextLost: boolean;
  96314. /**
  96315. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96317. */
  96318. doNotHandleContextLost: boolean;
  96319. /**
  96320. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96321. */
  96322. disableVertexArrayObjects: boolean;
  96323. /** @hidden */
  96324. protected _depthCullingState: DepthCullingState;
  96325. /** @hidden */
  96326. protected _stencilState: StencilState;
  96327. /** @hidden */
  96328. protected _alphaState: AlphaState;
  96329. /** @hidden */
  96330. _internalTexturesCache: InternalTexture[];
  96331. /** @hidden */
  96332. protected _activeChannel: number;
  96333. private _currentTextureChannel;
  96334. /** @hidden */
  96335. protected _boundTexturesCache: {
  96336. [key: string]: Nullable<InternalTexture>;
  96337. };
  96338. /** @hidden */
  96339. protected _currentEffect: Nullable<Effect>;
  96340. /** @hidden */
  96341. protected _currentProgram: Nullable<WebGLProgram>;
  96342. private _compiledEffects;
  96343. private _vertexAttribArraysEnabled;
  96344. /** @hidden */
  96345. protected _cachedViewport: Nullable<IViewportLike>;
  96346. private _cachedVertexArrayObject;
  96347. /** @hidden */
  96348. protected _cachedVertexBuffers: any;
  96349. /** @hidden */
  96350. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96351. /** @hidden */
  96352. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96353. /** @hidden */
  96354. _currentRenderTarget: Nullable<InternalTexture>;
  96355. private _uintIndicesCurrentlySet;
  96356. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96357. /** @hidden */
  96358. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96359. private _currentBufferPointers;
  96360. private _currentInstanceLocations;
  96361. private _currentInstanceBuffers;
  96362. private _textureUnits;
  96363. /** @hidden */
  96364. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96365. /** @hidden */
  96366. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96367. /** @hidden */
  96368. _bindedRenderFunction: any;
  96369. private _vaoRecordInProgress;
  96370. private _mustWipeVertexAttributes;
  96371. private _emptyTexture;
  96372. private _emptyCubeTexture;
  96373. private _emptyTexture3D;
  96374. /** @hidden */
  96375. _frameHandler: number;
  96376. private _nextFreeTextureSlots;
  96377. private _maxSimultaneousTextures;
  96378. private _activeRequests;
  96379. protected _texturesSupported: string[];
  96380. /** @hidden */
  96381. _textureFormatInUse: Nullable<string>;
  96382. protected readonly _supportsHardwareTextureRescaling: boolean;
  96383. /**
  96384. * Gets the list of texture formats supported
  96385. */
  96386. readonly texturesSupported: Array<string>;
  96387. /**
  96388. * Gets the list of texture formats in use
  96389. */
  96390. readonly textureFormatInUse: Nullable<string>;
  96391. /**
  96392. * Gets the current viewport
  96393. */
  96394. readonly currentViewport: Nullable<IViewportLike>;
  96395. /**
  96396. * Gets the default empty texture
  96397. */
  96398. readonly emptyTexture: InternalTexture;
  96399. /**
  96400. * Gets the default empty 3D texture
  96401. */
  96402. readonly emptyTexture3D: InternalTexture;
  96403. /**
  96404. * Gets the default empty cube texture
  96405. */
  96406. readonly emptyCubeTexture: InternalTexture;
  96407. /**
  96408. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96409. */
  96410. readonly premultipliedAlpha: boolean;
  96411. /**
  96412. * Observable event triggered before each texture is initialized
  96413. */
  96414. onBeforeTextureInitObservable: Observable<Texture>;
  96415. /**
  96416. * Creates a new engine
  96417. * @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
  96418. * @param antialias defines enable antialiasing (default: false)
  96419. * @param options defines further options to be sent to the getContext() function
  96420. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96421. */
  96422. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96423. private _rebuildInternalTextures;
  96424. private _rebuildEffects;
  96425. /**
  96426. * Gets a boolean indicating if all created effects are ready
  96427. * @returns true if all effects are ready
  96428. */
  96429. areAllEffectsReady(): boolean;
  96430. protected _rebuildBuffers(): void;
  96431. private _initGLContext;
  96432. /**
  96433. * Gets version of the current webGL context
  96434. */
  96435. readonly webGLVersion: number;
  96436. /**
  96437. * Gets a string idenfifying the name of the class
  96438. * @returns "Engine" string
  96439. */
  96440. getClassName(): string;
  96441. /**
  96442. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96443. */
  96444. readonly isStencilEnable: boolean;
  96445. /** @hidden */
  96446. _prepareWorkingCanvas(): void;
  96447. /**
  96448. * Reset the texture cache to empty state
  96449. */
  96450. resetTextureCache(): void;
  96451. /**
  96452. * Gets an object containing information about the current webGL context
  96453. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96454. */
  96455. getGlInfo(): {
  96456. vendor: string;
  96457. renderer: string;
  96458. version: string;
  96459. };
  96460. /**
  96461. * Defines the hardware scaling level.
  96462. * By default the hardware scaling level is computed from the window device ratio.
  96463. * 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.
  96464. * @param level defines the level to use
  96465. */
  96466. setHardwareScalingLevel(level: number): void;
  96467. /**
  96468. * Gets the current hardware scaling level.
  96469. * By default the hardware scaling level is computed from the window device ratio.
  96470. * 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.
  96471. * @returns a number indicating the current hardware scaling level
  96472. */
  96473. getHardwareScalingLevel(): number;
  96474. /**
  96475. * Gets the list of loaded textures
  96476. * @returns an array containing all loaded textures
  96477. */
  96478. getLoadedTexturesCache(): InternalTexture[];
  96479. /**
  96480. * Gets the object containing all engine capabilities
  96481. * @returns the EngineCapabilities object
  96482. */
  96483. getCaps(): EngineCapabilities;
  96484. /**
  96485. * stop executing a render loop function and remove it from the execution array
  96486. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96487. */
  96488. stopRenderLoop(renderFunction?: () => void): void;
  96489. /** @hidden */
  96490. _renderLoop(): void;
  96491. /**
  96492. * Gets the HTML canvas attached with the current webGL context
  96493. * @returns a HTML canvas
  96494. */
  96495. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96496. /**
  96497. * Gets host window
  96498. * @returns the host window object
  96499. */
  96500. getHostWindow(): Nullable<Window>;
  96501. /**
  96502. * Gets the current render width
  96503. * @param useScreen defines if screen size must be used (or the current render target if any)
  96504. * @returns a number defining the current render width
  96505. */
  96506. getRenderWidth(useScreen?: boolean): number;
  96507. /**
  96508. * Gets the current render height
  96509. * @param useScreen defines if screen size must be used (or the current render target if any)
  96510. * @returns a number defining the current render height
  96511. */
  96512. getRenderHeight(useScreen?: boolean): number;
  96513. /**
  96514. * Can be used to override the current requestAnimationFrame requester.
  96515. * @hidden
  96516. */
  96517. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96518. /**
  96519. * Register and execute a render loop. The engine can have more than one render function
  96520. * @param renderFunction defines the function to continuously execute
  96521. */
  96522. runRenderLoop(renderFunction: () => void): void;
  96523. /**
  96524. * Clear the current render buffer or the current render target (if any is set up)
  96525. * @param color defines the color to use
  96526. * @param backBuffer defines if the back buffer must be cleared
  96527. * @param depth defines if the depth buffer must be cleared
  96528. * @param stencil defines if the stencil buffer must be cleared
  96529. */
  96530. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96531. private _viewportCached;
  96532. /** @hidden */
  96533. _viewport(x: number, y: number, width: number, height: number): void;
  96534. /**
  96535. * Set the WebGL's viewport
  96536. * @param viewport defines the viewport element to be used
  96537. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96538. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96539. */
  96540. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96541. /**
  96542. * Begin a new frame
  96543. */
  96544. beginFrame(): void;
  96545. /**
  96546. * Enf the current frame
  96547. */
  96548. endFrame(): void;
  96549. /**
  96550. * Resize the view according to the canvas' size
  96551. */
  96552. resize(): void;
  96553. /**
  96554. * Force a specific size of the canvas
  96555. * @param width defines the new canvas' width
  96556. * @param height defines the new canvas' height
  96557. */
  96558. setSize(width: number, height: number): void;
  96559. /**
  96560. * Binds the frame buffer to the specified texture.
  96561. * @param texture The texture to render to or null for the default canvas
  96562. * @param faceIndex The face of the texture to render to in case of cube texture
  96563. * @param requiredWidth The width of the target to render to
  96564. * @param requiredHeight The height of the target to render to
  96565. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96566. * @param depthStencilTexture The depth stencil texture to use to render
  96567. * @param lodLevel defines le lod level to bind to the frame buffer
  96568. */
  96569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96570. /** @hidden */
  96571. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96572. /**
  96573. * Unbind the current render target texture from the webGL context
  96574. * @param texture defines the render target texture to unbind
  96575. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96576. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96577. */
  96578. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96579. /**
  96580. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96581. */
  96582. flushFramebuffer(): void;
  96583. /**
  96584. * Unbind the current render target and bind the default framebuffer
  96585. */
  96586. restoreDefaultFramebuffer(): void;
  96587. private _resetVertexBufferBinding;
  96588. /**
  96589. * Creates a vertex buffer
  96590. * @param data the data for the vertex buffer
  96591. * @returns the new WebGL static buffer
  96592. */
  96593. createVertexBuffer(data: DataArray): DataBuffer;
  96594. private _createVertexBuffer;
  96595. /**
  96596. * Creates a dynamic vertex buffer
  96597. * @param data the data for the dynamic vertex buffer
  96598. * @returns the new WebGL dynamic buffer
  96599. */
  96600. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96601. /**
  96602. * Updates a dynamic vertex buffer.
  96603. * @param vertexBuffer the vertex buffer to update
  96604. * @param data the data used to update the vertex buffer
  96605. * @param byteOffset the byte offset of the data
  96606. * @param byteLength the byte length of the data
  96607. */
  96608. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96609. protected _resetIndexBufferBinding(): void;
  96610. /**
  96611. * Creates a new index buffer
  96612. * @param indices defines the content of the index buffer
  96613. * @param updatable defines if the index buffer must be updatable
  96614. * @returns a new webGL buffer
  96615. */
  96616. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96617. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96618. /**
  96619. * Bind a webGL buffer to the webGL context
  96620. * @param buffer defines the buffer to bind
  96621. */
  96622. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96623. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96624. private bindBuffer;
  96625. /**
  96626. * update the bound buffer with the given data
  96627. * @param data defines the data to update
  96628. */
  96629. updateArrayBuffer(data: Float32Array): void;
  96630. private _vertexAttribPointer;
  96631. private _bindIndexBufferWithCache;
  96632. private _bindVertexBuffersAttributes;
  96633. /**
  96634. * Records a vertex array object
  96635. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96636. * @param vertexBuffers defines the list of vertex buffers to store
  96637. * @param indexBuffer defines the index buffer to store
  96638. * @param effect defines the effect to store
  96639. * @returns the new vertex array object
  96640. */
  96641. recordVertexArrayObject(vertexBuffers: {
  96642. [key: string]: VertexBuffer;
  96643. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96644. /**
  96645. * Bind a specific vertex array object
  96646. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96647. * @param vertexArrayObject defines the vertex array object to bind
  96648. * @param indexBuffer defines the index buffer to bind
  96649. */
  96650. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96651. /**
  96652. * Bind webGl buffers directly to the webGL context
  96653. * @param vertexBuffer defines the vertex buffer to bind
  96654. * @param indexBuffer defines the index buffer to bind
  96655. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96656. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96657. * @param effect defines the effect associated with the vertex buffer
  96658. */
  96659. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96660. private _unbindVertexArrayObject;
  96661. /**
  96662. * Bind a list of vertex buffers to the webGL context
  96663. * @param vertexBuffers defines the list of vertex buffers to bind
  96664. * @param indexBuffer defines the index buffer to bind
  96665. * @param effect defines the effect associated with the vertex buffers
  96666. */
  96667. bindBuffers(vertexBuffers: {
  96668. [key: string]: Nullable<VertexBuffer>;
  96669. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96670. /**
  96671. * Unbind all instance attributes
  96672. */
  96673. unbindInstanceAttributes(): void;
  96674. /**
  96675. * Release and free the memory of a vertex array object
  96676. * @param vao defines the vertex array object to delete
  96677. */
  96678. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96679. /** @hidden */
  96680. _releaseBuffer(buffer: DataBuffer): boolean;
  96681. protected _deleteBuffer(buffer: DataBuffer): void;
  96682. /**
  96683. * Creates a webGL buffer to use with instanciation
  96684. * @param capacity defines the size of the buffer
  96685. * @returns the webGL buffer
  96686. */
  96687. createInstancesBuffer(capacity: number): DataBuffer;
  96688. /**
  96689. * Delete a webGL buffer used with instanciation
  96690. * @param buffer defines the webGL buffer to delete
  96691. */
  96692. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96693. /**
  96694. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96695. * @param instancesBuffer defines the webGL buffer to update and bind
  96696. * @param data defines the data to store in the buffer
  96697. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96698. */
  96699. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96700. /**
  96701. * Apply all cached states (depth, culling, stencil and alpha)
  96702. */
  96703. applyStates(): void;
  96704. /**
  96705. * Send a draw order
  96706. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96707. * @param indexStart defines the starting index
  96708. * @param indexCount defines the number of index to draw
  96709. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96710. */
  96711. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96712. /**
  96713. * Draw a list of points
  96714. * @param verticesStart defines the index of first vertex to draw
  96715. * @param verticesCount defines the count of vertices to draw
  96716. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96717. */
  96718. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96719. /**
  96720. * Draw a list of unindexed primitives
  96721. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96722. * @param verticesStart defines the index of first vertex to draw
  96723. * @param verticesCount defines the count of vertices to draw
  96724. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96725. */
  96726. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96727. /**
  96728. * Draw a list of indexed primitives
  96729. * @param fillMode defines the primitive to use
  96730. * @param indexStart defines the starting index
  96731. * @param indexCount defines the number of index to draw
  96732. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96733. */
  96734. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96735. /**
  96736. * Draw a list of unindexed primitives
  96737. * @param fillMode defines the primitive to use
  96738. * @param verticesStart defines the index of first vertex to draw
  96739. * @param verticesCount defines the count of vertices to draw
  96740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96741. */
  96742. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96743. private _drawMode;
  96744. /** @hidden */
  96745. protected _reportDrawCall(): void;
  96746. /** @hidden */
  96747. _releaseEffect(effect: Effect): void;
  96748. /** @hidden */
  96749. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96750. /**
  96751. * Create a new effect (used to store vertex/fragment shaders)
  96752. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96753. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96754. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96755. * @param samplers defines an array of string used to represent textures
  96756. * @param defines defines the string containing the defines to use to compile the shaders
  96757. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96758. * @param onCompiled defines a function to call when the effect creation is successful
  96759. * @param onError defines a function to call when the effect creation has failed
  96760. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96761. * @returns the new Effect
  96762. */
  96763. 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;
  96764. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96765. private _compileShader;
  96766. private _compileRawShader;
  96767. /**
  96768. * Directly creates a webGL program
  96769. * @param pipelineContext defines the pipeline context to attach to
  96770. * @param vertexCode defines the vertex shader code to use
  96771. * @param fragmentCode defines the fragment shader code to use
  96772. * @param context defines the webGL context to use (if not set, the current one will be used)
  96773. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96774. * @returns the new webGL program
  96775. */
  96776. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96777. /**
  96778. * Creates a webGL program
  96779. * @param pipelineContext defines the pipeline context to attach to
  96780. * @param vertexCode defines the vertex shader code to use
  96781. * @param fragmentCode defines the fragment shader code to use
  96782. * @param defines defines the string containing the defines to use to compile the shaders
  96783. * @param context defines the webGL context to use (if not set, the current one will be used)
  96784. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96785. * @returns the new webGL program
  96786. */
  96787. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96788. /**
  96789. * Creates a new pipeline context
  96790. * @returns the new pipeline
  96791. */
  96792. createPipelineContext(): IPipelineContext;
  96793. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96794. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96795. /** @hidden */
  96796. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96797. /** @hidden */
  96798. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96799. /** @hidden */
  96800. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96801. /**
  96802. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96803. * @param pipelineContext defines the pipeline context to use
  96804. * @param uniformsNames defines the list of uniform names
  96805. * @returns an array of webGL uniform locations
  96806. */
  96807. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96808. /**
  96809. * Gets the lsit of active attributes for a given webGL program
  96810. * @param pipelineContext defines the pipeline context to use
  96811. * @param attributesNames defines the list of attribute names to get
  96812. * @returns an array of indices indicating the offset of each attribute
  96813. */
  96814. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96815. /**
  96816. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96817. * @param effect defines the effect to activate
  96818. */
  96819. enableEffect(effect: Nullable<Effect>): void;
  96820. /**
  96821. * Set the value of an uniform to an array of int32
  96822. * @param uniform defines the webGL uniform location where to store the value
  96823. * @param array defines the array of int32 to store
  96824. */
  96825. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96826. /**
  96827. * Set the value of an uniform to an array of int32 (stored as vec2)
  96828. * @param uniform defines the webGL uniform location where to store the value
  96829. * @param array defines the array of int32 to store
  96830. */
  96831. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96832. /**
  96833. * Set the value of an uniform to an array of int32 (stored as vec3)
  96834. * @param uniform defines the webGL uniform location where to store the value
  96835. * @param array defines the array of int32 to store
  96836. */
  96837. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96838. /**
  96839. * Set the value of an uniform to an array of int32 (stored as vec4)
  96840. * @param uniform defines the webGL uniform location where to store the value
  96841. * @param array defines the array of int32 to store
  96842. */
  96843. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96844. /**
  96845. * Set the value of an uniform to an array of float32
  96846. * @param uniform defines the webGL uniform location where to store the value
  96847. * @param array defines the array of float32 to store
  96848. */
  96849. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96850. /**
  96851. * Set the value of an uniform to an array of float32 (stored as vec2)
  96852. * @param uniform defines the webGL uniform location where to store the value
  96853. * @param array defines the array of float32 to store
  96854. */
  96855. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96856. /**
  96857. * Set the value of an uniform to an array of float32 (stored as vec3)
  96858. * @param uniform defines the webGL uniform location where to store the value
  96859. * @param array defines the array of float32 to store
  96860. */
  96861. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96862. /**
  96863. * Set the value of an uniform to an array of float32 (stored as vec4)
  96864. * @param uniform defines the webGL uniform location where to store the value
  96865. * @param array defines the array of float32 to store
  96866. */
  96867. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96868. /**
  96869. * Set the value of an uniform to an array of number
  96870. * @param uniform defines the webGL uniform location where to store the value
  96871. * @param array defines the array of number to store
  96872. */
  96873. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96874. /**
  96875. * Set the value of an uniform to an array of number (stored as vec2)
  96876. * @param uniform defines the webGL uniform location where to store the value
  96877. * @param array defines the array of number to store
  96878. */
  96879. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96880. /**
  96881. * Set the value of an uniform to an array of number (stored as vec3)
  96882. * @param uniform defines the webGL uniform location where to store the value
  96883. * @param array defines the array of number to store
  96884. */
  96885. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96886. /**
  96887. * Set the value of an uniform to an array of number (stored as vec4)
  96888. * @param uniform defines the webGL uniform location where to store the value
  96889. * @param array defines the array of number to store
  96890. */
  96891. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96892. /**
  96893. * Set the value of an uniform to an array of float32 (stored as matrices)
  96894. * @param uniform defines the webGL uniform location where to store the value
  96895. * @param matrices defines the array of float32 to store
  96896. */
  96897. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96898. /**
  96899. * Set the value of an uniform to a matrix (3x3)
  96900. * @param uniform defines the webGL uniform location where to store the value
  96901. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96902. */
  96903. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96904. /**
  96905. * Set the value of an uniform to a matrix (2x2)
  96906. * @param uniform defines the webGL uniform location where to store the value
  96907. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96908. */
  96909. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96910. /**
  96911. * Set the value of an uniform to a number (int)
  96912. * @param uniform defines the webGL uniform location where to store the value
  96913. * @param value defines the int number to store
  96914. */
  96915. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96916. /**
  96917. * Set the value of an uniform to a number (float)
  96918. * @param uniform defines the webGL uniform location where to store the value
  96919. * @param value defines the float number to store
  96920. */
  96921. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96922. /**
  96923. * Set the value of an uniform to a vec2
  96924. * @param uniform defines the webGL uniform location where to store the value
  96925. * @param x defines the 1st component of the value
  96926. * @param y defines the 2nd component of the value
  96927. */
  96928. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96929. /**
  96930. * Set the value of an uniform to a vec3
  96931. * @param uniform defines the webGL uniform location where to store the value
  96932. * @param x defines the 1st component of the value
  96933. * @param y defines the 2nd component of the value
  96934. * @param z defines the 3rd component of the value
  96935. */
  96936. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96937. /**
  96938. * Set the value of an uniform to a boolean
  96939. * @param uniform defines the webGL uniform location where to store the value
  96940. * @param bool defines the boolean to store
  96941. */
  96942. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96943. /**
  96944. * Set the value of an uniform to a vec4
  96945. * @param uniform defines the webGL uniform location where to store the value
  96946. * @param x defines the 1st component of the value
  96947. * @param y defines the 2nd component of the value
  96948. * @param z defines the 3rd component of the value
  96949. * @param w defines the 4th component of the value
  96950. */
  96951. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96952. /**
  96953. * Sets a Color4 on a uniform variable
  96954. * @param uniform defines the uniform location
  96955. * @param color4 defines the value to be set
  96956. */
  96957. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96958. /**
  96959. * Gets the depth culling state manager
  96960. */
  96961. readonly depthCullingState: DepthCullingState;
  96962. /**
  96963. * Gets the alpha state manager
  96964. */
  96965. readonly alphaState: AlphaState;
  96966. /**
  96967. * Gets the stencil state manager
  96968. */
  96969. readonly stencilState: StencilState;
  96970. /**
  96971. * Clears the list of texture accessible through engine.
  96972. * This can help preventing texture load conflict due to name collision.
  96973. */
  96974. clearInternalTexturesCache(): void;
  96975. /**
  96976. * Force the entire cache to be cleared
  96977. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96978. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96979. */
  96980. wipeCaches(bruteForce?: boolean): void;
  96981. /** @hidden */
  96982. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96983. min: number;
  96984. mag: number;
  96985. };
  96986. /** @hidden */
  96987. _createTexture(): WebGLTexture;
  96988. /**
  96989. * Usually called from Texture.ts.
  96990. * Passed information to create a WebGLTexture
  96991. * @param urlArg defines a value which contains one of the following:
  96992. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96993. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96994. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96996. * @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)
  96997. * @param scene needed for loading to the correct scene
  96998. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96999. * @param onLoad optional callback to be called upon successful completion
  97000. * @param onError optional callback to be called upon failure
  97001. * @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
  97002. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97003. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97004. * @param forcedExtension defines the extension to use to pick the right loader
  97005. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97006. * @param mimeType defines an optional mime type
  97007. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97008. */
  97009. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97010. /**
  97011. * @hidden
  97012. */
  97013. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97014. /**
  97015. * Creates a raw texture
  97016. * @param data defines the data to store in the texture
  97017. * @param width defines the width of the texture
  97018. * @param height defines the height of the texture
  97019. * @param format defines the format of the data
  97020. * @param generateMipMaps defines if the engine should generate the mip levels
  97021. * @param invertY defines if data must be stored with Y axis inverted
  97022. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97023. * @param compression defines the compression used (null by default)
  97024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97025. * @returns the raw texture inside an InternalTexture
  97026. */
  97027. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97028. /**
  97029. * Creates a new raw cube texture
  97030. * @param data defines the array of data to use to create each face
  97031. * @param size defines the size of the textures
  97032. * @param format defines the format of the data
  97033. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97034. * @param generateMipMaps defines if the engine should generate the mip levels
  97035. * @param invertY defines if data must be stored with Y axis inverted
  97036. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97037. * @param compression defines the compression used (null by default)
  97038. * @returns the cube texture as an InternalTexture
  97039. */
  97040. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97041. /**
  97042. * Creates a new raw 3D texture
  97043. * @param data defines the data used to create the texture
  97044. * @param width defines the width of the texture
  97045. * @param height defines the height of the texture
  97046. * @param depth defines the depth of the texture
  97047. * @param format defines the format of the texture
  97048. * @param generateMipMaps defines if the engine must generate mip levels
  97049. * @param invertY defines if data must be stored with Y axis inverted
  97050. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97051. * @param compression defines the compressed used (can be null)
  97052. * @param textureType defines the compressed used (can be null)
  97053. * @returns a new raw 3D texture (stored in an InternalTexture)
  97054. */
  97055. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97056. private _unpackFlipYCached;
  97057. /**
  97058. * In case you are sharing the context with other applications, it might
  97059. * be interested to not cache the unpack flip y state to ensure a consistent
  97060. * value would be set.
  97061. */
  97062. enableUnpackFlipYCached: boolean;
  97063. /** @hidden */
  97064. _unpackFlipY(value: boolean): void;
  97065. /** @hidden */
  97066. _getUnpackAlignement(): number;
  97067. /**
  97068. * Update the sampling mode of a given texture
  97069. * @param samplingMode defines the required sampling mode
  97070. * @param texture defines the texture to update
  97071. */
  97072. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97073. /**
  97074. * Updates a depth texture Comparison Mode and Function.
  97075. * If the comparison Function is equal to 0, the mode will be set to none.
  97076. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97077. * @param texture The texture to set the comparison function for
  97078. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97079. */
  97080. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97081. /** @hidden */
  97082. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97083. width: number;
  97084. height: number;
  97085. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97086. /**
  97087. * Creates a depth stencil texture.
  97088. * This is only available in WebGL 2 or with the depth texture extension available.
  97089. * @param size The size of face edge in the texture.
  97090. * @param options The options defining the texture.
  97091. * @returns The texture
  97092. */
  97093. createDepthStencilTexture(size: number | {
  97094. width: number;
  97095. height: number;
  97096. }, options: DepthTextureCreationOptions): InternalTexture;
  97097. /**
  97098. * Creates a depth stencil texture.
  97099. * This is only available in WebGL 2 or with the depth texture extension available.
  97100. * @param size The size of face edge in the texture.
  97101. * @param options The options defining the texture.
  97102. * @returns The texture
  97103. */
  97104. private _createDepthStencilTexture;
  97105. /** @hidden */
  97106. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97107. /** @hidden */
  97108. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97109. /** @hidden */
  97110. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97111. /** @hidden */
  97112. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  97113. /**
  97114. * @hidden
  97115. */
  97116. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97117. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97118. private _prepareWebGLTexture;
  97119. /** @hidden */
  97120. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97121. /** @hidden */
  97122. _releaseFramebufferObjects(texture: InternalTexture): void;
  97123. /** @hidden */
  97124. _releaseTexture(texture: InternalTexture): void;
  97125. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97126. protected _setProgram(program: WebGLProgram): void;
  97127. protected _boundUniforms: {
  97128. [key: number]: WebGLUniformLocation;
  97129. };
  97130. /**
  97131. * Binds an effect to the webGL context
  97132. * @param effect defines the effect to bind
  97133. */
  97134. bindSamplers(effect: Effect): void;
  97135. private _activateCurrentTexture;
  97136. /** @hidden */
  97137. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97138. /** @hidden */
  97139. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97140. /**
  97141. * Unbind all textures from the webGL context
  97142. */
  97143. unbindAllTextures(): void;
  97144. /**
  97145. * Sets a texture to the according uniform.
  97146. * @param channel The texture channel
  97147. * @param uniform The uniform to set
  97148. * @param texture The texture to apply
  97149. */
  97150. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97151. private _bindSamplerUniformToChannel;
  97152. private _getTextureWrapMode;
  97153. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97154. /**
  97155. * Sets an array of texture to the webGL context
  97156. * @param channel defines the channel where the texture array must be set
  97157. * @param uniform defines the associated uniform location
  97158. * @param textures defines the array of textures to bind
  97159. */
  97160. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97161. /** @hidden */
  97162. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97163. private _setTextureParameterFloat;
  97164. private _setTextureParameterInteger;
  97165. /**
  97166. * Unbind all vertex attributes from the webGL context
  97167. */
  97168. unbindAllAttributes(): void;
  97169. /**
  97170. * 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
  97171. */
  97172. releaseEffects(): void;
  97173. /**
  97174. * Dispose and release all associated resources
  97175. */
  97176. dispose(): void;
  97177. /**
  97178. * Attach a new callback raised when context lost event is fired
  97179. * @param callback defines the callback to call
  97180. */
  97181. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97182. /**
  97183. * Attach a new callback raised when context restored event is fired
  97184. * @param callback defines the callback to call
  97185. */
  97186. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97187. /**
  97188. * Get the current error code of the webGL context
  97189. * @returns the error code
  97190. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97191. */
  97192. getError(): number;
  97193. private _canRenderToFloatFramebuffer;
  97194. private _canRenderToHalfFloatFramebuffer;
  97195. private _canRenderToFramebuffer;
  97196. /** @hidden */
  97197. _getWebGLTextureType(type: number): number;
  97198. /** @hidden */
  97199. _getInternalFormat(format: number): number;
  97200. /** @hidden */
  97201. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97202. /** @hidden */
  97203. _getRGBAMultiSampleBufferFormat(type: number): number;
  97204. /** @hidden */
  97205. _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;
  97206. /**
  97207. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97208. * @returns true if the engine can be created
  97209. * @ignorenaming
  97210. */
  97211. static isSupported(): boolean;
  97212. /**
  97213. * Find the next highest power of two.
  97214. * @param x Number to start search from.
  97215. * @return Next highest power of two.
  97216. */
  97217. static CeilingPOT(x: number): number;
  97218. /**
  97219. * Find the next lowest power of two.
  97220. * @param x Number to start search from.
  97221. * @return Next lowest power of two.
  97222. */
  97223. static FloorPOT(x: number): number;
  97224. /**
  97225. * Find the nearest power of two.
  97226. * @param x Number to start search from.
  97227. * @return Next nearest power of two.
  97228. */
  97229. static NearestPOT(x: number): number;
  97230. /**
  97231. * Get the closest exponent of two
  97232. * @param value defines the value to approximate
  97233. * @param max defines the maximum value to return
  97234. * @param mode defines how to define the closest value
  97235. * @returns closest exponent of two of the given value
  97236. */
  97237. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97238. /**
  97239. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97240. * @param func - the function to be called
  97241. * @param requester - the object that will request the next frame. Falls back to window.
  97242. * @returns frame number
  97243. */
  97244. static QueueNewFrame(func: () => void, requester?: any): number;
  97245. }
  97246. }
  97247. declare module BABYLON {
  97248. /**
  97249. * Class representing spherical harmonics coefficients to the 3rd degree
  97250. */
  97251. export class SphericalHarmonics {
  97252. /**
  97253. * Defines whether or not the harmonics have been prescaled for rendering.
  97254. */
  97255. preScaled: boolean;
  97256. /**
  97257. * The l0,0 coefficients of the spherical harmonics
  97258. */
  97259. l00: Vector3;
  97260. /**
  97261. * The l1,-1 coefficients of the spherical harmonics
  97262. */
  97263. l1_1: Vector3;
  97264. /**
  97265. * The l1,0 coefficients of the spherical harmonics
  97266. */
  97267. l10: Vector3;
  97268. /**
  97269. * The l1,1 coefficients of the spherical harmonics
  97270. */
  97271. l11: Vector3;
  97272. /**
  97273. * The l2,-2 coefficients of the spherical harmonics
  97274. */
  97275. l2_2: Vector3;
  97276. /**
  97277. * The l2,-1 coefficients of the spherical harmonics
  97278. */
  97279. l2_1: Vector3;
  97280. /**
  97281. * The l2,0 coefficients of the spherical harmonics
  97282. */
  97283. l20: Vector3;
  97284. /**
  97285. * The l2,1 coefficients of the spherical harmonics
  97286. */
  97287. l21: Vector3;
  97288. /**
  97289. * The l2,2 coefficients of the spherical harmonics
  97290. */
  97291. l22: Vector3;
  97292. /**
  97293. * Adds a light to the spherical harmonics
  97294. * @param direction the direction of the light
  97295. * @param color the color of the light
  97296. * @param deltaSolidAngle the delta solid angle of the light
  97297. */
  97298. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97299. /**
  97300. * Scales the spherical harmonics by the given amount
  97301. * @param scale the amount to scale
  97302. */
  97303. scaleInPlace(scale: number): void;
  97304. /**
  97305. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97306. *
  97307. * ```
  97308. * E_lm = A_l * L_lm
  97309. * ```
  97310. *
  97311. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97312. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97313. * the scaling factors are given in equation 9.
  97314. */
  97315. convertIncidentRadianceToIrradiance(): void;
  97316. /**
  97317. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97318. *
  97319. * ```
  97320. * L = (1/pi) * E * rho
  97321. * ```
  97322. *
  97323. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97324. */
  97325. convertIrradianceToLambertianRadiance(): void;
  97326. /**
  97327. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97328. * required operations at run time.
  97329. *
  97330. * This is simply done by scaling back the SH with Ylm constants parameter.
  97331. * The trigonometric part being applied by the shader at run time.
  97332. */
  97333. preScaleForRendering(): void;
  97334. /**
  97335. * Constructs a spherical harmonics from an array.
  97336. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97337. * @returns the spherical harmonics
  97338. */
  97339. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97340. /**
  97341. * Gets the spherical harmonics from polynomial
  97342. * @param polynomial the spherical polynomial
  97343. * @returns the spherical harmonics
  97344. */
  97345. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97346. }
  97347. /**
  97348. * Class representing spherical polynomial coefficients to the 3rd degree
  97349. */
  97350. export class SphericalPolynomial {
  97351. private _harmonics;
  97352. /**
  97353. * The spherical harmonics used to create the polynomials.
  97354. */
  97355. readonly preScaledHarmonics: SphericalHarmonics;
  97356. /**
  97357. * The x coefficients of the spherical polynomial
  97358. */
  97359. x: Vector3;
  97360. /**
  97361. * The y coefficients of the spherical polynomial
  97362. */
  97363. y: Vector3;
  97364. /**
  97365. * The z coefficients of the spherical polynomial
  97366. */
  97367. z: Vector3;
  97368. /**
  97369. * The xx coefficients of the spherical polynomial
  97370. */
  97371. xx: Vector3;
  97372. /**
  97373. * The yy coefficients of the spherical polynomial
  97374. */
  97375. yy: Vector3;
  97376. /**
  97377. * The zz coefficients of the spherical polynomial
  97378. */
  97379. zz: Vector3;
  97380. /**
  97381. * The xy coefficients of the spherical polynomial
  97382. */
  97383. xy: Vector3;
  97384. /**
  97385. * The yz coefficients of the spherical polynomial
  97386. */
  97387. yz: Vector3;
  97388. /**
  97389. * The zx coefficients of the spherical polynomial
  97390. */
  97391. zx: Vector3;
  97392. /**
  97393. * Adds an ambient color to the spherical polynomial
  97394. * @param color the color to add
  97395. */
  97396. addAmbient(color: Color3): void;
  97397. /**
  97398. * Scales the spherical polynomial by the given amount
  97399. * @param scale the amount to scale
  97400. */
  97401. scaleInPlace(scale: number): void;
  97402. /**
  97403. * Gets the spherical polynomial from harmonics
  97404. * @param harmonics the spherical harmonics
  97405. * @returns the spherical polynomial
  97406. */
  97407. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97408. /**
  97409. * Constructs a spherical polynomial from an array.
  97410. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97411. * @returns the spherical polynomial
  97412. */
  97413. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97414. }
  97415. }
  97416. declare module BABYLON {
  97417. /**
  97418. * Defines the source of the internal texture
  97419. */
  97420. export enum InternalTextureSource {
  97421. /**
  97422. * The source of the texture data is unknown
  97423. */
  97424. Unknown = 0,
  97425. /**
  97426. * Texture data comes from an URL
  97427. */
  97428. Url = 1,
  97429. /**
  97430. * Texture data is only used for temporary storage
  97431. */
  97432. Temp = 2,
  97433. /**
  97434. * Texture data comes from raw data (ArrayBuffer)
  97435. */
  97436. Raw = 3,
  97437. /**
  97438. * Texture content is dynamic (video or dynamic texture)
  97439. */
  97440. Dynamic = 4,
  97441. /**
  97442. * Texture content is generated by rendering to it
  97443. */
  97444. RenderTarget = 5,
  97445. /**
  97446. * Texture content is part of a multi render target process
  97447. */
  97448. MultiRenderTarget = 6,
  97449. /**
  97450. * Texture data comes from a cube data file
  97451. */
  97452. Cube = 7,
  97453. /**
  97454. * Texture data comes from a raw cube data
  97455. */
  97456. CubeRaw = 8,
  97457. /**
  97458. * Texture data come from a prefiltered cube data file
  97459. */
  97460. CubePrefiltered = 9,
  97461. /**
  97462. * Texture content is raw 3D data
  97463. */
  97464. Raw3D = 10,
  97465. /**
  97466. * Texture content is a depth texture
  97467. */
  97468. Depth = 11,
  97469. /**
  97470. * Texture data comes from a raw cube data encoded with RGBD
  97471. */
  97472. CubeRawRGBD = 12
  97473. }
  97474. /**
  97475. * Class used to store data associated with WebGL texture data for the engine
  97476. * This class should not be used directly
  97477. */
  97478. export class InternalTexture {
  97479. /** @hidden */
  97480. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97481. /**
  97482. * Defines if the texture is ready
  97483. */
  97484. isReady: boolean;
  97485. /**
  97486. * Defines if the texture is a cube texture
  97487. */
  97488. isCube: boolean;
  97489. /**
  97490. * Defines if the texture contains 3D data
  97491. */
  97492. is3D: boolean;
  97493. /**
  97494. * Defines if the texture contains multiview data
  97495. */
  97496. isMultiview: boolean;
  97497. /**
  97498. * Gets the URL used to load this texture
  97499. */
  97500. url: string;
  97501. /**
  97502. * Gets the sampling mode of the texture
  97503. */
  97504. samplingMode: number;
  97505. /**
  97506. * Gets a boolean indicating if the texture needs mipmaps generation
  97507. */
  97508. generateMipMaps: boolean;
  97509. /**
  97510. * Gets the number of samples used by the texture (WebGL2+ only)
  97511. */
  97512. samples: number;
  97513. /**
  97514. * Gets the type of the texture (int, float...)
  97515. */
  97516. type: number;
  97517. /**
  97518. * Gets the format of the texture (RGB, RGBA...)
  97519. */
  97520. format: number;
  97521. /**
  97522. * Observable called when the texture is loaded
  97523. */
  97524. onLoadedObservable: Observable<InternalTexture>;
  97525. /**
  97526. * Gets the width of the texture
  97527. */
  97528. width: number;
  97529. /**
  97530. * Gets the height of the texture
  97531. */
  97532. height: number;
  97533. /**
  97534. * Gets the depth of the texture
  97535. */
  97536. depth: number;
  97537. /**
  97538. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97539. */
  97540. baseWidth: number;
  97541. /**
  97542. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97543. */
  97544. baseHeight: number;
  97545. /**
  97546. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97547. */
  97548. baseDepth: number;
  97549. /**
  97550. * Gets a boolean indicating if the texture is inverted on Y axis
  97551. */
  97552. invertY: boolean;
  97553. /** @hidden */
  97554. _invertVScale: boolean;
  97555. /** @hidden */
  97556. _associatedChannel: number;
  97557. /** @hidden */
  97558. _source: InternalTextureSource;
  97559. /** @hidden */
  97560. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  97561. /** @hidden */
  97562. _bufferView: Nullable<ArrayBufferView>;
  97563. /** @hidden */
  97564. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97565. /** @hidden */
  97566. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97567. /** @hidden */
  97568. _size: number;
  97569. /** @hidden */
  97570. _extension: string;
  97571. /** @hidden */
  97572. _files: Nullable<string[]>;
  97573. /** @hidden */
  97574. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97575. /** @hidden */
  97576. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97577. /** @hidden */
  97578. _framebuffer: Nullable<WebGLFramebuffer>;
  97579. /** @hidden */
  97580. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97581. /** @hidden */
  97582. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97583. /** @hidden */
  97584. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97585. /** @hidden */
  97586. _attachments: Nullable<number[]>;
  97587. /** @hidden */
  97588. _cachedCoordinatesMode: Nullable<number>;
  97589. /** @hidden */
  97590. _cachedWrapU: Nullable<number>;
  97591. /** @hidden */
  97592. _cachedWrapV: Nullable<number>;
  97593. /** @hidden */
  97594. _cachedWrapR: Nullable<number>;
  97595. /** @hidden */
  97596. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97597. /** @hidden */
  97598. _isDisabled: boolean;
  97599. /** @hidden */
  97600. _compression: Nullable<string>;
  97601. /** @hidden */
  97602. _generateStencilBuffer: boolean;
  97603. /** @hidden */
  97604. _generateDepthBuffer: boolean;
  97605. /** @hidden */
  97606. _comparisonFunction: number;
  97607. /** @hidden */
  97608. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97609. /** @hidden */
  97610. _lodGenerationScale: number;
  97611. /** @hidden */
  97612. _lodGenerationOffset: number;
  97613. /** @hidden */
  97614. _colorTextureArray: Nullable<WebGLTexture>;
  97615. /** @hidden */
  97616. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97617. /** @hidden */
  97618. _lodTextureHigh: Nullable<BaseTexture>;
  97619. /** @hidden */
  97620. _lodTextureMid: Nullable<BaseTexture>;
  97621. /** @hidden */
  97622. _lodTextureLow: Nullable<BaseTexture>;
  97623. /** @hidden */
  97624. _isRGBD: boolean;
  97625. /** @hidden */
  97626. _linearSpecularLOD: boolean;
  97627. /** @hidden */
  97628. _irradianceTexture: Nullable<BaseTexture>;
  97629. /** @hidden */
  97630. _webGLTexture: Nullable<WebGLTexture>;
  97631. /** @hidden */
  97632. _references: number;
  97633. private _engine;
  97634. /**
  97635. * Gets the Engine the texture belongs to.
  97636. * @returns The babylon engine
  97637. */
  97638. getEngine(): ThinEngine;
  97639. /**
  97640. * Gets the data source type of the texture
  97641. */
  97642. readonly source: InternalTextureSource;
  97643. /**
  97644. * Creates a new InternalTexture
  97645. * @param engine defines the engine to use
  97646. * @param source defines the type of data that will be used
  97647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97648. */
  97649. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97650. /**
  97651. * Increments the number of references (ie. the number of Texture that point to it)
  97652. */
  97653. incrementReferences(): void;
  97654. /**
  97655. * Change the size of the texture (not the size of the content)
  97656. * @param width defines the new width
  97657. * @param height defines the new height
  97658. * @param depth defines the new depth (1 by default)
  97659. */
  97660. updateSize(width: int, height: int, depth?: int): void;
  97661. /** @hidden */
  97662. _rebuild(): void;
  97663. /** @hidden */
  97664. _swapAndDie(target: InternalTexture): void;
  97665. /**
  97666. * Dispose the current allocated resources
  97667. */
  97668. dispose(): void;
  97669. }
  97670. }
  97671. declare module BABYLON {
  97672. /**
  97673. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97675. */
  97676. export class Analyser {
  97677. /**
  97678. * Gets or sets the smoothing
  97679. * @ignorenaming
  97680. */
  97681. SMOOTHING: number;
  97682. /**
  97683. * Gets or sets the FFT table size
  97684. * @ignorenaming
  97685. */
  97686. FFT_SIZE: number;
  97687. /**
  97688. * Gets or sets the bar graph amplitude
  97689. * @ignorenaming
  97690. */
  97691. BARGRAPHAMPLITUDE: number;
  97692. /**
  97693. * Gets or sets the position of the debug canvas
  97694. * @ignorenaming
  97695. */
  97696. DEBUGCANVASPOS: {
  97697. x: number;
  97698. y: number;
  97699. };
  97700. /**
  97701. * Gets or sets the debug canvas size
  97702. * @ignorenaming
  97703. */
  97704. DEBUGCANVASSIZE: {
  97705. width: number;
  97706. height: number;
  97707. };
  97708. private _byteFreqs;
  97709. private _byteTime;
  97710. private _floatFreqs;
  97711. private _webAudioAnalyser;
  97712. private _debugCanvas;
  97713. private _debugCanvasContext;
  97714. private _scene;
  97715. private _registerFunc;
  97716. private _audioEngine;
  97717. /**
  97718. * Creates a new analyser
  97719. * @param scene defines hosting scene
  97720. */
  97721. constructor(scene: Scene);
  97722. /**
  97723. * Get the number of data values you will have to play with for the visualization
  97724. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97725. * @returns a number
  97726. */
  97727. getFrequencyBinCount(): number;
  97728. /**
  97729. * Gets the current frequency data as a byte array
  97730. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97731. * @returns a Uint8Array
  97732. */
  97733. getByteFrequencyData(): Uint8Array;
  97734. /**
  97735. * Gets the current waveform as a byte array
  97736. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97737. * @returns a Uint8Array
  97738. */
  97739. getByteTimeDomainData(): Uint8Array;
  97740. /**
  97741. * Gets the current frequency data as a float array
  97742. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97743. * @returns a Float32Array
  97744. */
  97745. getFloatFrequencyData(): Float32Array;
  97746. /**
  97747. * Renders the debug canvas
  97748. */
  97749. drawDebugCanvas(): void;
  97750. /**
  97751. * Stops rendering the debug canvas and removes it
  97752. */
  97753. stopDebugCanvas(): void;
  97754. /**
  97755. * Connects two audio nodes
  97756. * @param inputAudioNode defines first node to connect
  97757. * @param outputAudioNode defines second node to connect
  97758. */
  97759. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97760. /**
  97761. * Releases all associated resources
  97762. */
  97763. dispose(): void;
  97764. }
  97765. }
  97766. declare module BABYLON {
  97767. /**
  97768. * This represents an audio engine and it is responsible
  97769. * to play, synchronize and analyse sounds throughout the application.
  97770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97771. */
  97772. export interface IAudioEngine extends IDisposable {
  97773. /**
  97774. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97775. */
  97776. readonly canUseWebAudio: boolean;
  97777. /**
  97778. * Gets the current AudioContext if available.
  97779. */
  97780. readonly audioContext: Nullable<AudioContext>;
  97781. /**
  97782. * The master gain node defines the global audio volume of your audio engine.
  97783. */
  97784. readonly masterGain: GainNode;
  97785. /**
  97786. * Gets whether or not mp3 are supported by your browser.
  97787. */
  97788. readonly isMP3supported: boolean;
  97789. /**
  97790. * Gets whether or not ogg are supported by your browser.
  97791. */
  97792. readonly isOGGsupported: boolean;
  97793. /**
  97794. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97795. * @ignoreNaming
  97796. */
  97797. WarnedWebAudioUnsupported: boolean;
  97798. /**
  97799. * Defines if the audio engine relies on a custom unlocked button.
  97800. * In this case, the embedded button will not be displayed.
  97801. */
  97802. useCustomUnlockedButton: boolean;
  97803. /**
  97804. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97805. */
  97806. readonly unlocked: boolean;
  97807. /**
  97808. * Event raised when audio has been unlocked on the browser.
  97809. */
  97810. onAudioUnlockedObservable: Observable<AudioEngine>;
  97811. /**
  97812. * Event raised when audio has been locked on the browser.
  97813. */
  97814. onAudioLockedObservable: Observable<AudioEngine>;
  97815. /**
  97816. * Flags the audio engine in Locked state.
  97817. * This happens due to new browser policies preventing audio to autoplay.
  97818. */
  97819. lock(): void;
  97820. /**
  97821. * Unlocks the audio engine once a user action has been done on the dom.
  97822. * This is helpful to resume play once browser policies have been satisfied.
  97823. */
  97824. unlock(): void;
  97825. }
  97826. /**
  97827. * This represents the default audio engine used in babylon.
  97828. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97830. */
  97831. export class AudioEngine implements IAudioEngine {
  97832. private _audioContext;
  97833. private _audioContextInitialized;
  97834. private _muteButton;
  97835. private _hostElement;
  97836. /**
  97837. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97838. */
  97839. canUseWebAudio: boolean;
  97840. /**
  97841. * The master gain node defines the global audio volume of your audio engine.
  97842. */
  97843. masterGain: GainNode;
  97844. /**
  97845. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97846. * @ignoreNaming
  97847. */
  97848. WarnedWebAudioUnsupported: boolean;
  97849. /**
  97850. * Gets whether or not mp3 are supported by your browser.
  97851. */
  97852. isMP3supported: boolean;
  97853. /**
  97854. * Gets whether or not ogg are supported by your browser.
  97855. */
  97856. isOGGsupported: boolean;
  97857. /**
  97858. * Gets whether audio has been unlocked on the device.
  97859. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97860. * a user interaction has happened.
  97861. */
  97862. unlocked: boolean;
  97863. /**
  97864. * Defines if the audio engine relies on a custom unlocked button.
  97865. * In this case, the embedded button will not be displayed.
  97866. */
  97867. useCustomUnlockedButton: boolean;
  97868. /**
  97869. * Event raised when audio has been unlocked on the browser.
  97870. */
  97871. onAudioUnlockedObservable: Observable<AudioEngine>;
  97872. /**
  97873. * Event raised when audio has been locked on the browser.
  97874. */
  97875. onAudioLockedObservable: Observable<AudioEngine>;
  97876. /**
  97877. * Gets the current AudioContext if available.
  97878. */
  97879. readonly audioContext: Nullable<AudioContext>;
  97880. private _connectedAnalyser;
  97881. /**
  97882. * Instantiates a new audio engine.
  97883. *
  97884. * There should be only one per page as some browsers restrict the number
  97885. * of audio contexts you can create.
  97886. * @param hostElement defines the host element where to display the mute icon if necessary
  97887. */
  97888. constructor(hostElement?: Nullable<HTMLElement>);
  97889. /**
  97890. * Flags the audio engine in Locked state.
  97891. * This happens due to new browser policies preventing audio to autoplay.
  97892. */
  97893. lock(): void;
  97894. /**
  97895. * Unlocks the audio engine once a user action has been done on the dom.
  97896. * This is helpful to resume play once browser policies have been satisfied.
  97897. */
  97898. unlock(): void;
  97899. private _resumeAudioContext;
  97900. private _initializeAudioContext;
  97901. private _tryToRun;
  97902. private _triggerRunningState;
  97903. private _triggerSuspendedState;
  97904. private _displayMuteButton;
  97905. private _moveButtonToTopLeft;
  97906. private _onResize;
  97907. private _hideMuteButton;
  97908. /**
  97909. * Destroy and release the resources associated with the audio ccontext.
  97910. */
  97911. dispose(): void;
  97912. /**
  97913. * Gets the global volume sets on the master gain.
  97914. * @returns the global volume if set or -1 otherwise
  97915. */
  97916. getGlobalVolume(): number;
  97917. /**
  97918. * Sets the global volume of your experience (sets on the master gain).
  97919. * @param newVolume Defines the new global volume of the application
  97920. */
  97921. setGlobalVolume(newVolume: number): void;
  97922. /**
  97923. * Connect the audio engine to an audio analyser allowing some amazing
  97924. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97926. * @param analyser The analyser to connect to the engine
  97927. */
  97928. connectToAnalyser(analyser: Analyser): void;
  97929. }
  97930. }
  97931. declare module BABYLON {
  97932. /**
  97933. * Interface used to present a loading screen while loading a scene
  97934. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97935. */
  97936. export interface ILoadingScreen {
  97937. /**
  97938. * Function called to display the loading screen
  97939. */
  97940. displayLoadingUI: () => void;
  97941. /**
  97942. * Function called to hide the loading screen
  97943. */
  97944. hideLoadingUI: () => void;
  97945. /**
  97946. * Gets or sets the color to use for the background
  97947. */
  97948. loadingUIBackgroundColor: string;
  97949. /**
  97950. * Gets or sets the text to display while loading
  97951. */
  97952. loadingUIText: string;
  97953. }
  97954. /**
  97955. * Class used for the default loading screen
  97956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97957. */
  97958. export class DefaultLoadingScreen implements ILoadingScreen {
  97959. private _renderingCanvas;
  97960. private _loadingText;
  97961. private _loadingDivBackgroundColor;
  97962. private _loadingDiv;
  97963. private _loadingTextDiv;
  97964. /** Gets or sets the logo url to use for the default loading screen */
  97965. static DefaultLogoUrl: string;
  97966. /** Gets or sets the spinner url to use for the default loading screen */
  97967. static DefaultSpinnerUrl: string;
  97968. /**
  97969. * Creates a new default loading screen
  97970. * @param _renderingCanvas defines the canvas used to render the scene
  97971. * @param _loadingText defines the default text to display
  97972. * @param _loadingDivBackgroundColor defines the default background color
  97973. */
  97974. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97975. /**
  97976. * Function called to display the loading screen
  97977. */
  97978. displayLoadingUI(): void;
  97979. /**
  97980. * Function called to hide the loading screen
  97981. */
  97982. hideLoadingUI(): void;
  97983. /**
  97984. * Gets or sets the text to display while loading
  97985. */
  97986. loadingUIText: string;
  97987. /**
  97988. * Gets or sets the color to use for the background
  97989. */
  97990. loadingUIBackgroundColor: string;
  97991. private _resizeLoadingUI;
  97992. }
  97993. }
  97994. declare module BABYLON {
  97995. /**
  97996. * Interface for any object that can request an animation frame
  97997. */
  97998. export interface ICustomAnimationFrameRequester {
  97999. /**
  98000. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98001. */
  98002. renderFunction?: Function;
  98003. /**
  98004. * Called to request the next frame to render to
  98005. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98006. */
  98007. requestAnimationFrame: Function;
  98008. /**
  98009. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98010. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98011. */
  98012. requestID?: number;
  98013. }
  98014. }
  98015. declare module BABYLON {
  98016. /**
  98017. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98018. */
  98019. export class PerformanceMonitor {
  98020. private _enabled;
  98021. private _rollingFrameTime;
  98022. private _lastFrameTimeMs;
  98023. /**
  98024. * constructor
  98025. * @param frameSampleSize The number of samples required to saturate the sliding window
  98026. */
  98027. constructor(frameSampleSize?: number);
  98028. /**
  98029. * Samples current frame
  98030. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98031. */
  98032. sampleFrame(timeMs?: number): void;
  98033. /**
  98034. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98035. */
  98036. readonly averageFrameTime: number;
  98037. /**
  98038. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98039. */
  98040. readonly averageFrameTimeVariance: number;
  98041. /**
  98042. * Returns the frame time of the most recent frame
  98043. */
  98044. readonly instantaneousFrameTime: number;
  98045. /**
  98046. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98047. */
  98048. readonly averageFPS: number;
  98049. /**
  98050. * Returns the average framerate in frames per second using the most recent frame time
  98051. */
  98052. readonly instantaneousFPS: number;
  98053. /**
  98054. * Returns true if enough samples have been taken to completely fill the sliding window
  98055. */
  98056. readonly isSaturated: boolean;
  98057. /**
  98058. * Enables contributions to the sliding window sample set
  98059. */
  98060. enable(): void;
  98061. /**
  98062. * Disables contributions to the sliding window sample set
  98063. * Samples will not be interpolated over the disabled period
  98064. */
  98065. disable(): void;
  98066. /**
  98067. * Returns true if sampling is enabled
  98068. */
  98069. readonly isEnabled: boolean;
  98070. /**
  98071. * Resets performance monitor
  98072. */
  98073. reset(): void;
  98074. }
  98075. /**
  98076. * RollingAverage
  98077. *
  98078. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98079. */
  98080. export class RollingAverage {
  98081. /**
  98082. * Current average
  98083. */
  98084. average: number;
  98085. /**
  98086. * Current variance
  98087. */
  98088. variance: number;
  98089. protected _samples: Array<number>;
  98090. protected _sampleCount: number;
  98091. protected _pos: number;
  98092. protected _m2: number;
  98093. /**
  98094. * constructor
  98095. * @param length The number of samples required to saturate the sliding window
  98096. */
  98097. constructor(length: number);
  98098. /**
  98099. * Adds a sample to the sample set
  98100. * @param v The sample value
  98101. */
  98102. add(v: number): void;
  98103. /**
  98104. * Returns previously added values or null if outside of history or outside the sliding window domain
  98105. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98106. * @return Value previously recorded with add() or null if outside of range
  98107. */
  98108. history(i: number): number;
  98109. /**
  98110. * Returns true if enough samples have been taken to completely fill the sliding window
  98111. * @return true if sample-set saturated
  98112. */
  98113. isSaturated(): boolean;
  98114. /**
  98115. * Resets the rolling average (equivalent to 0 samples taken so far)
  98116. */
  98117. reset(): void;
  98118. /**
  98119. * Wraps a value around the sample range boundaries
  98120. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98121. * @return Wrapped position in sample range
  98122. */
  98123. protected _wrapPosition(i: number): number;
  98124. }
  98125. }
  98126. declare module BABYLON {
  98127. /**
  98128. * This class is used to track a performance counter which is number based.
  98129. * The user has access to many properties which give statistics of different nature.
  98130. *
  98131. * The implementer can track two kinds of Performance Counter: time and count.
  98132. * 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.
  98133. * 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.
  98134. */
  98135. export class PerfCounter {
  98136. /**
  98137. * Gets or sets a global boolean to turn on and off all the counters
  98138. */
  98139. static Enabled: boolean;
  98140. /**
  98141. * Returns the smallest value ever
  98142. */
  98143. readonly min: number;
  98144. /**
  98145. * Returns the biggest value ever
  98146. */
  98147. readonly max: number;
  98148. /**
  98149. * Returns the average value since the performance counter is running
  98150. */
  98151. readonly average: number;
  98152. /**
  98153. * Returns the average value of the last second the counter was monitored
  98154. */
  98155. readonly lastSecAverage: number;
  98156. /**
  98157. * Returns the current value
  98158. */
  98159. readonly current: number;
  98160. /**
  98161. * Gets the accumulated total
  98162. */
  98163. readonly total: number;
  98164. /**
  98165. * Gets the total value count
  98166. */
  98167. readonly count: number;
  98168. /**
  98169. * Creates a new counter
  98170. */
  98171. constructor();
  98172. /**
  98173. * Call this method to start monitoring a new frame.
  98174. * 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.
  98175. */
  98176. fetchNewFrame(): void;
  98177. /**
  98178. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98179. * @param newCount the count value to add to the monitored count
  98180. * @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.
  98181. */
  98182. addCount(newCount: number, fetchResult: boolean): void;
  98183. /**
  98184. * Start monitoring this performance counter
  98185. */
  98186. beginMonitoring(): void;
  98187. /**
  98188. * Compute the time lapsed since the previous beginMonitoring() call.
  98189. * @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
  98190. */
  98191. endMonitoring(newFrame?: boolean): void;
  98192. private _fetchResult;
  98193. private _startMonitoringTime;
  98194. private _min;
  98195. private _max;
  98196. private _average;
  98197. private _current;
  98198. private _totalValueCount;
  98199. private _totalAccumulated;
  98200. private _lastSecAverage;
  98201. private _lastSecAccumulated;
  98202. private _lastSecTime;
  98203. private _lastSecValueCount;
  98204. }
  98205. }
  98206. declare module BABYLON {
  98207. /**
  98208. * Defines the interface used by display changed events
  98209. */
  98210. export interface IDisplayChangedEventArgs {
  98211. /** Gets the vrDisplay object (if any) */
  98212. vrDisplay: Nullable<any>;
  98213. /** Gets a boolean indicating if webVR is supported */
  98214. vrSupported: boolean;
  98215. }
  98216. /**
  98217. * Defines the interface used by objects containing a viewport (like a camera)
  98218. */
  98219. interface IViewportOwnerLike {
  98220. /**
  98221. * Gets or sets the viewport
  98222. */
  98223. viewport: IViewportLike;
  98224. }
  98225. /**
  98226. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98227. */
  98228. export class Engine extends ThinEngine {
  98229. /** Defines that alpha blending is disabled */
  98230. static readonly ALPHA_DISABLE: number;
  98231. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98232. static readonly ALPHA_ADD: number;
  98233. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98234. static readonly ALPHA_COMBINE: number;
  98235. /** Defines that alpha blending to DEST - SRC * DEST */
  98236. static readonly ALPHA_SUBTRACT: number;
  98237. /** Defines that alpha blending to SRC * DEST */
  98238. static readonly ALPHA_MULTIPLY: number;
  98239. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98240. static readonly ALPHA_MAXIMIZED: number;
  98241. /** Defines that alpha blending to SRC + DEST */
  98242. static readonly ALPHA_ONEONE: number;
  98243. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98244. static readonly ALPHA_PREMULTIPLIED: number;
  98245. /**
  98246. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98247. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98248. */
  98249. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98250. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98251. static readonly ALPHA_INTERPOLATE: number;
  98252. /**
  98253. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98254. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98255. */
  98256. static readonly ALPHA_SCREENMODE: number;
  98257. /** Defines that the ressource is not delayed*/
  98258. static readonly DELAYLOADSTATE_NONE: number;
  98259. /** Defines that the ressource was successfully delay loaded */
  98260. static readonly DELAYLOADSTATE_LOADED: number;
  98261. /** Defines that the ressource is currently delay loading */
  98262. static readonly DELAYLOADSTATE_LOADING: number;
  98263. /** Defines that the ressource is delayed and has not started loading */
  98264. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98265. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98266. static readonly NEVER: number;
  98267. /** 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 */
  98268. static readonly ALWAYS: number;
  98269. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98270. static readonly LESS: number;
  98271. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98272. static readonly EQUAL: number;
  98273. /** 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 */
  98274. static readonly LEQUAL: number;
  98275. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98276. static readonly GREATER: number;
  98277. /** 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 */
  98278. static readonly GEQUAL: number;
  98279. /** 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 */
  98280. static readonly NOTEQUAL: number;
  98281. /** Passed to stencilOperation to specify that stencil value must be kept */
  98282. static readonly KEEP: number;
  98283. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98284. static readonly REPLACE: number;
  98285. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98286. static readonly INCR: number;
  98287. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98288. static readonly DECR: number;
  98289. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98290. static readonly INVERT: number;
  98291. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98292. static readonly INCR_WRAP: number;
  98293. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98294. static readonly DECR_WRAP: number;
  98295. /** Texture is not repeating outside of 0..1 UVs */
  98296. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98297. /** Texture is repeating outside of 0..1 UVs */
  98298. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98299. /** Texture is repeating and mirrored */
  98300. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98301. /** ALPHA */
  98302. static readonly TEXTUREFORMAT_ALPHA: number;
  98303. /** LUMINANCE */
  98304. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98305. /** LUMINANCE_ALPHA */
  98306. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98307. /** RGB */
  98308. static readonly TEXTUREFORMAT_RGB: number;
  98309. /** RGBA */
  98310. static readonly TEXTUREFORMAT_RGBA: number;
  98311. /** RED */
  98312. static readonly TEXTUREFORMAT_RED: number;
  98313. /** RED (2nd reference) */
  98314. static readonly TEXTUREFORMAT_R: number;
  98315. /** RG */
  98316. static readonly TEXTUREFORMAT_RG: number;
  98317. /** RED_INTEGER */
  98318. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98319. /** RED_INTEGER (2nd reference) */
  98320. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98321. /** RG_INTEGER */
  98322. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98323. /** RGB_INTEGER */
  98324. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98325. /** RGBA_INTEGER */
  98326. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98327. /** UNSIGNED_BYTE */
  98328. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98329. /** UNSIGNED_BYTE (2nd reference) */
  98330. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98331. /** FLOAT */
  98332. static readonly TEXTURETYPE_FLOAT: number;
  98333. /** HALF_FLOAT */
  98334. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98335. /** BYTE */
  98336. static readonly TEXTURETYPE_BYTE: number;
  98337. /** SHORT */
  98338. static readonly TEXTURETYPE_SHORT: number;
  98339. /** UNSIGNED_SHORT */
  98340. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98341. /** INT */
  98342. static readonly TEXTURETYPE_INT: number;
  98343. /** UNSIGNED_INT */
  98344. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98345. /** UNSIGNED_SHORT_4_4_4_4 */
  98346. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98347. /** UNSIGNED_SHORT_5_5_5_1 */
  98348. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98349. /** UNSIGNED_SHORT_5_6_5 */
  98350. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98351. /** UNSIGNED_INT_2_10_10_10_REV */
  98352. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98353. /** UNSIGNED_INT_24_8 */
  98354. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98355. /** UNSIGNED_INT_10F_11F_11F_REV */
  98356. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98357. /** UNSIGNED_INT_5_9_9_9_REV */
  98358. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98359. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98360. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98361. /** nearest is mag = nearest and min = nearest and mip = linear */
  98362. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98364. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98365. /** Trilinear is mag = linear and min = linear and mip = linear */
  98366. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98367. /** nearest is mag = nearest and min = nearest and mip = linear */
  98368. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98369. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98370. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98371. /** Trilinear is mag = linear and min = linear and mip = linear */
  98372. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98373. /** mag = nearest and min = nearest and mip = nearest */
  98374. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98375. /** mag = nearest and min = linear and mip = nearest */
  98376. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98377. /** mag = nearest and min = linear and mip = linear */
  98378. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98379. /** mag = nearest and min = linear and mip = none */
  98380. static readonly TEXTURE_NEAREST_LINEAR: number;
  98381. /** mag = nearest and min = nearest and mip = none */
  98382. static readonly TEXTURE_NEAREST_NEAREST: number;
  98383. /** mag = linear and min = nearest and mip = nearest */
  98384. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98385. /** mag = linear and min = nearest and mip = linear */
  98386. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98387. /** mag = linear and min = linear and mip = none */
  98388. static readonly TEXTURE_LINEAR_LINEAR: number;
  98389. /** mag = linear and min = nearest and mip = none */
  98390. static readonly TEXTURE_LINEAR_NEAREST: number;
  98391. /** Explicit coordinates mode */
  98392. static readonly TEXTURE_EXPLICIT_MODE: number;
  98393. /** Spherical coordinates mode */
  98394. static readonly TEXTURE_SPHERICAL_MODE: number;
  98395. /** Planar coordinates mode */
  98396. static readonly TEXTURE_PLANAR_MODE: number;
  98397. /** Cubic coordinates mode */
  98398. static readonly TEXTURE_CUBIC_MODE: number;
  98399. /** Projection coordinates mode */
  98400. static readonly TEXTURE_PROJECTION_MODE: number;
  98401. /** Skybox coordinates mode */
  98402. static readonly TEXTURE_SKYBOX_MODE: number;
  98403. /** Inverse Cubic coordinates mode */
  98404. static readonly TEXTURE_INVCUBIC_MODE: number;
  98405. /** Equirectangular coordinates mode */
  98406. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98407. /** Equirectangular Fixed coordinates mode */
  98408. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98409. /** Equirectangular Fixed Mirrored coordinates mode */
  98410. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98411. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98412. static readonly SCALEMODE_FLOOR: number;
  98413. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98414. static readonly SCALEMODE_NEAREST: number;
  98415. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98416. static readonly SCALEMODE_CEILING: number;
  98417. /**
  98418. * Returns the current npm package of the sdk
  98419. */
  98420. static readonly NpmPackage: string;
  98421. /**
  98422. * Returns the current version of the framework
  98423. */
  98424. static readonly Version: string;
  98425. /** Gets the list of created engines */
  98426. static readonly Instances: Engine[];
  98427. /**
  98428. * Gets the latest created engine
  98429. */
  98430. static readonly LastCreatedEngine: Nullable<Engine>;
  98431. /**
  98432. * Gets the latest created scene
  98433. */
  98434. static readonly LastCreatedScene: Nullable<Scene>;
  98435. /**
  98436. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98437. * @param flag defines which part of the materials must be marked as dirty
  98438. * @param predicate defines a predicate used to filter which materials should be affected
  98439. */
  98440. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98441. /**
  98442. * Method called to create the default loading screen.
  98443. * This can be overriden in your own app.
  98444. * @param canvas The rendering canvas element
  98445. * @returns The loading screen
  98446. */
  98447. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98448. /**
  98449. * Method called to create the default rescale post process on each engine.
  98450. */
  98451. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98452. /**
  98453. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98454. **/
  98455. enableOfflineSupport: boolean;
  98456. /**
  98457. * 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)
  98458. **/
  98459. disableManifestCheck: boolean;
  98460. /**
  98461. * Gets the list of created scenes
  98462. */
  98463. scenes: Scene[];
  98464. /**
  98465. * Event raised when a new scene is created
  98466. */
  98467. onNewSceneAddedObservable: Observable<Scene>;
  98468. /**
  98469. * Gets the list of created postprocesses
  98470. */
  98471. postProcesses: PostProcess[];
  98472. /**
  98473. * Gets a boolean indicating if the pointer is currently locked
  98474. */
  98475. isPointerLock: boolean;
  98476. /**
  98477. * Observable event triggered each time the rendering canvas is resized
  98478. */
  98479. onResizeObservable: Observable<Engine>;
  98480. /**
  98481. * Observable event triggered each time the canvas loses focus
  98482. */
  98483. onCanvasBlurObservable: Observable<Engine>;
  98484. /**
  98485. * Observable event triggered each time the canvas gains focus
  98486. */
  98487. onCanvasFocusObservable: Observable<Engine>;
  98488. /**
  98489. * Observable event triggered each time the canvas receives pointerout event
  98490. */
  98491. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98492. /**
  98493. * Observable raised when the engine begins a new frame
  98494. */
  98495. onBeginFrameObservable: Observable<Engine>;
  98496. /**
  98497. * If set, will be used to request the next animation frame for the render loop
  98498. */
  98499. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98500. /**
  98501. * Observable raised when the engine ends the current frame
  98502. */
  98503. onEndFrameObservable: Observable<Engine>;
  98504. /**
  98505. * Observable raised when the engine is about to compile a shader
  98506. */
  98507. onBeforeShaderCompilationObservable: Observable<Engine>;
  98508. /**
  98509. * Observable raised when the engine has jsut compiled a shader
  98510. */
  98511. onAfterShaderCompilationObservable: Observable<Engine>;
  98512. /**
  98513. * Gets the audio engine
  98514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98515. * @ignorenaming
  98516. */
  98517. static audioEngine: IAudioEngine;
  98518. /**
  98519. * Default AudioEngine factory responsible of creating the Audio Engine.
  98520. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98521. */
  98522. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98523. /**
  98524. * Default offline support factory responsible of creating a tool used to store data locally.
  98525. * By default, this will create a Database object if the workload has been embedded.
  98526. */
  98527. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98528. private _loadingScreen;
  98529. private _pointerLockRequested;
  98530. private _dummyFramebuffer;
  98531. private _rescalePostProcess;
  98532. /** @hidden */
  98533. protected _alphaMode: number;
  98534. /** @hidden */
  98535. protected _alphaEquation: number;
  98536. private _deterministicLockstep;
  98537. private _lockstepMaxSteps;
  98538. protected readonly _supportsHardwareTextureRescaling: boolean;
  98539. private _fps;
  98540. private _deltaTime;
  98541. /** @hidden */
  98542. _drawCalls: PerfCounter;
  98543. /**
  98544. * Turn this value on if you want to pause FPS computation when in background
  98545. */
  98546. disablePerformanceMonitorInBackground: boolean;
  98547. private _performanceMonitor;
  98548. /**
  98549. * Gets the performance monitor attached to this engine
  98550. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98551. */
  98552. readonly performanceMonitor: PerformanceMonitor;
  98553. private _onFocus;
  98554. private _onBlur;
  98555. private _onCanvasPointerOut;
  98556. private _onCanvasBlur;
  98557. private _onCanvasFocus;
  98558. private _onFullscreenChange;
  98559. private _onPointerLockChange;
  98560. /**
  98561. * Creates a new engine
  98562. * @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
  98563. * @param antialias defines enable antialiasing (default: false)
  98564. * @param options defines further options to be sent to the getContext() function
  98565. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98566. */
  98567. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98568. /**
  98569. * Gets current aspect ratio
  98570. * @param viewportOwner defines the camera to use to get the aspect ratio
  98571. * @param useScreen defines if screen size must be used (or the current render target if any)
  98572. * @returns a number defining the aspect ratio
  98573. */
  98574. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98575. /**
  98576. * Gets current screen aspect ratio
  98577. * @returns a number defining the aspect ratio
  98578. */
  98579. getScreenAspectRatio(): number;
  98580. /**
  98581. * Gets host document
  98582. * @returns the host document object
  98583. */
  98584. getHostDocument(): Document;
  98585. /**
  98586. * Gets the client rect of the HTML canvas attached with the current webGL context
  98587. * @returns a client rectanglee
  98588. */
  98589. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98590. /**
  98591. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98593. * @returns true if engine is in deterministic lock step mode
  98594. */
  98595. isDeterministicLockStep(): boolean;
  98596. /**
  98597. * Gets the max steps when engine is running in deterministic lock step
  98598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98599. * @returns the max steps
  98600. */
  98601. getLockstepMaxSteps(): number;
  98602. /**
  98603. * Force the mipmap generation for the given render target texture
  98604. * @param texture defines the render target texture to use
  98605. */
  98606. generateMipMapsForCubemap(texture: InternalTexture): void;
  98607. /** States */
  98608. /**
  98609. * Set various states to the webGL context
  98610. * @param culling defines backface culling state
  98611. * @param zOffset defines the value to apply to zOffset (0 by default)
  98612. * @param force defines if states must be applied even if cache is up to date
  98613. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98614. */
  98615. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98616. /**
  98617. * Set the z offset to apply to current rendering
  98618. * @param value defines the offset to apply
  98619. */
  98620. setZOffset(value: number): void;
  98621. /**
  98622. * Gets the current value of the zOffset
  98623. * @returns the current zOffset state
  98624. */
  98625. getZOffset(): number;
  98626. /**
  98627. * Enable or disable depth buffering
  98628. * @param enable defines the state to set
  98629. */
  98630. setDepthBuffer(enable: boolean): void;
  98631. /**
  98632. * Gets a boolean indicating if depth writing is enabled
  98633. * @returns the current depth writing state
  98634. */
  98635. getDepthWrite(): boolean;
  98636. /**
  98637. * Enable or disable depth writing
  98638. * @param enable defines the state to set
  98639. */
  98640. setDepthWrite(enable: boolean): void;
  98641. /**
  98642. * Enable or disable color writing
  98643. * @param enable defines the state to set
  98644. */
  98645. setColorWrite(enable: boolean): void;
  98646. /**
  98647. * Gets a boolean indicating if color writing is enabled
  98648. * @returns the current color writing state
  98649. */
  98650. getColorWrite(): boolean;
  98651. /**
  98652. * Sets alpha constants used by some alpha blending modes
  98653. * @param r defines the red component
  98654. * @param g defines the green component
  98655. * @param b defines the blue component
  98656. * @param a defines the alpha component
  98657. */
  98658. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98659. /**
  98660. * Sets the current alpha mode
  98661. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98662. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98663. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98664. */
  98665. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98666. /**
  98667. * Gets the current alpha mode
  98668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98669. * @returns the current alpha mode
  98670. */
  98671. getAlphaMode(): number;
  98672. /**
  98673. * Sets the current alpha equation
  98674. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98675. */
  98676. setAlphaEquation(equation: number): void;
  98677. /**
  98678. * Gets the current alpha equation.
  98679. * @returns the current alpha equation
  98680. */
  98681. getAlphaEquation(): number;
  98682. /**
  98683. * Gets a boolean indicating if stencil buffer is enabled
  98684. * @returns the current stencil buffer state
  98685. */
  98686. getStencilBuffer(): boolean;
  98687. /**
  98688. * Enable or disable the stencil buffer
  98689. * @param enable defines if the stencil buffer must be enabled or disabled
  98690. */
  98691. setStencilBuffer(enable: boolean): void;
  98692. /**
  98693. * Gets the current stencil mask
  98694. * @returns a number defining the new stencil mask to use
  98695. */
  98696. getStencilMask(): number;
  98697. /**
  98698. * Sets the current stencil mask
  98699. * @param mask defines the new stencil mask to use
  98700. */
  98701. setStencilMask(mask: number): void;
  98702. /**
  98703. * Gets the current stencil function
  98704. * @returns a number defining the stencil function to use
  98705. */
  98706. getStencilFunction(): number;
  98707. /**
  98708. * Gets the current stencil reference value
  98709. * @returns a number defining the stencil reference value to use
  98710. */
  98711. getStencilFunctionReference(): number;
  98712. /**
  98713. * Gets the current stencil mask
  98714. * @returns a number defining the stencil mask to use
  98715. */
  98716. getStencilFunctionMask(): number;
  98717. /**
  98718. * Sets the current stencil function
  98719. * @param stencilFunc defines the new stencil function to use
  98720. */
  98721. setStencilFunction(stencilFunc: number): void;
  98722. /**
  98723. * Sets the current stencil reference
  98724. * @param reference defines the new stencil reference to use
  98725. */
  98726. setStencilFunctionReference(reference: number): void;
  98727. /**
  98728. * Sets the current stencil mask
  98729. * @param mask defines the new stencil mask to use
  98730. */
  98731. setStencilFunctionMask(mask: number): void;
  98732. /**
  98733. * Gets the current stencil operation when stencil fails
  98734. * @returns a number defining stencil operation to use when stencil fails
  98735. */
  98736. getStencilOperationFail(): number;
  98737. /**
  98738. * Gets the current stencil operation when depth fails
  98739. * @returns a number defining stencil operation to use when depth fails
  98740. */
  98741. getStencilOperationDepthFail(): number;
  98742. /**
  98743. * Gets the current stencil operation when stencil passes
  98744. * @returns a number defining stencil operation to use when stencil passes
  98745. */
  98746. getStencilOperationPass(): number;
  98747. /**
  98748. * Sets the stencil operation to use when stencil fails
  98749. * @param operation defines the stencil operation to use when stencil fails
  98750. */
  98751. setStencilOperationFail(operation: number): void;
  98752. /**
  98753. * Sets the stencil operation to use when depth fails
  98754. * @param operation defines the stencil operation to use when depth fails
  98755. */
  98756. setStencilOperationDepthFail(operation: number): void;
  98757. /**
  98758. * Sets the stencil operation to use when stencil passes
  98759. * @param operation defines the stencil operation to use when stencil passes
  98760. */
  98761. setStencilOperationPass(operation: number): void;
  98762. /**
  98763. * Sets a boolean indicating if the dithering state is enabled or disabled
  98764. * @param value defines the dithering state
  98765. */
  98766. setDitheringState(value: boolean): void;
  98767. /**
  98768. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98769. * @param value defines the rasterizer state
  98770. */
  98771. setRasterizerState(value: boolean): void;
  98772. /**
  98773. * Gets the current depth function
  98774. * @returns a number defining the depth function
  98775. */
  98776. getDepthFunction(): Nullable<number>;
  98777. /**
  98778. * Sets the current depth function
  98779. * @param depthFunc defines the function to use
  98780. */
  98781. setDepthFunction(depthFunc: number): void;
  98782. /**
  98783. * Sets the current depth function to GREATER
  98784. */
  98785. setDepthFunctionToGreater(): void;
  98786. /**
  98787. * Sets the current depth function to GEQUAL
  98788. */
  98789. setDepthFunctionToGreaterOrEqual(): void;
  98790. /**
  98791. * Sets the current depth function to LESS
  98792. */
  98793. setDepthFunctionToLess(): void;
  98794. /**
  98795. * Sets the current depth function to LEQUAL
  98796. */
  98797. setDepthFunctionToLessOrEqual(): void;
  98798. private _cachedStencilBuffer;
  98799. private _cachedStencilFunction;
  98800. private _cachedStencilMask;
  98801. private _cachedStencilOperationPass;
  98802. private _cachedStencilOperationFail;
  98803. private _cachedStencilOperationDepthFail;
  98804. private _cachedStencilReference;
  98805. /**
  98806. * Caches the the state of the stencil buffer
  98807. */
  98808. cacheStencilState(): void;
  98809. /**
  98810. * Restores the state of the stencil buffer
  98811. */
  98812. restoreStencilState(): void;
  98813. /**
  98814. * Directly set the WebGL Viewport
  98815. * @param x defines the x coordinate of the viewport (in screen space)
  98816. * @param y defines the y coordinate of the viewport (in screen space)
  98817. * @param width defines the width of the viewport (in screen space)
  98818. * @param height defines the height of the viewport (in screen space)
  98819. * @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
  98820. */
  98821. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98822. /**
  98823. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98824. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98825. * @param y defines the y-coordinate of the corner of the clear rectangle
  98826. * @param width defines the width of the clear rectangle
  98827. * @param height defines the height of the clear rectangle
  98828. * @param clearColor defines the clear color
  98829. */
  98830. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98831. /**
  98832. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98833. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98834. * @param y defines the y-coordinate of the corner of the clear rectangle
  98835. * @param width defines the width of the clear rectangle
  98836. * @param height defines the height of the clear rectangle
  98837. */
  98838. enableScissor(x: number, y: number, width: number, height: number): void;
  98839. /**
  98840. * Disable previously set scissor test rectangle
  98841. */
  98842. disableScissor(): void;
  98843. protected _reportDrawCall(): void;
  98844. /**
  98845. * Initializes a webVR display and starts listening to display change events
  98846. * The onVRDisplayChangedObservable will be notified upon these changes
  98847. * @returns The onVRDisplayChangedObservable
  98848. */
  98849. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98850. /** @hidden */
  98851. _prepareVRComponent(): void;
  98852. /** @hidden */
  98853. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98854. /** @hidden */
  98855. _submitVRFrame(): void;
  98856. /**
  98857. * Call this function to leave webVR mode
  98858. * Will do nothing if webVR is not supported or if there is no webVR device
  98859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98860. */
  98861. disableVR(): void;
  98862. /**
  98863. * Gets a boolean indicating that the system is in VR mode and is presenting
  98864. * @returns true if VR mode is engaged
  98865. */
  98866. isVRPresenting(): boolean;
  98867. /** @hidden */
  98868. _requestVRFrame(): void;
  98869. /** @hidden */
  98870. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98871. /**
  98872. * Gets the source code of the vertex shader associated with a specific webGL program
  98873. * @param program defines the program to use
  98874. * @returns a string containing the source code of the vertex shader associated with the program
  98875. */
  98876. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98877. /**
  98878. * Gets the source code of the fragment shader associated with a specific webGL program
  98879. * @param program defines the program to use
  98880. * @returns a string containing the source code of the fragment shader associated with the program
  98881. */
  98882. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98883. /**
  98884. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98885. * @param x defines the x coordinate of the rectangle where pixels must be read
  98886. * @param y defines the y coordinate of the rectangle where pixels must be read
  98887. * @param width defines the width of the rectangle where pixels must be read
  98888. * @param height defines the height of the rectangle where pixels must be read
  98889. * @returns a Uint8Array containing RGBA colors
  98890. */
  98891. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98892. /**
  98893. * Sets a depth stencil texture from a render target to the according uniform.
  98894. * @param channel The texture channel
  98895. * @param uniform The uniform to set
  98896. * @param texture The render target texture containing the depth stencil texture to apply
  98897. */
  98898. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98899. /**
  98900. * Sets a texture to the webGL context from a postprocess
  98901. * @param channel defines the channel to use
  98902. * @param postProcess defines the source postprocess
  98903. */
  98904. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98905. /**
  98906. * Binds the output of the passed in post process to the texture channel specified
  98907. * @param channel The channel the texture should be bound to
  98908. * @param postProcess The post process which's output should be bound
  98909. */
  98910. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98911. /** @hidden */
  98912. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98913. protected _rebuildBuffers(): void;
  98914. _renderLoop(): void;
  98915. /**
  98916. * Toggle full screen mode
  98917. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98918. */
  98919. switchFullscreen(requestPointerLock: boolean): void;
  98920. /**
  98921. * Enters full screen mode
  98922. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98923. */
  98924. enterFullscreen(requestPointerLock: boolean): void;
  98925. /**
  98926. * Exits full screen mode
  98927. */
  98928. exitFullscreen(): void;
  98929. /**
  98930. * Enters Pointerlock mode
  98931. */
  98932. enterPointerlock(): void;
  98933. /**
  98934. * Exits Pointerlock mode
  98935. */
  98936. exitPointerlock(): void;
  98937. /**
  98938. * Begin a new frame
  98939. */
  98940. beginFrame(): void;
  98941. /**
  98942. * Enf the current frame
  98943. */
  98944. endFrame(): void;
  98945. resize(): void;
  98946. /**
  98947. * Set the compressed texture format to use, based on the formats you have, and the formats
  98948. * supported by the hardware / browser.
  98949. *
  98950. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98951. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98952. * to API arguments needed to compressed textures. This puts the burden on the container
  98953. * generator to house the arcane code for determining these for current & future formats.
  98954. *
  98955. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98956. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98957. *
  98958. * Note: The result of this call is not taken into account when a texture is base64.
  98959. *
  98960. * @param formatsAvailable defines the list of those format families you have created
  98961. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98962. *
  98963. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98964. * @returns The extension selected.
  98965. */
  98966. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98967. /**
  98968. * Force a specific size of the canvas
  98969. * @param width defines the new canvas' width
  98970. * @param height defines the new canvas' height
  98971. */
  98972. setSize(width: number, height: number): void;
  98973. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98974. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98975. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98976. _releaseTexture(texture: InternalTexture): void;
  98977. /**
  98978. * @hidden
  98979. * Rescales a texture
  98980. * @param source input texutre
  98981. * @param destination destination texture
  98982. * @param scene scene to use to render the resize
  98983. * @param internalFormat format to use when resizing
  98984. * @param onComplete callback to be called when resize has completed
  98985. */
  98986. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98987. /**
  98988. * Gets the current framerate
  98989. * @returns a number representing the framerate
  98990. */
  98991. getFps(): number;
  98992. /**
  98993. * Gets the time spent between current and previous frame
  98994. * @returns a number representing the delta time in ms
  98995. */
  98996. getDeltaTime(): number;
  98997. private _measureFps;
  98998. /**
  98999. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99000. * @param renderTarget The render target to set the frame buffer for
  99001. */
  99002. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99003. /**
  99004. * Update a dynamic index buffer
  99005. * @param indexBuffer defines the target index buffer
  99006. * @param indices defines the data to update
  99007. * @param offset defines the offset in the target index buffer where update should start
  99008. */
  99009. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99010. /**
  99011. * Updates the sample count of a render target texture
  99012. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99013. * @param texture defines the texture to update
  99014. * @param samples defines the sample count to set
  99015. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99016. */
  99017. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99018. /** @hidden */
  99019. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99020. dispose(): void;
  99021. private _disableTouchAction;
  99022. /**
  99023. * Display the loading screen
  99024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99025. */
  99026. displayLoadingUI(): void;
  99027. /**
  99028. * Hide the loading screen
  99029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99030. */
  99031. hideLoadingUI(): void;
  99032. /**
  99033. * Gets the current loading screen object
  99034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99035. */
  99036. /**
  99037. * Sets the current loading screen object
  99038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99039. */
  99040. loadingScreen: ILoadingScreen;
  99041. /**
  99042. * Sets the current loading screen text
  99043. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99044. */
  99045. loadingUIText: string;
  99046. /**
  99047. * Sets the current loading screen background color
  99048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99049. */
  99050. loadingUIBackgroundColor: string;
  99051. /** Pointerlock and fullscreen */
  99052. /**
  99053. * Ask the browser to promote the current element to pointerlock mode
  99054. * @param element defines the DOM element to promote
  99055. */
  99056. static _RequestPointerlock(element: HTMLElement): void;
  99057. /**
  99058. * Asks the browser to exit pointerlock mode
  99059. */
  99060. static _ExitPointerlock(): void;
  99061. /**
  99062. * Ask the browser to promote the current element to fullscreen rendering mode
  99063. * @param element defines the DOM element to promote
  99064. */
  99065. static _RequestFullscreen(element: HTMLElement): void;
  99066. /**
  99067. * Asks the browser to exit fullscreen mode
  99068. */
  99069. static _ExitFullscreen(): void;
  99070. }
  99071. }
  99072. declare module BABYLON {
  99073. /**
  99074. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99075. * during the life time of the application.
  99076. */
  99077. export class EngineStore {
  99078. /** Gets the list of created engines */
  99079. static Instances: Engine[];
  99080. /** @hidden */
  99081. static _LastCreatedScene: Nullable<Scene>;
  99082. /**
  99083. * Gets the latest created engine
  99084. */
  99085. static readonly LastCreatedEngine: Nullable<Engine>;
  99086. /**
  99087. * Gets the latest created scene
  99088. */
  99089. static readonly LastCreatedScene: Nullable<Scene>;
  99090. /**
  99091. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99092. * @ignorenaming
  99093. */
  99094. static UseFallbackTexture: boolean;
  99095. /**
  99096. * Texture content used if a texture cannot loaded
  99097. * @ignorenaming
  99098. */
  99099. static FallbackTexture: string;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Helper class that provides a small promise polyfill
  99105. */
  99106. export class PromisePolyfill {
  99107. /**
  99108. * Static function used to check if the polyfill is required
  99109. * If this is the case then the function will inject the polyfill to window.Promise
  99110. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99111. */
  99112. static Apply(force?: boolean): void;
  99113. }
  99114. }
  99115. declare module BABYLON {
  99116. /**
  99117. * Interface for screenshot methods with describe argument called `size` as object with options
  99118. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99119. */
  99120. export interface IScreenshotSize {
  99121. /**
  99122. * number in pixels for canvas height
  99123. */
  99124. height?: number;
  99125. /**
  99126. * multiplier allowing render at a higher or lower resolution
  99127. * If value is defined then height and width will be ignored and taken from camera
  99128. */
  99129. precision?: number;
  99130. /**
  99131. * number in pixels for canvas width
  99132. */
  99133. width?: number;
  99134. }
  99135. }
  99136. declare module BABYLON {
  99137. interface IColor4Like {
  99138. r: float;
  99139. g: float;
  99140. b: float;
  99141. a: float;
  99142. }
  99143. /**
  99144. * Class containing a set of static utilities functions
  99145. */
  99146. export class Tools {
  99147. /**
  99148. * Gets or sets the base URL to use to load assets
  99149. */
  99150. static BaseUrl: string;
  99151. /**
  99152. * Enable/Disable Custom HTTP Request Headers globally.
  99153. * default = false
  99154. * @see CustomRequestHeaders
  99155. */
  99156. static UseCustomRequestHeaders: boolean;
  99157. /**
  99158. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99159. * i.e. when loading files, where the server/service expects an Authorization header
  99160. */
  99161. static CustomRequestHeaders: {
  99162. [key: string]: string;
  99163. };
  99164. /**
  99165. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99166. */
  99167. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99168. /**
  99169. * Default behaviour for cors in the application.
  99170. * It can be a string if the expected behavior is identical in the entire app.
  99171. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99172. */
  99173. static CorsBehavior: string | ((url: string | string[]) => string);
  99174. /**
  99175. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99176. * @ignorenaming
  99177. */
  99178. static UseFallbackTexture: boolean;
  99179. /**
  99180. * Use this object to register external classes like custom textures or material
  99181. * to allow the laoders to instantiate them
  99182. */
  99183. static RegisteredExternalClasses: {
  99184. [key: string]: Object;
  99185. };
  99186. /**
  99187. * Texture content used if a texture cannot loaded
  99188. * @ignorenaming
  99189. */
  99190. static fallbackTexture: string;
  99191. /**
  99192. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99193. * @param u defines the coordinate on X axis
  99194. * @param v defines the coordinate on Y axis
  99195. * @param width defines the width of the source data
  99196. * @param height defines the height of the source data
  99197. * @param pixels defines the source byte array
  99198. * @param color defines the output color
  99199. */
  99200. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99201. /**
  99202. * Interpolates between a and b via alpha
  99203. * @param a The lower value (returned when alpha = 0)
  99204. * @param b The upper value (returned when alpha = 1)
  99205. * @param alpha The interpolation-factor
  99206. * @return The mixed value
  99207. */
  99208. static Mix(a: number, b: number, alpha: number): number;
  99209. /**
  99210. * Tries to instantiate a new object from a given class name
  99211. * @param className defines the class name to instantiate
  99212. * @returns the new object or null if the system was not able to do the instantiation
  99213. */
  99214. static Instantiate(className: string): any;
  99215. /**
  99216. * Provides a slice function that will work even on IE
  99217. * @param data defines the array to slice
  99218. * @param start defines the start of the data (optional)
  99219. * @param end defines the end of the data (optional)
  99220. * @returns the new sliced array
  99221. */
  99222. static Slice<T>(data: T, start?: number, end?: number): T;
  99223. /**
  99224. * Polyfill for setImmediate
  99225. * @param action defines the action to execute after the current execution block
  99226. */
  99227. static SetImmediate(action: () => void): void;
  99228. /**
  99229. * Function indicating if a number is an exponent of 2
  99230. * @param value defines the value to test
  99231. * @returns true if the value is an exponent of 2
  99232. */
  99233. static IsExponentOfTwo(value: number): boolean;
  99234. private static _tmpFloatArray;
  99235. /**
  99236. * Returns the nearest 32-bit single precision float representation of a Number
  99237. * @param value A Number. If the parameter is of a different type, it will get converted
  99238. * to a number or to NaN if it cannot be converted
  99239. * @returns number
  99240. */
  99241. static FloatRound(value: number): number;
  99242. /**
  99243. * Extracts the filename from a path
  99244. * @param path defines the path to use
  99245. * @returns the filename
  99246. */
  99247. static GetFilename(path: string): string;
  99248. /**
  99249. * Extracts the "folder" part of a path (everything before the filename).
  99250. * @param uri The URI to extract the info from
  99251. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99252. * @returns The "folder" part of the path
  99253. */
  99254. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99255. /**
  99256. * Extracts text content from a DOM element hierarchy
  99257. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99258. */
  99259. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99260. /**
  99261. * Convert an angle in radians to degrees
  99262. * @param angle defines the angle to convert
  99263. * @returns the angle in degrees
  99264. */
  99265. static ToDegrees(angle: number): number;
  99266. /**
  99267. * Convert an angle in degrees to radians
  99268. * @param angle defines the angle to convert
  99269. * @returns the angle in radians
  99270. */
  99271. static ToRadians(angle: number): number;
  99272. /**
  99273. * Encode a buffer to a base64 string
  99274. * @param buffer defines the buffer to encode
  99275. * @returns the encoded string
  99276. */
  99277. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  99278. /**
  99279. * Returns an array if obj is not an array
  99280. * @param obj defines the object to evaluate as an array
  99281. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99282. * @returns either obj directly if obj is an array or a new array containing obj
  99283. */
  99284. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99285. /**
  99286. * Gets the pointer prefix to use
  99287. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99288. */
  99289. static GetPointerPrefix(): string;
  99290. /**
  99291. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99292. * @param url define the url we are trying
  99293. * @param element define the dom element where to configure the cors policy
  99294. */
  99295. static SetCorsBehavior(url: string | string[], element: {
  99296. crossOrigin: string | null;
  99297. }): void;
  99298. /**
  99299. * Removes unwanted characters from an url
  99300. * @param url defines the url to clean
  99301. * @returns the cleaned url
  99302. */
  99303. static CleanUrl(url: string): string;
  99304. /**
  99305. * Gets or sets a function used to pre-process url before using them to load assets
  99306. */
  99307. static PreprocessUrl: (url: string) => string;
  99308. /**
  99309. * Loads an image as an HTMLImageElement.
  99310. * @param input url string, ArrayBuffer, or Blob to load
  99311. * @param onLoad callback called when the image successfully loads
  99312. * @param onError callback called when the image fails to load
  99313. * @param offlineProvider offline provider for caching
  99314. * @param mimeType optional mime type
  99315. * @returns the HTMLImageElement of the loaded image
  99316. */
  99317. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99318. /**
  99319. * Loads a file
  99320. * @param url url string, ArrayBuffer, or Blob to load
  99321. * @param onSuccess callback called when the file successfully loads
  99322. * @param onProgress callback called while file is loading (if the server supports this mode)
  99323. * @param offlineProvider defines the offline provider for caching
  99324. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99325. * @param onError callback called when the file fails to load
  99326. * @returns a file request object
  99327. */
  99328. 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;
  99329. /**
  99330. * Loads a file from a url
  99331. * @param url the file url to load
  99332. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99333. */
  99334. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99335. /**
  99336. * Load a script (identified by an url). When the url returns, the
  99337. * content of this file is added into a new script element, attached to the DOM (body element)
  99338. * @param scriptUrl defines the url of the script to laod
  99339. * @param onSuccess defines the callback called when the script is loaded
  99340. * @param onError defines the callback to call if an error occurs
  99341. * @param scriptId defines the id of the script element
  99342. */
  99343. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99344. /**
  99345. * Load an asynchronous script (identified by an url). When the url returns, the
  99346. * content of this file is added into a new script element, attached to the DOM (body element)
  99347. * @param scriptUrl defines the url of the script to laod
  99348. * @param scriptId defines the id of the script element
  99349. * @returns a promise request object
  99350. */
  99351. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99352. /**
  99353. * Loads a file from a blob
  99354. * @param fileToLoad defines the blob to use
  99355. * @param callback defines the callback to call when data is loaded
  99356. * @param progressCallback defines the callback to call during loading process
  99357. * @returns a file request object
  99358. */
  99359. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99360. /**
  99361. * Loads a file
  99362. * @param fileToLoad defines the file to load
  99363. * @param callback defines the callback to call when data is loaded
  99364. * @param progressCallBack defines the callback to call during loading process
  99365. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99366. * @returns a file request object
  99367. */
  99368. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  99369. /**
  99370. * Creates a data url from a given string content
  99371. * @param content defines the content to convert
  99372. * @returns the new data url link
  99373. */
  99374. static FileAsURL(content: string): string;
  99375. /**
  99376. * Format the given number to a specific decimal format
  99377. * @param value defines the number to format
  99378. * @param decimals defines the number of decimals to use
  99379. * @returns the formatted string
  99380. */
  99381. static Format(value: number, decimals?: number): string;
  99382. /**
  99383. * Tries to copy an object by duplicating every property
  99384. * @param source defines the source object
  99385. * @param destination defines the target object
  99386. * @param doNotCopyList defines a list of properties to avoid
  99387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99388. */
  99389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99390. /**
  99391. * Gets a boolean indicating if the given object has no own property
  99392. * @param obj defines the object to test
  99393. * @returns true if object has no own property
  99394. */
  99395. static IsEmpty(obj: any): boolean;
  99396. /**
  99397. * Function used to register events at window level
  99398. * @param windowElement defines the Window object to use
  99399. * @param events defines the events to register
  99400. */
  99401. static RegisterTopRootEvents(windowElement: Window, events: {
  99402. name: string;
  99403. handler: Nullable<(e: FocusEvent) => any>;
  99404. }[]): void;
  99405. /**
  99406. * Function used to unregister events from window level
  99407. * @param windowElement defines the Window object to use
  99408. * @param events defines the events to unregister
  99409. */
  99410. static UnregisterTopRootEvents(windowElement: Window, events: {
  99411. name: string;
  99412. handler: Nullable<(e: FocusEvent) => any>;
  99413. }[]): void;
  99414. /**
  99415. * @ignore
  99416. */
  99417. static _ScreenshotCanvas: HTMLCanvasElement;
  99418. /**
  99419. * Dumps the current bound framebuffer
  99420. * @param width defines the rendering width
  99421. * @param height defines the rendering height
  99422. * @param engine defines the hosting engine
  99423. * @param successCallback defines the callback triggered once the data are available
  99424. * @param mimeType defines the mime type of the result
  99425. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99426. */
  99427. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99428. /**
  99429. * Converts the canvas data to blob.
  99430. * This acts as a polyfill for browsers not supporting the to blob function.
  99431. * @param canvas Defines the canvas to extract the data from
  99432. * @param successCallback Defines the callback triggered once the data are available
  99433. * @param mimeType Defines the mime type of the result
  99434. */
  99435. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99436. /**
  99437. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99438. * @param successCallback defines the callback triggered once the data are available
  99439. * @param mimeType defines the mime type of the result
  99440. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99441. */
  99442. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99443. /**
  99444. * Downloads a blob in the browser
  99445. * @param blob defines the blob to download
  99446. * @param fileName defines the name of the downloaded file
  99447. */
  99448. static Download(blob: Blob, fileName: string): void;
  99449. /**
  99450. * Captures a screenshot of the current rendering
  99451. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99452. * @param engine defines the rendering engine
  99453. * @param camera defines the source camera
  99454. * @param size This parameter can be set to a single number or to an object with the
  99455. * following (optional) properties: precision, width, height. If a single number is passed,
  99456. * it will be used for both width and height. If an object is passed, the screenshot size
  99457. * will be derived from the parameters. The precision property is a multiplier allowing
  99458. * rendering at a higher or lower resolution
  99459. * @param successCallback defines the callback receives a single parameter which contains the
  99460. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99461. * src parameter of an <img> to display it
  99462. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99463. * Check your browser for supported MIME types
  99464. */
  99465. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99466. /**
  99467. * Captures a screenshot of the current rendering
  99468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99469. * @param engine defines the rendering engine
  99470. * @param camera defines the source camera
  99471. * @param size This parameter can be set to a single number or to an object with the
  99472. * following (optional) properties: precision, width, height. If a single number is passed,
  99473. * it will be used for both width and height. If an object is passed, the screenshot size
  99474. * will be derived from the parameters. The precision property is a multiplier allowing
  99475. * rendering at a higher or lower resolution
  99476. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99477. * Check your browser for supported MIME types
  99478. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99479. * to the src parameter of an <img> to display it
  99480. */
  99481. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99482. /**
  99483. * Generates an image screenshot from the specified camera.
  99484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99485. * @param engine The engine to use for rendering
  99486. * @param camera The camera to use for rendering
  99487. * @param size This parameter can be set to a single number or to an object with the
  99488. * following (optional) properties: precision, width, height. If a single number is passed,
  99489. * it will be used for both width and height. If an object is passed, the screenshot size
  99490. * will be derived from the parameters. The precision property is a multiplier allowing
  99491. * rendering at a higher or lower resolution
  99492. * @param successCallback The callback receives a single parameter which contains the
  99493. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99494. * src parameter of an <img> to display it
  99495. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99496. * Check your browser for supported MIME types
  99497. * @param samples Texture samples (default: 1)
  99498. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99499. * @param fileName A name for for the downloaded file.
  99500. */
  99501. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99502. /**
  99503. * Generates an image screenshot from the specified camera.
  99504. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99505. * @param engine The engine to use for rendering
  99506. * @param camera The camera to use for rendering
  99507. * @param size This parameter can be set to a single number or to an object with the
  99508. * following (optional) properties: precision, width, height. If a single number is passed,
  99509. * it will be used for both width and height. If an object is passed, the screenshot size
  99510. * will be derived from the parameters. The precision property is a multiplier allowing
  99511. * rendering at a higher or lower resolution
  99512. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99513. * Check your browser for supported MIME types
  99514. * @param samples Texture samples (default: 1)
  99515. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99516. * @param fileName A name for for the downloaded file.
  99517. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99518. * to the src parameter of an <img> to display it
  99519. */
  99520. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99521. /**
  99522. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99523. * Be aware Math.random() could cause collisions, but:
  99524. * "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"
  99525. * @returns a pseudo random id
  99526. */
  99527. static RandomId(): string;
  99528. /**
  99529. * Test if the given uri is a base64 string
  99530. * @param uri The uri to test
  99531. * @return True if the uri is a base64 string or false otherwise
  99532. */
  99533. static IsBase64(uri: string): boolean;
  99534. /**
  99535. * Decode the given base64 uri.
  99536. * @param uri The uri to decode
  99537. * @return The decoded base64 data.
  99538. */
  99539. static DecodeBase64(uri: string): ArrayBuffer;
  99540. /**
  99541. * Gets the absolute url.
  99542. * @param url the input url
  99543. * @return the absolute url
  99544. */
  99545. static GetAbsoluteUrl(url: string): string;
  99546. /**
  99547. * No log
  99548. */
  99549. static readonly NoneLogLevel: number;
  99550. /**
  99551. * Only message logs
  99552. */
  99553. static readonly MessageLogLevel: number;
  99554. /**
  99555. * Only warning logs
  99556. */
  99557. static readonly WarningLogLevel: number;
  99558. /**
  99559. * Only error logs
  99560. */
  99561. static readonly ErrorLogLevel: number;
  99562. /**
  99563. * All logs
  99564. */
  99565. static readonly AllLogLevel: number;
  99566. /**
  99567. * Gets a value indicating the number of loading errors
  99568. * @ignorenaming
  99569. */
  99570. static readonly errorsCount: number;
  99571. /**
  99572. * Callback called when a new log is added
  99573. */
  99574. static OnNewCacheEntry: (entry: string) => void;
  99575. /**
  99576. * Log a message to the console
  99577. * @param message defines the message to log
  99578. */
  99579. static Log(message: string): void;
  99580. /**
  99581. * Write a warning message to the console
  99582. * @param message defines the message to log
  99583. */
  99584. static Warn(message: string): void;
  99585. /**
  99586. * Write an error message to the console
  99587. * @param message defines the message to log
  99588. */
  99589. static Error(message: string): void;
  99590. /**
  99591. * Gets current log cache (list of logs)
  99592. */
  99593. static readonly LogCache: string;
  99594. /**
  99595. * Clears the log cache
  99596. */
  99597. static ClearLogCache(): void;
  99598. /**
  99599. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99600. */
  99601. static LogLevels: number;
  99602. /**
  99603. * Checks if the window object exists
  99604. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99605. */
  99606. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99607. /**
  99608. * No performance log
  99609. */
  99610. static readonly PerformanceNoneLogLevel: number;
  99611. /**
  99612. * Use user marks to log performance
  99613. */
  99614. static readonly PerformanceUserMarkLogLevel: number;
  99615. /**
  99616. * Log performance to the console
  99617. */
  99618. static readonly PerformanceConsoleLogLevel: number;
  99619. private static _performance;
  99620. /**
  99621. * Sets the current performance log level
  99622. */
  99623. static PerformanceLogLevel: number;
  99624. private static _StartPerformanceCounterDisabled;
  99625. private static _EndPerformanceCounterDisabled;
  99626. private static _StartUserMark;
  99627. private static _EndUserMark;
  99628. private static _StartPerformanceConsole;
  99629. private static _EndPerformanceConsole;
  99630. /**
  99631. * Starts a performance counter
  99632. */
  99633. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99634. /**
  99635. * Ends a specific performance coutner
  99636. */
  99637. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99638. /**
  99639. * Gets either window.performance.now() if supported or Date.now() else
  99640. */
  99641. static readonly Now: number;
  99642. /**
  99643. * This method will return the name of the class used to create the instance of the given object.
  99644. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99645. * @param object the object to get the class name from
  99646. * @param isType defines if the object is actually a type
  99647. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99648. */
  99649. static GetClassName(object: any, isType?: boolean): string;
  99650. /**
  99651. * Gets the first element of an array satisfying a given predicate
  99652. * @param array defines the array to browse
  99653. * @param predicate defines the predicate to use
  99654. * @returns null if not found or the element
  99655. */
  99656. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99657. /**
  99658. * This method will return the name of the full name of the class, including its owning module (if any).
  99659. * 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).
  99660. * @param object the object to get the class name from
  99661. * @param isType defines if the object is actually a type
  99662. * @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.
  99663. * @ignorenaming
  99664. */
  99665. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99666. /**
  99667. * Returns a promise that resolves after the given amount of time.
  99668. * @param delay Number of milliseconds to delay
  99669. * @returns Promise that resolves after the given amount of time
  99670. */
  99671. static DelayAsync(delay: number): Promise<void>;
  99672. }
  99673. /**
  99674. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99675. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99676. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99677. * @param name The name of the class, case should be preserved
  99678. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99679. */
  99680. export function className(name: string, module?: string): (target: Object) => void;
  99681. /**
  99682. * An implementation of a loop for asynchronous functions.
  99683. */
  99684. export class AsyncLoop {
  99685. /**
  99686. * Defines the number of iterations for the loop
  99687. */
  99688. iterations: number;
  99689. /**
  99690. * Defines the current index of the loop.
  99691. */
  99692. index: number;
  99693. private _done;
  99694. private _fn;
  99695. private _successCallback;
  99696. /**
  99697. * Constructor.
  99698. * @param iterations the number of iterations.
  99699. * @param func the function to run each iteration
  99700. * @param successCallback the callback that will be called upon succesful execution
  99701. * @param offset starting offset.
  99702. */
  99703. constructor(
  99704. /**
  99705. * Defines the number of iterations for the loop
  99706. */
  99707. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99708. /**
  99709. * Execute the next iteration. Must be called after the last iteration was finished.
  99710. */
  99711. executeNext(): void;
  99712. /**
  99713. * Break the loop and run the success callback.
  99714. */
  99715. breakLoop(): void;
  99716. /**
  99717. * Create and run an async loop.
  99718. * @param iterations the number of iterations.
  99719. * @param fn the function to run each iteration
  99720. * @param successCallback the callback that will be called upon succesful execution
  99721. * @param offset starting offset.
  99722. * @returns the created async loop object
  99723. */
  99724. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99725. /**
  99726. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99727. * @param iterations total number of iterations
  99728. * @param syncedIterations number of synchronous iterations in each async iteration.
  99729. * @param fn the function to call each iteration.
  99730. * @param callback a success call back that will be called when iterating stops.
  99731. * @param breakFunction a break condition (optional)
  99732. * @param timeout timeout settings for the setTimeout function. default - 0.
  99733. * @returns the created async loop object
  99734. */
  99735. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99736. }
  99737. }
  99738. declare module BABYLON {
  99739. /**
  99740. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99741. * The underlying implementation relies on an associative array to ensure the best performances.
  99742. * The value can be anything including 'null' but except 'undefined'
  99743. */
  99744. export class StringDictionary<T> {
  99745. /**
  99746. * This will clear this dictionary and copy the content from the 'source' one.
  99747. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99748. * @param source the dictionary to take the content from and copy to this dictionary
  99749. */
  99750. copyFrom(source: StringDictionary<T>): void;
  99751. /**
  99752. * Get a value based from its key
  99753. * @param key the given key to get the matching value from
  99754. * @return the value if found, otherwise undefined is returned
  99755. */
  99756. get(key: string): T | undefined;
  99757. /**
  99758. * Get a value from its key or add it if it doesn't exist.
  99759. * This method will ensure you that a given key/data will be present in the dictionary.
  99760. * @param key the given key to get the matching value from
  99761. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99762. * The factory will only be invoked if there's no data for the given key.
  99763. * @return the value corresponding to the key.
  99764. */
  99765. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99766. /**
  99767. * Get a value from its key if present in the dictionary otherwise add it
  99768. * @param key the key to get the value from
  99769. * @param val if there's no such key/value pair in the dictionary add it with this value
  99770. * @return the value corresponding to the key
  99771. */
  99772. getOrAdd(key: string, val: T): T;
  99773. /**
  99774. * Check if there's a given key in the dictionary
  99775. * @param key the key to check for
  99776. * @return true if the key is present, false otherwise
  99777. */
  99778. contains(key: string): boolean;
  99779. /**
  99780. * Add a new key and its corresponding value
  99781. * @param key the key to add
  99782. * @param value the value corresponding to the key
  99783. * @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
  99784. */
  99785. add(key: string, value: T): boolean;
  99786. /**
  99787. * Update a specific value associated to a key
  99788. * @param key defines the key to use
  99789. * @param value defines the value to store
  99790. * @returns true if the value was updated (or false if the key was not found)
  99791. */
  99792. set(key: string, value: T): boolean;
  99793. /**
  99794. * Get the element of the given key and remove it from the dictionary
  99795. * @param key defines the key to search
  99796. * @returns the value associated with the key or null if not found
  99797. */
  99798. getAndRemove(key: string): Nullable<T>;
  99799. /**
  99800. * Remove a key/value from the dictionary.
  99801. * @param key the key to remove
  99802. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99803. */
  99804. remove(key: string): boolean;
  99805. /**
  99806. * Clear the whole content of the dictionary
  99807. */
  99808. clear(): void;
  99809. /**
  99810. * Gets the current count
  99811. */
  99812. readonly count: number;
  99813. /**
  99814. * Execute a callback on each key/val of the dictionary.
  99815. * Note that you can remove any element in this dictionary in the callback implementation
  99816. * @param callback the callback to execute on a given key/value pair
  99817. */
  99818. forEach(callback: (key: string, val: T) => void): void;
  99819. /**
  99820. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99821. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99822. * Note that you can remove any element in this dictionary in the callback implementation
  99823. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99824. * @returns the first item
  99825. */
  99826. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99827. private _count;
  99828. private _data;
  99829. }
  99830. }
  99831. declare module BABYLON {
  99832. /** @hidden */
  99833. export interface ICollisionCoordinator {
  99834. createCollider(): Collider;
  99835. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99836. init(scene: Scene): void;
  99837. }
  99838. /** @hidden */
  99839. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99840. private _scene;
  99841. private _scaledPosition;
  99842. private _scaledVelocity;
  99843. private _finalPosition;
  99844. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99845. createCollider(): Collider;
  99846. init(scene: Scene): void;
  99847. private _collideWithWorld;
  99848. }
  99849. }
  99850. declare module BABYLON {
  99851. /**
  99852. * Class used to manage all inputs for the scene.
  99853. */
  99854. export class InputManager {
  99855. /** The distance in pixel that you have to move to prevent some events */
  99856. static DragMovementThreshold: number;
  99857. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99858. static LongPressDelay: number;
  99859. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99860. static DoubleClickDelay: number;
  99861. /** If you need to check double click without raising a single click at first click, enable this flag */
  99862. static ExclusiveDoubleClickMode: boolean;
  99863. private _wheelEventName;
  99864. private _onPointerMove;
  99865. private _onPointerDown;
  99866. private _onPointerUp;
  99867. private _initClickEvent;
  99868. private _initActionManager;
  99869. private _delayedSimpleClick;
  99870. private _delayedSimpleClickTimeout;
  99871. private _previousDelayedSimpleClickTimeout;
  99872. private _meshPickProceed;
  99873. private _previousButtonPressed;
  99874. private _currentPickResult;
  99875. private _previousPickResult;
  99876. private _totalPointersPressed;
  99877. private _doubleClickOccured;
  99878. private _pointerOverMesh;
  99879. private _pickedDownMesh;
  99880. private _pickedUpMesh;
  99881. private _pointerX;
  99882. private _pointerY;
  99883. private _unTranslatedPointerX;
  99884. private _unTranslatedPointerY;
  99885. private _startingPointerPosition;
  99886. private _previousStartingPointerPosition;
  99887. private _startingPointerTime;
  99888. private _previousStartingPointerTime;
  99889. private _pointerCaptures;
  99890. private _onKeyDown;
  99891. private _onKeyUp;
  99892. private _onCanvasFocusObserver;
  99893. private _onCanvasBlurObserver;
  99894. private _scene;
  99895. /**
  99896. * Creates a new InputManager
  99897. * @param scene defines the hosting scene
  99898. */
  99899. constructor(scene: Scene);
  99900. /**
  99901. * Gets the mesh that is currently under the pointer
  99902. */
  99903. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99904. /**
  99905. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99906. */
  99907. readonly unTranslatedPointer: Vector2;
  99908. /**
  99909. * Gets or sets the current on-screen X position of the pointer
  99910. */
  99911. pointerX: number;
  99912. /**
  99913. * Gets or sets the current on-screen Y position of the pointer
  99914. */
  99915. pointerY: number;
  99916. private _updatePointerPosition;
  99917. private _processPointerMove;
  99918. private _setRayOnPointerInfo;
  99919. private _checkPrePointerObservable;
  99920. /**
  99921. * Use this method to simulate a pointer move on a mesh
  99922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99925. */
  99926. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99927. /**
  99928. * Use this method to simulate a pointer down on a mesh
  99929. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99930. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99931. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99932. */
  99933. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99934. private _processPointerDown;
  99935. /** @hidden */
  99936. _isPointerSwiping(): boolean;
  99937. /**
  99938. * Use this method to simulate a pointer up on a mesh
  99939. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99940. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99941. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99942. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99943. */
  99944. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99945. private _processPointerUp;
  99946. /**
  99947. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99948. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99949. * @returns true if the pointer was captured
  99950. */
  99951. isPointerCaptured(pointerId?: number): boolean;
  99952. /**
  99953. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99954. * @param attachUp defines if you want to attach events to pointerup
  99955. * @param attachDown defines if you want to attach events to pointerdown
  99956. * @param attachMove defines if you want to attach events to pointermove
  99957. */
  99958. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99959. /**
  99960. * Detaches all event handlers
  99961. */
  99962. detachControl(): void;
  99963. /**
  99964. * Force the value of meshUnderPointer
  99965. * @param mesh defines the mesh to use
  99966. */
  99967. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99968. /**
  99969. * Gets the mesh under the pointer
  99970. * @returns a Mesh or null if no mesh is under the pointer
  99971. */
  99972. getPointerOverMesh(): Nullable<AbstractMesh>;
  99973. }
  99974. }
  99975. declare module BABYLON {
  99976. /**
  99977. * Helper class used to generate session unique ID
  99978. */
  99979. export class UniqueIdGenerator {
  99980. private static _UniqueIdCounter;
  99981. /**
  99982. * Gets an unique (relatively to the current scene) Id
  99983. */
  99984. static readonly UniqueId: number;
  99985. }
  99986. }
  99987. declare module BABYLON {
  99988. /**
  99989. * This class defines the direct association between an animation and a target
  99990. */
  99991. export class TargetedAnimation {
  99992. /**
  99993. * Animation to perform
  99994. */
  99995. animation: Animation;
  99996. /**
  99997. * Target to animate
  99998. */
  99999. target: any;
  100000. /**
  100001. * Serialize the object
  100002. * @returns the JSON object representing the current entity
  100003. */
  100004. serialize(): any;
  100005. }
  100006. /**
  100007. * Use this class to create coordinated animations on multiple targets
  100008. */
  100009. export class AnimationGroup implements IDisposable {
  100010. /** The name of the animation group */
  100011. name: string;
  100012. private _scene;
  100013. private _targetedAnimations;
  100014. private _animatables;
  100015. private _from;
  100016. private _to;
  100017. private _isStarted;
  100018. private _isPaused;
  100019. private _speedRatio;
  100020. private _loopAnimation;
  100021. /**
  100022. * Gets or sets the unique id of the node
  100023. */
  100024. uniqueId: number;
  100025. /**
  100026. * This observable will notify when one animation have ended
  100027. */
  100028. onAnimationEndObservable: Observable<TargetedAnimation>;
  100029. /**
  100030. * Observer raised when one animation loops
  100031. */
  100032. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100033. /**
  100034. * This observable will notify when all animations have ended.
  100035. */
  100036. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100037. /**
  100038. * This observable will notify when all animations have paused.
  100039. */
  100040. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100041. /**
  100042. * This observable will notify when all animations are playing.
  100043. */
  100044. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100045. /**
  100046. * Gets the first frame
  100047. */
  100048. readonly from: number;
  100049. /**
  100050. * Gets the last frame
  100051. */
  100052. readonly to: number;
  100053. /**
  100054. * Define if the animations are started
  100055. */
  100056. readonly isStarted: boolean;
  100057. /**
  100058. * Gets a value indicating that the current group is playing
  100059. */
  100060. readonly isPlaying: boolean;
  100061. /**
  100062. * Gets or sets the speed ratio to use for all animations
  100063. */
  100064. /**
  100065. * Gets or sets the speed ratio to use for all animations
  100066. */
  100067. speedRatio: number;
  100068. /**
  100069. * Gets or sets if all animations should loop or not
  100070. */
  100071. loopAnimation: boolean;
  100072. /**
  100073. * Gets the targeted animations for this animation group
  100074. */
  100075. readonly targetedAnimations: Array<TargetedAnimation>;
  100076. /**
  100077. * returning the list of animatables controlled by this animation group.
  100078. */
  100079. readonly animatables: Array<Animatable>;
  100080. /**
  100081. * Instantiates a new Animation Group.
  100082. * This helps managing several animations at once.
  100083. * @see http://doc.babylonjs.com/how_to/group
  100084. * @param name Defines the name of the group
  100085. * @param scene Defines the scene the group belongs to
  100086. */
  100087. constructor(
  100088. /** The name of the animation group */
  100089. name: string, scene?: Nullable<Scene>);
  100090. /**
  100091. * Add an animation (with its target) in the group
  100092. * @param animation defines the animation we want to add
  100093. * @param target defines the target of the animation
  100094. * @returns the TargetedAnimation object
  100095. */
  100096. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100097. /**
  100098. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100099. * It can add constant keys at begin or end
  100100. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100101. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100102. * @returns the animation group
  100103. */
  100104. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100105. /**
  100106. * Start all animations on given targets
  100107. * @param loop defines if animations must loop
  100108. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100109. * @param from defines the from key (optional)
  100110. * @param to defines the to key (optional)
  100111. * @returns the current animation group
  100112. */
  100113. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100114. /**
  100115. * Pause all animations
  100116. * @returns the animation group
  100117. */
  100118. pause(): AnimationGroup;
  100119. /**
  100120. * Play all animations to initial state
  100121. * This function will start() the animations if they were not started or will restart() them if they were paused
  100122. * @param loop defines if animations must loop
  100123. * @returns the animation group
  100124. */
  100125. play(loop?: boolean): AnimationGroup;
  100126. /**
  100127. * Reset all animations to initial state
  100128. * @returns the animation group
  100129. */
  100130. reset(): AnimationGroup;
  100131. /**
  100132. * Restart animations from key 0
  100133. * @returns the animation group
  100134. */
  100135. restart(): AnimationGroup;
  100136. /**
  100137. * Stop all animations
  100138. * @returns the animation group
  100139. */
  100140. stop(): AnimationGroup;
  100141. /**
  100142. * Set animation weight for all animatables
  100143. * @param weight defines the weight to use
  100144. * @return the animationGroup
  100145. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100146. */
  100147. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100148. /**
  100149. * Synchronize and normalize all animatables with a source animatable
  100150. * @param root defines the root animatable to synchronize with
  100151. * @return the animationGroup
  100152. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100153. */
  100154. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100155. /**
  100156. * Goes to a specific frame in this animation group
  100157. * @param frame the frame number to go to
  100158. * @return the animationGroup
  100159. */
  100160. goToFrame(frame: number): AnimationGroup;
  100161. /**
  100162. * Dispose all associated resources
  100163. */
  100164. dispose(): void;
  100165. private _checkAnimationGroupEnded;
  100166. /**
  100167. * Clone the current animation group and returns a copy
  100168. * @param newName defines the name of the new group
  100169. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100170. * @returns the new aniamtion group
  100171. */
  100172. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100173. /**
  100174. * Serializes the animationGroup to an object
  100175. * @returns Serialized object
  100176. */
  100177. serialize(): any;
  100178. /**
  100179. * Returns a new AnimationGroup object parsed from the source provided.
  100180. * @param parsedAnimationGroup defines the source
  100181. * @param scene defines the scene that will receive the animationGroup
  100182. * @returns a new AnimationGroup
  100183. */
  100184. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100185. /**
  100186. * Returns the string "AnimationGroup"
  100187. * @returns "AnimationGroup"
  100188. */
  100189. getClassName(): string;
  100190. /**
  100191. * Creates a detailled string about the object
  100192. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100193. * @returns a string representing the object
  100194. */
  100195. toString(fullDetails?: boolean): string;
  100196. }
  100197. }
  100198. declare module BABYLON {
  100199. /**
  100200. * Define an interface for all classes that will hold resources
  100201. */
  100202. export interface IDisposable {
  100203. /**
  100204. * Releases all held resources
  100205. */
  100206. dispose(): void;
  100207. }
  100208. /** Interface defining initialization parameters for Scene class */
  100209. export interface SceneOptions {
  100210. /**
  100211. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100212. * It will improve performance when the number of geometries becomes important.
  100213. */
  100214. useGeometryUniqueIdsMap?: boolean;
  100215. /**
  100216. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100217. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100218. */
  100219. useMaterialMeshMap?: boolean;
  100220. /**
  100221. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100222. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100223. */
  100224. useClonedMeshhMap?: boolean;
  100225. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100226. virtual?: boolean;
  100227. }
  100228. /**
  100229. * Represents a scene to be rendered by the engine.
  100230. * @see http://doc.babylonjs.com/features/scene
  100231. */
  100232. export class Scene extends AbstractScene implements IAnimatable {
  100233. /** The fog is deactivated */
  100234. static readonly FOGMODE_NONE: number;
  100235. /** The fog density is following an exponential function */
  100236. static readonly FOGMODE_EXP: number;
  100237. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100238. static readonly FOGMODE_EXP2: number;
  100239. /** The fog density is following a linear function. */
  100240. static readonly FOGMODE_LINEAR: number;
  100241. /**
  100242. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100244. */
  100245. static MinDeltaTime: number;
  100246. /**
  100247. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100249. */
  100250. static MaxDeltaTime: number;
  100251. /**
  100252. * Factory used to create the default material.
  100253. * @param name The name of the material to create
  100254. * @param scene The scene to create the material for
  100255. * @returns The default material
  100256. */
  100257. static DefaultMaterialFactory(scene: Scene): Material;
  100258. /**
  100259. * Factory used to create the a collision coordinator.
  100260. * @returns The collision coordinator
  100261. */
  100262. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100263. /** @hidden */
  100264. _inputManager: InputManager;
  100265. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100266. cameraToUseForPointers: Nullable<Camera>;
  100267. /** @hidden */
  100268. readonly _isScene: boolean;
  100269. /**
  100270. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100271. */
  100272. autoClear: boolean;
  100273. /**
  100274. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100275. */
  100276. autoClearDepthAndStencil: boolean;
  100277. /**
  100278. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100279. */
  100280. clearColor: Color4;
  100281. /**
  100282. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100283. */
  100284. ambientColor: Color3;
  100285. /**
  100286. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100287. * It should only be one of the following (if not the default embedded one):
  100288. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100289. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100290. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100291. * The material properties need to be setup according to the type of texture in use.
  100292. */
  100293. environmentBRDFTexture: BaseTexture;
  100294. /** @hidden */
  100295. protected _environmentTexture: Nullable<BaseTexture>;
  100296. /**
  100297. * Texture used in all pbr material as the reflection texture.
  100298. * As in the majority of the scene they are the same (exception for multi room and so on),
  100299. * this is easier to reference from here than from all the materials.
  100300. */
  100301. /**
  100302. * Texture used in all pbr material as the reflection texture.
  100303. * As in the majority of the scene they are the same (exception for multi room and so on),
  100304. * this is easier to set here than in all the materials.
  100305. */
  100306. environmentTexture: Nullable<BaseTexture>;
  100307. /** @hidden */
  100308. protected _environmentIntensity: number;
  100309. /**
  100310. * Intensity of the environment in all pbr material.
  100311. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100312. * As in the majority of the scene they are the same (exception for multi room and so on),
  100313. * this is easier to reference from here than from all the materials.
  100314. */
  100315. /**
  100316. * Intensity of the environment in all pbr material.
  100317. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100318. * As in the majority of the scene they are the same (exception for multi room and so on),
  100319. * this is easier to set here than in all the materials.
  100320. */
  100321. environmentIntensity: number;
  100322. /** @hidden */
  100323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100324. /**
  100325. * Default image processing configuration used either in the rendering
  100326. * Forward main pass or through the imageProcessingPostProcess if present.
  100327. * As in the majority of the scene they are the same (exception for multi camera),
  100328. * this is easier to reference from here than from all the materials and post process.
  100329. *
  100330. * No setter as we it is a shared configuration, you can set the values instead.
  100331. */
  100332. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100333. private _forceWireframe;
  100334. /**
  100335. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100336. */
  100337. forceWireframe: boolean;
  100338. private _forcePointsCloud;
  100339. /**
  100340. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100341. */
  100342. forcePointsCloud: boolean;
  100343. /**
  100344. * Gets or sets the active clipplane 1
  100345. */
  100346. clipPlane: Nullable<Plane>;
  100347. /**
  100348. * Gets or sets the active clipplane 2
  100349. */
  100350. clipPlane2: Nullable<Plane>;
  100351. /**
  100352. * Gets or sets the active clipplane 3
  100353. */
  100354. clipPlane3: Nullable<Plane>;
  100355. /**
  100356. * Gets or sets the active clipplane 4
  100357. */
  100358. clipPlane4: Nullable<Plane>;
  100359. /**
  100360. * Gets or sets a boolean indicating if animations are enabled
  100361. */
  100362. animationsEnabled: boolean;
  100363. private _animationPropertiesOverride;
  100364. /**
  100365. * Gets or sets the animation properties override
  100366. */
  100367. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100368. /**
  100369. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100370. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100371. */
  100372. useConstantAnimationDeltaTime: boolean;
  100373. /**
  100374. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100375. * Please note that it requires to run a ray cast through the scene on every frame
  100376. */
  100377. constantlyUpdateMeshUnderPointer: boolean;
  100378. /**
  100379. * Defines the HTML cursor to use when hovering over interactive elements
  100380. */
  100381. hoverCursor: string;
  100382. /**
  100383. * Defines the HTML default cursor to use (empty by default)
  100384. */
  100385. defaultCursor: string;
  100386. /**
  100387. * Defines wether cursors are handled by the scene.
  100388. */
  100389. doNotHandleCursors: boolean;
  100390. /**
  100391. * This is used to call preventDefault() on pointer down
  100392. * in order to block unwanted artifacts like system double clicks
  100393. */
  100394. preventDefaultOnPointerDown: boolean;
  100395. /**
  100396. * This is used to call preventDefault() on pointer up
  100397. * in order to block unwanted artifacts like system double clicks
  100398. */
  100399. preventDefaultOnPointerUp: boolean;
  100400. /**
  100401. * Gets or sets user defined metadata
  100402. */
  100403. metadata: any;
  100404. /**
  100405. * For internal use only. Please do not use.
  100406. */
  100407. reservedDataStore: any;
  100408. /**
  100409. * Gets the name of the plugin used to load this scene (null by default)
  100410. */
  100411. loadingPluginName: string;
  100412. /**
  100413. * Use this array to add regular expressions used to disable offline support for specific urls
  100414. */
  100415. disableOfflineSupportExceptionRules: RegExp[];
  100416. /**
  100417. * An event triggered when the scene is disposed.
  100418. */
  100419. onDisposeObservable: Observable<Scene>;
  100420. private _onDisposeObserver;
  100421. /** Sets a function to be executed when this scene is disposed. */
  100422. onDispose: () => void;
  100423. /**
  100424. * An event triggered before rendering the scene (right after animations and physics)
  100425. */
  100426. onBeforeRenderObservable: Observable<Scene>;
  100427. private _onBeforeRenderObserver;
  100428. /** Sets a function to be executed before rendering this scene */
  100429. beforeRender: Nullable<() => void>;
  100430. /**
  100431. * An event triggered after rendering the scene
  100432. */
  100433. onAfterRenderObservable: Observable<Scene>;
  100434. /**
  100435. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100436. */
  100437. onAfterRenderCameraObservable: Observable<Camera>;
  100438. private _onAfterRenderObserver;
  100439. /** Sets a function to be executed after rendering this scene */
  100440. afterRender: Nullable<() => void>;
  100441. /**
  100442. * An event triggered before animating the scene
  100443. */
  100444. onBeforeAnimationsObservable: Observable<Scene>;
  100445. /**
  100446. * An event triggered after animations processing
  100447. */
  100448. onAfterAnimationsObservable: Observable<Scene>;
  100449. /**
  100450. * An event triggered before draw calls are ready to be sent
  100451. */
  100452. onBeforeDrawPhaseObservable: Observable<Scene>;
  100453. /**
  100454. * An event triggered after draw calls have been sent
  100455. */
  100456. onAfterDrawPhaseObservable: Observable<Scene>;
  100457. /**
  100458. * An event triggered when the scene is ready
  100459. */
  100460. onReadyObservable: Observable<Scene>;
  100461. /**
  100462. * An event triggered before rendering a camera
  100463. */
  100464. onBeforeCameraRenderObservable: Observable<Camera>;
  100465. private _onBeforeCameraRenderObserver;
  100466. /** Sets a function to be executed before rendering a camera*/
  100467. beforeCameraRender: () => void;
  100468. /**
  100469. * An event triggered after rendering a camera
  100470. */
  100471. onAfterCameraRenderObservable: Observable<Camera>;
  100472. private _onAfterCameraRenderObserver;
  100473. /** Sets a function to be executed after rendering a camera*/
  100474. afterCameraRender: () => void;
  100475. /**
  100476. * An event triggered when active meshes evaluation is about to start
  100477. */
  100478. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100479. /**
  100480. * An event triggered when active meshes evaluation is done
  100481. */
  100482. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100483. /**
  100484. * An event triggered when particles rendering is about to start
  100485. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100486. */
  100487. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100488. /**
  100489. * An event triggered when particles rendering is done
  100490. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100491. */
  100492. onAfterParticlesRenderingObservable: Observable<Scene>;
  100493. /**
  100494. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100495. */
  100496. onDataLoadedObservable: Observable<Scene>;
  100497. /**
  100498. * An event triggered when a camera is created
  100499. */
  100500. onNewCameraAddedObservable: Observable<Camera>;
  100501. /**
  100502. * An event triggered when a camera is removed
  100503. */
  100504. onCameraRemovedObservable: Observable<Camera>;
  100505. /**
  100506. * An event triggered when a light is created
  100507. */
  100508. onNewLightAddedObservable: Observable<Light>;
  100509. /**
  100510. * An event triggered when a light is removed
  100511. */
  100512. onLightRemovedObservable: Observable<Light>;
  100513. /**
  100514. * An event triggered when a geometry is created
  100515. */
  100516. onNewGeometryAddedObservable: Observable<Geometry>;
  100517. /**
  100518. * An event triggered when a geometry is removed
  100519. */
  100520. onGeometryRemovedObservable: Observable<Geometry>;
  100521. /**
  100522. * An event triggered when a transform node is created
  100523. */
  100524. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100525. /**
  100526. * An event triggered when a transform node is removed
  100527. */
  100528. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100529. /**
  100530. * An event triggered when a mesh is created
  100531. */
  100532. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100533. /**
  100534. * An event triggered when a mesh is removed
  100535. */
  100536. onMeshRemovedObservable: Observable<AbstractMesh>;
  100537. /**
  100538. * An event triggered when a skeleton is created
  100539. */
  100540. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100541. /**
  100542. * An event triggered when a skeleton is removed
  100543. */
  100544. onSkeletonRemovedObservable: Observable<Skeleton>;
  100545. /**
  100546. * An event triggered when a material is created
  100547. */
  100548. onNewMaterialAddedObservable: Observable<Material>;
  100549. /**
  100550. * An event triggered when a material is removed
  100551. */
  100552. onMaterialRemovedObservable: Observable<Material>;
  100553. /**
  100554. * An event triggered when a texture is created
  100555. */
  100556. onNewTextureAddedObservable: Observable<BaseTexture>;
  100557. /**
  100558. * An event triggered when a texture is removed
  100559. */
  100560. onTextureRemovedObservable: Observable<BaseTexture>;
  100561. /**
  100562. * An event triggered when render targets are about to be rendered
  100563. * Can happen multiple times per frame.
  100564. */
  100565. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100566. /**
  100567. * An event triggered when render targets were rendered.
  100568. * Can happen multiple times per frame.
  100569. */
  100570. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100571. /**
  100572. * An event triggered before calculating deterministic simulation step
  100573. */
  100574. onBeforeStepObservable: Observable<Scene>;
  100575. /**
  100576. * An event triggered after calculating deterministic simulation step
  100577. */
  100578. onAfterStepObservable: Observable<Scene>;
  100579. /**
  100580. * An event triggered when the activeCamera property is updated
  100581. */
  100582. onActiveCameraChanged: Observable<Scene>;
  100583. /**
  100584. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100585. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100586. * 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)
  100587. */
  100588. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100589. /**
  100590. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100591. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100592. * 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)
  100593. */
  100594. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100595. /**
  100596. * This Observable will when a mesh has been imported into the scene.
  100597. */
  100598. onMeshImportedObservable: Observable<AbstractMesh>;
  100599. /**
  100600. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100601. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100602. */
  100603. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100604. /** @hidden */
  100605. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100606. /**
  100607. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100608. */
  100609. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100610. /**
  100611. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100612. */
  100613. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100614. /**
  100615. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100616. */
  100617. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100618. /** Callback called when a pointer move is detected */
  100619. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100620. /** Callback called when a pointer down is detected */
  100621. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100622. /** Callback called when a pointer up is detected */
  100623. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100624. /** Callback called when a pointer pick is detected */
  100625. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100626. /**
  100627. * 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).
  100628. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100629. */
  100630. onPrePointerObservable: Observable<PointerInfoPre>;
  100631. /**
  100632. * Observable event triggered each time an input event is received from the rendering canvas
  100633. */
  100634. onPointerObservable: Observable<PointerInfo>;
  100635. /**
  100636. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100637. */
  100638. readonly unTranslatedPointer: Vector2;
  100639. /**
  100640. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100641. */
  100642. static DragMovementThreshold: number;
  100643. /**
  100644. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100645. */
  100646. static LongPressDelay: number;
  100647. /**
  100648. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100649. */
  100650. static DoubleClickDelay: number;
  100651. /** If you need to check double click without raising a single click at first click, enable this flag */
  100652. static ExclusiveDoubleClickMode: boolean;
  100653. /** @hidden */
  100654. _mirroredCameraPosition: Nullable<Vector3>;
  100655. /**
  100656. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100657. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100658. */
  100659. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100660. /**
  100661. * Observable event triggered each time an keyboard event is received from the hosting window
  100662. */
  100663. onKeyboardObservable: Observable<KeyboardInfo>;
  100664. private _useRightHandedSystem;
  100665. /**
  100666. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100667. */
  100668. useRightHandedSystem: boolean;
  100669. private _timeAccumulator;
  100670. private _currentStepId;
  100671. private _currentInternalStep;
  100672. /**
  100673. * Sets the step Id used by deterministic lock step
  100674. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100675. * @param newStepId defines the step Id
  100676. */
  100677. setStepId(newStepId: number): void;
  100678. /**
  100679. * Gets the step Id used by deterministic lock step
  100680. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100681. * @returns the step Id
  100682. */
  100683. getStepId(): number;
  100684. /**
  100685. * Gets the internal step used by deterministic lock step
  100686. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100687. * @returns the internal step
  100688. */
  100689. getInternalStep(): number;
  100690. private _fogEnabled;
  100691. /**
  100692. * Gets or sets a boolean indicating if fog is enabled on this scene
  100693. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100694. * (Default is true)
  100695. */
  100696. fogEnabled: boolean;
  100697. private _fogMode;
  100698. /**
  100699. * Gets or sets the fog mode to use
  100700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100701. * | mode | value |
  100702. * | --- | --- |
  100703. * | FOGMODE_NONE | 0 |
  100704. * | FOGMODE_EXP | 1 |
  100705. * | FOGMODE_EXP2 | 2 |
  100706. * | FOGMODE_LINEAR | 3 |
  100707. */
  100708. fogMode: number;
  100709. /**
  100710. * Gets or sets the fog color to use
  100711. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100712. * (Default is Color3(0.2, 0.2, 0.3))
  100713. */
  100714. fogColor: Color3;
  100715. /**
  100716. * Gets or sets the fog density to use
  100717. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100718. * (Default is 0.1)
  100719. */
  100720. fogDensity: number;
  100721. /**
  100722. * Gets or sets the fog start distance to use
  100723. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100724. * (Default is 0)
  100725. */
  100726. fogStart: number;
  100727. /**
  100728. * Gets or sets the fog end distance to use
  100729. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100730. * (Default is 1000)
  100731. */
  100732. fogEnd: number;
  100733. private _shadowsEnabled;
  100734. /**
  100735. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100736. */
  100737. shadowsEnabled: boolean;
  100738. private _lightsEnabled;
  100739. /**
  100740. * Gets or sets a boolean indicating if lights are enabled on this scene
  100741. */
  100742. lightsEnabled: boolean;
  100743. /** All of the active cameras added to this scene. */
  100744. activeCameras: Camera[];
  100745. /** @hidden */
  100746. _activeCamera: Nullable<Camera>;
  100747. /** Gets or sets the current active camera */
  100748. activeCamera: Nullable<Camera>;
  100749. private _defaultMaterial;
  100750. /** The default material used on meshes when no material is affected */
  100751. /** The default material used on meshes when no material is affected */
  100752. defaultMaterial: Material;
  100753. private _texturesEnabled;
  100754. /**
  100755. * Gets or sets a boolean indicating if textures are enabled on this scene
  100756. */
  100757. texturesEnabled: boolean;
  100758. /**
  100759. * Gets or sets a boolean indicating if particles are enabled on this scene
  100760. */
  100761. particlesEnabled: boolean;
  100762. /**
  100763. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100764. */
  100765. spritesEnabled: boolean;
  100766. private _skeletonsEnabled;
  100767. /**
  100768. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100769. */
  100770. skeletonsEnabled: boolean;
  100771. /**
  100772. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100773. */
  100774. lensFlaresEnabled: boolean;
  100775. /**
  100776. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100778. */
  100779. collisionsEnabled: boolean;
  100780. private _collisionCoordinator;
  100781. /** @hidden */
  100782. readonly collisionCoordinator: ICollisionCoordinator;
  100783. /**
  100784. * Defines the gravity applied to this scene (used only for collisions)
  100785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100786. */
  100787. gravity: Vector3;
  100788. /**
  100789. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100790. */
  100791. postProcessesEnabled: boolean;
  100792. /**
  100793. * The list of postprocesses added to the scene
  100794. */
  100795. postProcesses: PostProcess[];
  100796. /**
  100797. * Gets the current postprocess manager
  100798. */
  100799. postProcessManager: PostProcessManager;
  100800. /**
  100801. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100802. */
  100803. renderTargetsEnabled: boolean;
  100804. /**
  100805. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100806. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100807. */
  100808. dumpNextRenderTargets: boolean;
  100809. /**
  100810. * The list of user defined render targets added to the scene
  100811. */
  100812. customRenderTargets: RenderTargetTexture[];
  100813. /**
  100814. * Defines if texture loading must be delayed
  100815. * If true, textures will only be loaded when they need to be rendered
  100816. */
  100817. useDelayedTextureLoading: boolean;
  100818. /**
  100819. * Gets the list of meshes imported to the scene through SceneLoader
  100820. */
  100821. importedMeshesFiles: String[];
  100822. /**
  100823. * Gets or sets a boolean indicating if probes are enabled on this scene
  100824. */
  100825. probesEnabled: boolean;
  100826. /**
  100827. * Gets or sets the current offline provider to use to store scene data
  100828. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100829. */
  100830. offlineProvider: IOfflineProvider;
  100831. /**
  100832. * Gets or sets the action manager associated with the scene
  100833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100834. */
  100835. actionManager: AbstractActionManager;
  100836. private _meshesForIntersections;
  100837. /**
  100838. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100839. */
  100840. proceduralTexturesEnabled: boolean;
  100841. private _engine;
  100842. private _totalVertices;
  100843. /** @hidden */
  100844. _activeIndices: PerfCounter;
  100845. /** @hidden */
  100846. _activeParticles: PerfCounter;
  100847. /** @hidden */
  100848. _activeBones: PerfCounter;
  100849. private _animationRatio;
  100850. /** @hidden */
  100851. _animationTimeLast: number;
  100852. /** @hidden */
  100853. _animationTime: number;
  100854. /**
  100855. * Gets or sets a general scale for animation speed
  100856. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100857. */
  100858. animationTimeScale: number;
  100859. /** @hidden */
  100860. _cachedMaterial: Nullable<Material>;
  100861. /** @hidden */
  100862. _cachedEffect: Nullable<Effect>;
  100863. /** @hidden */
  100864. _cachedVisibility: Nullable<number>;
  100865. private _renderId;
  100866. private _frameId;
  100867. private _executeWhenReadyTimeoutId;
  100868. private _intermediateRendering;
  100869. private _viewUpdateFlag;
  100870. private _projectionUpdateFlag;
  100871. /** @hidden */
  100872. _toBeDisposed: Nullable<IDisposable>[];
  100873. private _activeRequests;
  100874. /** @hidden */
  100875. _pendingData: any[];
  100876. private _isDisposed;
  100877. /**
  100878. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100879. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100880. */
  100881. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100882. private _activeMeshes;
  100883. private _processedMaterials;
  100884. private _renderTargets;
  100885. /** @hidden */
  100886. _activeParticleSystems: SmartArray<IParticleSystem>;
  100887. private _activeSkeletons;
  100888. private _softwareSkinnedMeshes;
  100889. private _renderingManager;
  100890. /** @hidden */
  100891. _activeAnimatables: Animatable[];
  100892. private _transformMatrix;
  100893. private _sceneUbo;
  100894. /** @hidden */
  100895. _viewMatrix: Matrix;
  100896. private _projectionMatrix;
  100897. /** @hidden */
  100898. _forcedViewPosition: Nullable<Vector3>;
  100899. /** @hidden */
  100900. _frustumPlanes: Plane[];
  100901. /**
  100902. * Gets the list of frustum planes (built from the active camera)
  100903. */
  100904. readonly frustumPlanes: Plane[];
  100905. /**
  100906. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100907. * This is useful if there are more lights that the maximum simulteanous authorized
  100908. */
  100909. requireLightSorting: boolean;
  100910. /** @hidden */
  100911. readonly useMaterialMeshMap: boolean;
  100912. /** @hidden */
  100913. readonly useClonedMeshhMap: boolean;
  100914. private _externalData;
  100915. private _uid;
  100916. /**
  100917. * @hidden
  100918. * Backing store of defined scene components.
  100919. */
  100920. _components: ISceneComponent[];
  100921. /**
  100922. * @hidden
  100923. * Backing store of defined scene components.
  100924. */
  100925. _serializableComponents: ISceneSerializableComponent[];
  100926. /**
  100927. * List of components to register on the next registration step.
  100928. */
  100929. private _transientComponents;
  100930. /**
  100931. * Registers the transient components if needed.
  100932. */
  100933. private _registerTransientComponents;
  100934. /**
  100935. * @hidden
  100936. * Add a component to the scene.
  100937. * Note that the ccomponent could be registered on th next frame if this is called after
  100938. * the register component stage.
  100939. * @param component Defines the component to add to the scene
  100940. */
  100941. _addComponent(component: ISceneComponent): void;
  100942. /**
  100943. * @hidden
  100944. * Gets a component from the scene.
  100945. * @param name defines the name of the component to retrieve
  100946. * @returns the component or null if not present
  100947. */
  100948. _getComponent(name: string): Nullable<ISceneComponent>;
  100949. /**
  100950. * @hidden
  100951. * Defines the actions happening before camera updates.
  100952. */
  100953. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100954. /**
  100955. * @hidden
  100956. * Defines the actions happening before clear the canvas.
  100957. */
  100958. _beforeClearStage: Stage<SimpleStageAction>;
  100959. /**
  100960. * @hidden
  100961. * Defines the actions when collecting render targets for the frame.
  100962. */
  100963. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100964. /**
  100965. * @hidden
  100966. * Defines the actions happening for one camera in the frame.
  100967. */
  100968. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100969. /**
  100970. * @hidden
  100971. * Defines the actions happening during the per mesh ready checks.
  100972. */
  100973. _isReadyForMeshStage: Stage<MeshStageAction>;
  100974. /**
  100975. * @hidden
  100976. * Defines the actions happening before evaluate active mesh checks.
  100977. */
  100978. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100979. /**
  100980. * @hidden
  100981. * Defines the actions happening during the evaluate sub mesh checks.
  100982. */
  100983. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100984. /**
  100985. * @hidden
  100986. * Defines the actions happening during the active mesh stage.
  100987. */
  100988. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100989. /**
  100990. * @hidden
  100991. * Defines the actions happening during the per camera render target step.
  100992. */
  100993. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100994. /**
  100995. * @hidden
  100996. * Defines the actions happening just before the active camera is drawing.
  100997. */
  100998. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100999. /**
  101000. * @hidden
  101001. * Defines the actions happening just before a render target is drawing.
  101002. */
  101003. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101004. /**
  101005. * @hidden
  101006. * Defines the actions happening just before a rendering group is drawing.
  101007. */
  101008. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101009. /**
  101010. * @hidden
  101011. * Defines the actions happening just before a mesh is drawing.
  101012. */
  101013. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101014. /**
  101015. * @hidden
  101016. * Defines the actions happening just after a mesh has been drawn.
  101017. */
  101018. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101019. /**
  101020. * @hidden
  101021. * Defines the actions happening just after a rendering group has been drawn.
  101022. */
  101023. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101024. /**
  101025. * @hidden
  101026. * Defines the actions happening just after the active camera has been drawn.
  101027. */
  101028. _afterCameraDrawStage: Stage<CameraStageAction>;
  101029. /**
  101030. * @hidden
  101031. * Defines the actions happening just after a render target has been drawn.
  101032. */
  101033. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101034. /**
  101035. * @hidden
  101036. * Defines the actions happening just after rendering all cameras and computing intersections.
  101037. */
  101038. _afterRenderStage: Stage<SimpleStageAction>;
  101039. /**
  101040. * @hidden
  101041. * Defines the actions happening when a pointer move event happens.
  101042. */
  101043. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101044. /**
  101045. * @hidden
  101046. * Defines the actions happening when a pointer down event happens.
  101047. */
  101048. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101049. /**
  101050. * @hidden
  101051. * Defines the actions happening when a pointer up event happens.
  101052. */
  101053. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101054. /**
  101055. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101056. */
  101057. private geometriesByUniqueId;
  101058. /**
  101059. * Creates a new Scene
  101060. * @param engine defines the engine to use to render this scene
  101061. * @param options defines the scene options
  101062. */
  101063. constructor(engine: Engine, options?: SceneOptions);
  101064. /**
  101065. * Gets a string idenfifying the name of the class
  101066. * @returns "Scene" string
  101067. */
  101068. getClassName(): string;
  101069. private _defaultMeshCandidates;
  101070. /**
  101071. * @hidden
  101072. */
  101073. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101074. private _defaultSubMeshCandidates;
  101075. /**
  101076. * @hidden
  101077. */
  101078. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101079. /**
  101080. * Sets the default candidate providers for the scene.
  101081. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101082. * and getCollidingSubMeshCandidates to their default function
  101083. */
  101084. setDefaultCandidateProviders(): void;
  101085. /**
  101086. * Gets the mesh that is currently under the pointer
  101087. */
  101088. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101089. /**
  101090. * Gets or sets the current on-screen X position of the pointer
  101091. */
  101092. pointerX: number;
  101093. /**
  101094. * Gets or sets the current on-screen Y position of the pointer
  101095. */
  101096. pointerY: number;
  101097. /**
  101098. * Gets the cached material (ie. the latest rendered one)
  101099. * @returns the cached material
  101100. */
  101101. getCachedMaterial(): Nullable<Material>;
  101102. /**
  101103. * Gets the cached effect (ie. the latest rendered one)
  101104. * @returns the cached effect
  101105. */
  101106. getCachedEffect(): Nullable<Effect>;
  101107. /**
  101108. * Gets the cached visibility state (ie. the latest rendered one)
  101109. * @returns the cached visibility state
  101110. */
  101111. getCachedVisibility(): Nullable<number>;
  101112. /**
  101113. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101114. * @param material defines the current material
  101115. * @param effect defines the current effect
  101116. * @param visibility defines the current visibility state
  101117. * @returns true if one parameter is not cached
  101118. */
  101119. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101120. /**
  101121. * Gets the engine associated with the scene
  101122. * @returns an Engine
  101123. */
  101124. getEngine(): Engine;
  101125. /**
  101126. * Gets the total number of vertices rendered per frame
  101127. * @returns the total number of vertices rendered per frame
  101128. */
  101129. getTotalVertices(): number;
  101130. /**
  101131. * Gets the performance counter for total vertices
  101132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101133. */
  101134. readonly totalVerticesPerfCounter: PerfCounter;
  101135. /**
  101136. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101137. * @returns the total number of active indices rendered per frame
  101138. */
  101139. getActiveIndices(): number;
  101140. /**
  101141. * Gets the performance counter for active indices
  101142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101143. */
  101144. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101145. /**
  101146. * Gets the total number of active particles rendered per frame
  101147. * @returns the total number of active particles rendered per frame
  101148. */
  101149. getActiveParticles(): number;
  101150. /**
  101151. * Gets the performance counter for active particles
  101152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101153. */
  101154. readonly activeParticlesPerfCounter: PerfCounter;
  101155. /**
  101156. * Gets the total number of active bones rendered per frame
  101157. * @returns the total number of active bones rendered per frame
  101158. */
  101159. getActiveBones(): number;
  101160. /**
  101161. * Gets the performance counter for active bones
  101162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101163. */
  101164. readonly activeBonesPerfCounter: PerfCounter;
  101165. /**
  101166. * Gets the array of active meshes
  101167. * @returns an array of AbstractMesh
  101168. */
  101169. getActiveMeshes(): SmartArray<AbstractMesh>;
  101170. /**
  101171. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101172. * @returns a number
  101173. */
  101174. getAnimationRatio(): number;
  101175. /**
  101176. * Gets an unique Id for the current render phase
  101177. * @returns a number
  101178. */
  101179. getRenderId(): number;
  101180. /**
  101181. * Gets an unique Id for the current frame
  101182. * @returns a number
  101183. */
  101184. getFrameId(): number;
  101185. /** Call this function if you want to manually increment the render Id*/
  101186. incrementRenderId(): void;
  101187. private _createUbo;
  101188. /**
  101189. * Use this method to simulate a pointer move on a mesh
  101190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101193. * @returns the current scene
  101194. */
  101195. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101196. /**
  101197. * Use this method to simulate a pointer down on a mesh
  101198. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101199. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101200. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101201. * @returns the current scene
  101202. */
  101203. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101204. /**
  101205. * Use this method to simulate a pointer up on a mesh
  101206. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101207. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101208. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101209. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101210. * @returns the current scene
  101211. */
  101212. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101213. /**
  101214. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101215. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101216. * @returns true if the pointer was captured
  101217. */
  101218. isPointerCaptured(pointerId?: number): boolean;
  101219. /**
  101220. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101221. * @param attachUp defines if you want to attach events to pointerup
  101222. * @param attachDown defines if you want to attach events to pointerdown
  101223. * @param attachMove defines if you want to attach events to pointermove
  101224. */
  101225. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101226. /** Detaches all event handlers*/
  101227. detachControl(): void;
  101228. /**
  101229. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101230. * Delay loaded resources are not taking in account
  101231. * @return true if all required resources are ready
  101232. */
  101233. isReady(): boolean;
  101234. /** Resets all cached information relative to material (including effect and visibility) */
  101235. resetCachedMaterial(): void;
  101236. /**
  101237. * Registers a function to be called before every frame render
  101238. * @param func defines the function to register
  101239. */
  101240. registerBeforeRender(func: () => void): void;
  101241. /**
  101242. * Unregisters a function called before every frame render
  101243. * @param func defines the function to unregister
  101244. */
  101245. unregisterBeforeRender(func: () => void): void;
  101246. /**
  101247. * Registers a function to be called after every frame render
  101248. * @param func defines the function to register
  101249. */
  101250. registerAfterRender(func: () => void): void;
  101251. /**
  101252. * Unregisters a function called after every frame render
  101253. * @param func defines the function to unregister
  101254. */
  101255. unregisterAfterRender(func: () => void): void;
  101256. private _executeOnceBeforeRender;
  101257. /**
  101258. * The provided function will run before render once and will be disposed afterwards.
  101259. * A timeout delay can be provided so that the function will be executed in N ms.
  101260. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101261. * @param func The function to be executed.
  101262. * @param timeout optional delay in ms
  101263. */
  101264. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101265. /** @hidden */
  101266. _addPendingData(data: any): void;
  101267. /** @hidden */
  101268. _removePendingData(data: any): void;
  101269. /**
  101270. * Returns the number of items waiting to be loaded
  101271. * @returns the number of items waiting to be loaded
  101272. */
  101273. getWaitingItemsCount(): number;
  101274. /**
  101275. * Returns a boolean indicating if the scene is still loading data
  101276. */
  101277. readonly isLoading: boolean;
  101278. /**
  101279. * Registers a function to be executed when the scene is ready
  101280. * @param {Function} func - the function to be executed
  101281. */
  101282. executeWhenReady(func: () => void): void;
  101283. /**
  101284. * Returns a promise that resolves when the scene is ready
  101285. * @returns A promise that resolves when the scene is ready
  101286. */
  101287. whenReadyAsync(): Promise<void>;
  101288. /** @hidden */
  101289. _checkIsReady(): void;
  101290. /**
  101291. * Gets all animatable attached to the scene
  101292. */
  101293. readonly animatables: Animatable[];
  101294. /**
  101295. * Resets the last animation time frame.
  101296. * Useful to override when animations start running when loading a scene for the first time.
  101297. */
  101298. resetLastAnimationTimeFrame(): void;
  101299. /**
  101300. * Gets the current view matrix
  101301. * @returns a Matrix
  101302. */
  101303. getViewMatrix(): Matrix;
  101304. /**
  101305. * Gets the current projection matrix
  101306. * @returns a Matrix
  101307. */
  101308. getProjectionMatrix(): Matrix;
  101309. /**
  101310. * Gets the current transform matrix
  101311. * @returns a Matrix made of View * Projection
  101312. */
  101313. getTransformMatrix(): Matrix;
  101314. /**
  101315. * Sets the current transform matrix
  101316. * @param viewL defines the View matrix to use
  101317. * @param projectionL defines the Projection matrix to use
  101318. * @param viewR defines the right View matrix to use (if provided)
  101319. * @param projectionR defines the right Projection matrix to use (if provided)
  101320. */
  101321. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101322. /**
  101323. * Gets the uniform buffer used to store scene data
  101324. * @returns a UniformBuffer
  101325. */
  101326. getSceneUniformBuffer(): UniformBuffer;
  101327. /**
  101328. * Gets an unique (relatively to the current scene) Id
  101329. * @returns an unique number for the scene
  101330. */
  101331. getUniqueId(): number;
  101332. /**
  101333. * Add a mesh to the list of scene's meshes
  101334. * @param newMesh defines the mesh to add
  101335. * @param recursive if all child meshes should also be added to the scene
  101336. */
  101337. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101338. /**
  101339. * Remove a mesh for the list of scene's meshes
  101340. * @param toRemove defines the mesh to remove
  101341. * @param recursive if all child meshes should also be removed from the scene
  101342. * @returns the index where the mesh was in the mesh list
  101343. */
  101344. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101345. /**
  101346. * Add a transform node to the list of scene's transform nodes
  101347. * @param newTransformNode defines the transform node to add
  101348. */
  101349. addTransformNode(newTransformNode: TransformNode): void;
  101350. /**
  101351. * Remove a transform node for the list of scene's transform nodes
  101352. * @param toRemove defines the transform node to remove
  101353. * @returns the index where the transform node was in the transform node list
  101354. */
  101355. removeTransformNode(toRemove: TransformNode): number;
  101356. /**
  101357. * Remove a skeleton for the list of scene's skeletons
  101358. * @param toRemove defines the skeleton to remove
  101359. * @returns the index where the skeleton was in the skeleton list
  101360. */
  101361. removeSkeleton(toRemove: Skeleton): number;
  101362. /**
  101363. * Remove a morph target for the list of scene's morph targets
  101364. * @param toRemove defines the morph target to remove
  101365. * @returns the index where the morph target was in the morph target list
  101366. */
  101367. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101368. /**
  101369. * Remove a light for the list of scene's lights
  101370. * @param toRemove defines the light to remove
  101371. * @returns the index where the light was in the light list
  101372. */
  101373. removeLight(toRemove: Light): number;
  101374. /**
  101375. * Remove a camera for the list of scene's cameras
  101376. * @param toRemove defines the camera to remove
  101377. * @returns the index where the camera was in the camera list
  101378. */
  101379. removeCamera(toRemove: Camera): number;
  101380. /**
  101381. * Remove a particle system for the list of scene's particle systems
  101382. * @param toRemove defines the particle system to remove
  101383. * @returns the index where the particle system was in the particle system list
  101384. */
  101385. removeParticleSystem(toRemove: IParticleSystem): number;
  101386. /**
  101387. * Remove a animation for the list of scene's animations
  101388. * @param toRemove defines the animation to remove
  101389. * @returns the index where the animation was in the animation list
  101390. */
  101391. removeAnimation(toRemove: Animation): number;
  101392. /**
  101393. * Will stop the animation of the given target
  101394. * @param target - the target
  101395. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101396. * @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)
  101397. */
  101398. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101399. /**
  101400. * Removes the given animation group from this scene.
  101401. * @param toRemove The animation group to remove
  101402. * @returns The index of the removed animation group
  101403. */
  101404. removeAnimationGroup(toRemove: AnimationGroup): number;
  101405. /**
  101406. * Removes the given multi-material from this scene.
  101407. * @param toRemove The multi-material to remove
  101408. * @returns The index of the removed multi-material
  101409. */
  101410. removeMultiMaterial(toRemove: MultiMaterial): number;
  101411. /**
  101412. * Removes the given material from this scene.
  101413. * @param toRemove The material to remove
  101414. * @returns The index of the removed material
  101415. */
  101416. removeMaterial(toRemove: Material): number;
  101417. /**
  101418. * Removes the given action manager from this scene.
  101419. * @param toRemove The action manager to remove
  101420. * @returns The index of the removed action manager
  101421. */
  101422. removeActionManager(toRemove: AbstractActionManager): number;
  101423. /**
  101424. * Removes the given texture from this scene.
  101425. * @param toRemove The texture to remove
  101426. * @returns The index of the removed texture
  101427. */
  101428. removeTexture(toRemove: BaseTexture): number;
  101429. /**
  101430. * Adds the given light to this scene
  101431. * @param newLight The light to add
  101432. */
  101433. addLight(newLight: Light): void;
  101434. /**
  101435. * Sorts the list list based on light priorities
  101436. */
  101437. sortLightsByPriority(): void;
  101438. /**
  101439. * Adds the given camera to this scene
  101440. * @param newCamera The camera to add
  101441. */
  101442. addCamera(newCamera: Camera): void;
  101443. /**
  101444. * Adds the given skeleton to this scene
  101445. * @param newSkeleton The skeleton to add
  101446. */
  101447. addSkeleton(newSkeleton: Skeleton): void;
  101448. /**
  101449. * Adds the given particle system to this scene
  101450. * @param newParticleSystem The particle system to add
  101451. */
  101452. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101453. /**
  101454. * Adds the given animation to this scene
  101455. * @param newAnimation The animation to add
  101456. */
  101457. addAnimation(newAnimation: Animation): void;
  101458. /**
  101459. * Adds the given animation group to this scene.
  101460. * @param newAnimationGroup The animation group to add
  101461. */
  101462. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101463. /**
  101464. * Adds the given multi-material to this scene
  101465. * @param newMultiMaterial The multi-material to add
  101466. */
  101467. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101468. /**
  101469. * Adds the given material to this scene
  101470. * @param newMaterial The material to add
  101471. */
  101472. addMaterial(newMaterial: Material): void;
  101473. /**
  101474. * Adds the given morph target to this scene
  101475. * @param newMorphTargetManager The morph target to add
  101476. */
  101477. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101478. /**
  101479. * Adds the given geometry to this scene
  101480. * @param newGeometry The geometry to add
  101481. */
  101482. addGeometry(newGeometry: Geometry): void;
  101483. /**
  101484. * Adds the given action manager to this scene
  101485. * @param newActionManager The action manager to add
  101486. */
  101487. addActionManager(newActionManager: AbstractActionManager): void;
  101488. /**
  101489. * Adds the given texture to this scene.
  101490. * @param newTexture The texture to add
  101491. */
  101492. addTexture(newTexture: BaseTexture): void;
  101493. /**
  101494. * Switch active camera
  101495. * @param newCamera defines the new active camera
  101496. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101497. */
  101498. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101499. /**
  101500. * sets the active camera of the scene using its ID
  101501. * @param id defines the camera's ID
  101502. * @return the new active camera or null if none found.
  101503. */
  101504. setActiveCameraByID(id: string): Nullable<Camera>;
  101505. /**
  101506. * sets the active camera of the scene using its name
  101507. * @param name defines the camera's name
  101508. * @returns the new active camera or null if none found.
  101509. */
  101510. setActiveCameraByName(name: string): Nullable<Camera>;
  101511. /**
  101512. * get an animation group using its name
  101513. * @param name defines the material's name
  101514. * @return the animation group or null if none found.
  101515. */
  101516. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101517. /**
  101518. * Get a material using its unique id
  101519. * @param uniqueId defines the material's unique id
  101520. * @return the material or null if none found.
  101521. */
  101522. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101523. /**
  101524. * get a material using its id
  101525. * @param id defines the material's ID
  101526. * @return the material or null if none found.
  101527. */
  101528. getMaterialByID(id: string): Nullable<Material>;
  101529. /**
  101530. * Gets a the last added material using a given id
  101531. * @param id defines the material's ID
  101532. * @return the last material with the given id or null if none found.
  101533. */
  101534. getLastMaterialByID(id: string): Nullable<Material>;
  101535. /**
  101536. * Gets a material using its name
  101537. * @param name defines the material's name
  101538. * @return the material or null if none found.
  101539. */
  101540. getMaterialByName(name: string): Nullable<Material>;
  101541. /**
  101542. * Get a texture using its unique id
  101543. * @param uniqueId defines the texture's unique id
  101544. * @return the texture or null if none found.
  101545. */
  101546. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101547. /**
  101548. * Gets a camera using its id
  101549. * @param id defines the id to look for
  101550. * @returns the camera or null if not found
  101551. */
  101552. getCameraByID(id: string): Nullable<Camera>;
  101553. /**
  101554. * Gets a camera using its unique id
  101555. * @param uniqueId defines the unique id to look for
  101556. * @returns the camera or null if not found
  101557. */
  101558. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101559. /**
  101560. * Gets a camera using its name
  101561. * @param name defines the camera's name
  101562. * @return the camera or null if none found.
  101563. */
  101564. getCameraByName(name: string): Nullable<Camera>;
  101565. /**
  101566. * Gets a bone using its id
  101567. * @param id defines the bone's id
  101568. * @return the bone or null if not found
  101569. */
  101570. getBoneByID(id: string): Nullable<Bone>;
  101571. /**
  101572. * Gets a bone using its id
  101573. * @param name defines the bone's name
  101574. * @return the bone or null if not found
  101575. */
  101576. getBoneByName(name: string): Nullable<Bone>;
  101577. /**
  101578. * Gets a light node using its name
  101579. * @param name defines the the light's name
  101580. * @return the light or null if none found.
  101581. */
  101582. getLightByName(name: string): Nullable<Light>;
  101583. /**
  101584. * Gets a light node using its id
  101585. * @param id defines the light's id
  101586. * @return the light or null if none found.
  101587. */
  101588. getLightByID(id: string): Nullable<Light>;
  101589. /**
  101590. * Gets a light node using its scene-generated unique ID
  101591. * @param uniqueId defines the light's unique id
  101592. * @return the light or null if none found.
  101593. */
  101594. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101595. /**
  101596. * Gets a particle system by id
  101597. * @param id defines the particle system id
  101598. * @return the corresponding system or null if none found
  101599. */
  101600. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101601. /**
  101602. * Gets a geometry using its ID
  101603. * @param id defines the geometry's id
  101604. * @return the geometry or null if none found.
  101605. */
  101606. getGeometryByID(id: string): Nullable<Geometry>;
  101607. private _getGeometryByUniqueID;
  101608. /**
  101609. * Add a new geometry to this scene
  101610. * @param geometry defines the geometry to be added to the scene.
  101611. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101612. * @return a boolean defining if the geometry was added or not
  101613. */
  101614. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101615. /**
  101616. * Removes an existing geometry
  101617. * @param geometry defines the geometry to be removed from the scene
  101618. * @return a boolean defining if the geometry was removed or not
  101619. */
  101620. removeGeometry(geometry: Geometry): boolean;
  101621. /**
  101622. * Gets the list of geometries attached to the scene
  101623. * @returns an array of Geometry
  101624. */
  101625. getGeometries(): Geometry[];
  101626. /**
  101627. * Gets the first added mesh found of a given ID
  101628. * @param id defines the id to search for
  101629. * @return the mesh found or null if not found at all
  101630. */
  101631. getMeshByID(id: string): Nullable<AbstractMesh>;
  101632. /**
  101633. * Gets a list of meshes using their id
  101634. * @param id defines the id to search for
  101635. * @returns a list of meshes
  101636. */
  101637. getMeshesByID(id: string): Array<AbstractMesh>;
  101638. /**
  101639. * Gets the first added transform node found of a given ID
  101640. * @param id defines the id to search for
  101641. * @return the found transform node or null if not found at all.
  101642. */
  101643. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101644. /**
  101645. * Gets a transform node with its auto-generated unique id
  101646. * @param uniqueId efines the unique id to search for
  101647. * @return the found transform node or null if not found at all.
  101648. */
  101649. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101650. /**
  101651. * Gets a list of transform nodes using their id
  101652. * @param id defines the id to search for
  101653. * @returns a list of transform nodes
  101654. */
  101655. getTransformNodesByID(id: string): Array<TransformNode>;
  101656. /**
  101657. * Gets a mesh with its auto-generated unique id
  101658. * @param uniqueId defines the unique id to search for
  101659. * @return the found mesh or null if not found at all.
  101660. */
  101661. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101662. /**
  101663. * Gets a the last added mesh using a given id
  101664. * @param id defines the id to search for
  101665. * @return the found mesh or null if not found at all.
  101666. */
  101667. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101668. /**
  101669. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101670. * @param id defines the id to search for
  101671. * @return the found node or null if not found at all
  101672. */
  101673. getLastEntryByID(id: string): Nullable<Node>;
  101674. /**
  101675. * Gets a node (Mesh, Camera, Light) using a given id
  101676. * @param id defines the id to search for
  101677. * @return the found node or null if not found at all
  101678. */
  101679. getNodeByID(id: string): Nullable<Node>;
  101680. /**
  101681. * Gets a node (Mesh, Camera, Light) using a given name
  101682. * @param name defines the name to search for
  101683. * @return the found node or null if not found at all.
  101684. */
  101685. getNodeByName(name: string): Nullable<Node>;
  101686. /**
  101687. * Gets a mesh using a given name
  101688. * @param name defines the name to search for
  101689. * @return the found mesh or null if not found at all.
  101690. */
  101691. getMeshByName(name: string): Nullable<AbstractMesh>;
  101692. /**
  101693. * Gets a transform node using a given name
  101694. * @param name defines the name to search for
  101695. * @return the found transform node or null if not found at all.
  101696. */
  101697. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101698. /**
  101699. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101700. * @param id defines the id to search for
  101701. * @return the found skeleton or null if not found at all.
  101702. */
  101703. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101704. /**
  101705. * Gets a skeleton using a given auto generated unique id
  101706. * @param uniqueId defines the unique id to search for
  101707. * @return the found skeleton or null if not found at all.
  101708. */
  101709. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101710. /**
  101711. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101712. * @param id defines the id to search for
  101713. * @return the found skeleton or null if not found at all.
  101714. */
  101715. getSkeletonById(id: string): Nullable<Skeleton>;
  101716. /**
  101717. * Gets a skeleton using a given name
  101718. * @param name defines the name to search for
  101719. * @return the found skeleton or null if not found at all.
  101720. */
  101721. getSkeletonByName(name: string): Nullable<Skeleton>;
  101722. /**
  101723. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101724. * @param id defines the id to search for
  101725. * @return the found morph target manager or null if not found at all.
  101726. */
  101727. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101728. /**
  101729. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101730. * @param id defines the id to search for
  101731. * @return the found morph target or null if not found at all.
  101732. */
  101733. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101734. /**
  101735. * Gets a boolean indicating if the given mesh is active
  101736. * @param mesh defines the mesh to look for
  101737. * @returns true if the mesh is in the active list
  101738. */
  101739. isActiveMesh(mesh: AbstractMesh): boolean;
  101740. /**
  101741. * Return a unique id as a string which can serve as an identifier for the scene
  101742. */
  101743. readonly uid: string;
  101744. /**
  101745. * Add an externaly attached data from its key.
  101746. * This method call will fail and return false, if such key already exists.
  101747. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101748. * @param key the unique key that identifies the data
  101749. * @param data the data object to associate to the key for this Engine instance
  101750. * @return true if no such key were already present and the data was added successfully, false otherwise
  101751. */
  101752. addExternalData<T>(key: string, data: T): boolean;
  101753. /**
  101754. * Get an externaly attached data from its key
  101755. * @param key the unique key that identifies the data
  101756. * @return the associated data, if present (can be null), or undefined if not present
  101757. */
  101758. getExternalData<T>(key: string): Nullable<T>;
  101759. /**
  101760. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101761. * @param key the unique key that identifies the data
  101762. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101763. * @return the associated data, can be null if the factory returned null.
  101764. */
  101765. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101766. /**
  101767. * Remove an externaly attached data from the Engine instance
  101768. * @param key the unique key that identifies the data
  101769. * @return true if the data was successfully removed, false if it doesn't exist
  101770. */
  101771. removeExternalData(key: string): boolean;
  101772. private _evaluateSubMesh;
  101773. /**
  101774. * Clear the processed materials smart array preventing retention point in material dispose.
  101775. */
  101776. freeProcessedMaterials(): void;
  101777. private _preventFreeActiveMeshesAndRenderingGroups;
  101778. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101779. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101780. * when disposing several meshes in a row or a hierarchy of meshes.
  101781. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101782. */
  101783. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101784. /**
  101785. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101786. */
  101787. freeActiveMeshes(): void;
  101788. /**
  101789. * Clear the info related to rendering groups preventing retention points during dispose.
  101790. */
  101791. freeRenderingGroups(): void;
  101792. /** @hidden */
  101793. _isInIntermediateRendering(): boolean;
  101794. /**
  101795. * Lambda returning the list of potentially active meshes.
  101796. */
  101797. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101798. /**
  101799. * Lambda returning the list of potentially active sub meshes.
  101800. */
  101801. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101802. /**
  101803. * Lambda returning the list of potentially intersecting sub meshes.
  101804. */
  101805. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101806. /**
  101807. * Lambda returning the list of potentially colliding sub meshes.
  101808. */
  101809. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101810. private _activeMeshesFrozen;
  101811. /**
  101812. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101813. * @returns the current scene
  101814. */
  101815. freezeActiveMeshes(): Scene;
  101816. /**
  101817. * Use this function to restart evaluating active meshes on every frame
  101818. * @returns the current scene
  101819. */
  101820. unfreezeActiveMeshes(): Scene;
  101821. private _evaluateActiveMeshes;
  101822. private _activeMesh;
  101823. /**
  101824. * Update the transform matrix to update from the current active camera
  101825. * @param force defines a boolean used to force the update even if cache is up to date
  101826. */
  101827. updateTransformMatrix(force?: boolean): void;
  101828. private _bindFrameBuffer;
  101829. /** @hidden */
  101830. _allowPostProcessClearColor: boolean;
  101831. /** @hidden */
  101832. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101833. private _processSubCameras;
  101834. private _checkIntersections;
  101835. /** @hidden */
  101836. _advancePhysicsEngineStep(step: number): void;
  101837. /**
  101838. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101839. */
  101840. getDeterministicFrameTime: () => number;
  101841. /** @hidden */
  101842. _animate(): void;
  101843. /** Execute all animations (for a frame) */
  101844. animate(): void;
  101845. /**
  101846. * Render the scene
  101847. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101848. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101849. */
  101850. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101851. /**
  101852. * Freeze all materials
  101853. * A frozen material will not be updatable but should be faster to render
  101854. */
  101855. freezeMaterials(): void;
  101856. /**
  101857. * Unfreeze all materials
  101858. * A frozen material will not be updatable but should be faster to render
  101859. */
  101860. unfreezeMaterials(): void;
  101861. /**
  101862. * Releases all held ressources
  101863. */
  101864. dispose(): void;
  101865. /**
  101866. * Gets if the scene is already disposed
  101867. */
  101868. readonly isDisposed: boolean;
  101869. /**
  101870. * Call this function to reduce memory footprint of the scene.
  101871. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101872. */
  101873. clearCachedVertexData(): void;
  101874. /**
  101875. * This function will remove the local cached buffer data from texture.
  101876. * It will save memory but will prevent the texture from being rebuilt
  101877. */
  101878. cleanCachedTextureBuffer(): void;
  101879. /**
  101880. * Get the world extend vectors with an optional filter
  101881. *
  101882. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101883. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101884. */
  101885. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101886. min: Vector3;
  101887. max: Vector3;
  101888. };
  101889. /**
  101890. * Creates a ray that can be used to pick in the scene
  101891. * @param x defines the x coordinate of the origin (on-screen)
  101892. * @param y defines the y coordinate of the origin (on-screen)
  101893. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101894. * @param camera defines the camera to use for the picking
  101895. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101896. * @returns a Ray
  101897. */
  101898. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101899. /**
  101900. * Creates a ray that can be used to pick in the scene
  101901. * @param x defines the x coordinate of the origin (on-screen)
  101902. * @param y defines the y coordinate of the origin (on-screen)
  101903. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101904. * @param result defines the ray where to store the picking ray
  101905. * @param camera defines the camera to use for the picking
  101906. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101907. * @returns the current scene
  101908. */
  101909. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101910. /**
  101911. * Creates a ray that can be used to pick in the scene
  101912. * @param x defines the x coordinate of the origin (on-screen)
  101913. * @param y defines the y coordinate of the origin (on-screen)
  101914. * @param camera defines the camera to use for the picking
  101915. * @returns a Ray
  101916. */
  101917. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101918. /**
  101919. * Creates a ray that can be used to pick in the scene
  101920. * @param x defines the x coordinate of the origin (on-screen)
  101921. * @param y defines the y coordinate of the origin (on-screen)
  101922. * @param result defines the ray where to store the picking ray
  101923. * @param camera defines the camera to use for the picking
  101924. * @returns the current scene
  101925. */
  101926. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101927. /** Launch a ray to try to pick a mesh in the scene
  101928. * @param x position on screen
  101929. * @param y position on screen
  101930. * @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
  101931. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101932. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101933. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101934. * @returns a PickingInfo
  101935. */
  101936. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101937. /** Use the given ray to pick a mesh in the scene
  101938. * @param ray The ray to use to pick meshes
  101939. * @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
  101940. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101941. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101942. * @returns a PickingInfo
  101943. */
  101944. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101945. /**
  101946. * Launch a ray to try to pick a mesh in the scene
  101947. * @param x X position on screen
  101948. * @param y Y position on screen
  101949. * @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
  101950. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101952. * @returns an array of PickingInfo
  101953. */
  101954. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101955. /**
  101956. * Launch a ray to try to pick a mesh in the scene
  101957. * @param ray Ray to use
  101958. * @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
  101959. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101960. * @returns an array of PickingInfo
  101961. */
  101962. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101963. /**
  101964. * Force the value of meshUnderPointer
  101965. * @param mesh defines the mesh to use
  101966. */
  101967. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101968. /**
  101969. * Gets the mesh under the pointer
  101970. * @returns a Mesh or null if no mesh is under the pointer
  101971. */
  101972. getPointerOverMesh(): Nullable<AbstractMesh>;
  101973. /** @hidden */
  101974. _rebuildGeometries(): void;
  101975. /** @hidden */
  101976. _rebuildTextures(): void;
  101977. private _getByTags;
  101978. /**
  101979. * Get a list of meshes by tags
  101980. * @param tagsQuery defines the tags query to use
  101981. * @param forEach defines a predicate used to filter results
  101982. * @returns an array of Mesh
  101983. */
  101984. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101985. /**
  101986. * Get a list of cameras by tags
  101987. * @param tagsQuery defines the tags query to use
  101988. * @param forEach defines a predicate used to filter results
  101989. * @returns an array of Camera
  101990. */
  101991. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101992. /**
  101993. * Get a list of lights by tags
  101994. * @param tagsQuery defines the tags query to use
  101995. * @param forEach defines a predicate used to filter results
  101996. * @returns an array of Light
  101997. */
  101998. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101999. /**
  102000. * Get a list of materials by tags
  102001. * @param tagsQuery defines the tags query to use
  102002. * @param forEach defines a predicate used to filter results
  102003. * @returns an array of Material
  102004. */
  102005. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102006. /**
  102007. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102008. * This allowed control for front to back rendering or reversly depending of the special needs.
  102009. *
  102010. * @param renderingGroupId The rendering group id corresponding to its index
  102011. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102012. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102013. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102014. */
  102015. 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;
  102016. /**
  102017. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102018. *
  102019. * @param renderingGroupId The rendering group id corresponding to its index
  102020. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102021. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102022. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102023. */
  102024. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102025. /**
  102026. * Gets the current auto clear configuration for one rendering group of the rendering
  102027. * manager.
  102028. * @param index the rendering group index to get the information for
  102029. * @returns The auto clear setup for the requested rendering group
  102030. */
  102031. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102032. private _blockMaterialDirtyMechanism;
  102033. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102034. blockMaterialDirtyMechanism: boolean;
  102035. /**
  102036. * Will flag all materials as dirty to trigger new shader compilation
  102037. * @param flag defines the flag used to specify which material part must be marked as dirty
  102038. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102039. */
  102040. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102041. /** @hidden */
  102042. _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;
  102043. /** @hidden */
  102044. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102045. }
  102046. }
  102047. declare module BABYLON {
  102048. /**
  102049. * Set of assets to keep when moving a scene into an asset container.
  102050. */
  102051. export class KeepAssets extends AbstractScene {
  102052. }
  102053. /**
  102054. * Container with a set of assets that can be added or removed from a scene.
  102055. */
  102056. export class AssetContainer extends AbstractScene {
  102057. /**
  102058. * The scene the AssetContainer belongs to.
  102059. */
  102060. scene: Scene;
  102061. /**
  102062. * Instantiates an AssetContainer.
  102063. * @param scene The scene the AssetContainer belongs to.
  102064. */
  102065. constructor(scene: Scene);
  102066. /**
  102067. * Adds all the assets from the container to the scene.
  102068. */
  102069. addAllToScene(): void;
  102070. /**
  102071. * Removes all the assets in the container from the scene
  102072. */
  102073. removeAllFromScene(): void;
  102074. /**
  102075. * Disposes all the assets in the container
  102076. */
  102077. dispose(): void;
  102078. private _moveAssets;
  102079. /**
  102080. * Removes all the assets contained in the scene and adds them to the container.
  102081. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102082. */
  102083. moveAllFromScene(keepAssets?: KeepAssets): void;
  102084. /**
  102085. * 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.
  102086. * @returns the root mesh
  102087. */
  102088. createRootMesh(): Mesh;
  102089. }
  102090. }
  102091. declare module BABYLON {
  102092. /**
  102093. * Defines how the parser contract is defined.
  102094. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102095. */
  102096. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102097. /**
  102098. * Defines how the individual parser contract is defined.
  102099. * These parser can parse an individual asset
  102100. */
  102101. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102102. /**
  102103. * Base class of the scene acting as a container for the different elements composing a scene.
  102104. * This class is dynamically extended by the different components of the scene increasing
  102105. * flexibility and reducing coupling
  102106. */
  102107. export abstract class AbstractScene {
  102108. /**
  102109. * Stores the list of available parsers in the application.
  102110. */
  102111. private static _BabylonFileParsers;
  102112. /**
  102113. * Stores the list of available individual parsers in the application.
  102114. */
  102115. private static _IndividualBabylonFileParsers;
  102116. /**
  102117. * Adds a parser in the list of available ones
  102118. * @param name Defines the name of the parser
  102119. * @param parser Defines the parser to add
  102120. */
  102121. static AddParser(name: string, parser: BabylonFileParser): void;
  102122. /**
  102123. * Gets a general parser from the list of avaialble ones
  102124. * @param name Defines the name of the parser
  102125. * @returns the requested parser or null
  102126. */
  102127. static GetParser(name: string): Nullable<BabylonFileParser>;
  102128. /**
  102129. * Adds n individual parser in the list of available ones
  102130. * @param name Defines the name of the parser
  102131. * @param parser Defines the parser to add
  102132. */
  102133. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102134. /**
  102135. * Gets an individual parser from the list of avaialble ones
  102136. * @param name Defines the name of the parser
  102137. * @returns the requested parser or null
  102138. */
  102139. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102140. /**
  102141. * Parser json data and populate both a scene and its associated container object
  102142. * @param jsonData Defines the data to parse
  102143. * @param scene Defines the scene to parse the data for
  102144. * @param container Defines the container attached to the parsing sequence
  102145. * @param rootUrl Defines the root url of the data
  102146. */
  102147. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102148. /**
  102149. * Gets the list of root nodes (ie. nodes with no parent)
  102150. */
  102151. rootNodes: Node[];
  102152. /** All of the cameras added to this scene
  102153. * @see http://doc.babylonjs.com/babylon101/cameras
  102154. */
  102155. cameras: Camera[];
  102156. /**
  102157. * All of the lights added to this scene
  102158. * @see http://doc.babylonjs.com/babylon101/lights
  102159. */
  102160. lights: Light[];
  102161. /**
  102162. * All of the (abstract) meshes added to this scene
  102163. */
  102164. meshes: AbstractMesh[];
  102165. /**
  102166. * The list of skeletons added to the scene
  102167. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102168. */
  102169. skeletons: Skeleton[];
  102170. /**
  102171. * All of the particle systems added to this scene
  102172. * @see http://doc.babylonjs.com/babylon101/particles
  102173. */
  102174. particleSystems: IParticleSystem[];
  102175. /**
  102176. * Gets a list of Animations associated with the scene
  102177. */
  102178. animations: Animation[];
  102179. /**
  102180. * All of the animation groups added to this scene
  102181. * @see http://doc.babylonjs.com/how_to/group
  102182. */
  102183. animationGroups: AnimationGroup[];
  102184. /**
  102185. * All of the multi-materials added to this scene
  102186. * @see http://doc.babylonjs.com/how_to/multi_materials
  102187. */
  102188. multiMaterials: MultiMaterial[];
  102189. /**
  102190. * All of the materials added to this scene
  102191. * In the context of a Scene, it is not supposed to be modified manually.
  102192. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  102193. * Note also that the order of the Material wihin the array is not significant and might change.
  102194. * @see http://doc.babylonjs.com/babylon101/materials
  102195. */
  102196. materials: Material[];
  102197. /**
  102198. * The list of morph target managers added to the scene
  102199. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102200. */
  102201. morphTargetManagers: MorphTargetManager[];
  102202. /**
  102203. * The list of geometries used in the scene.
  102204. */
  102205. geometries: Geometry[];
  102206. /**
  102207. * All of the tranform nodes added to this scene
  102208. * In the context of a Scene, it is not supposed to be modified manually.
  102209. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102210. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102211. * @see http://doc.babylonjs.com/how_to/transformnode
  102212. */
  102213. transformNodes: TransformNode[];
  102214. /**
  102215. * ActionManagers available on the scene.
  102216. */
  102217. actionManagers: AbstractActionManager[];
  102218. /**
  102219. * Textures to keep.
  102220. */
  102221. textures: BaseTexture[];
  102222. /**
  102223. * Environment texture for the scene
  102224. */
  102225. environmentTexture: Nullable<BaseTexture>;
  102226. }
  102227. }
  102228. declare module BABYLON {
  102229. /**
  102230. * Interface used to define options for Sound class
  102231. */
  102232. export interface ISoundOptions {
  102233. /**
  102234. * Does the sound autoplay once loaded.
  102235. */
  102236. autoplay?: boolean;
  102237. /**
  102238. * Does the sound loop after it finishes playing once.
  102239. */
  102240. loop?: boolean;
  102241. /**
  102242. * Sound's volume
  102243. */
  102244. volume?: number;
  102245. /**
  102246. * Is it a spatial sound?
  102247. */
  102248. spatialSound?: boolean;
  102249. /**
  102250. * Maximum distance to hear that sound
  102251. */
  102252. maxDistance?: number;
  102253. /**
  102254. * Uses user defined attenuation function
  102255. */
  102256. useCustomAttenuation?: boolean;
  102257. /**
  102258. * Define the roll off factor of spatial sounds.
  102259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102260. */
  102261. rolloffFactor?: number;
  102262. /**
  102263. * Define the reference distance the sound should be heard perfectly.
  102264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102265. */
  102266. refDistance?: number;
  102267. /**
  102268. * Define the distance attenuation model the sound will follow.
  102269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102270. */
  102271. distanceModel?: string;
  102272. /**
  102273. * Defines the playback speed (1 by default)
  102274. */
  102275. playbackRate?: number;
  102276. /**
  102277. * Defines if the sound is from a streaming source
  102278. */
  102279. streaming?: boolean;
  102280. /**
  102281. * Defines an optional length (in seconds) inside the sound file
  102282. */
  102283. length?: number;
  102284. /**
  102285. * Defines an optional offset (in seconds) inside the sound file
  102286. */
  102287. offset?: number;
  102288. /**
  102289. * If true, URLs will not be required to state the audio file codec to use.
  102290. */
  102291. skipCodecCheck?: boolean;
  102292. }
  102293. /**
  102294. * Defines a sound that can be played in the application.
  102295. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102297. */
  102298. export class Sound {
  102299. /**
  102300. * The name of the sound in the scene.
  102301. */
  102302. name: string;
  102303. /**
  102304. * Does the sound autoplay once loaded.
  102305. */
  102306. autoplay: boolean;
  102307. /**
  102308. * Does the sound loop after it finishes playing once.
  102309. */
  102310. loop: boolean;
  102311. /**
  102312. * Does the sound use a custom attenuation curve to simulate the falloff
  102313. * happening when the source gets further away from the camera.
  102314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102315. */
  102316. useCustomAttenuation: boolean;
  102317. /**
  102318. * The sound track id this sound belongs to.
  102319. */
  102320. soundTrackId: number;
  102321. /**
  102322. * Is this sound currently played.
  102323. */
  102324. isPlaying: boolean;
  102325. /**
  102326. * Is this sound currently paused.
  102327. */
  102328. isPaused: boolean;
  102329. /**
  102330. * Does this sound enables spatial sound.
  102331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102332. */
  102333. spatialSound: boolean;
  102334. /**
  102335. * Define the reference distance the sound should be heard perfectly.
  102336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102337. */
  102338. refDistance: number;
  102339. /**
  102340. * Define the roll off factor of spatial sounds.
  102341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102342. */
  102343. rolloffFactor: number;
  102344. /**
  102345. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102347. */
  102348. maxDistance: number;
  102349. /**
  102350. * Define the distance attenuation model the sound will follow.
  102351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102352. */
  102353. distanceModel: string;
  102354. /**
  102355. * @hidden
  102356. * Back Compat
  102357. **/
  102358. onended: () => any;
  102359. /**
  102360. * Observable event when the current playing sound finishes.
  102361. */
  102362. onEndedObservable: Observable<Sound>;
  102363. private _panningModel;
  102364. private _playbackRate;
  102365. private _streaming;
  102366. private _startTime;
  102367. private _startOffset;
  102368. private _position;
  102369. /** @hidden */
  102370. _positionInEmitterSpace: boolean;
  102371. private _localDirection;
  102372. private _volume;
  102373. private _isReadyToPlay;
  102374. private _isDirectional;
  102375. private _readyToPlayCallback;
  102376. private _audioBuffer;
  102377. private _soundSource;
  102378. private _streamingSource;
  102379. private _soundPanner;
  102380. private _soundGain;
  102381. private _inputAudioNode;
  102382. private _outputAudioNode;
  102383. private _coneInnerAngle;
  102384. private _coneOuterAngle;
  102385. private _coneOuterGain;
  102386. private _scene;
  102387. private _connectedTransformNode;
  102388. private _customAttenuationFunction;
  102389. private _registerFunc;
  102390. private _isOutputConnected;
  102391. private _htmlAudioElement;
  102392. private _urlType;
  102393. private _length?;
  102394. private _offset?;
  102395. /** @hidden */
  102396. static _SceneComponentInitialization: (scene: Scene) => void;
  102397. /**
  102398. * Create a sound and attach it to a scene
  102399. * @param name Name of your sound
  102400. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102401. * @param scene defines the scene the sound belongs to
  102402. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102403. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102404. */
  102405. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102406. /**
  102407. * Release the sound and its associated resources
  102408. */
  102409. dispose(): void;
  102410. /**
  102411. * Gets if the sounds is ready to be played or not.
  102412. * @returns true if ready, otherwise false
  102413. */
  102414. isReady(): boolean;
  102415. private _soundLoaded;
  102416. /**
  102417. * Sets the data of the sound from an audiobuffer
  102418. * @param audioBuffer The audioBuffer containing the data
  102419. */
  102420. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102421. /**
  102422. * Updates the current sounds options such as maxdistance, loop...
  102423. * @param options A JSON object containing values named as the object properties
  102424. */
  102425. updateOptions(options: ISoundOptions): void;
  102426. private _createSpatialParameters;
  102427. private _updateSpatialParameters;
  102428. /**
  102429. * Switch the panning model to HRTF:
  102430. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102431. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102432. */
  102433. switchPanningModelToHRTF(): void;
  102434. /**
  102435. * Switch the panning model to Equal Power:
  102436. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102438. */
  102439. switchPanningModelToEqualPower(): void;
  102440. private _switchPanningModel;
  102441. /**
  102442. * Connect this sound to a sound track audio node like gain...
  102443. * @param soundTrackAudioNode the sound track audio node to connect to
  102444. */
  102445. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102446. /**
  102447. * Transform this sound into a directional source
  102448. * @param coneInnerAngle Size of the inner cone in degree
  102449. * @param coneOuterAngle Size of the outer cone in degree
  102450. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102451. */
  102452. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102453. /**
  102454. * Gets or sets the inner angle for the directional cone.
  102455. */
  102456. /**
  102457. * Gets or sets the inner angle for the directional cone.
  102458. */
  102459. directionalConeInnerAngle: number;
  102460. /**
  102461. * Gets or sets the outer angle for the directional cone.
  102462. */
  102463. /**
  102464. * Gets or sets the outer angle for the directional cone.
  102465. */
  102466. directionalConeOuterAngle: number;
  102467. /**
  102468. * Sets the position of the emitter if spatial sound is enabled
  102469. * @param newPosition Defines the new posisiton
  102470. */
  102471. setPosition(newPosition: Vector3): void;
  102472. /**
  102473. * Sets the local direction of the emitter if spatial sound is enabled
  102474. * @param newLocalDirection Defines the new local direction
  102475. */
  102476. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102477. private _updateDirection;
  102478. /** @hidden */
  102479. updateDistanceFromListener(): void;
  102480. /**
  102481. * Sets a new custom attenuation function for the sound.
  102482. * @param callback Defines the function used for the attenuation
  102483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102484. */
  102485. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102486. /**
  102487. * Play the sound
  102488. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102489. * @param offset (optional) Start the sound at a specific time in seconds
  102490. * @param length (optional) Sound duration (in seconds)
  102491. */
  102492. play(time?: number, offset?: number, length?: number): void;
  102493. private _onended;
  102494. /**
  102495. * Stop the sound
  102496. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102497. */
  102498. stop(time?: number): void;
  102499. /**
  102500. * Put the sound in pause
  102501. */
  102502. pause(): void;
  102503. /**
  102504. * Sets a dedicated volume for this sounds
  102505. * @param newVolume Define the new volume of the sound
  102506. * @param time Define time for gradual change to new volume
  102507. */
  102508. setVolume(newVolume: number, time?: number): void;
  102509. /**
  102510. * Set the sound play back rate
  102511. * @param newPlaybackRate Define the playback rate the sound should be played at
  102512. */
  102513. setPlaybackRate(newPlaybackRate: number): void;
  102514. /**
  102515. * Gets the volume of the sound.
  102516. * @returns the volume of the sound
  102517. */
  102518. getVolume(): number;
  102519. /**
  102520. * Attach the sound to a dedicated mesh
  102521. * @param transformNode The transform node to connect the sound with
  102522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102523. */
  102524. attachToMesh(transformNode: TransformNode): void;
  102525. /**
  102526. * Detach the sound from the previously attached mesh
  102527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102528. */
  102529. detachFromMesh(): void;
  102530. private _onRegisterAfterWorldMatrixUpdate;
  102531. /**
  102532. * Clone the current sound in the scene.
  102533. * @returns the new sound clone
  102534. */
  102535. clone(): Nullable<Sound>;
  102536. /**
  102537. * Gets the current underlying audio buffer containing the data
  102538. * @returns the audio buffer
  102539. */
  102540. getAudioBuffer(): Nullable<AudioBuffer>;
  102541. /**
  102542. * Serializes the Sound in a JSON representation
  102543. * @returns the JSON representation of the sound
  102544. */
  102545. serialize(): any;
  102546. /**
  102547. * Parse a JSON representation of a sound to innstantiate in a given scene
  102548. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102549. * @param scene Define the scene the new parsed sound should be created in
  102550. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102551. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102552. * @returns the newly parsed sound
  102553. */
  102554. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102555. }
  102556. }
  102557. declare module BABYLON {
  102558. /**
  102559. * This defines an action helpful to play a defined sound on a triggered action.
  102560. */
  102561. export class PlaySoundAction extends Action {
  102562. private _sound;
  102563. /**
  102564. * Instantiate the action
  102565. * @param triggerOptions defines the trigger options
  102566. * @param sound defines the sound to play
  102567. * @param condition defines the trigger related conditions
  102568. */
  102569. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102570. /** @hidden */
  102571. _prepare(): void;
  102572. /**
  102573. * Execute the action and play the sound.
  102574. */
  102575. execute(): void;
  102576. /**
  102577. * Serializes the actions and its related information.
  102578. * @param parent defines the object to serialize in
  102579. * @returns the serialized object
  102580. */
  102581. serialize(parent: any): any;
  102582. }
  102583. /**
  102584. * This defines an action helpful to stop a defined sound on a triggered action.
  102585. */
  102586. export class StopSoundAction extends Action {
  102587. private _sound;
  102588. /**
  102589. * Instantiate the action
  102590. * @param triggerOptions defines the trigger options
  102591. * @param sound defines the sound to stop
  102592. * @param condition defines the trigger related conditions
  102593. */
  102594. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102595. /** @hidden */
  102596. _prepare(): void;
  102597. /**
  102598. * Execute the action and stop the sound.
  102599. */
  102600. execute(): void;
  102601. /**
  102602. * Serializes the actions and its related information.
  102603. * @param parent defines the object to serialize in
  102604. * @returns the serialized object
  102605. */
  102606. serialize(parent: any): any;
  102607. }
  102608. }
  102609. declare module BABYLON {
  102610. /**
  102611. * This defines an action responsible to change the value of a property
  102612. * by interpolating between its current value and the newly set one once triggered.
  102613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102614. */
  102615. export class InterpolateValueAction extends Action {
  102616. /**
  102617. * Defines the path of the property where the value should be interpolated
  102618. */
  102619. propertyPath: string;
  102620. /**
  102621. * Defines the target value at the end of the interpolation.
  102622. */
  102623. value: any;
  102624. /**
  102625. * Defines the time it will take for the property to interpolate to the value.
  102626. */
  102627. duration: number;
  102628. /**
  102629. * Defines if the other scene animations should be stopped when the action has been triggered
  102630. */
  102631. stopOtherAnimations?: boolean;
  102632. /**
  102633. * Defines a callback raised once the interpolation animation has been done.
  102634. */
  102635. onInterpolationDone?: () => void;
  102636. /**
  102637. * Observable triggered once the interpolation animation has been done.
  102638. */
  102639. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102640. private _target;
  102641. private _effectiveTarget;
  102642. private _property;
  102643. /**
  102644. * Instantiate the action
  102645. * @param triggerOptions defines the trigger options
  102646. * @param target defines the object containing the value to interpolate
  102647. * @param propertyPath defines the path to the property in the target object
  102648. * @param value defines the target value at the end of the interpolation
  102649. * @param duration deines the time it will take for the property to interpolate to the value.
  102650. * @param condition defines the trigger related conditions
  102651. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102652. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102653. */
  102654. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102655. /** @hidden */
  102656. _prepare(): void;
  102657. /**
  102658. * Execute the action starts the value interpolation.
  102659. */
  102660. execute(): void;
  102661. /**
  102662. * Serializes the actions and its related information.
  102663. * @param parent defines the object to serialize in
  102664. * @returns the serialized object
  102665. */
  102666. serialize(parent: any): any;
  102667. }
  102668. }
  102669. declare module BABYLON {
  102670. /**
  102671. * Options allowed during the creation of a sound track.
  102672. */
  102673. export interface ISoundTrackOptions {
  102674. /**
  102675. * The volume the sound track should take during creation
  102676. */
  102677. volume?: number;
  102678. /**
  102679. * Define if the sound track is the main sound track of the scene
  102680. */
  102681. mainTrack?: boolean;
  102682. }
  102683. /**
  102684. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102685. * It will be also used in a future release to apply effects on a specific track.
  102686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102687. */
  102688. export class SoundTrack {
  102689. /**
  102690. * The unique identifier of the sound track in the scene.
  102691. */
  102692. id: number;
  102693. /**
  102694. * The list of sounds included in the sound track.
  102695. */
  102696. soundCollection: Array<Sound>;
  102697. private _outputAudioNode;
  102698. private _scene;
  102699. private _isMainTrack;
  102700. private _connectedAnalyser;
  102701. private _options;
  102702. private _isInitialized;
  102703. /**
  102704. * Creates a new sound track.
  102705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102706. * @param scene Define the scene the sound track belongs to
  102707. * @param options
  102708. */
  102709. constructor(scene: Scene, options?: ISoundTrackOptions);
  102710. private _initializeSoundTrackAudioGraph;
  102711. /**
  102712. * Release the sound track and its associated resources
  102713. */
  102714. dispose(): void;
  102715. /**
  102716. * Adds a sound to this sound track
  102717. * @param sound define the cound to add
  102718. * @ignoreNaming
  102719. */
  102720. AddSound(sound: Sound): void;
  102721. /**
  102722. * Removes a sound to this sound track
  102723. * @param sound define the cound to remove
  102724. * @ignoreNaming
  102725. */
  102726. RemoveSound(sound: Sound): void;
  102727. /**
  102728. * Set a global volume for the full sound track.
  102729. * @param newVolume Define the new volume of the sound track
  102730. */
  102731. setVolume(newVolume: number): void;
  102732. /**
  102733. * Switch the panning model to HRTF:
  102734. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102736. */
  102737. switchPanningModelToHRTF(): void;
  102738. /**
  102739. * Switch the panning model to Equal Power:
  102740. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102742. */
  102743. switchPanningModelToEqualPower(): void;
  102744. /**
  102745. * Connect the sound track to an audio analyser allowing some amazing
  102746. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102748. * @param analyser The analyser to connect to the engine
  102749. */
  102750. connectToAnalyser(analyser: Analyser): void;
  102751. }
  102752. }
  102753. declare module BABYLON {
  102754. interface AbstractScene {
  102755. /**
  102756. * The list of sounds used in the scene.
  102757. */
  102758. sounds: Nullable<Array<Sound>>;
  102759. }
  102760. interface Scene {
  102761. /**
  102762. * @hidden
  102763. * Backing field
  102764. */
  102765. _mainSoundTrack: SoundTrack;
  102766. /**
  102767. * The main sound track played by the scene.
  102768. * It cotains your primary collection of sounds.
  102769. */
  102770. mainSoundTrack: SoundTrack;
  102771. /**
  102772. * The list of sound tracks added to the scene
  102773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102774. */
  102775. soundTracks: Nullable<Array<SoundTrack>>;
  102776. /**
  102777. * Gets a sound using a given name
  102778. * @param name defines the name to search for
  102779. * @return the found sound or null if not found at all.
  102780. */
  102781. getSoundByName(name: string): Nullable<Sound>;
  102782. /**
  102783. * Gets or sets if audio support is enabled
  102784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102785. */
  102786. audioEnabled: boolean;
  102787. /**
  102788. * Gets or sets if audio will be output to headphones
  102789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102790. */
  102791. headphone: boolean;
  102792. /**
  102793. * Gets or sets custom audio listener position provider
  102794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102795. */
  102796. audioListenerPositionProvider: Nullable<() => Vector3>;
  102797. }
  102798. /**
  102799. * Defines the sound scene component responsible to manage any sounds
  102800. * in a given scene.
  102801. */
  102802. export class AudioSceneComponent implements ISceneSerializableComponent {
  102803. /**
  102804. * The component name helpfull to identify the component in the list of scene components.
  102805. */
  102806. readonly name: string;
  102807. /**
  102808. * The scene the component belongs to.
  102809. */
  102810. scene: Scene;
  102811. private _audioEnabled;
  102812. /**
  102813. * Gets whether audio is enabled or not.
  102814. * Please use related enable/disable method to switch state.
  102815. */
  102816. readonly audioEnabled: boolean;
  102817. private _headphone;
  102818. /**
  102819. * Gets whether audio is outputing to headphone or not.
  102820. * Please use the according Switch methods to change output.
  102821. */
  102822. readonly headphone: boolean;
  102823. private _audioListenerPositionProvider;
  102824. /**
  102825. * Gets the current audio listener position provider
  102826. */
  102827. /**
  102828. * Sets a custom listener position for all sounds in the scene
  102829. * By default, this is the position of the first active camera
  102830. */
  102831. audioListenerPositionProvider: Nullable<() => Vector3>;
  102832. /**
  102833. * Creates a new instance of the component for the given scene
  102834. * @param scene Defines the scene to register the component in
  102835. */
  102836. constructor(scene: Scene);
  102837. /**
  102838. * Registers the component in a given scene
  102839. */
  102840. register(): void;
  102841. /**
  102842. * Rebuilds the elements related to this component in case of
  102843. * context lost for instance.
  102844. */
  102845. rebuild(): void;
  102846. /**
  102847. * Serializes the component data to the specified json object
  102848. * @param serializationObject The object to serialize to
  102849. */
  102850. serialize(serializationObject: any): void;
  102851. /**
  102852. * Adds all the elements from the container to the scene
  102853. * @param container the container holding the elements
  102854. */
  102855. addFromContainer(container: AbstractScene): void;
  102856. /**
  102857. * Removes all the elements in the container from the scene
  102858. * @param container contains the elements to remove
  102859. * @param dispose if the removed element should be disposed (default: false)
  102860. */
  102861. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102862. /**
  102863. * Disposes the component and the associated ressources.
  102864. */
  102865. dispose(): void;
  102866. /**
  102867. * Disables audio in the associated scene.
  102868. */
  102869. disableAudio(): void;
  102870. /**
  102871. * Enables audio in the associated scene.
  102872. */
  102873. enableAudio(): void;
  102874. /**
  102875. * Switch audio to headphone output.
  102876. */
  102877. switchAudioModeForHeadphones(): void;
  102878. /**
  102879. * Switch audio to normal speakers.
  102880. */
  102881. switchAudioModeForNormalSpeakers(): void;
  102882. private _afterRender;
  102883. }
  102884. }
  102885. declare module BABYLON {
  102886. /**
  102887. * Wraps one or more Sound objects and selects one with random weight for playback.
  102888. */
  102889. export class WeightedSound {
  102890. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102891. loop: boolean;
  102892. private _coneInnerAngle;
  102893. private _coneOuterAngle;
  102894. private _volume;
  102895. /** A Sound is currently playing. */
  102896. isPlaying: boolean;
  102897. /** A Sound is currently paused. */
  102898. isPaused: boolean;
  102899. private _sounds;
  102900. private _weights;
  102901. private _currentIndex?;
  102902. /**
  102903. * Creates a new WeightedSound from the list of sounds given.
  102904. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102905. * @param sounds Array of Sounds that will be selected from.
  102906. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102907. */
  102908. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102909. /**
  102910. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102911. */
  102912. /**
  102913. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102914. */
  102915. directionalConeInnerAngle: number;
  102916. /**
  102917. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102918. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102919. */
  102920. /**
  102921. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102922. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102923. */
  102924. directionalConeOuterAngle: number;
  102925. /**
  102926. * Playback volume.
  102927. */
  102928. /**
  102929. * Playback volume.
  102930. */
  102931. volume: number;
  102932. private _onended;
  102933. /**
  102934. * Suspend playback
  102935. */
  102936. pause(): void;
  102937. /**
  102938. * Stop playback
  102939. */
  102940. stop(): void;
  102941. /**
  102942. * Start playback.
  102943. * @param startOffset Position the clip head at a specific time in seconds.
  102944. */
  102945. play(startOffset?: number): void;
  102946. }
  102947. }
  102948. declare module BABYLON {
  102949. /**
  102950. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102952. */
  102953. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102954. /**
  102955. * Gets the name of the behavior.
  102956. */
  102957. readonly name: string;
  102958. /**
  102959. * The easing function used by animations
  102960. */
  102961. static EasingFunction: BackEase;
  102962. /**
  102963. * The easing mode used by animations
  102964. */
  102965. static EasingMode: number;
  102966. /**
  102967. * The duration of the animation, in milliseconds
  102968. */
  102969. transitionDuration: number;
  102970. /**
  102971. * Length of the distance animated by the transition when lower radius is reached
  102972. */
  102973. lowerRadiusTransitionRange: number;
  102974. /**
  102975. * Length of the distance animated by the transition when upper radius is reached
  102976. */
  102977. upperRadiusTransitionRange: number;
  102978. private _autoTransitionRange;
  102979. /**
  102980. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102981. */
  102982. /**
  102983. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102984. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102985. */
  102986. autoTransitionRange: boolean;
  102987. private _attachedCamera;
  102988. private _onAfterCheckInputsObserver;
  102989. private _onMeshTargetChangedObserver;
  102990. /**
  102991. * Initializes the behavior.
  102992. */
  102993. init(): void;
  102994. /**
  102995. * Attaches the behavior to its arc rotate camera.
  102996. * @param camera Defines the camera to attach the behavior to
  102997. */
  102998. attach(camera: ArcRotateCamera): void;
  102999. /**
  103000. * Detaches the behavior from its current arc rotate camera.
  103001. */
  103002. detach(): void;
  103003. private _radiusIsAnimating;
  103004. private _radiusBounceTransition;
  103005. private _animatables;
  103006. private _cachedWheelPrecision;
  103007. /**
  103008. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103009. * @param radiusLimit The limit to check against.
  103010. * @return Bool to indicate if at limit.
  103011. */
  103012. private _isRadiusAtLimit;
  103013. /**
  103014. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103015. * @param radiusDelta The delta by which to animate to. Can be negative.
  103016. */
  103017. private _applyBoundRadiusAnimation;
  103018. /**
  103019. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103020. */
  103021. protected _clearAnimationLocks(): void;
  103022. /**
  103023. * Stops and removes all animations that have been applied to the camera
  103024. */
  103025. stopAllAnimations(): void;
  103026. }
  103027. }
  103028. declare module BABYLON {
  103029. /**
  103030. * 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.
  103031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103032. */
  103033. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103034. /**
  103035. * Gets the name of the behavior.
  103036. */
  103037. readonly name: string;
  103038. private _mode;
  103039. private _radiusScale;
  103040. private _positionScale;
  103041. private _defaultElevation;
  103042. private _elevationReturnTime;
  103043. private _elevationReturnWaitTime;
  103044. private _zoomStopsAnimation;
  103045. private _framingTime;
  103046. /**
  103047. * The easing function used by animations
  103048. */
  103049. static EasingFunction: ExponentialEase;
  103050. /**
  103051. * The easing mode used by animations
  103052. */
  103053. static EasingMode: number;
  103054. /**
  103055. * Sets the current mode used by the behavior
  103056. */
  103057. /**
  103058. * Gets current mode used by the behavior.
  103059. */
  103060. mode: number;
  103061. /**
  103062. * Sets the scale applied to the radius (1 by default)
  103063. */
  103064. /**
  103065. * Gets the scale applied to the radius
  103066. */
  103067. radiusScale: number;
  103068. /**
  103069. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103070. */
  103071. /**
  103072. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103073. */
  103074. positionScale: number;
  103075. /**
  103076. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103077. * behaviour is triggered, in radians.
  103078. */
  103079. /**
  103080. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103081. * behaviour is triggered, in radians.
  103082. */
  103083. defaultElevation: number;
  103084. /**
  103085. * Sets the time (in milliseconds) taken to return to the default beta position.
  103086. * Negative value indicates camera should not return to default.
  103087. */
  103088. /**
  103089. * Gets the time (in milliseconds) taken to return to the default beta position.
  103090. * Negative value indicates camera should not return to default.
  103091. */
  103092. elevationReturnTime: number;
  103093. /**
  103094. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103095. */
  103096. /**
  103097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103098. */
  103099. elevationReturnWaitTime: number;
  103100. /**
  103101. * Sets the flag that indicates if user zooming should stop animation.
  103102. */
  103103. /**
  103104. * Gets the flag that indicates if user zooming should stop animation.
  103105. */
  103106. zoomStopsAnimation: boolean;
  103107. /**
  103108. * Sets the transition time when framing the mesh, in milliseconds
  103109. */
  103110. /**
  103111. * Gets the transition time when framing the mesh, in milliseconds
  103112. */
  103113. framingTime: number;
  103114. /**
  103115. * Define if the behavior should automatically change the configured
  103116. * camera limits and sensibilities.
  103117. */
  103118. autoCorrectCameraLimitsAndSensibility: boolean;
  103119. private _onPrePointerObservableObserver;
  103120. private _onAfterCheckInputsObserver;
  103121. private _onMeshTargetChangedObserver;
  103122. private _attachedCamera;
  103123. private _isPointerDown;
  103124. private _lastInteractionTime;
  103125. /**
  103126. * Initializes the behavior.
  103127. */
  103128. init(): void;
  103129. /**
  103130. * Attaches the behavior to its arc rotate camera.
  103131. * @param camera Defines the camera to attach the behavior to
  103132. */
  103133. attach(camera: ArcRotateCamera): void;
  103134. /**
  103135. * Detaches the behavior from its current arc rotate camera.
  103136. */
  103137. detach(): void;
  103138. private _animatables;
  103139. private _betaIsAnimating;
  103140. private _betaTransition;
  103141. private _radiusTransition;
  103142. private _vectorTransition;
  103143. /**
  103144. * Targets the given mesh and updates zoom level accordingly.
  103145. * @param mesh The mesh to target.
  103146. * @param radius Optional. If a cached radius position already exists, overrides default.
  103147. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103150. */
  103151. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103152. /**
  103153. * Targets the given mesh with its children and updates zoom level accordingly.
  103154. * @param mesh The mesh to target.
  103155. * @param radius Optional. If a cached radius position already exists, overrides default.
  103156. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103157. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103158. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103159. */
  103160. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103161. /**
  103162. * Targets the given meshes with their children and updates zoom level accordingly.
  103163. * @param meshes The mesh to target.
  103164. * @param radius Optional. If a cached radius position already exists, overrides default.
  103165. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103166. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103167. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103168. */
  103169. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103170. /**
  103171. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103172. * @param minimumWorld Determines the smaller position of the bounding box extend
  103173. * @param maximumWorld Determines the bigger position of the bounding box extend
  103174. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103175. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103176. */
  103177. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103178. /**
  103179. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103180. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103181. * frustum width.
  103182. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103183. * to fully enclose the mesh in the viewing frustum.
  103184. */
  103185. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103186. /**
  103187. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103188. * is automatically returned to its default position (expected to be above ground plane).
  103189. */
  103190. private _maintainCameraAboveGround;
  103191. /**
  103192. * Returns the frustum slope based on the canvas ratio and camera FOV
  103193. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103194. */
  103195. private _getFrustumSlope;
  103196. /**
  103197. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103198. */
  103199. private _clearAnimationLocks;
  103200. /**
  103201. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103202. */
  103203. private _applyUserInteraction;
  103204. /**
  103205. * Stops and removes all animations that have been applied to the camera
  103206. */
  103207. stopAllAnimations(): void;
  103208. /**
  103209. * Gets a value indicating if the user is moving the camera
  103210. */
  103211. readonly isUserIsMoving: boolean;
  103212. /**
  103213. * The camera can move all the way towards the mesh.
  103214. */
  103215. static IgnoreBoundsSizeMode: number;
  103216. /**
  103217. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103218. */
  103219. static FitFrustumSidesMode: number;
  103220. }
  103221. }
  103222. declare module BABYLON {
  103223. /**
  103224. * Base class for Camera Pointer Inputs.
  103225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103226. * for example usage.
  103227. */
  103228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103229. /**
  103230. * Defines the camera the input is attached to.
  103231. */
  103232. abstract camera: Camera;
  103233. /**
  103234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103235. */
  103236. protected _altKey: boolean;
  103237. protected _ctrlKey: boolean;
  103238. protected _metaKey: boolean;
  103239. protected _shiftKey: boolean;
  103240. /**
  103241. * Which mouse buttons were pressed at time of last mouse event.
  103242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103243. */
  103244. protected _buttonsPressed: number;
  103245. /**
  103246. * Defines the buttons associated with the input to handle camera move.
  103247. */
  103248. buttons: number[];
  103249. /**
  103250. * Attach the input controls to a specific dom element to get the input from.
  103251. * @param element Defines the element the controls should be listened from
  103252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103253. */
  103254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103255. /**
  103256. * Detach the current controls from the specified dom element.
  103257. * @param element Defines the element to stop listening the inputs from
  103258. */
  103259. detachControl(element: Nullable<HTMLElement>): void;
  103260. /**
  103261. * Gets the class name of the current input.
  103262. * @returns the class name
  103263. */
  103264. getClassName(): string;
  103265. /**
  103266. * Get the friendly name associated with the input class.
  103267. * @returns the input friendly name
  103268. */
  103269. getSimpleName(): string;
  103270. /**
  103271. * Called on pointer POINTERDOUBLETAP event.
  103272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103273. */
  103274. protected onDoubleTap(type: string): void;
  103275. /**
  103276. * Called on pointer POINTERMOVE event if only a single touch is active.
  103277. * Override this method to provide functionality.
  103278. */
  103279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103280. /**
  103281. * Called on pointer POINTERMOVE event if multiple touches are active.
  103282. * Override this method to provide functionality.
  103283. */
  103284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103285. /**
  103286. * Called on JS contextmenu event.
  103287. * Override this method to provide functionality.
  103288. */
  103289. protected onContextMenu(evt: PointerEvent): void;
  103290. /**
  103291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103292. * press.
  103293. * Override this method to provide functionality.
  103294. */
  103295. protected onButtonDown(evt: PointerEvent): void;
  103296. /**
  103297. * Called each time a new POINTERUP event occurs. Ie, for each button
  103298. * release.
  103299. * Override this method to provide functionality.
  103300. */
  103301. protected onButtonUp(evt: PointerEvent): void;
  103302. /**
  103303. * Called when window becomes inactive.
  103304. * Override this method to provide functionality.
  103305. */
  103306. protected onLostFocus(): void;
  103307. private _pointerInput;
  103308. private _observer;
  103309. private _onLostFocus;
  103310. private pointA;
  103311. private pointB;
  103312. }
  103313. }
  103314. declare module BABYLON {
  103315. /**
  103316. * Manage the pointers inputs to control an arc rotate camera.
  103317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103318. */
  103319. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103320. /**
  103321. * Defines the camera the input is attached to.
  103322. */
  103323. camera: ArcRotateCamera;
  103324. /**
  103325. * Gets the class name of the current input.
  103326. * @returns the class name
  103327. */
  103328. getClassName(): string;
  103329. /**
  103330. * Defines the buttons associated with the input to handle camera move.
  103331. */
  103332. buttons: number[];
  103333. /**
  103334. * Defines the pointer angular sensibility along the X axis or how fast is
  103335. * the camera rotating.
  103336. */
  103337. angularSensibilityX: number;
  103338. /**
  103339. * Defines the pointer angular sensibility along the Y axis or how fast is
  103340. * the camera rotating.
  103341. */
  103342. angularSensibilityY: number;
  103343. /**
  103344. * Defines the pointer pinch precision or how fast is the camera zooming.
  103345. */
  103346. pinchPrecision: number;
  103347. /**
  103348. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103349. * from 0.
  103350. * It defines the percentage of current camera.radius to use as delta when
  103351. * pinch zoom is used.
  103352. */
  103353. pinchDeltaPercentage: number;
  103354. /**
  103355. * Defines the pointer panning sensibility or how fast is the camera moving.
  103356. */
  103357. panningSensibility: number;
  103358. /**
  103359. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103360. */
  103361. multiTouchPanning: boolean;
  103362. /**
  103363. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103364. * zoom (pinch) through multitouch.
  103365. */
  103366. multiTouchPanAndZoom: boolean;
  103367. /**
  103368. * Revers pinch action direction.
  103369. */
  103370. pinchInwards: boolean;
  103371. private _isPanClick;
  103372. private _twoFingerActivityCount;
  103373. private _isPinching;
  103374. /**
  103375. * Called on pointer POINTERMOVE event if only a single touch is active.
  103376. */
  103377. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103378. /**
  103379. * Called on pointer POINTERDOUBLETAP event.
  103380. */
  103381. protected onDoubleTap(type: string): void;
  103382. /**
  103383. * Called on pointer POINTERMOVE event if multiple touches are active.
  103384. */
  103385. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103386. /**
  103387. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103388. * press.
  103389. */
  103390. protected onButtonDown(evt: PointerEvent): void;
  103391. /**
  103392. * Called each time a new POINTERUP event occurs. Ie, for each button
  103393. * release.
  103394. */
  103395. protected onButtonUp(evt: PointerEvent): void;
  103396. /**
  103397. * Called when window becomes inactive.
  103398. */
  103399. protected onLostFocus(): void;
  103400. }
  103401. }
  103402. declare module BABYLON {
  103403. /**
  103404. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103406. */
  103407. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103408. /**
  103409. * Defines the camera the input is attached to.
  103410. */
  103411. camera: ArcRotateCamera;
  103412. /**
  103413. * Defines the list of key codes associated with the up action (increase alpha)
  103414. */
  103415. keysUp: number[];
  103416. /**
  103417. * Defines the list of key codes associated with the down action (decrease alpha)
  103418. */
  103419. keysDown: number[];
  103420. /**
  103421. * Defines the list of key codes associated with the left action (increase beta)
  103422. */
  103423. keysLeft: number[];
  103424. /**
  103425. * Defines the list of key codes associated with the right action (decrease beta)
  103426. */
  103427. keysRight: number[];
  103428. /**
  103429. * Defines the list of key codes associated with the reset action.
  103430. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103431. */
  103432. keysReset: number[];
  103433. /**
  103434. * Defines the panning sensibility of the inputs.
  103435. * (How fast is the camera paning)
  103436. */
  103437. panningSensibility: number;
  103438. /**
  103439. * Defines the zooming sensibility of the inputs.
  103440. * (How fast is the camera zooming)
  103441. */
  103442. zoomingSensibility: number;
  103443. /**
  103444. * Defines wether maintaining the alt key down switch the movement mode from
  103445. * orientation to zoom.
  103446. */
  103447. useAltToZoom: boolean;
  103448. /**
  103449. * Rotation speed of the camera
  103450. */
  103451. angularSpeed: number;
  103452. private _keys;
  103453. private _ctrlPressed;
  103454. private _altPressed;
  103455. private _onCanvasBlurObserver;
  103456. private _onKeyboardObserver;
  103457. private _engine;
  103458. private _scene;
  103459. /**
  103460. * Attach the input controls to a specific dom element to get the input from.
  103461. * @param element Defines the element the controls should be listened from
  103462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103463. */
  103464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103465. /**
  103466. * Detach the current controls from the specified dom element.
  103467. * @param element Defines the element to stop listening the inputs from
  103468. */
  103469. detachControl(element: Nullable<HTMLElement>): void;
  103470. /**
  103471. * Update the current camera state depending on the inputs that have been used this frame.
  103472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103473. */
  103474. checkInputs(): void;
  103475. /**
  103476. * Gets the class name of the current intput.
  103477. * @returns the class name
  103478. */
  103479. getClassName(): string;
  103480. /**
  103481. * Get the friendly name associated with the input class.
  103482. * @returns the input friendly name
  103483. */
  103484. getSimpleName(): string;
  103485. }
  103486. }
  103487. declare module BABYLON {
  103488. /**
  103489. * Manage the mouse wheel inputs to control an arc rotate camera.
  103490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103491. */
  103492. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103493. /**
  103494. * Defines the camera the input is attached to.
  103495. */
  103496. camera: ArcRotateCamera;
  103497. /**
  103498. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103499. */
  103500. wheelPrecision: number;
  103501. /**
  103502. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103503. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103504. */
  103505. wheelDeltaPercentage: number;
  103506. private _wheel;
  103507. private _observer;
  103508. private computeDeltaFromMouseWheelLegacyEvent;
  103509. /**
  103510. * Attach the input controls to a specific dom element to get the input from.
  103511. * @param element Defines the element the controls should be listened from
  103512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103513. */
  103514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103515. /**
  103516. * Detach the current controls from the specified dom element.
  103517. * @param element Defines the element to stop listening the inputs from
  103518. */
  103519. detachControl(element: Nullable<HTMLElement>): void;
  103520. /**
  103521. * Gets the class name of the current intput.
  103522. * @returns the class name
  103523. */
  103524. getClassName(): string;
  103525. /**
  103526. * Get the friendly name associated with the input class.
  103527. * @returns the input friendly name
  103528. */
  103529. getSimpleName(): string;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * Default Inputs manager for the ArcRotateCamera.
  103535. * It groups all the default supported inputs for ease of use.
  103536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103537. */
  103538. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103539. /**
  103540. * Instantiates a new ArcRotateCameraInputsManager.
  103541. * @param camera Defines the camera the inputs belong to
  103542. */
  103543. constructor(camera: ArcRotateCamera);
  103544. /**
  103545. * Add mouse wheel input support to the input manager.
  103546. * @returns the current input manager
  103547. */
  103548. addMouseWheel(): ArcRotateCameraInputsManager;
  103549. /**
  103550. * Add pointers input support to the input manager.
  103551. * @returns the current input manager
  103552. */
  103553. addPointers(): ArcRotateCameraInputsManager;
  103554. /**
  103555. * Add keyboard input support to the input manager.
  103556. * @returns the current input manager
  103557. */
  103558. addKeyboard(): ArcRotateCameraInputsManager;
  103559. }
  103560. }
  103561. declare module BABYLON {
  103562. /**
  103563. * This represents an orbital type of camera.
  103564. *
  103565. * 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.
  103566. * 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.
  103567. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103568. */
  103569. export class ArcRotateCamera extends TargetCamera {
  103570. /**
  103571. * Defines the rotation angle of the camera along the longitudinal axis.
  103572. */
  103573. alpha: number;
  103574. /**
  103575. * Defines the rotation angle of the camera along the latitudinal axis.
  103576. */
  103577. beta: number;
  103578. /**
  103579. * Defines the radius of the camera from it s target point.
  103580. */
  103581. radius: number;
  103582. protected _target: Vector3;
  103583. protected _targetHost: Nullable<AbstractMesh>;
  103584. /**
  103585. * Defines the target point of the camera.
  103586. * The camera looks towards it form the radius distance.
  103587. */
  103588. target: Vector3;
  103589. /**
  103590. * Define the current local position of the camera in the scene
  103591. */
  103592. position: Vector3;
  103593. protected _upVector: Vector3;
  103594. protected _upToYMatrix: Matrix;
  103595. protected _YToUpMatrix: Matrix;
  103596. /**
  103597. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103598. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103599. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103600. */
  103601. upVector: Vector3;
  103602. /**
  103603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103604. */
  103605. setMatUp(): void;
  103606. /**
  103607. * Current inertia value on the longitudinal axis.
  103608. * The bigger this number the longer it will take for the camera to stop.
  103609. */
  103610. inertialAlphaOffset: number;
  103611. /**
  103612. * Current inertia value on the latitudinal axis.
  103613. * The bigger this number the longer it will take for the camera to stop.
  103614. */
  103615. inertialBetaOffset: number;
  103616. /**
  103617. * Current inertia value on the radius axis.
  103618. * The bigger this number the longer it will take for the camera to stop.
  103619. */
  103620. inertialRadiusOffset: number;
  103621. /**
  103622. * Minimum allowed angle on the longitudinal axis.
  103623. * This can help limiting how the Camera is able to move in the scene.
  103624. */
  103625. lowerAlphaLimit: Nullable<number>;
  103626. /**
  103627. * Maximum allowed angle on the longitudinal axis.
  103628. * This can help limiting how the Camera is able to move in the scene.
  103629. */
  103630. upperAlphaLimit: Nullable<number>;
  103631. /**
  103632. * Minimum allowed angle on the latitudinal axis.
  103633. * This can help limiting how the Camera is able to move in the scene.
  103634. */
  103635. lowerBetaLimit: number;
  103636. /**
  103637. * Maximum allowed angle on the latitudinal axis.
  103638. * This can help limiting how the Camera is able to move in the scene.
  103639. */
  103640. upperBetaLimit: number;
  103641. /**
  103642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103643. * This can help limiting how the Camera is able to move in the scene.
  103644. */
  103645. lowerRadiusLimit: Nullable<number>;
  103646. /**
  103647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103648. * This can help limiting how the Camera is able to move in the scene.
  103649. */
  103650. upperRadiusLimit: Nullable<number>;
  103651. /**
  103652. * Defines the current inertia value used during panning of the camera along the X axis.
  103653. */
  103654. inertialPanningX: number;
  103655. /**
  103656. * Defines the current inertia value used during panning of the camera along the Y axis.
  103657. */
  103658. inertialPanningY: number;
  103659. /**
  103660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103661. * Basically if your fingers moves away from more than this distance you will be considered
  103662. * in pinch mode.
  103663. */
  103664. pinchToPanMaxDistance: number;
  103665. /**
  103666. * Defines the maximum distance the camera can pan.
  103667. * This could help keeping the cammera always in your scene.
  103668. */
  103669. panningDistanceLimit: Nullable<number>;
  103670. /**
  103671. * Defines the target of the camera before paning.
  103672. */
  103673. panningOriginTarget: Vector3;
  103674. /**
  103675. * Defines the value of the inertia used during panning.
  103676. * 0 would mean stop inertia and one would mean no decelleration at all.
  103677. */
  103678. panningInertia: number;
  103679. /**
  103680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103681. */
  103682. angularSensibilityX: number;
  103683. /**
  103684. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103685. */
  103686. angularSensibilityY: number;
  103687. /**
  103688. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103689. */
  103690. pinchPrecision: number;
  103691. /**
  103692. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103693. * It will be used instead of pinchDeltaPrecision if different from 0.
  103694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103695. */
  103696. pinchDeltaPercentage: number;
  103697. /**
  103698. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103699. */
  103700. panningSensibility: number;
  103701. /**
  103702. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103703. */
  103704. keysUp: number[];
  103705. /**
  103706. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103707. */
  103708. keysDown: number[];
  103709. /**
  103710. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103711. */
  103712. keysLeft: number[];
  103713. /**
  103714. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103715. */
  103716. keysRight: number[];
  103717. /**
  103718. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103719. */
  103720. wheelPrecision: number;
  103721. /**
  103722. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103723. * It will be used instead of pinchDeltaPrecision if different from 0.
  103724. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103725. */
  103726. wheelDeltaPercentage: number;
  103727. /**
  103728. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103729. */
  103730. zoomOnFactor: number;
  103731. /**
  103732. * Defines a screen offset for the camera position.
  103733. */
  103734. targetScreenOffset: Vector2;
  103735. /**
  103736. * Allows the camera to be completely reversed.
  103737. * If false the camera can not arrive upside down.
  103738. */
  103739. allowUpsideDown: boolean;
  103740. /**
  103741. * Define if double tap/click is used to restore the previously saved state of the camera.
  103742. */
  103743. useInputToRestoreState: boolean;
  103744. /** @hidden */
  103745. _viewMatrix: Matrix;
  103746. /** @hidden */
  103747. _useCtrlForPanning: boolean;
  103748. /** @hidden */
  103749. _panningMouseButton: number;
  103750. /**
  103751. * Defines the input associated to the camera.
  103752. */
  103753. inputs: ArcRotateCameraInputsManager;
  103754. /** @hidden */
  103755. _reset: () => void;
  103756. /**
  103757. * Defines the allowed panning axis.
  103758. */
  103759. panningAxis: Vector3;
  103760. protected _localDirection: Vector3;
  103761. protected _transformedDirection: Vector3;
  103762. private _bouncingBehavior;
  103763. /**
  103764. * Gets the bouncing behavior of the camera if it has been enabled.
  103765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103766. */
  103767. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103768. /**
  103769. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103770. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103771. */
  103772. useBouncingBehavior: boolean;
  103773. private _framingBehavior;
  103774. /**
  103775. * Gets the framing behavior of the camera if it has been enabled.
  103776. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103777. */
  103778. readonly framingBehavior: Nullable<FramingBehavior>;
  103779. /**
  103780. * Defines if the framing behavior of the camera is enabled on the camera.
  103781. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103782. */
  103783. useFramingBehavior: boolean;
  103784. private _autoRotationBehavior;
  103785. /**
  103786. * Gets the auto rotation behavior of the camera if it has been enabled.
  103787. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103788. */
  103789. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103790. /**
  103791. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103792. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103793. */
  103794. useAutoRotationBehavior: boolean;
  103795. /**
  103796. * Observable triggered when the mesh target has been changed on the camera.
  103797. */
  103798. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103799. /**
  103800. * Event raised when the camera is colliding with a mesh.
  103801. */
  103802. onCollide: (collidedMesh: AbstractMesh) => void;
  103803. /**
  103804. * Defines whether the camera should check collision with the objects oh the scene.
  103805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103806. */
  103807. checkCollisions: boolean;
  103808. /**
  103809. * Defines the collision radius of the camera.
  103810. * This simulates a sphere around the camera.
  103811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103812. */
  103813. collisionRadius: Vector3;
  103814. protected _collider: Collider;
  103815. protected _previousPosition: Vector3;
  103816. protected _collisionVelocity: Vector3;
  103817. protected _newPosition: Vector3;
  103818. protected _previousAlpha: number;
  103819. protected _previousBeta: number;
  103820. protected _previousRadius: number;
  103821. protected _collisionTriggered: boolean;
  103822. protected _targetBoundingCenter: Nullable<Vector3>;
  103823. private _computationVector;
  103824. /**
  103825. * Instantiates a new ArcRotateCamera in a given scene
  103826. * @param name Defines the name of the camera
  103827. * @param alpha Defines the camera rotation along the logitudinal axis
  103828. * @param beta Defines the camera rotation along the latitudinal axis
  103829. * @param radius Defines the camera distance from its target
  103830. * @param target Defines the camera target
  103831. * @param scene Defines the scene the camera belongs to
  103832. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103833. */
  103834. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103835. /** @hidden */
  103836. _initCache(): void;
  103837. /** @hidden */
  103838. _updateCache(ignoreParentClass?: boolean): void;
  103839. protected _getTargetPosition(): Vector3;
  103840. private _storedAlpha;
  103841. private _storedBeta;
  103842. private _storedRadius;
  103843. private _storedTarget;
  103844. private _storedTargetScreenOffset;
  103845. /**
  103846. * Stores the current state of the camera (alpha, beta, radius and target)
  103847. * @returns the camera itself
  103848. */
  103849. storeState(): Camera;
  103850. /**
  103851. * @hidden
  103852. * Restored camera state. You must call storeState() first
  103853. */
  103854. _restoreStateValues(): boolean;
  103855. /** @hidden */
  103856. _isSynchronizedViewMatrix(): boolean;
  103857. /**
  103858. * Attached controls to the current camera.
  103859. * @param element Defines the element the controls should be listened from
  103860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103861. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103862. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103863. */
  103864. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103865. /**
  103866. * Detach the current controls from the camera.
  103867. * The camera will stop reacting to inputs.
  103868. * @param element Defines the element to stop listening the inputs from
  103869. */
  103870. detachControl(element: HTMLElement): void;
  103871. /** @hidden */
  103872. _checkInputs(): void;
  103873. protected _checkLimits(): void;
  103874. /**
  103875. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103876. */
  103877. rebuildAnglesAndRadius(): void;
  103878. /**
  103879. * Use a position to define the current camera related information like alpha, beta and radius
  103880. * @param position Defines the position to set the camera at
  103881. */
  103882. setPosition(position: Vector3): void;
  103883. /**
  103884. * Defines the target the camera should look at.
  103885. * This will automatically adapt alpha beta and radius to fit within the new target.
  103886. * @param target Defines the new target as a Vector or a mesh
  103887. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103888. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103889. */
  103890. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103891. /** @hidden */
  103892. _getViewMatrix(): Matrix;
  103893. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103894. /**
  103895. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103896. * @param meshes Defines the mesh to zoom on
  103897. * @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)
  103898. */
  103899. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103900. /**
  103901. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103902. * The target will be changed but the radius
  103903. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103904. * @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)
  103905. */
  103906. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103907. min: Vector3;
  103908. max: Vector3;
  103909. distance: number;
  103910. }, doNotUpdateMaxZ?: boolean): void;
  103911. /**
  103912. * @override
  103913. * Override Camera.createRigCamera
  103914. */
  103915. createRigCamera(name: string, cameraIndex: number): Camera;
  103916. /**
  103917. * @hidden
  103918. * @override
  103919. * Override Camera._updateRigCameras
  103920. */
  103921. _updateRigCameras(): void;
  103922. /**
  103923. * Destroy the camera and release the current resources hold by it.
  103924. */
  103925. dispose(): void;
  103926. /**
  103927. * Gets the current object class name.
  103928. * @return the class name
  103929. */
  103930. getClassName(): string;
  103931. }
  103932. }
  103933. declare module BABYLON {
  103934. /**
  103935. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103937. */
  103938. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103939. /**
  103940. * Gets the name of the behavior.
  103941. */
  103942. readonly name: string;
  103943. private _zoomStopsAnimation;
  103944. private _idleRotationSpeed;
  103945. private _idleRotationWaitTime;
  103946. private _idleRotationSpinupTime;
  103947. /**
  103948. * Sets the flag that indicates if user zooming should stop animation.
  103949. */
  103950. /**
  103951. * Gets the flag that indicates if user zooming should stop animation.
  103952. */
  103953. zoomStopsAnimation: boolean;
  103954. /**
  103955. * Sets the default speed at which the camera rotates around the model.
  103956. */
  103957. /**
  103958. * Gets the default speed at which the camera rotates around the model.
  103959. */
  103960. idleRotationSpeed: number;
  103961. /**
  103962. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103963. */
  103964. /**
  103965. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103966. */
  103967. idleRotationWaitTime: number;
  103968. /**
  103969. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103970. */
  103971. /**
  103972. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103973. */
  103974. idleRotationSpinupTime: number;
  103975. /**
  103976. * Gets a value indicating if the camera is currently rotating because of this behavior
  103977. */
  103978. readonly rotationInProgress: boolean;
  103979. private _onPrePointerObservableObserver;
  103980. private _onAfterCheckInputsObserver;
  103981. private _attachedCamera;
  103982. private _isPointerDown;
  103983. private _lastFrameTime;
  103984. private _lastInteractionTime;
  103985. private _cameraRotationSpeed;
  103986. /**
  103987. * Initializes the behavior.
  103988. */
  103989. init(): void;
  103990. /**
  103991. * Attaches the behavior to its arc rotate camera.
  103992. * @param camera Defines the camera to attach the behavior to
  103993. */
  103994. attach(camera: ArcRotateCamera): void;
  103995. /**
  103996. * Detaches the behavior from its current arc rotate camera.
  103997. */
  103998. detach(): void;
  103999. /**
  104000. * Returns true if user is scrolling.
  104001. * @return true if user is scrolling.
  104002. */
  104003. private _userIsZooming;
  104004. private _lastFrameRadius;
  104005. private _shouldAnimationStopForInteraction;
  104006. /**
  104007. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104008. */
  104009. private _applyUserInteraction;
  104010. private _userIsMoving;
  104011. }
  104012. }
  104013. declare module BABYLON {
  104014. /**
  104015. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104016. */
  104017. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104018. private ui;
  104019. /**
  104020. * The name of the behavior
  104021. */
  104022. name: string;
  104023. /**
  104024. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104025. */
  104026. distanceAwayFromFace: number;
  104027. /**
  104028. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104029. */
  104030. distanceAwayFromBottomOfFace: number;
  104031. private _faceVectors;
  104032. private _target;
  104033. private _scene;
  104034. private _onRenderObserver;
  104035. private _tmpMatrix;
  104036. private _tmpVector;
  104037. /**
  104038. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104039. * @param ui The transform node that should be attched to the mesh
  104040. */
  104041. constructor(ui: TransformNode);
  104042. /**
  104043. * Initializes the behavior
  104044. */
  104045. init(): void;
  104046. private _closestFace;
  104047. private _zeroVector;
  104048. private _lookAtTmpMatrix;
  104049. private _lookAtToRef;
  104050. /**
  104051. * Attaches the AttachToBoxBehavior to the passed in mesh
  104052. * @param target The mesh that the specified node will be attached to
  104053. */
  104054. attach(target: Mesh): void;
  104055. /**
  104056. * Detaches the behavior from the mesh
  104057. */
  104058. detach(): void;
  104059. }
  104060. }
  104061. declare module BABYLON {
  104062. /**
  104063. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104064. */
  104065. export class FadeInOutBehavior implements Behavior<Mesh> {
  104066. /**
  104067. * Time in milliseconds to delay before fading in (Default: 0)
  104068. */
  104069. delay: number;
  104070. /**
  104071. * Time in milliseconds for the mesh to fade in (Default: 300)
  104072. */
  104073. fadeInTime: number;
  104074. private _millisecondsPerFrame;
  104075. private _hovered;
  104076. private _hoverValue;
  104077. private _ownerNode;
  104078. /**
  104079. * Instatiates the FadeInOutBehavior
  104080. */
  104081. constructor();
  104082. /**
  104083. * The name of the behavior
  104084. */
  104085. readonly name: string;
  104086. /**
  104087. * Initializes the behavior
  104088. */
  104089. init(): void;
  104090. /**
  104091. * Attaches the fade behavior on the passed in mesh
  104092. * @param ownerNode The mesh that will be faded in/out once attached
  104093. */
  104094. attach(ownerNode: Mesh): void;
  104095. /**
  104096. * Detaches the behavior from the mesh
  104097. */
  104098. detach(): void;
  104099. /**
  104100. * Triggers the mesh to begin fading in or out
  104101. * @param value if the object should fade in or out (true to fade in)
  104102. */
  104103. fadeIn(value: boolean): void;
  104104. private _update;
  104105. private _setAllVisibility;
  104106. }
  104107. }
  104108. declare module BABYLON {
  104109. /**
  104110. * Class containing a set of static utilities functions for managing Pivots
  104111. * @hidden
  104112. */
  104113. export class PivotTools {
  104114. private static _PivotCached;
  104115. private static _OldPivotPoint;
  104116. private static _PivotTranslation;
  104117. private static _PivotTmpVector;
  104118. /** @hidden */
  104119. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104120. /** @hidden */
  104121. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104122. }
  104123. }
  104124. declare module BABYLON {
  104125. /**
  104126. * Class containing static functions to help procedurally build meshes
  104127. */
  104128. export class PlaneBuilder {
  104129. /**
  104130. * Creates a plane mesh
  104131. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104132. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104133. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104137. * @param name defines the name of the mesh
  104138. * @param options defines the options used to create the mesh
  104139. * @param scene defines the hosting scene
  104140. * @returns the plane mesh
  104141. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104142. */
  104143. static CreatePlane(name: string, options: {
  104144. size?: number;
  104145. width?: number;
  104146. height?: number;
  104147. sideOrientation?: number;
  104148. frontUVs?: Vector4;
  104149. backUVs?: Vector4;
  104150. updatable?: boolean;
  104151. sourcePlane?: Plane;
  104152. }, scene?: Nullable<Scene>): Mesh;
  104153. }
  104154. }
  104155. declare module BABYLON {
  104156. /**
  104157. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104158. */
  104159. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104160. private static _AnyMouseID;
  104161. /**
  104162. * Abstract mesh the behavior is set on
  104163. */
  104164. attachedNode: AbstractMesh;
  104165. private _dragPlane;
  104166. private _scene;
  104167. private _pointerObserver;
  104168. private _beforeRenderObserver;
  104169. private static _planeScene;
  104170. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104171. /**
  104172. * 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)
  104173. */
  104174. maxDragAngle: number;
  104175. /**
  104176. * @hidden
  104177. */
  104178. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104179. /**
  104180. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104181. */
  104182. currentDraggingPointerID: number;
  104183. /**
  104184. * The last position where the pointer hit the drag plane in world space
  104185. */
  104186. lastDragPosition: Vector3;
  104187. /**
  104188. * If the behavior is currently in a dragging state
  104189. */
  104190. dragging: boolean;
  104191. /**
  104192. * 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)
  104193. */
  104194. dragDeltaRatio: number;
  104195. /**
  104196. * If the drag plane orientation should be updated during the dragging (Default: true)
  104197. */
  104198. updateDragPlane: boolean;
  104199. private _debugMode;
  104200. private _moving;
  104201. /**
  104202. * Fires each time the attached mesh is dragged with the pointer
  104203. * * delta between last drag position and current drag position in world space
  104204. * * dragDistance along the drag axis
  104205. * * dragPlaneNormal normal of the current drag plane used during the drag
  104206. * * dragPlanePoint in world space where the drag intersects the drag plane
  104207. */
  104208. onDragObservable: Observable<{
  104209. delta: Vector3;
  104210. dragPlanePoint: Vector3;
  104211. dragPlaneNormal: Vector3;
  104212. dragDistance: number;
  104213. pointerId: number;
  104214. }>;
  104215. /**
  104216. * Fires each time a drag begins (eg. mouse down on mesh)
  104217. */
  104218. onDragStartObservable: Observable<{
  104219. dragPlanePoint: Vector3;
  104220. pointerId: number;
  104221. }>;
  104222. /**
  104223. * Fires each time a drag ends (eg. mouse release after drag)
  104224. */
  104225. onDragEndObservable: Observable<{
  104226. dragPlanePoint: Vector3;
  104227. pointerId: number;
  104228. }>;
  104229. /**
  104230. * If the attached mesh should be moved when dragged
  104231. */
  104232. moveAttached: boolean;
  104233. /**
  104234. * If the drag behavior will react to drag events (Default: true)
  104235. */
  104236. enabled: boolean;
  104237. /**
  104238. * If pointer events should start and release the drag (Default: true)
  104239. */
  104240. startAndReleaseDragOnPointerEvents: boolean;
  104241. /**
  104242. * If camera controls should be detached during the drag
  104243. */
  104244. detachCameraControls: boolean;
  104245. /**
  104246. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104247. */
  104248. useObjectOrienationForDragging: boolean;
  104249. private _options;
  104250. /**
  104251. * Creates a pointer drag behavior that can be attached to a mesh
  104252. * @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)
  104253. */
  104254. constructor(options?: {
  104255. dragAxis?: Vector3;
  104256. dragPlaneNormal?: Vector3;
  104257. });
  104258. /**
  104259. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104260. */
  104261. validateDrag: (targetPosition: Vector3) => boolean;
  104262. /**
  104263. * The name of the behavior
  104264. */
  104265. readonly name: string;
  104266. /**
  104267. * Initializes the behavior
  104268. */
  104269. init(): void;
  104270. private _tmpVector;
  104271. private _alternatePickedPoint;
  104272. private _worldDragAxis;
  104273. private _targetPosition;
  104274. private _attachedElement;
  104275. /**
  104276. * Attaches the drag behavior the passed in mesh
  104277. * @param ownerNode The mesh that will be dragged around once attached
  104278. * @param predicate Predicate to use for pick filtering
  104279. */
  104280. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104281. /**
  104282. * Force relase the drag action by code.
  104283. */
  104284. releaseDrag(): void;
  104285. private _startDragRay;
  104286. private _lastPointerRay;
  104287. /**
  104288. * Simulates the start of a pointer drag event on the behavior
  104289. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104290. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104291. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104292. */
  104293. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104294. private _startDrag;
  104295. private _dragDelta;
  104296. private _moveDrag;
  104297. private _pickWithRayOnDragPlane;
  104298. private _pointA;
  104299. private _pointB;
  104300. private _pointC;
  104301. private _lineA;
  104302. private _lineB;
  104303. private _localAxis;
  104304. private _lookAt;
  104305. private _updateDragPlanePosition;
  104306. /**
  104307. * Detaches the behavior from the mesh
  104308. */
  104309. detach(): void;
  104310. }
  104311. }
  104312. declare module BABYLON {
  104313. /**
  104314. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104315. */
  104316. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104317. private _dragBehaviorA;
  104318. private _dragBehaviorB;
  104319. private _startDistance;
  104320. private _initialScale;
  104321. private _targetScale;
  104322. private _ownerNode;
  104323. private _sceneRenderObserver;
  104324. /**
  104325. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104326. */
  104327. constructor();
  104328. /**
  104329. * The name of the behavior
  104330. */
  104331. readonly name: string;
  104332. /**
  104333. * Initializes the behavior
  104334. */
  104335. init(): void;
  104336. private _getCurrentDistance;
  104337. /**
  104338. * Attaches the scale behavior the passed in mesh
  104339. * @param ownerNode The mesh that will be scaled around once attached
  104340. */
  104341. attach(ownerNode: Mesh): void;
  104342. /**
  104343. * Detaches the behavior from the mesh
  104344. */
  104345. detach(): void;
  104346. }
  104347. }
  104348. declare module BABYLON {
  104349. /**
  104350. * 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
  104351. */
  104352. export class SixDofDragBehavior implements Behavior<Mesh> {
  104353. private static _virtualScene;
  104354. private _ownerNode;
  104355. private _sceneRenderObserver;
  104356. private _scene;
  104357. private _targetPosition;
  104358. private _virtualOriginMesh;
  104359. private _virtualDragMesh;
  104360. private _pointerObserver;
  104361. private _moving;
  104362. private _startingOrientation;
  104363. /**
  104364. * 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)
  104365. */
  104366. private zDragFactor;
  104367. /**
  104368. * If the object should rotate to face the drag origin
  104369. */
  104370. rotateDraggedObject: boolean;
  104371. /**
  104372. * If the behavior is currently in a dragging state
  104373. */
  104374. dragging: boolean;
  104375. /**
  104376. * 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)
  104377. */
  104378. dragDeltaRatio: number;
  104379. /**
  104380. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104381. */
  104382. currentDraggingPointerID: number;
  104383. /**
  104384. * If camera controls should be detached during the drag
  104385. */
  104386. detachCameraControls: boolean;
  104387. /**
  104388. * Fires each time a drag starts
  104389. */
  104390. onDragStartObservable: Observable<{}>;
  104391. /**
  104392. * Fires each time a drag ends (eg. mouse release after drag)
  104393. */
  104394. onDragEndObservable: Observable<{}>;
  104395. /**
  104396. * 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
  104397. */
  104398. constructor();
  104399. /**
  104400. * The name of the behavior
  104401. */
  104402. readonly name: string;
  104403. /**
  104404. * Initializes the behavior
  104405. */
  104406. init(): void;
  104407. /**
  104408. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104409. */
  104410. private readonly _pointerCamera;
  104411. /**
  104412. * Attaches the scale behavior the passed in mesh
  104413. * @param ownerNode The mesh that will be scaled around once attached
  104414. */
  104415. attach(ownerNode: Mesh): void;
  104416. /**
  104417. * Detaches the behavior from the mesh
  104418. */
  104419. detach(): void;
  104420. }
  104421. }
  104422. declare module BABYLON {
  104423. /**
  104424. * Class used to apply inverse kinematics to bones
  104425. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104426. */
  104427. export class BoneIKController {
  104428. private static _tmpVecs;
  104429. private static _tmpQuat;
  104430. private static _tmpMats;
  104431. /**
  104432. * Gets or sets the target mesh
  104433. */
  104434. targetMesh: AbstractMesh;
  104435. /** Gets or sets the mesh used as pole */
  104436. poleTargetMesh: AbstractMesh;
  104437. /**
  104438. * Gets or sets the bone used as pole
  104439. */
  104440. poleTargetBone: Nullable<Bone>;
  104441. /**
  104442. * Gets or sets the target position
  104443. */
  104444. targetPosition: Vector3;
  104445. /**
  104446. * Gets or sets the pole target position
  104447. */
  104448. poleTargetPosition: Vector3;
  104449. /**
  104450. * Gets or sets the pole target local offset
  104451. */
  104452. poleTargetLocalOffset: Vector3;
  104453. /**
  104454. * Gets or sets the pole angle
  104455. */
  104456. poleAngle: number;
  104457. /**
  104458. * Gets or sets the mesh associated with the controller
  104459. */
  104460. mesh: AbstractMesh;
  104461. /**
  104462. * 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)
  104463. */
  104464. slerpAmount: number;
  104465. private _bone1Quat;
  104466. private _bone1Mat;
  104467. private _bone2Ang;
  104468. private _bone1;
  104469. private _bone2;
  104470. private _bone1Length;
  104471. private _bone2Length;
  104472. private _maxAngle;
  104473. private _maxReach;
  104474. private _rightHandedSystem;
  104475. private _bendAxis;
  104476. private _slerping;
  104477. private _adjustRoll;
  104478. /**
  104479. * Gets or sets maximum allowed angle
  104480. */
  104481. maxAngle: number;
  104482. /**
  104483. * Creates a new BoneIKController
  104484. * @param mesh defines the mesh to control
  104485. * @param bone defines the bone to control
  104486. * @param options defines options to set up the controller
  104487. */
  104488. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104489. targetMesh?: AbstractMesh;
  104490. poleTargetMesh?: AbstractMesh;
  104491. poleTargetBone?: Bone;
  104492. poleTargetLocalOffset?: Vector3;
  104493. poleAngle?: number;
  104494. bendAxis?: Vector3;
  104495. maxAngle?: number;
  104496. slerpAmount?: number;
  104497. });
  104498. private _setMaxAngle;
  104499. /**
  104500. * Force the controller to update the bones
  104501. */
  104502. update(): void;
  104503. }
  104504. }
  104505. declare module BABYLON {
  104506. /**
  104507. * Class used to make a bone look toward a point in space
  104508. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104509. */
  104510. export class BoneLookController {
  104511. private static _tmpVecs;
  104512. private static _tmpQuat;
  104513. private static _tmpMats;
  104514. /**
  104515. * The target Vector3 that the bone will look at
  104516. */
  104517. target: Vector3;
  104518. /**
  104519. * The mesh that the bone is attached to
  104520. */
  104521. mesh: AbstractMesh;
  104522. /**
  104523. * The bone that will be looking to the target
  104524. */
  104525. bone: Bone;
  104526. /**
  104527. * The up axis of the coordinate system that is used when the bone is rotated
  104528. */
  104529. upAxis: Vector3;
  104530. /**
  104531. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104532. */
  104533. upAxisSpace: Space;
  104534. /**
  104535. * Used to make an adjustment to the yaw of the bone
  104536. */
  104537. adjustYaw: number;
  104538. /**
  104539. * Used to make an adjustment to the pitch of the bone
  104540. */
  104541. adjustPitch: number;
  104542. /**
  104543. * Used to make an adjustment to the roll of the bone
  104544. */
  104545. adjustRoll: number;
  104546. /**
  104547. * 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)
  104548. */
  104549. slerpAmount: number;
  104550. private _minYaw;
  104551. private _maxYaw;
  104552. private _minPitch;
  104553. private _maxPitch;
  104554. private _minYawSin;
  104555. private _minYawCos;
  104556. private _maxYawSin;
  104557. private _maxYawCos;
  104558. private _midYawConstraint;
  104559. private _minPitchTan;
  104560. private _maxPitchTan;
  104561. private _boneQuat;
  104562. private _slerping;
  104563. private _transformYawPitch;
  104564. private _transformYawPitchInv;
  104565. private _firstFrameSkipped;
  104566. private _yawRange;
  104567. private _fowardAxis;
  104568. /**
  104569. * Gets or sets the minimum yaw angle that the bone can look to
  104570. */
  104571. minYaw: number;
  104572. /**
  104573. * Gets or sets the maximum yaw angle that the bone can look to
  104574. */
  104575. maxYaw: number;
  104576. /**
  104577. * Gets or sets the minimum pitch angle that the bone can look to
  104578. */
  104579. minPitch: number;
  104580. /**
  104581. * Gets or sets the maximum pitch angle that the bone can look to
  104582. */
  104583. maxPitch: number;
  104584. /**
  104585. * Create a BoneLookController
  104586. * @param mesh the mesh that the bone belongs to
  104587. * @param bone the bone that will be looking to the target
  104588. * @param target the target Vector3 to look at
  104589. * @param options optional settings:
  104590. * * maxYaw: the maximum angle the bone will yaw to
  104591. * * minYaw: the minimum angle the bone will yaw to
  104592. * * maxPitch: the maximum angle the bone will pitch to
  104593. * * minPitch: the minimum angle the bone will yaw to
  104594. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104595. * * upAxis: the up axis of the coordinate system
  104596. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104597. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104598. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104599. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104600. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104601. * * adjustRoll: used to make an adjustment to the roll of the bone
  104602. **/
  104603. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104604. maxYaw?: number;
  104605. minYaw?: number;
  104606. maxPitch?: number;
  104607. minPitch?: number;
  104608. slerpAmount?: number;
  104609. upAxis?: Vector3;
  104610. upAxisSpace?: Space;
  104611. yawAxis?: Vector3;
  104612. pitchAxis?: Vector3;
  104613. adjustYaw?: number;
  104614. adjustPitch?: number;
  104615. adjustRoll?: number;
  104616. });
  104617. /**
  104618. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104619. */
  104620. update(): void;
  104621. private _getAngleDiff;
  104622. private _getAngleBetween;
  104623. private _isAngleBetween;
  104624. }
  104625. }
  104626. declare module BABYLON {
  104627. /**
  104628. * Manage the gamepad inputs to control an arc rotate camera.
  104629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104630. */
  104631. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104632. /**
  104633. * Defines the camera the input is attached to.
  104634. */
  104635. camera: ArcRotateCamera;
  104636. /**
  104637. * Defines the gamepad the input is gathering event from.
  104638. */
  104639. gamepad: Nullable<Gamepad>;
  104640. /**
  104641. * Defines the gamepad rotation sensiblity.
  104642. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104643. */
  104644. gamepadRotationSensibility: number;
  104645. /**
  104646. * Defines the gamepad move sensiblity.
  104647. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104648. */
  104649. gamepadMoveSensibility: number;
  104650. private _yAxisScale;
  104651. /**
  104652. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104653. */
  104654. invertYAxis: boolean;
  104655. private _onGamepadConnectedObserver;
  104656. private _onGamepadDisconnectedObserver;
  104657. /**
  104658. * Attach the input controls to a specific dom element to get the input from.
  104659. * @param element Defines the element the controls should be listened from
  104660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104661. */
  104662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104663. /**
  104664. * Detach the current controls from the specified dom element.
  104665. * @param element Defines the element to stop listening the inputs from
  104666. */
  104667. detachControl(element: Nullable<HTMLElement>): void;
  104668. /**
  104669. * Update the current camera state depending on the inputs that have been used this frame.
  104670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104671. */
  104672. checkInputs(): void;
  104673. /**
  104674. * Gets the class name of the current intput.
  104675. * @returns the class name
  104676. */
  104677. getClassName(): string;
  104678. /**
  104679. * Get the friendly name associated with the input class.
  104680. * @returns the input friendly name
  104681. */
  104682. getSimpleName(): string;
  104683. }
  104684. }
  104685. declare module BABYLON {
  104686. interface ArcRotateCameraInputsManager {
  104687. /**
  104688. * Add orientation input support to the input manager.
  104689. * @returns the current input manager
  104690. */
  104691. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104692. }
  104693. /**
  104694. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104696. */
  104697. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104698. /**
  104699. * Defines the camera the input is attached to.
  104700. */
  104701. camera: ArcRotateCamera;
  104702. /**
  104703. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104704. */
  104705. alphaCorrection: number;
  104706. /**
  104707. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104708. */
  104709. gammaCorrection: number;
  104710. private _alpha;
  104711. private _gamma;
  104712. private _dirty;
  104713. private _deviceOrientationHandler;
  104714. /**
  104715. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104716. */
  104717. constructor();
  104718. /**
  104719. * Attach the input controls to a specific dom element to get the input from.
  104720. * @param element Defines the element the controls should be listened from
  104721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104722. */
  104723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104724. /** @hidden */
  104725. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104726. /**
  104727. * Update the current camera state depending on the inputs that have been used this frame.
  104728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104729. */
  104730. checkInputs(): void;
  104731. /**
  104732. * Detach the current controls from the specified dom element.
  104733. * @param element Defines the element to stop listening the inputs from
  104734. */
  104735. detachControl(element: Nullable<HTMLElement>): void;
  104736. /**
  104737. * Gets the class name of the current intput.
  104738. * @returns the class name
  104739. */
  104740. getClassName(): string;
  104741. /**
  104742. * Get the friendly name associated with the input class.
  104743. * @returns the input friendly name
  104744. */
  104745. getSimpleName(): string;
  104746. }
  104747. }
  104748. declare module BABYLON {
  104749. /**
  104750. * Listen to mouse events to control the camera.
  104751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104752. */
  104753. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104754. /**
  104755. * Defines the camera the input is attached to.
  104756. */
  104757. camera: FlyCamera;
  104758. /**
  104759. * Defines if touch is enabled. (Default is true.)
  104760. */
  104761. touchEnabled: boolean;
  104762. /**
  104763. * Defines the buttons associated with the input to handle camera rotation.
  104764. */
  104765. buttons: number[];
  104766. /**
  104767. * Assign buttons for Yaw control.
  104768. */
  104769. buttonsYaw: number[];
  104770. /**
  104771. * Assign buttons for Pitch control.
  104772. */
  104773. buttonsPitch: number[];
  104774. /**
  104775. * Assign buttons for Roll control.
  104776. */
  104777. buttonsRoll: number[];
  104778. /**
  104779. * Detect if any button is being pressed while mouse is moved.
  104780. * -1 = Mouse locked.
  104781. * 0 = Left button.
  104782. * 1 = Middle Button.
  104783. * 2 = Right Button.
  104784. */
  104785. activeButton: number;
  104786. /**
  104787. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104788. * Higher values reduce its sensitivity.
  104789. */
  104790. angularSensibility: number;
  104791. private _mousemoveCallback;
  104792. private _observer;
  104793. private _rollObserver;
  104794. private previousPosition;
  104795. private noPreventDefault;
  104796. private element;
  104797. /**
  104798. * Listen to mouse events to control the camera.
  104799. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104801. */
  104802. constructor(touchEnabled?: boolean);
  104803. /**
  104804. * Attach the mouse control to the HTML DOM element.
  104805. * @param element Defines the element that listens to the input events.
  104806. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104807. */
  104808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104809. /**
  104810. * Detach the current controls from the specified dom element.
  104811. * @param element Defines the element to stop listening the inputs from
  104812. */
  104813. detachControl(element: Nullable<HTMLElement>): void;
  104814. /**
  104815. * Gets the class name of the current input.
  104816. * @returns the class name.
  104817. */
  104818. getClassName(): string;
  104819. /**
  104820. * Get the friendly name associated with the input class.
  104821. * @returns the input's friendly name.
  104822. */
  104823. getSimpleName(): string;
  104824. private _pointerInput;
  104825. private _onMouseMove;
  104826. /**
  104827. * Rotate camera by mouse offset.
  104828. */
  104829. private rotateCamera;
  104830. }
  104831. }
  104832. declare module BABYLON {
  104833. /**
  104834. * Default Inputs manager for the FlyCamera.
  104835. * It groups all the default supported inputs for ease of use.
  104836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104837. */
  104838. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104839. /**
  104840. * Instantiates a new FlyCameraInputsManager.
  104841. * @param camera Defines the camera the inputs belong to.
  104842. */
  104843. constructor(camera: FlyCamera);
  104844. /**
  104845. * Add keyboard input support to the input manager.
  104846. * @returns the new FlyCameraKeyboardMoveInput().
  104847. */
  104848. addKeyboard(): FlyCameraInputsManager;
  104849. /**
  104850. * Add mouse input support to the input manager.
  104851. * @param touchEnabled Enable touch screen support.
  104852. * @returns the new FlyCameraMouseInput().
  104853. */
  104854. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104855. }
  104856. }
  104857. declare module BABYLON {
  104858. /**
  104859. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104860. * such as in a 3D Space Shooter or a Flight Simulator.
  104861. */
  104862. export class FlyCamera extends TargetCamera {
  104863. /**
  104864. * Define the collision ellipsoid of the camera.
  104865. * This is helpful for simulating a camera body, like a player's body.
  104866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104867. */
  104868. ellipsoid: Vector3;
  104869. /**
  104870. * Define an offset for the position of the ellipsoid around the camera.
  104871. * This can be helpful if the camera is attached away from the player's body center,
  104872. * such as at its head.
  104873. */
  104874. ellipsoidOffset: Vector3;
  104875. /**
  104876. * Enable or disable collisions of the camera with the rest of the scene objects.
  104877. */
  104878. checkCollisions: boolean;
  104879. /**
  104880. * Enable or disable gravity on the camera.
  104881. */
  104882. applyGravity: boolean;
  104883. /**
  104884. * Define the current direction the camera is moving to.
  104885. */
  104886. cameraDirection: Vector3;
  104887. /**
  104888. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104889. * This overrides and empties cameraRotation.
  104890. */
  104891. rotationQuaternion: Quaternion;
  104892. /**
  104893. * Track Roll to maintain the wanted Rolling when looking around.
  104894. */
  104895. _trackRoll: number;
  104896. /**
  104897. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104898. */
  104899. rollCorrect: number;
  104900. /**
  104901. * Mimic a banked turn, Rolling the camera when Yawing.
  104902. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104903. */
  104904. bankedTurn: boolean;
  104905. /**
  104906. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104907. */
  104908. bankedTurnLimit: number;
  104909. /**
  104910. * Value of 0 disables the banked Roll.
  104911. * Value of 1 is equal to the Yaw angle in radians.
  104912. */
  104913. bankedTurnMultiplier: number;
  104914. /**
  104915. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104916. */
  104917. inputs: FlyCameraInputsManager;
  104918. /**
  104919. * Gets the input sensibility for mouse input.
  104920. * Higher values reduce sensitivity.
  104921. */
  104922. /**
  104923. * Sets the input sensibility for a mouse input.
  104924. * Higher values reduce sensitivity.
  104925. */
  104926. angularSensibility: number;
  104927. /**
  104928. * Get the keys for camera movement forward.
  104929. */
  104930. /**
  104931. * Set the keys for camera movement forward.
  104932. */
  104933. keysForward: number[];
  104934. /**
  104935. * Get the keys for camera movement backward.
  104936. */
  104937. keysBackward: number[];
  104938. /**
  104939. * Get the keys for camera movement up.
  104940. */
  104941. /**
  104942. * Set the keys for camera movement up.
  104943. */
  104944. keysUp: number[];
  104945. /**
  104946. * Get the keys for camera movement down.
  104947. */
  104948. /**
  104949. * Set the keys for camera movement down.
  104950. */
  104951. keysDown: number[];
  104952. /**
  104953. * Get the keys for camera movement left.
  104954. */
  104955. /**
  104956. * Set the keys for camera movement left.
  104957. */
  104958. keysLeft: number[];
  104959. /**
  104960. * Set the keys for camera movement right.
  104961. */
  104962. /**
  104963. * Set the keys for camera movement right.
  104964. */
  104965. keysRight: number[];
  104966. /**
  104967. * Event raised when the camera collides with a mesh in the scene.
  104968. */
  104969. onCollide: (collidedMesh: AbstractMesh) => void;
  104970. private _collider;
  104971. private _needMoveForGravity;
  104972. private _oldPosition;
  104973. private _diffPosition;
  104974. private _newPosition;
  104975. /** @hidden */
  104976. _localDirection: Vector3;
  104977. /** @hidden */
  104978. _transformedDirection: Vector3;
  104979. /**
  104980. * Instantiates a FlyCamera.
  104981. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104982. * such as in a 3D Space Shooter or a Flight Simulator.
  104983. * @param name Define the name of the camera in the scene.
  104984. * @param position Define the starting position of the camera in the scene.
  104985. * @param scene Define the scene the camera belongs to.
  104986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104987. */
  104988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104989. /**
  104990. * Attach a control to the HTML DOM element.
  104991. * @param element Defines the element that listens to the input events.
  104992. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104993. */
  104994. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104995. /**
  104996. * Detach a control from the HTML DOM element.
  104997. * The camera will stop reacting to that input.
  104998. * @param element Defines the element that listens to the input events.
  104999. */
  105000. detachControl(element: HTMLElement): void;
  105001. private _collisionMask;
  105002. /**
  105003. * Get the mask that the camera ignores in collision events.
  105004. */
  105005. /**
  105006. * Set the mask that the camera ignores in collision events.
  105007. */
  105008. collisionMask: number;
  105009. /** @hidden */
  105010. _collideWithWorld(displacement: Vector3): void;
  105011. /** @hidden */
  105012. private _onCollisionPositionChange;
  105013. /** @hidden */
  105014. _checkInputs(): void;
  105015. /** @hidden */
  105016. _decideIfNeedsToMove(): boolean;
  105017. /** @hidden */
  105018. _updatePosition(): void;
  105019. /**
  105020. * Restore the Roll to its target value at the rate specified.
  105021. * @param rate - Higher means slower restoring.
  105022. * @hidden
  105023. */
  105024. restoreRoll(rate: number): void;
  105025. /**
  105026. * Destroy the camera and release the current resources held by it.
  105027. */
  105028. dispose(): void;
  105029. /**
  105030. * Get the current object class name.
  105031. * @returns the class name.
  105032. */
  105033. getClassName(): string;
  105034. }
  105035. }
  105036. declare module BABYLON {
  105037. /**
  105038. * Listen to keyboard events to control the camera.
  105039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105040. */
  105041. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105042. /**
  105043. * Defines the camera the input is attached to.
  105044. */
  105045. camera: FlyCamera;
  105046. /**
  105047. * The list of keyboard keys used to control the forward move of the camera.
  105048. */
  105049. keysForward: number[];
  105050. /**
  105051. * The list of keyboard keys used to control the backward move of the camera.
  105052. */
  105053. keysBackward: number[];
  105054. /**
  105055. * The list of keyboard keys used to control the forward move of the camera.
  105056. */
  105057. keysUp: number[];
  105058. /**
  105059. * The list of keyboard keys used to control the backward move of the camera.
  105060. */
  105061. keysDown: number[];
  105062. /**
  105063. * The list of keyboard keys used to control the right strafe move of the camera.
  105064. */
  105065. keysRight: number[];
  105066. /**
  105067. * The list of keyboard keys used to control the left strafe move of the camera.
  105068. */
  105069. keysLeft: number[];
  105070. private _keys;
  105071. private _onCanvasBlurObserver;
  105072. private _onKeyboardObserver;
  105073. private _engine;
  105074. private _scene;
  105075. /**
  105076. * Attach the input controls to a specific dom element to get the input from.
  105077. * @param element Defines the element the controls should be listened from
  105078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105079. */
  105080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105081. /**
  105082. * Detach the current controls from the specified dom element.
  105083. * @param element Defines the element to stop listening the inputs from
  105084. */
  105085. detachControl(element: Nullable<HTMLElement>): void;
  105086. /**
  105087. * Gets the class name of the current intput.
  105088. * @returns the class name
  105089. */
  105090. getClassName(): string;
  105091. /** @hidden */
  105092. _onLostFocus(e: FocusEvent): void;
  105093. /**
  105094. * Get the friendly name associated with the input class.
  105095. * @returns the input friendly name
  105096. */
  105097. getSimpleName(): string;
  105098. /**
  105099. * Update the current camera state depending on the inputs that have been used this frame.
  105100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105101. */
  105102. checkInputs(): void;
  105103. }
  105104. }
  105105. declare module BABYLON {
  105106. /**
  105107. * Manage the mouse wheel inputs to control a follow camera.
  105108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105109. */
  105110. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105111. /**
  105112. * Defines the camera the input is attached to.
  105113. */
  105114. camera: FollowCamera;
  105115. /**
  105116. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105117. */
  105118. axisControlRadius: boolean;
  105119. /**
  105120. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105121. */
  105122. axisControlHeight: boolean;
  105123. /**
  105124. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105125. */
  105126. axisControlRotation: boolean;
  105127. /**
  105128. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105129. * relation to mouseWheel events.
  105130. */
  105131. wheelPrecision: number;
  105132. /**
  105133. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105134. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105135. */
  105136. wheelDeltaPercentage: number;
  105137. private _wheel;
  105138. private _observer;
  105139. /**
  105140. * Attach the input controls to a specific dom element to get the input from.
  105141. * @param element Defines the element the controls should be listened from
  105142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105143. */
  105144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105145. /**
  105146. * Detach the current controls from the specified dom element.
  105147. * @param element Defines the element to stop listening the inputs from
  105148. */
  105149. detachControl(element: Nullable<HTMLElement>): void;
  105150. /**
  105151. * Gets the class name of the current intput.
  105152. * @returns the class name
  105153. */
  105154. getClassName(): string;
  105155. /**
  105156. * Get the friendly name associated with the input class.
  105157. * @returns the input friendly name
  105158. */
  105159. getSimpleName(): string;
  105160. }
  105161. }
  105162. declare module BABYLON {
  105163. /**
  105164. * Manage the pointers inputs to control an follow camera.
  105165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105166. */
  105167. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105168. /**
  105169. * Defines the camera the input is attached to.
  105170. */
  105171. camera: FollowCamera;
  105172. /**
  105173. * Gets the class name of the current input.
  105174. * @returns the class name
  105175. */
  105176. getClassName(): string;
  105177. /**
  105178. * Defines the pointer angular sensibility along the X axis or how fast is
  105179. * the camera rotating.
  105180. * A negative number will reverse the axis direction.
  105181. */
  105182. angularSensibilityX: number;
  105183. /**
  105184. * Defines the pointer angular sensibility along the Y axis or how fast is
  105185. * the camera rotating.
  105186. * A negative number will reverse the axis direction.
  105187. */
  105188. angularSensibilityY: number;
  105189. /**
  105190. * Defines the pointer pinch precision or how fast is the camera zooming.
  105191. * A negative number will reverse the axis direction.
  105192. */
  105193. pinchPrecision: number;
  105194. /**
  105195. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105196. * from 0.
  105197. * It defines the percentage of current camera.radius to use as delta when
  105198. * pinch zoom is used.
  105199. */
  105200. pinchDeltaPercentage: number;
  105201. /**
  105202. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105203. */
  105204. axisXControlRadius: boolean;
  105205. /**
  105206. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105207. */
  105208. axisXControlHeight: boolean;
  105209. /**
  105210. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105211. */
  105212. axisXControlRotation: boolean;
  105213. /**
  105214. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105215. */
  105216. axisYControlRadius: boolean;
  105217. /**
  105218. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105219. */
  105220. axisYControlHeight: boolean;
  105221. /**
  105222. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105223. */
  105224. axisYControlRotation: boolean;
  105225. /**
  105226. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105227. */
  105228. axisPinchControlRadius: boolean;
  105229. /**
  105230. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105231. */
  105232. axisPinchControlHeight: boolean;
  105233. /**
  105234. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105235. */
  105236. axisPinchControlRotation: boolean;
  105237. /**
  105238. * Log error messages if basic misconfiguration has occurred.
  105239. */
  105240. warningEnable: boolean;
  105241. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105242. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105243. private _warningCounter;
  105244. private _warning;
  105245. }
  105246. }
  105247. declare module BABYLON {
  105248. /**
  105249. * Default Inputs manager for the FollowCamera.
  105250. * It groups all the default supported inputs for ease of use.
  105251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105252. */
  105253. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105254. /**
  105255. * Instantiates a new FollowCameraInputsManager.
  105256. * @param camera Defines the camera the inputs belong to
  105257. */
  105258. constructor(camera: FollowCamera);
  105259. /**
  105260. * Add keyboard input support to the input manager.
  105261. * @returns the current input manager
  105262. */
  105263. addKeyboard(): FollowCameraInputsManager;
  105264. /**
  105265. * Add mouse wheel input support to the input manager.
  105266. * @returns the current input manager
  105267. */
  105268. addMouseWheel(): FollowCameraInputsManager;
  105269. /**
  105270. * Add pointers input support to the input manager.
  105271. * @returns the current input manager
  105272. */
  105273. addPointers(): FollowCameraInputsManager;
  105274. /**
  105275. * Add orientation input support to the input manager.
  105276. * @returns the current input manager
  105277. */
  105278. addVRDeviceOrientation(): FollowCameraInputsManager;
  105279. }
  105280. }
  105281. declare module BABYLON {
  105282. /**
  105283. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105284. * an arc rotate version arcFollowCamera are available.
  105285. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105286. */
  105287. export class FollowCamera extends TargetCamera {
  105288. /**
  105289. * Distance the follow camera should follow an object at
  105290. */
  105291. radius: number;
  105292. /**
  105293. * Minimum allowed distance of the camera to the axis of rotation
  105294. * (The camera can not get closer).
  105295. * This can help limiting how the Camera is able to move in the scene.
  105296. */
  105297. lowerRadiusLimit: Nullable<number>;
  105298. /**
  105299. * Maximum allowed distance of the camera to the axis of rotation
  105300. * (The camera can not get further).
  105301. * This can help limiting how the Camera is able to move in the scene.
  105302. */
  105303. upperRadiusLimit: Nullable<number>;
  105304. /**
  105305. * Define a rotation offset between the camera and the object it follows
  105306. */
  105307. rotationOffset: number;
  105308. /**
  105309. * Minimum allowed angle to camera position relative to target object.
  105310. * This can help limiting how the Camera is able to move in the scene.
  105311. */
  105312. lowerRotationOffsetLimit: Nullable<number>;
  105313. /**
  105314. * Maximum allowed angle to camera position relative to target object.
  105315. * This can help limiting how the Camera is able to move in the scene.
  105316. */
  105317. upperRotationOffsetLimit: Nullable<number>;
  105318. /**
  105319. * Define a height offset between the camera and the object it follows.
  105320. * It can help following an object from the top (like a car chaing a plane)
  105321. */
  105322. heightOffset: number;
  105323. /**
  105324. * Minimum allowed height of camera position relative to target object.
  105325. * This can help limiting how the Camera is able to move in the scene.
  105326. */
  105327. lowerHeightOffsetLimit: Nullable<number>;
  105328. /**
  105329. * Maximum allowed height of camera position relative to target object.
  105330. * This can help limiting how the Camera is able to move in the scene.
  105331. */
  105332. upperHeightOffsetLimit: Nullable<number>;
  105333. /**
  105334. * Define how fast the camera can accelerate to follow it s target.
  105335. */
  105336. cameraAcceleration: number;
  105337. /**
  105338. * Define the speed limit of the camera following an object.
  105339. */
  105340. maxCameraSpeed: number;
  105341. /**
  105342. * Define the target of the camera.
  105343. */
  105344. lockedTarget: Nullable<AbstractMesh>;
  105345. /**
  105346. * Defines the input associated with the camera.
  105347. */
  105348. inputs: FollowCameraInputsManager;
  105349. /**
  105350. * Instantiates the follow camera.
  105351. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105352. * @param name Define the name of the camera in the scene
  105353. * @param position Define the position of the camera
  105354. * @param scene Define the scene the camera belong to
  105355. * @param lockedTarget Define the target of the camera
  105356. */
  105357. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105358. private _follow;
  105359. /**
  105360. * Attached controls to the current camera.
  105361. * @param element Defines the element the controls should be listened from
  105362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105363. */
  105364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105365. /**
  105366. * Detach the current controls from the camera.
  105367. * The camera will stop reacting to inputs.
  105368. * @param element Defines the element to stop listening the inputs from
  105369. */
  105370. detachControl(element: HTMLElement): void;
  105371. /** @hidden */
  105372. _checkInputs(): void;
  105373. private _checkLimits;
  105374. /**
  105375. * Gets the camera class name.
  105376. * @returns the class name
  105377. */
  105378. getClassName(): string;
  105379. }
  105380. /**
  105381. * Arc Rotate version of the follow camera.
  105382. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105384. */
  105385. export class ArcFollowCamera extends TargetCamera {
  105386. /** The longitudinal angle of the camera */
  105387. alpha: number;
  105388. /** The latitudinal angle of the camera */
  105389. beta: number;
  105390. /** The radius of the camera from its target */
  105391. radius: number;
  105392. /** Define the camera target (the messh it should follow) */
  105393. target: Nullable<AbstractMesh>;
  105394. private _cartesianCoordinates;
  105395. /**
  105396. * Instantiates a new ArcFollowCamera
  105397. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105398. * @param name Define the name of the camera
  105399. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105400. * @param beta Define the rotation angle of the camera around the elevation axis
  105401. * @param radius Define the radius of the camera from its target point
  105402. * @param target Define the target of the camera
  105403. * @param scene Define the scene the camera belongs to
  105404. */
  105405. constructor(name: string,
  105406. /** The longitudinal angle of the camera */
  105407. alpha: number,
  105408. /** The latitudinal angle of the camera */
  105409. beta: number,
  105410. /** The radius of the camera from its target */
  105411. radius: number,
  105412. /** Define the camera target (the messh it should follow) */
  105413. target: Nullable<AbstractMesh>, scene: Scene);
  105414. private _follow;
  105415. /** @hidden */
  105416. _checkInputs(): void;
  105417. /**
  105418. * Returns the class name of the object.
  105419. * It is mostly used internally for serialization purposes.
  105420. */
  105421. getClassName(): string;
  105422. }
  105423. }
  105424. declare module BABYLON {
  105425. /**
  105426. * Manage the keyboard inputs to control the movement of a follow camera.
  105427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105428. */
  105429. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105430. /**
  105431. * Defines the camera the input is attached to.
  105432. */
  105433. camera: FollowCamera;
  105434. /**
  105435. * Defines the list of key codes associated with the up action (increase heightOffset)
  105436. */
  105437. keysHeightOffsetIncr: number[];
  105438. /**
  105439. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105440. */
  105441. keysHeightOffsetDecr: number[];
  105442. /**
  105443. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105444. */
  105445. keysHeightOffsetModifierAlt: boolean;
  105446. /**
  105447. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105448. */
  105449. keysHeightOffsetModifierCtrl: boolean;
  105450. /**
  105451. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105452. */
  105453. keysHeightOffsetModifierShift: boolean;
  105454. /**
  105455. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105456. */
  105457. keysRotationOffsetIncr: number[];
  105458. /**
  105459. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105460. */
  105461. keysRotationOffsetDecr: number[];
  105462. /**
  105463. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105464. */
  105465. keysRotationOffsetModifierAlt: boolean;
  105466. /**
  105467. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105468. */
  105469. keysRotationOffsetModifierCtrl: boolean;
  105470. /**
  105471. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105472. */
  105473. keysRotationOffsetModifierShift: boolean;
  105474. /**
  105475. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105476. */
  105477. keysRadiusIncr: number[];
  105478. /**
  105479. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105480. */
  105481. keysRadiusDecr: number[];
  105482. /**
  105483. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105484. */
  105485. keysRadiusModifierAlt: boolean;
  105486. /**
  105487. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105488. */
  105489. keysRadiusModifierCtrl: boolean;
  105490. /**
  105491. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105492. */
  105493. keysRadiusModifierShift: boolean;
  105494. /**
  105495. * Defines the rate of change of heightOffset.
  105496. */
  105497. heightSensibility: number;
  105498. /**
  105499. * Defines the rate of change of rotationOffset.
  105500. */
  105501. rotationSensibility: number;
  105502. /**
  105503. * Defines the rate of change of radius.
  105504. */
  105505. radiusSensibility: number;
  105506. private _keys;
  105507. private _ctrlPressed;
  105508. private _altPressed;
  105509. private _shiftPressed;
  105510. private _onCanvasBlurObserver;
  105511. private _onKeyboardObserver;
  105512. private _engine;
  105513. private _scene;
  105514. /**
  105515. * Attach the input controls to a specific dom element to get the input from.
  105516. * @param element Defines the element the controls should be listened from
  105517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105518. */
  105519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105520. /**
  105521. * Detach the current controls from the specified dom element.
  105522. * @param element Defines the element to stop listening the inputs from
  105523. */
  105524. detachControl(element: Nullable<HTMLElement>): void;
  105525. /**
  105526. * Update the current camera state depending on the inputs that have been used this frame.
  105527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105528. */
  105529. checkInputs(): void;
  105530. /**
  105531. * Gets the class name of the current input.
  105532. * @returns the class name
  105533. */
  105534. getClassName(): string;
  105535. /**
  105536. * Get the friendly name associated with the input class.
  105537. * @returns the input friendly name
  105538. */
  105539. getSimpleName(): string;
  105540. /**
  105541. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105542. * allow modification of the heightOffset value.
  105543. */
  105544. private _modifierHeightOffset;
  105545. /**
  105546. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105547. * allow modification of the rotationOffset value.
  105548. */
  105549. private _modifierRotationOffset;
  105550. /**
  105551. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105552. * allow modification of the radius value.
  105553. */
  105554. private _modifierRadius;
  105555. }
  105556. }
  105557. declare module BABYLON {
  105558. interface FreeCameraInputsManager {
  105559. /**
  105560. * @hidden
  105561. */
  105562. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105563. /**
  105564. * Add orientation input support to the input manager.
  105565. * @returns the current input manager
  105566. */
  105567. addDeviceOrientation(): FreeCameraInputsManager;
  105568. }
  105569. /**
  105570. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105571. * Screen rotation is taken into account.
  105572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105573. */
  105574. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105575. private _camera;
  105576. private _screenOrientationAngle;
  105577. private _constantTranform;
  105578. private _screenQuaternion;
  105579. private _alpha;
  105580. private _beta;
  105581. private _gamma;
  105582. /**
  105583. * Can be used to detect if a device orientation sensor is availible on a device
  105584. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105585. * @returns a promise that will resolve on orientation change
  105586. */
  105587. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105588. /**
  105589. * @hidden
  105590. */
  105591. _onDeviceOrientationChangedObservable: Observable<void>;
  105592. /**
  105593. * Instantiates a new input
  105594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105595. */
  105596. constructor();
  105597. /**
  105598. * Define the camera controlled by the input.
  105599. */
  105600. camera: FreeCamera;
  105601. /**
  105602. * Attach the input controls to a specific dom element to get the input from.
  105603. * @param element Defines the element the controls should be listened from
  105604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105605. */
  105606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105607. private _orientationChanged;
  105608. private _deviceOrientation;
  105609. /**
  105610. * Detach the current controls from the specified dom element.
  105611. * @param element Defines the element to stop listening the inputs from
  105612. */
  105613. detachControl(element: Nullable<HTMLElement>): void;
  105614. /**
  105615. * Update the current camera state depending on the inputs that have been used this frame.
  105616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105617. */
  105618. checkInputs(): void;
  105619. /**
  105620. * Gets the class name of the current intput.
  105621. * @returns the class name
  105622. */
  105623. getClassName(): string;
  105624. /**
  105625. * Get the friendly name associated with the input class.
  105626. * @returns the input friendly name
  105627. */
  105628. getSimpleName(): string;
  105629. }
  105630. }
  105631. declare module BABYLON {
  105632. /**
  105633. * Manage the gamepad inputs to control a free camera.
  105634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105635. */
  105636. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105637. /**
  105638. * Define the camera the input is attached to.
  105639. */
  105640. camera: FreeCamera;
  105641. /**
  105642. * Define the Gamepad controlling the input
  105643. */
  105644. gamepad: Nullable<Gamepad>;
  105645. /**
  105646. * Defines the gamepad rotation sensiblity.
  105647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105648. */
  105649. gamepadAngularSensibility: number;
  105650. /**
  105651. * Defines the gamepad move sensiblity.
  105652. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105653. */
  105654. gamepadMoveSensibility: number;
  105655. private _yAxisScale;
  105656. /**
  105657. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105658. */
  105659. invertYAxis: boolean;
  105660. private _onGamepadConnectedObserver;
  105661. private _onGamepadDisconnectedObserver;
  105662. private _cameraTransform;
  105663. private _deltaTransform;
  105664. private _vector3;
  105665. private _vector2;
  105666. /**
  105667. * Attach the input controls to a specific dom element to get the input from.
  105668. * @param element Defines the element the controls should be listened from
  105669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105670. */
  105671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105672. /**
  105673. * Detach the current controls from the specified dom element.
  105674. * @param element Defines the element to stop listening the inputs from
  105675. */
  105676. detachControl(element: Nullable<HTMLElement>): void;
  105677. /**
  105678. * Update the current camera state depending on the inputs that have been used this frame.
  105679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105680. */
  105681. checkInputs(): void;
  105682. /**
  105683. * Gets the class name of the current intput.
  105684. * @returns the class name
  105685. */
  105686. getClassName(): string;
  105687. /**
  105688. * Get the friendly name associated with the input class.
  105689. * @returns the input friendly name
  105690. */
  105691. getSimpleName(): string;
  105692. }
  105693. }
  105694. declare module BABYLON {
  105695. /**
  105696. * Defines the potential axis of a Joystick
  105697. */
  105698. export enum JoystickAxis {
  105699. /** X axis */
  105700. X = 0,
  105701. /** Y axis */
  105702. Y = 1,
  105703. /** Z axis */
  105704. Z = 2
  105705. }
  105706. /**
  105707. * Class used to define virtual joystick (used in touch mode)
  105708. */
  105709. export class VirtualJoystick {
  105710. /**
  105711. * Gets or sets a boolean indicating that left and right values must be inverted
  105712. */
  105713. reverseLeftRight: boolean;
  105714. /**
  105715. * Gets or sets a boolean indicating that up and down values must be inverted
  105716. */
  105717. reverseUpDown: boolean;
  105718. /**
  105719. * Gets the offset value for the position (ie. the change of the position value)
  105720. */
  105721. deltaPosition: Vector3;
  105722. /**
  105723. * Gets a boolean indicating if the virtual joystick was pressed
  105724. */
  105725. pressed: boolean;
  105726. /**
  105727. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105728. */
  105729. static Canvas: Nullable<HTMLCanvasElement>;
  105730. private static _globalJoystickIndex;
  105731. private static vjCanvasContext;
  105732. private static vjCanvasWidth;
  105733. private static vjCanvasHeight;
  105734. private static halfWidth;
  105735. private _action;
  105736. private _axisTargetedByLeftAndRight;
  105737. private _axisTargetedByUpAndDown;
  105738. private _joystickSensibility;
  105739. private _inversedSensibility;
  105740. private _joystickPointerID;
  105741. private _joystickColor;
  105742. private _joystickPointerPos;
  105743. private _joystickPreviousPointerPos;
  105744. private _joystickPointerStartPos;
  105745. private _deltaJoystickVector;
  105746. private _leftJoystick;
  105747. private _touches;
  105748. private _onPointerDownHandlerRef;
  105749. private _onPointerMoveHandlerRef;
  105750. private _onPointerUpHandlerRef;
  105751. private _onResize;
  105752. /**
  105753. * Creates a new virtual joystick
  105754. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105755. */
  105756. constructor(leftJoystick?: boolean);
  105757. /**
  105758. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105759. * @param newJoystickSensibility defines the new sensibility
  105760. */
  105761. setJoystickSensibility(newJoystickSensibility: number): void;
  105762. private _onPointerDown;
  105763. private _onPointerMove;
  105764. private _onPointerUp;
  105765. /**
  105766. * Change the color of the virtual joystick
  105767. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105768. */
  105769. setJoystickColor(newColor: string): void;
  105770. /**
  105771. * Defines a callback to call when the joystick is touched
  105772. * @param action defines the callback
  105773. */
  105774. setActionOnTouch(action: () => any): void;
  105775. /**
  105776. * Defines which axis you'd like to control for left & right
  105777. * @param axis defines the axis to use
  105778. */
  105779. setAxisForLeftRight(axis: JoystickAxis): void;
  105780. /**
  105781. * Defines which axis you'd like to control for up & down
  105782. * @param axis defines the axis to use
  105783. */
  105784. setAxisForUpDown(axis: JoystickAxis): void;
  105785. private _drawVirtualJoystick;
  105786. /**
  105787. * Release internal HTML canvas
  105788. */
  105789. releaseCanvas(): void;
  105790. }
  105791. }
  105792. declare module BABYLON {
  105793. interface FreeCameraInputsManager {
  105794. /**
  105795. * Add virtual joystick input support to the input manager.
  105796. * @returns the current input manager
  105797. */
  105798. addVirtualJoystick(): FreeCameraInputsManager;
  105799. }
  105800. /**
  105801. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105803. */
  105804. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105805. /**
  105806. * Defines the camera the input is attached to.
  105807. */
  105808. camera: FreeCamera;
  105809. private _leftjoystick;
  105810. private _rightjoystick;
  105811. /**
  105812. * Gets the left stick of the virtual joystick.
  105813. * @returns The virtual Joystick
  105814. */
  105815. getLeftJoystick(): VirtualJoystick;
  105816. /**
  105817. * Gets the right stick of the virtual joystick.
  105818. * @returns The virtual Joystick
  105819. */
  105820. getRightJoystick(): VirtualJoystick;
  105821. /**
  105822. * Update the current camera state depending on the inputs that have been used this frame.
  105823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105824. */
  105825. checkInputs(): void;
  105826. /**
  105827. * Attach the input controls to a specific dom element to get the input from.
  105828. * @param element Defines the element the controls should be listened from
  105829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105830. */
  105831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105832. /**
  105833. * Detach the current controls from the specified dom element.
  105834. * @param element Defines the element to stop listening the inputs from
  105835. */
  105836. detachControl(element: Nullable<HTMLElement>): void;
  105837. /**
  105838. * Gets the class name of the current intput.
  105839. * @returns the class name
  105840. */
  105841. getClassName(): string;
  105842. /**
  105843. * Get the friendly name associated with the input class.
  105844. * @returns the input friendly name
  105845. */
  105846. getSimpleName(): string;
  105847. }
  105848. }
  105849. declare module BABYLON {
  105850. /**
  105851. * This represents a FPS type of camera controlled by touch.
  105852. * This is like a universal camera minus the Gamepad controls.
  105853. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105854. */
  105855. export class TouchCamera extends FreeCamera {
  105856. /**
  105857. * Defines the touch sensibility for rotation.
  105858. * The higher the faster.
  105859. */
  105860. touchAngularSensibility: number;
  105861. /**
  105862. * Defines the touch sensibility for move.
  105863. * The higher the faster.
  105864. */
  105865. touchMoveSensibility: number;
  105866. /**
  105867. * Instantiates a new touch camera.
  105868. * This represents a FPS type of camera controlled by touch.
  105869. * This is like a universal camera minus the Gamepad controls.
  105870. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105871. * @param name Define the name of the camera in the scene
  105872. * @param position Define the start position of the camera in the scene
  105873. * @param scene Define the scene the camera belongs to
  105874. */
  105875. constructor(name: string, position: Vector3, scene: Scene);
  105876. /**
  105877. * Gets the current object class name.
  105878. * @return the class name
  105879. */
  105880. getClassName(): string;
  105881. /** @hidden */
  105882. _setupInputs(): void;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105888. * being tilted forward or back and left or right.
  105889. */
  105890. export class DeviceOrientationCamera extends FreeCamera {
  105891. private _initialQuaternion;
  105892. private _quaternionCache;
  105893. private _tmpDragQuaternion;
  105894. private _disablePointerInputWhenUsingDeviceOrientation;
  105895. /**
  105896. * Creates a new device orientation camera
  105897. * @param name The name of the camera
  105898. * @param position The start position camera
  105899. * @param scene The scene the camera belongs to
  105900. */
  105901. constructor(name: string, position: Vector3, scene: Scene);
  105902. /**
  105903. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105904. */
  105905. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105906. private _dragFactor;
  105907. /**
  105908. * Enabled turning on the y axis when the orientation sensor is active
  105909. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105910. */
  105911. enableHorizontalDragging(dragFactor?: number): void;
  105912. /**
  105913. * Gets the current instance class name ("DeviceOrientationCamera").
  105914. * This helps avoiding instanceof at run time.
  105915. * @returns the class name
  105916. */
  105917. getClassName(): string;
  105918. /**
  105919. * @hidden
  105920. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105921. */
  105922. _checkInputs(): void;
  105923. /**
  105924. * Reset the camera to its default orientation on the specified axis only.
  105925. * @param axis The axis to reset
  105926. */
  105927. resetToCurrentRotation(axis?: Axis): void;
  105928. }
  105929. }
  105930. declare module BABYLON {
  105931. /**
  105932. * Defines supported buttons for XBox360 compatible gamepads
  105933. */
  105934. export enum Xbox360Button {
  105935. /** A */
  105936. A = 0,
  105937. /** B */
  105938. B = 1,
  105939. /** X */
  105940. X = 2,
  105941. /** Y */
  105942. Y = 3,
  105943. /** Start */
  105944. Start = 4,
  105945. /** Back */
  105946. Back = 5,
  105947. /** Left button */
  105948. LB = 6,
  105949. /** Right button */
  105950. RB = 7,
  105951. /** Left stick */
  105952. LeftStick = 8,
  105953. /** Right stick */
  105954. RightStick = 9
  105955. }
  105956. /** Defines values for XBox360 DPad */
  105957. export enum Xbox360Dpad {
  105958. /** Up */
  105959. Up = 0,
  105960. /** Down */
  105961. Down = 1,
  105962. /** Left */
  105963. Left = 2,
  105964. /** Right */
  105965. Right = 3
  105966. }
  105967. /**
  105968. * Defines a XBox360 gamepad
  105969. */
  105970. export class Xbox360Pad extends Gamepad {
  105971. private _leftTrigger;
  105972. private _rightTrigger;
  105973. private _onlefttriggerchanged;
  105974. private _onrighttriggerchanged;
  105975. private _onbuttondown;
  105976. private _onbuttonup;
  105977. private _ondpaddown;
  105978. private _ondpadup;
  105979. /** Observable raised when a button is pressed */
  105980. onButtonDownObservable: Observable<Xbox360Button>;
  105981. /** Observable raised when a button is released */
  105982. onButtonUpObservable: Observable<Xbox360Button>;
  105983. /** Observable raised when a pad is pressed */
  105984. onPadDownObservable: Observable<Xbox360Dpad>;
  105985. /** Observable raised when a pad is released */
  105986. onPadUpObservable: Observable<Xbox360Dpad>;
  105987. private _buttonA;
  105988. private _buttonB;
  105989. private _buttonX;
  105990. private _buttonY;
  105991. private _buttonBack;
  105992. private _buttonStart;
  105993. private _buttonLB;
  105994. private _buttonRB;
  105995. private _buttonLeftStick;
  105996. private _buttonRightStick;
  105997. private _dPadUp;
  105998. private _dPadDown;
  105999. private _dPadLeft;
  106000. private _dPadRight;
  106001. private _isXboxOnePad;
  106002. /**
  106003. * Creates a new XBox360 gamepad object
  106004. * @param id defines the id of this gamepad
  106005. * @param index defines its index
  106006. * @param gamepad defines the internal HTML gamepad object
  106007. * @param xboxOne defines if it is a XBox One gamepad
  106008. */
  106009. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106010. /**
  106011. * Defines the callback to call when left trigger is pressed
  106012. * @param callback defines the callback to use
  106013. */
  106014. onlefttriggerchanged(callback: (value: number) => void): void;
  106015. /**
  106016. * Defines the callback to call when right trigger is pressed
  106017. * @param callback defines the callback to use
  106018. */
  106019. onrighttriggerchanged(callback: (value: number) => void): void;
  106020. /**
  106021. * Gets the left trigger value
  106022. */
  106023. /**
  106024. * Sets the left trigger value
  106025. */
  106026. leftTrigger: number;
  106027. /**
  106028. * Gets the right trigger value
  106029. */
  106030. /**
  106031. * Sets the right trigger value
  106032. */
  106033. rightTrigger: number;
  106034. /**
  106035. * Defines the callback to call when a button is pressed
  106036. * @param callback defines the callback to use
  106037. */
  106038. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106039. /**
  106040. * Defines the callback to call when a button is released
  106041. * @param callback defines the callback to use
  106042. */
  106043. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106044. /**
  106045. * Defines the callback to call when a pad is pressed
  106046. * @param callback defines the callback to use
  106047. */
  106048. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106049. /**
  106050. * Defines the callback to call when a pad is released
  106051. * @param callback defines the callback to use
  106052. */
  106053. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106054. private _setButtonValue;
  106055. private _setDPadValue;
  106056. /**
  106057. * Gets the value of the `A` button
  106058. */
  106059. /**
  106060. * Sets the value of the `A` button
  106061. */
  106062. buttonA: number;
  106063. /**
  106064. * Gets the value of the `B` button
  106065. */
  106066. /**
  106067. * Sets the value of the `B` button
  106068. */
  106069. buttonB: number;
  106070. /**
  106071. * Gets the value of the `X` button
  106072. */
  106073. /**
  106074. * Sets the value of the `X` button
  106075. */
  106076. buttonX: number;
  106077. /**
  106078. * Gets the value of the `Y` button
  106079. */
  106080. /**
  106081. * Sets the value of the `Y` button
  106082. */
  106083. buttonY: number;
  106084. /**
  106085. * Gets the value of the `Start` button
  106086. */
  106087. /**
  106088. * Sets the value of the `Start` button
  106089. */
  106090. buttonStart: number;
  106091. /**
  106092. * Gets the value of the `Back` button
  106093. */
  106094. /**
  106095. * Sets the value of the `Back` button
  106096. */
  106097. buttonBack: number;
  106098. /**
  106099. * Gets the value of the `Left` button
  106100. */
  106101. /**
  106102. * Sets the value of the `Left` button
  106103. */
  106104. buttonLB: number;
  106105. /**
  106106. * Gets the value of the `Right` button
  106107. */
  106108. /**
  106109. * Sets the value of the `Right` button
  106110. */
  106111. buttonRB: number;
  106112. /**
  106113. * Gets the value of the Left joystick
  106114. */
  106115. /**
  106116. * Sets the value of the Left joystick
  106117. */
  106118. buttonLeftStick: number;
  106119. /**
  106120. * Gets the value of the Right joystick
  106121. */
  106122. /**
  106123. * Sets the value of the Right joystick
  106124. */
  106125. buttonRightStick: number;
  106126. /**
  106127. * Gets the value of D-pad up
  106128. */
  106129. /**
  106130. * Sets the value of D-pad up
  106131. */
  106132. dPadUp: number;
  106133. /**
  106134. * Gets the value of D-pad down
  106135. */
  106136. /**
  106137. * Sets the value of D-pad down
  106138. */
  106139. dPadDown: number;
  106140. /**
  106141. * Gets the value of D-pad left
  106142. */
  106143. /**
  106144. * Sets the value of D-pad left
  106145. */
  106146. dPadLeft: number;
  106147. /**
  106148. * Gets the value of D-pad right
  106149. */
  106150. /**
  106151. * Sets the value of D-pad right
  106152. */
  106153. dPadRight: number;
  106154. /**
  106155. * Force the gamepad to synchronize with device values
  106156. */
  106157. update(): void;
  106158. /**
  106159. * Disposes the gamepad
  106160. */
  106161. dispose(): void;
  106162. }
  106163. }
  106164. declare module BABYLON {
  106165. /**
  106166. * Defines supported buttons for DualShock compatible gamepads
  106167. */
  106168. export enum DualShockButton {
  106169. /** Cross */
  106170. Cross = 0,
  106171. /** Circle */
  106172. Circle = 1,
  106173. /** Square */
  106174. Square = 2,
  106175. /** Triangle */
  106176. Triangle = 3,
  106177. /** Options */
  106178. Options = 4,
  106179. /** Share */
  106180. Share = 5,
  106181. /** L1 */
  106182. L1 = 6,
  106183. /** R1 */
  106184. R1 = 7,
  106185. /** Left stick */
  106186. LeftStick = 8,
  106187. /** Right stick */
  106188. RightStick = 9
  106189. }
  106190. /** Defines values for DualShock DPad */
  106191. export enum DualShockDpad {
  106192. /** Up */
  106193. Up = 0,
  106194. /** Down */
  106195. Down = 1,
  106196. /** Left */
  106197. Left = 2,
  106198. /** Right */
  106199. Right = 3
  106200. }
  106201. /**
  106202. * Defines a DualShock gamepad
  106203. */
  106204. export class DualShockPad extends Gamepad {
  106205. private _leftTrigger;
  106206. private _rightTrigger;
  106207. private _onlefttriggerchanged;
  106208. private _onrighttriggerchanged;
  106209. private _onbuttondown;
  106210. private _onbuttonup;
  106211. private _ondpaddown;
  106212. private _ondpadup;
  106213. /** Observable raised when a button is pressed */
  106214. onButtonDownObservable: Observable<DualShockButton>;
  106215. /** Observable raised when a button is released */
  106216. onButtonUpObservable: Observable<DualShockButton>;
  106217. /** Observable raised when a pad is pressed */
  106218. onPadDownObservable: Observable<DualShockDpad>;
  106219. /** Observable raised when a pad is released */
  106220. onPadUpObservable: Observable<DualShockDpad>;
  106221. private _buttonCross;
  106222. private _buttonCircle;
  106223. private _buttonSquare;
  106224. private _buttonTriangle;
  106225. private _buttonShare;
  106226. private _buttonOptions;
  106227. private _buttonL1;
  106228. private _buttonR1;
  106229. private _buttonLeftStick;
  106230. private _buttonRightStick;
  106231. private _dPadUp;
  106232. private _dPadDown;
  106233. private _dPadLeft;
  106234. private _dPadRight;
  106235. /**
  106236. * Creates a new DualShock gamepad object
  106237. * @param id defines the id of this gamepad
  106238. * @param index defines its index
  106239. * @param gamepad defines the internal HTML gamepad object
  106240. */
  106241. constructor(id: string, index: number, gamepad: any);
  106242. /**
  106243. * Defines the callback to call when left trigger is pressed
  106244. * @param callback defines the callback to use
  106245. */
  106246. onlefttriggerchanged(callback: (value: number) => void): void;
  106247. /**
  106248. * Defines the callback to call when right trigger is pressed
  106249. * @param callback defines the callback to use
  106250. */
  106251. onrighttriggerchanged(callback: (value: number) => void): void;
  106252. /**
  106253. * Gets the left trigger value
  106254. */
  106255. /**
  106256. * Sets the left trigger value
  106257. */
  106258. leftTrigger: number;
  106259. /**
  106260. * Gets the right trigger value
  106261. */
  106262. /**
  106263. * Sets the right trigger value
  106264. */
  106265. rightTrigger: number;
  106266. /**
  106267. * Defines the callback to call when a button is pressed
  106268. * @param callback defines the callback to use
  106269. */
  106270. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106271. /**
  106272. * Defines the callback to call when a button is released
  106273. * @param callback defines the callback to use
  106274. */
  106275. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106276. /**
  106277. * Defines the callback to call when a pad is pressed
  106278. * @param callback defines the callback to use
  106279. */
  106280. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106281. /**
  106282. * Defines the callback to call when a pad is released
  106283. * @param callback defines the callback to use
  106284. */
  106285. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106286. private _setButtonValue;
  106287. private _setDPadValue;
  106288. /**
  106289. * Gets the value of the `Cross` button
  106290. */
  106291. /**
  106292. * Sets the value of the `Cross` button
  106293. */
  106294. buttonCross: number;
  106295. /**
  106296. * Gets the value of the `Circle` button
  106297. */
  106298. /**
  106299. * Sets the value of the `Circle` button
  106300. */
  106301. buttonCircle: number;
  106302. /**
  106303. * Gets the value of the `Square` button
  106304. */
  106305. /**
  106306. * Sets the value of the `Square` button
  106307. */
  106308. buttonSquare: number;
  106309. /**
  106310. * Gets the value of the `Triangle` button
  106311. */
  106312. /**
  106313. * Sets the value of the `Triangle` button
  106314. */
  106315. buttonTriangle: number;
  106316. /**
  106317. * Gets the value of the `Options` button
  106318. */
  106319. /**
  106320. * Sets the value of the `Options` button
  106321. */
  106322. buttonOptions: number;
  106323. /**
  106324. * Gets the value of the `Share` button
  106325. */
  106326. /**
  106327. * Sets the value of the `Share` button
  106328. */
  106329. buttonShare: number;
  106330. /**
  106331. * Gets the value of the `L1` button
  106332. */
  106333. /**
  106334. * Sets the value of the `L1` button
  106335. */
  106336. buttonL1: number;
  106337. /**
  106338. * Gets the value of the `R1` button
  106339. */
  106340. /**
  106341. * Sets the value of the `R1` button
  106342. */
  106343. buttonR1: number;
  106344. /**
  106345. * Gets the value of the Left joystick
  106346. */
  106347. /**
  106348. * Sets the value of the Left joystick
  106349. */
  106350. buttonLeftStick: number;
  106351. /**
  106352. * Gets the value of the Right joystick
  106353. */
  106354. /**
  106355. * Sets the value of the Right joystick
  106356. */
  106357. buttonRightStick: number;
  106358. /**
  106359. * Gets the value of D-pad up
  106360. */
  106361. /**
  106362. * Sets the value of D-pad up
  106363. */
  106364. dPadUp: number;
  106365. /**
  106366. * Gets the value of D-pad down
  106367. */
  106368. /**
  106369. * Sets the value of D-pad down
  106370. */
  106371. dPadDown: number;
  106372. /**
  106373. * Gets the value of D-pad left
  106374. */
  106375. /**
  106376. * Sets the value of D-pad left
  106377. */
  106378. dPadLeft: number;
  106379. /**
  106380. * Gets the value of D-pad right
  106381. */
  106382. /**
  106383. * Sets the value of D-pad right
  106384. */
  106385. dPadRight: number;
  106386. /**
  106387. * Force the gamepad to synchronize with device values
  106388. */
  106389. update(): void;
  106390. /**
  106391. * Disposes the gamepad
  106392. */
  106393. dispose(): void;
  106394. }
  106395. }
  106396. declare module BABYLON {
  106397. /**
  106398. * Manager for handling gamepads
  106399. */
  106400. export class GamepadManager {
  106401. private _scene?;
  106402. private _babylonGamepads;
  106403. private _oneGamepadConnected;
  106404. /** @hidden */
  106405. _isMonitoring: boolean;
  106406. private _gamepadEventSupported;
  106407. private _gamepadSupport;
  106408. /**
  106409. * observable to be triggered when the gamepad controller has been connected
  106410. */
  106411. onGamepadConnectedObservable: Observable<Gamepad>;
  106412. /**
  106413. * observable to be triggered when the gamepad controller has been disconnected
  106414. */
  106415. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106416. private _onGamepadConnectedEvent;
  106417. private _onGamepadDisconnectedEvent;
  106418. /**
  106419. * Initializes the gamepad manager
  106420. * @param _scene BabylonJS scene
  106421. */
  106422. constructor(_scene?: Scene | undefined);
  106423. /**
  106424. * The gamepads in the game pad manager
  106425. */
  106426. readonly gamepads: Gamepad[];
  106427. /**
  106428. * Get the gamepad controllers based on type
  106429. * @param type The type of gamepad controller
  106430. * @returns Nullable gamepad
  106431. */
  106432. getGamepadByType(type?: number): Nullable<Gamepad>;
  106433. /**
  106434. * Disposes the gamepad manager
  106435. */
  106436. dispose(): void;
  106437. private _addNewGamepad;
  106438. private _startMonitoringGamepads;
  106439. private _stopMonitoringGamepads;
  106440. /** @hidden */
  106441. _checkGamepadsStatus(): void;
  106442. private _updateGamepadObjects;
  106443. }
  106444. }
  106445. declare module BABYLON {
  106446. interface Scene {
  106447. /** @hidden */
  106448. _gamepadManager: Nullable<GamepadManager>;
  106449. /**
  106450. * Gets the gamepad manager associated with the scene
  106451. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106452. */
  106453. gamepadManager: GamepadManager;
  106454. }
  106455. /**
  106456. * Interface representing a free camera inputs manager
  106457. */
  106458. interface FreeCameraInputsManager {
  106459. /**
  106460. * Adds gamepad input support to the FreeCameraInputsManager.
  106461. * @returns the FreeCameraInputsManager
  106462. */
  106463. addGamepad(): FreeCameraInputsManager;
  106464. }
  106465. /**
  106466. * Interface representing an arc rotate camera inputs manager
  106467. */
  106468. interface ArcRotateCameraInputsManager {
  106469. /**
  106470. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106471. * @returns the camera inputs manager
  106472. */
  106473. addGamepad(): ArcRotateCameraInputsManager;
  106474. }
  106475. /**
  106476. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106477. */
  106478. export class GamepadSystemSceneComponent implements ISceneComponent {
  106479. /**
  106480. * The component name helpfull to identify the component in the list of scene components.
  106481. */
  106482. readonly name: string;
  106483. /**
  106484. * The scene the component belongs to.
  106485. */
  106486. scene: Scene;
  106487. /**
  106488. * Creates a new instance of the component for the given scene
  106489. * @param scene Defines the scene to register the component in
  106490. */
  106491. constructor(scene: Scene);
  106492. /**
  106493. * Registers the component in a given scene
  106494. */
  106495. register(): void;
  106496. /**
  106497. * Rebuilds the elements related to this component in case of
  106498. * context lost for instance.
  106499. */
  106500. rebuild(): void;
  106501. /**
  106502. * Disposes the component and the associated ressources
  106503. */
  106504. dispose(): void;
  106505. private _beforeCameraUpdate;
  106506. }
  106507. }
  106508. declare module BABYLON {
  106509. /**
  106510. * 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,
  106511. * which still works and will still be found in many Playgrounds.
  106512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106513. */
  106514. export class UniversalCamera extends TouchCamera {
  106515. /**
  106516. * Defines the gamepad rotation sensiblity.
  106517. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106518. */
  106519. gamepadAngularSensibility: number;
  106520. /**
  106521. * Defines the gamepad move sensiblity.
  106522. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106523. */
  106524. gamepadMoveSensibility: number;
  106525. /**
  106526. * 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,
  106527. * which still works and will still be found in many Playgrounds.
  106528. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106529. * @param name Define the name of the camera in the scene
  106530. * @param position Define the start position of the camera in the scene
  106531. * @param scene Define the scene the camera belongs to
  106532. */
  106533. constructor(name: string, position: Vector3, scene: Scene);
  106534. /**
  106535. * Gets the current object class name.
  106536. * @return the class name
  106537. */
  106538. getClassName(): string;
  106539. }
  106540. }
  106541. declare module BABYLON {
  106542. /**
  106543. * This represents a FPS type of camera. This is only here for back compat purpose.
  106544. * Please use the UniversalCamera instead as both are identical.
  106545. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106546. */
  106547. export class GamepadCamera extends UniversalCamera {
  106548. /**
  106549. * Instantiates a new Gamepad Camera
  106550. * This represents a FPS type of camera. This is only here for back compat purpose.
  106551. * Please use the UniversalCamera instead as both are identical.
  106552. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106553. * @param name Define the name of the camera in the scene
  106554. * @param position Define the start position of the camera in the scene
  106555. * @param scene Define the scene the camera belongs to
  106556. */
  106557. constructor(name: string, position: Vector3, scene: Scene);
  106558. /**
  106559. * Gets the current object class name.
  106560. * @return the class name
  106561. */
  106562. getClassName(): string;
  106563. }
  106564. }
  106565. declare module BABYLON {
  106566. /** @hidden */
  106567. export var passPixelShader: {
  106568. name: string;
  106569. shader: string;
  106570. };
  106571. }
  106572. declare module BABYLON {
  106573. /** @hidden */
  106574. export var passCubePixelShader: {
  106575. name: string;
  106576. shader: string;
  106577. };
  106578. }
  106579. declare module BABYLON {
  106580. /**
  106581. * PassPostProcess which produces an output the same as it's input
  106582. */
  106583. export class PassPostProcess extends PostProcess {
  106584. /**
  106585. * Creates the PassPostProcess
  106586. * @param name The name of the effect.
  106587. * @param options The required width/height ratio to downsize to before computing the render pass.
  106588. * @param camera The camera to apply the render pass to.
  106589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106590. * @param engine The engine which the post process will be applied. (default: current engine)
  106591. * @param reusable If the post process can be reused on the same frame. (default: false)
  106592. * @param textureType The type of texture to be used when performing the post processing.
  106593. * @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)
  106594. */
  106595. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106596. }
  106597. /**
  106598. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106599. */
  106600. export class PassCubePostProcess extends PostProcess {
  106601. private _face;
  106602. /**
  106603. * Gets or sets the cube face to display.
  106604. * * 0 is +X
  106605. * * 1 is -X
  106606. * * 2 is +Y
  106607. * * 3 is -Y
  106608. * * 4 is +Z
  106609. * * 5 is -Z
  106610. */
  106611. face: number;
  106612. /**
  106613. * Creates the PassCubePostProcess
  106614. * @param name The name of the effect.
  106615. * @param options The required width/height ratio to downsize to before computing the render pass.
  106616. * @param camera The camera to apply the render pass to.
  106617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106618. * @param engine The engine which the post process will be applied. (default: current engine)
  106619. * @param reusable If the post process can be reused on the same frame. (default: false)
  106620. * @param textureType The type of texture to be used when performing the post processing.
  106621. * @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)
  106622. */
  106623. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106624. }
  106625. }
  106626. declare module BABYLON {
  106627. /** @hidden */
  106628. export var anaglyphPixelShader: {
  106629. name: string;
  106630. shader: string;
  106631. };
  106632. }
  106633. declare module BABYLON {
  106634. /**
  106635. * Postprocess used to generate anaglyphic rendering
  106636. */
  106637. export class AnaglyphPostProcess extends PostProcess {
  106638. private _passedProcess;
  106639. /**
  106640. * Creates a new AnaglyphPostProcess
  106641. * @param name defines postprocess name
  106642. * @param options defines creation options or target ratio scale
  106643. * @param rigCameras defines cameras using this postprocess
  106644. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106645. * @param engine defines hosting engine
  106646. * @param reusable defines if the postprocess will be reused multiple times per frame
  106647. */
  106648. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106649. }
  106650. }
  106651. declare module BABYLON {
  106652. /**
  106653. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106654. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106655. */
  106656. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106657. /**
  106658. * Creates a new AnaglyphArcRotateCamera
  106659. * @param name defines camera name
  106660. * @param alpha defines alpha angle (in radians)
  106661. * @param beta defines beta angle (in radians)
  106662. * @param radius defines radius
  106663. * @param target defines camera target
  106664. * @param interaxialDistance defines distance between each color axis
  106665. * @param scene defines the hosting scene
  106666. */
  106667. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106668. /**
  106669. * Gets camera class name
  106670. * @returns AnaglyphArcRotateCamera
  106671. */
  106672. getClassName(): string;
  106673. }
  106674. }
  106675. declare module BABYLON {
  106676. /**
  106677. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106678. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106679. */
  106680. export class AnaglyphFreeCamera extends FreeCamera {
  106681. /**
  106682. * Creates a new AnaglyphFreeCamera
  106683. * @param name defines camera name
  106684. * @param position defines initial position
  106685. * @param interaxialDistance defines distance between each color axis
  106686. * @param scene defines the hosting scene
  106687. */
  106688. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106689. /**
  106690. * Gets camera class name
  106691. * @returns AnaglyphFreeCamera
  106692. */
  106693. getClassName(): string;
  106694. }
  106695. }
  106696. declare module BABYLON {
  106697. /**
  106698. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106699. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106700. */
  106701. export class AnaglyphGamepadCamera extends GamepadCamera {
  106702. /**
  106703. * Creates a new AnaglyphGamepadCamera
  106704. * @param name defines camera name
  106705. * @param position defines initial position
  106706. * @param interaxialDistance defines distance between each color axis
  106707. * @param scene defines the hosting scene
  106708. */
  106709. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106710. /**
  106711. * Gets camera class name
  106712. * @returns AnaglyphGamepadCamera
  106713. */
  106714. getClassName(): string;
  106715. }
  106716. }
  106717. declare module BABYLON {
  106718. /**
  106719. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106721. */
  106722. export class AnaglyphUniversalCamera extends UniversalCamera {
  106723. /**
  106724. * Creates a new AnaglyphUniversalCamera
  106725. * @param name defines camera name
  106726. * @param position defines initial position
  106727. * @param interaxialDistance defines distance between each color axis
  106728. * @param scene defines the hosting scene
  106729. */
  106730. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106731. /**
  106732. * Gets camera class name
  106733. * @returns AnaglyphUniversalCamera
  106734. */
  106735. getClassName(): string;
  106736. }
  106737. }
  106738. declare module BABYLON {
  106739. /** @hidden */
  106740. export var stereoscopicInterlacePixelShader: {
  106741. name: string;
  106742. shader: string;
  106743. };
  106744. }
  106745. declare module BABYLON {
  106746. /**
  106747. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106748. */
  106749. export class StereoscopicInterlacePostProcess extends PostProcess {
  106750. private _stepSize;
  106751. private _passedProcess;
  106752. /**
  106753. * Initializes a StereoscopicInterlacePostProcess
  106754. * @param name The name of the effect.
  106755. * @param rigCameras The rig cameras to be appled to the post process
  106756. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106758. * @param engine The engine which the post process will be applied. (default: current engine)
  106759. * @param reusable If the post process can be reused on the same frame. (default: false)
  106760. */
  106761. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106762. }
  106763. }
  106764. declare module BABYLON {
  106765. /**
  106766. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106767. * @see http://doc.babylonjs.com/features/cameras
  106768. */
  106769. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106770. /**
  106771. * Creates a new StereoscopicArcRotateCamera
  106772. * @param name defines camera name
  106773. * @param alpha defines alpha angle (in radians)
  106774. * @param beta defines beta angle (in radians)
  106775. * @param radius defines radius
  106776. * @param target defines camera target
  106777. * @param interaxialDistance defines distance between each color axis
  106778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106779. * @param scene defines the hosting scene
  106780. */
  106781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106782. /**
  106783. * Gets camera class name
  106784. * @returns StereoscopicArcRotateCamera
  106785. */
  106786. getClassName(): string;
  106787. }
  106788. }
  106789. declare module BABYLON {
  106790. /**
  106791. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106792. * @see http://doc.babylonjs.com/features/cameras
  106793. */
  106794. export class StereoscopicFreeCamera extends FreeCamera {
  106795. /**
  106796. * Creates a new StereoscopicFreeCamera
  106797. * @param name defines camera name
  106798. * @param position defines initial position
  106799. * @param interaxialDistance defines distance between each color axis
  106800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106801. * @param scene defines the hosting scene
  106802. */
  106803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106804. /**
  106805. * Gets camera class name
  106806. * @returns StereoscopicFreeCamera
  106807. */
  106808. getClassName(): string;
  106809. }
  106810. }
  106811. declare module BABYLON {
  106812. /**
  106813. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106814. * @see http://doc.babylonjs.com/features/cameras
  106815. */
  106816. export class StereoscopicGamepadCamera extends GamepadCamera {
  106817. /**
  106818. * Creates a new StereoscopicGamepadCamera
  106819. * @param name defines camera name
  106820. * @param position defines initial position
  106821. * @param interaxialDistance defines distance between each color axis
  106822. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106823. * @param scene defines the hosting scene
  106824. */
  106825. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106826. /**
  106827. * Gets camera class name
  106828. * @returns StereoscopicGamepadCamera
  106829. */
  106830. getClassName(): string;
  106831. }
  106832. }
  106833. declare module BABYLON {
  106834. /**
  106835. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106836. * @see http://doc.babylonjs.com/features/cameras
  106837. */
  106838. export class StereoscopicUniversalCamera extends UniversalCamera {
  106839. /**
  106840. * Creates a new StereoscopicUniversalCamera
  106841. * @param name defines camera name
  106842. * @param position defines initial position
  106843. * @param interaxialDistance defines distance between each color axis
  106844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106845. * @param scene defines the hosting scene
  106846. */
  106847. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106848. /**
  106849. * Gets camera class name
  106850. * @returns StereoscopicUniversalCamera
  106851. */
  106852. getClassName(): string;
  106853. }
  106854. }
  106855. declare module BABYLON {
  106856. /**
  106857. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106858. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106859. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106860. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106861. */
  106862. export class VirtualJoysticksCamera extends FreeCamera {
  106863. /**
  106864. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106865. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106866. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106867. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106868. * @param name Define the name of the camera in the scene
  106869. * @param position Define the start position of the camera in the scene
  106870. * @param scene Define the scene the camera belongs to
  106871. */
  106872. constructor(name: string, position: Vector3, scene: Scene);
  106873. /**
  106874. * Gets the current object class name.
  106875. * @return the class name
  106876. */
  106877. getClassName(): string;
  106878. }
  106879. }
  106880. declare module BABYLON {
  106881. /**
  106882. * This represents all the required metrics to create a VR camera.
  106883. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106884. */
  106885. export class VRCameraMetrics {
  106886. /**
  106887. * Define the horizontal resolution off the screen.
  106888. */
  106889. hResolution: number;
  106890. /**
  106891. * Define the vertical resolution off the screen.
  106892. */
  106893. vResolution: number;
  106894. /**
  106895. * Define the horizontal screen size.
  106896. */
  106897. hScreenSize: number;
  106898. /**
  106899. * Define the vertical screen size.
  106900. */
  106901. vScreenSize: number;
  106902. /**
  106903. * Define the vertical screen center position.
  106904. */
  106905. vScreenCenter: number;
  106906. /**
  106907. * Define the distance of the eyes to the screen.
  106908. */
  106909. eyeToScreenDistance: number;
  106910. /**
  106911. * Define the distance between both lenses
  106912. */
  106913. lensSeparationDistance: number;
  106914. /**
  106915. * Define the distance between both viewer's eyes.
  106916. */
  106917. interpupillaryDistance: number;
  106918. /**
  106919. * Define the distortion factor of the VR postprocess.
  106920. * Please, touch with care.
  106921. */
  106922. distortionK: number[];
  106923. /**
  106924. * Define the chromatic aberration correction factors for the VR post process.
  106925. */
  106926. chromaAbCorrection: number[];
  106927. /**
  106928. * Define the scale factor of the post process.
  106929. * The smaller the better but the slower.
  106930. */
  106931. postProcessScaleFactor: number;
  106932. /**
  106933. * Define an offset for the lens center.
  106934. */
  106935. lensCenterOffset: number;
  106936. /**
  106937. * Define if the current vr camera should compensate the distortion of the lense or not.
  106938. */
  106939. compensateDistortion: boolean;
  106940. /**
  106941. * Defines if multiview should be enabled when rendering (Default: false)
  106942. */
  106943. multiviewEnabled: boolean;
  106944. /**
  106945. * Gets the rendering aspect ratio based on the provided resolutions.
  106946. */
  106947. readonly aspectRatio: number;
  106948. /**
  106949. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106950. */
  106951. readonly aspectRatioFov: number;
  106952. /**
  106953. * @hidden
  106954. */
  106955. readonly leftHMatrix: Matrix;
  106956. /**
  106957. * @hidden
  106958. */
  106959. readonly rightHMatrix: Matrix;
  106960. /**
  106961. * @hidden
  106962. */
  106963. readonly leftPreViewMatrix: Matrix;
  106964. /**
  106965. * @hidden
  106966. */
  106967. readonly rightPreViewMatrix: Matrix;
  106968. /**
  106969. * Get the default VRMetrics based on the most generic setup.
  106970. * @returns the default vr metrics
  106971. */
  106972. static GetDefault(): VRCameraMetrics;
  106973. }
  106974. }
  106975. declare module BABYLON {
  106976. /** @hidden */
  106977. export var vrDistortionCorrectionPixelShader: {
  106978. name: string;
  106979. shader: string;
  106980. };
  106981. }
  106982. declare module BABYLON {
  106983. /**
  106984. * VRDistortionCorrectionPostProcess used for mobile VR
  106985. */
  106986. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106987. private _isRightEye;
  106988. private _distortionFactors;
  106989. private _postProcessScaleFactor;
  106990. private _lensCenterOffset;
  106991. private _scaleIn;
  106992. private _scaleFactor;
  106993. private _lensCenter;
  106994. /**
  106995. * Initializes the VRDistortionCorrectionPostProcess
  106996. * @param name The name of the effect.
  106997. * @param camera The camera to apply the render pass to.
  106998. * @param isRightEye If this is for the right eye distortion
  106999. * @param vrMetrics All the required metrics for the VR camera
  107000. */
  107001. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107002. }
  107003. }
  107004. declare module BABYLON {
  107005. /**
  107006. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107008. */
  107009. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107010. /**
  107011. * Creates a new VRDeviceOrientationArcRotateCamera
  107012. * @param name defines camera name
  107013. * @param alpha defines the camera rotation along the logitudinal axis
  107014. * @param beta defines the camera rotation along the latitudinal axis
  107015. * @param radius defines the camera distance from its target
  107016. * @param target defines the camera target
  107017. * @param scene defines the scene the camera belongs to
  107018. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107019. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107020. */
  107021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107022. /**
  107023. * Gets camera class name
  107024. * @returns VRDeviceOrientationArcRotateCamera
  107025. */
  107026. getClassName(): string;
  107027. }
  107028. }
  107029. declare module BABYLON {
  107030. /**
  107031. * Camera used to simulate VR rendering (based on FreeCamera)
  107032. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107033. */
  107034. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107035. /**
  107036. * Creates a new VRDeviceOrientationFreeCamera
  107037. * @param name defines camera name
  107038. * @param position defines the start position of the camera
  107039. * @param scene defines the scene the camera belongs to
  107040. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107041. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107042. */
  107043. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107044. /**
  107045. * Gets camera class name
  107046. * @returns VRDeviceOrientationFreeCamera
  107047. */
  107048. getClassName(): string;
  107049. }
  107050. }
  107051. declare module BABYLON {
  107052. /**
  107053. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107054. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107055. */
  107056. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107057. /**
  107058. * Creates a new VRDeviceOrientationGamepadCamera
  107059. * @param name defines camera name
  107060. * @param position defines the start position of the camera
  107061. * @param scene defines the scene the camera belongs to
  107062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107064. */
  107065. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107066. /**
  107067. * Gets camera class name
  107068. * @returns VRDeviceOrientationGamepadCamera
  107069. */
  107070. getClassName(): string;
  107071. }
  107072. }
  107073. declare module BABYLON {
  107074. /**
  107075. * Base class of materials working in push mode in babylon JS
  107076. * @hidden
  107077. */
  107078. export class PushMaterial extends Material {
  107079. protected _activeEffect: Effect;
  107080. protected _normalMatrix: Matrix;
  107081. /**
  107082. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107083. * This means that the material can keep using a previous shader while a new one is being compiled.
  107084. * This is mostly used when shader parallel compilation is supported (true by default)
  107085. */
  107086. allowShaderHotSwapping: boolean;
  107087. constructor(name: string, scene: Scene);
  107088. getEffect(): Effect;
  107089. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107090. /**
  107091. * Binds the given world matrix to the active effect
  107092. *
  107093. * @param world the matrix to bind
  107094. */
  107095. bindOnlyWorldMatrix(world: Matrix): void;
  107096. /**
  107097. * Binds the given normal matrix to the active effect
  107098. *
  107099. * @param normalMatrix the matrix to bind
  107100. */
  107101. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107102. bind(world: Matrix, mesh?: Mesh): void;
  107103. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107104. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * This groups all the flags used to control the materials channel.
  107110. */
  107111. export class MaterialFlags {
  107112. private static _DiffuseTextureEnabled;
  107113. /**
  107114. * Are diffuse textures enabled in the application.
  107115. */
  107116. static DiffuseTextureEnabled: boolean;
  107117. private static _AmbientTextureEnabled;
  107118. /**
  107119. * Are ambient textures enabled in the application.
  107120. */
  107121. static AmbientTextureEnabled: boolean;
  107122. private static _OpacityTextureEnabled;
  107123. /**
  107124. * Are opacity textures enabled in the application.
  107125. */
  107126. static OpacityTextureEnabled: boolean;
  107127. private static _ReflectionTextureEnabled;
  107128. /**
  107129. * Are reflection textures enabled in the application.
  107130. */
  107131. static ReflectionTextureEnabled: boolean;
  107132. private static _EmissiveTextureEnabled;
  107133. /**
  107134. * Are emissive textures enabled in the application.
  107135. */
  107136. static EmissiveTextureEnabled: boolean;
  107137. private static _SpecularTextureEnabled;
  107138. /**
  107139. * Are specular textures enabled in the application.
  107140. */
  107141. static SpecularTextureEnabled: boolean;
  107142. private static _BumpTextureEnabled;
  107143. /**
  107144. * Are bump textures enabled in the application.
  107145. */
  107146. static BumpTextureEnabled: boolean;
  107147. private static _LightmapTextureEnabled;
  107148. /**
  107149. * Are lightmap textures enabled in the application.
  107150. */
  107151. static LightmapTextureEnabled: boolean;
  107152. private static _RefractionTextureEnabled;
  107153. /**
  107154. * Are refraction textures enabled in the application.
  107155. */
  107156. static RefractionTextureEnabled: boolean;
  107157. private static _ColorGradingTextureEnabled;
  107158. /**
  107159. * Are color grading textures enabled in the application.
  107160. */
  107161. static ColorGradingTextureEnabled: boolean;
  107162. private static _FresnelEnabled;
  107163. /**
  107164. * Are fresnels enabled in the application.
  107165. */
  107166. static FresnelEnabled: boolean;
  107167. private static _ClearCoatTextureEnabled;
  107168. /**
  107169. * Are clear coat textures enabled in the application.
  107170. */
  107171. static ClearCoatTextureEnabled: boolean;
  107172. private static _ClearCoatBumpTextureEnabled;
  107173. /**
  107174. * Are clear coat bump textures enabled in the application.
  107175. */
  107176. static ClearCoatBumpTextureEnabled: boolean;
  107177. private static _ClearCoatTintTextureEnabled;
  107178. /**
  107179. * Are clear coat tint textures enabled in the application.
  107180. */
  107181. static ClearCoatTintTextureEnabled: boolean;
  107182. private static _SheenTextureEnabled;
  107183. /**
  107184. * Are sheen textures enabled in the application.
  107185. */
  107186. static SheenTextureEnabled: boolean;
  107187. private static _AnisotropicTextureEnabled;
  107188. /**
  107189. * Are anisotropic textures enabled in the application.
  107190. */
  107191. static AnisotropicTextureEnabled: boolean;
  107192. private static _ThicknessTextureEnabled;
  107193. /**
  107194. * Are thickness textures enabled in the application.
  107195. */
  107196. static ThicknessTextureEnabled: boolean;
  107197. }
  107198. }
  107199. declare module BABYLON {
  107200. /** @hidden */
  107201. export var defaultFragmentDeclaration: {
  107202. name: string;
  107203. shader: string;
  107204. };
  107205. }
  107206. declare module BABYLON {
  107207. /** @hidden */
  107208. export var defaultUboDeclaration: {
  107209. name: string;
  107210. shader: string;
  107211. };
  107212. }
  107213. declare module BABYLON {
  107214. /** @hidden */
  107215. export var lightFragmentDeclaration: {
  107216. name: string;
  107217. shader: string;
  107218. };
  107219. }
  107220. declare module BABYLON {
  107221. /** @hidden */
  107222. export var lightUboDeclaration: {
  107223. name: string;
  107224. shader: string;
  107225. };
  107226. }
  107227. declare module BABYLON {
  107228. /** @hidden */
  107229. export var lightsFragmentFunctions: {
  107230. name: string;
  107231. shader: string;
  107232. };
  107233. }
  107234. declare module BABYLON {
  107235. /** @hidden */
  107236. export var shadowsFragmentFunctions: {
  107237. name: string;
  107238. shader: string;
  107239. };
  107240. }
  107241. declare module BABYLON {
  107242. /** @hidden */
  107243. export var fresnelFunction: {
  107244. name: string;
  107245. shader: string;
  107246. };
  107247. }
  107248. declare module BABYLON {
  107249. /** @hidden */
  107250. export var reflectionFunction: {
  107251. name: string;
  107252. shader: string;
  107253. };
  107254. }
  107255. declare module BABYLON {
  107256. /** @hidden */
  107257. export var bumpFragmentFunctions: {
  107258. name: string;
  107259. shader: string;
  107260. };
  107261. }
  107262. declare module BABYLON {
  107263. /** @hidden */
  107264. export var logDepthDeclaration: {
  107265. name: string;
  107266. shader: string;
  107267. };
  107268. }
  107269. declare module BABYLON {
  107270. /** @hidden */
  107271. export var bumpFragment: {
  107272. name: string;
  107273. shader: string;
  107274. };
  107275. }
  107276. declare module BABYLON {
  107277. /** @hidden */
  107278. export var depthPrePass: {
  107279. name: string;
  107280. shader: string;
  107281. };
  107282. }
  107283. declare module BABYLON {
  107284. /** @hidden */
  107285. export var lightFragment: {
  107286. name: string;
  107287. shader: string;
  107288. };
  107289. }
  107290. declare module BABYLON {
  107291. /** @hidden */
  107292. export var logDepthFragment: {
  107293. name: string;
  107294. shader: string;
  107295. };
  107296. }
  107297. declare module BABYLON {
  107298. /** @hidden */
  107299. export var defaultPixelShader: {
  107300. name: string;
  107301. shader: string;
  107302. };
  107303. }
  107304. declare module BABYLON {
  107305. /** @hidden */
  107306. export var defaultVertexDeclaration: {
  107307. name: string;
  107308. shader: string;
  107309. };
  107310. }
  107311. declare module BABYLON {
  107312. /** @hidden */
  107313. export var bumpVertexDeclaration: {
  107314. name: string;
  107315. shader: string;
  107316. };
  107317. }
  107318. declare module BABYLON {
  107319. /** @hidden */
  107320. export var bumpVertex: {
  107321. name: string;
  107322. shader: string;
  107323. };
  107324. }
  107325. declare module BABYLON {
  107326. /** @hidden */
  107327. export var fogVertex: {
  107328. name: string;
  107329. shader: string;
  107330. };
  107331. }
  107332. declare module BABYLON {
  107333. /** @hidden */
  107334. export var shadowsVertex: {
  107335. name: string;
  107336. shader: string;
  107337. };
  107338. }
  107339. declare module BABYLON {
  107340. /** @hidden */
  107341. export var pointCloudVertex: {
  107342. name: string;
  107343. shader: string;
  107344. };
  107345. }
  107346. declare module BABYLON {
  107347. /** @hidden */
  107348. export var logDepthVertex: {
  107349. name: string;
  107350. shader: string;
  107351. };
  107352. }
  107353. declare module BABYLON {
  107354. /** @hidden */
  107355. export var defaultVertexShader: {
  107356. name: string;
  107357. shader: string;
  107358. };
  107359. }
  107360. declare module BABYLON {
  107361. /** @hidden */
  107362. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107363. MAINUV1: boolean;
  107364. MAINUV2: boolean;
  107365. DIFFUSE: boolean;
  107366. DIFFUSEDIRECTUV: number;
  107367. AMBIENT: boolean;
  107368. AMBIENTDIRECTUV: number;
  107369. OPACITY: boolean;
  107370. OPACITYDIRECTUV: number;
  107371. OPACITYRGB: boolean;
  107372. REFLECTION: boolean;
  107373. EMISSIVE: boolean;
  107374. EMISSIVEDIRECTUV: number;
  107375. SPECULAR: boolean;
  107376. SPECULARDIRECTUV: number;
  107377. BUMP: boolean;
  107378. BUMPDIRECTUV: number;
  107379. PARALLAX: boolean;
  107380. PARALLAXOCCLUSION: boolean;
  107381. SPECULAROVERALPHA: boolean;
  107382. CLIPPLANE: boolean;
  107383. CLIPPLANE2: boolean;
  107384. CLIPPLANE3: boolean;
  107385. CLIPPLANE4: boolean;
  107386. ALPHATEST: boolean;
  107387. DEPTHPREPASS: boolean;
  107388. ALPHAFROMDIFFUSE: boolean;
  107389. POINTSIZE: boolean;
  107390. FOG: boolean;
  107391. SPECULARTERM: boolean;
  107392. DIFFUSEFRESNEL: boolean;
  107393. OPACITYFRESNEL: boolean;
  107394. REFLECTIONFRESNEL: boolean;
  107395. REFRACTIONFRESNEL: boolean;
  107396. EMISSIVEFRESNEL: boolean;
  107397. FRESNEL: boolean;
  107398. NORMAL: boolean;
  107399. UV1: boolean;
  107400. UV2: boolean;
  107401. VERTEXCOLOR: boolean;
  107402. VERTEXALPHA: boolean;
  107403. NUM_BONE_INFLUENCERS: number;
  107404. BonesPerMesh: number;
  107405. BONETEXTURE: boolean;
  107406. INSTANCES: boolean;
  107407. GLOSSINESS: boolean;
  107408. ROUGHNESS: boolean;
  107409. EMISSIVEASILLUMINATION: boolean;
  107410. LINKEMISSIVEWITHDIFFUSE: boolean;
  107411. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107412. LIGHTMAP: boolean;
  107413. LIGHTMAPDIRECTUV: number;
  107414. OBJECTSPACE_NORMALMAP: boolean;
  107415. USELIGHTMAPASSHADOWMAP: boolean;
  107416. REFLECTIONMAP_3D: boolean;
  107417. REFLECTIONMAP_SPHERICAL: boolean;
  107418. REFLECTIONMAP_PLANAR: boolean;
  107419. REFLECTIONMAP_CUBIC: boolean;
  107420. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107421. REFLECTIONMAP_PROJECTION: boolean;
  107422. REFLECTIONMAP_SKYBOX: boolean;
  107423. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107424. REFLECTIONMAP_EXPLICIT: boolean;
  107425. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107426. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107427. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107428. INVERTCUBICMAP: boolean;
  107429. LOGARITHMICDEPTH: boolean;
  107430. REFRACTION: boolean;
  107431. REFRACTIONMAP_3D: boolean;
  107432. REFLECTIONOVERALPHA: boolean;
  107433. TWOSIDEDLIGHTING: boolean;
  107434. SHADOWFLOAT: boolean;
  107435. MORPHTARGETS: boolean;
  107436. MORPHTARGETS_NORMAL: boolean;
  107437. MORPHTARGETS_TANGENT: boolean;
  107438. MORPHTARGETS_UV: boolean;
  107439. NUM_MORPH_INFLUENCERS: number;
  107440. NONUNIFORMSCALING: boolean;
  107441. PREMULTIPLYALPHA: boolean;
  107442. IMAGEPROCESSING: boolean;
  107443. VIGNETTE: boolean;
  107444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107445. VIGNETTEBLENDMODEOPAQUE: boolean;
  107446. TONEMAPPING: boolean;
  107447. TONEMAPPING_ACES: boolean;
  107448. CONTRAST: boolean;
  107449. COLORCURVES: boolean;
  107450. COLORGRADING: boolean;
  107451. COLORGRADING3D: boolean;
  107452. SAMPLER3DGREENDEPTH: boolean;
  107453. SAMPLER3DBGRMAP: boolean;
  107454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107455. MULTIVIEW: boolean;
  107456. /**
  107457. * If the reflection texture on this material is in linear color space
  107458. * @hidden
  107459. */
  107460. IS_REFLECTION_LINEAR: boolean;
  107461. /**
  107462. * If the refraction texture on this material is in linear color space
  107463. * @hidden
  107464. */
  107465. IS_REFRACTION_LINEAR: boolean;
  107466. EXPOSURE: boolean;
  107467. constructor();
  107468. setReflectionMode(modeToEnable: string): void;
  107469. }
  107470. /**
  107471. * This is the default material used in Babylon. It is the best trade off between quality
  107472. * and performances.
  107473. * @see http://doc.babylonjs.com/babylon101/materials
  107474. */
  107475. export class StandardMaterial extends PushMaterial {
  107476. private _diffuseTexture;
  107477. /**
  107478. * The basic texture of the material as viewed under a light.
  107479. */
  107480. diffuseTexture: Nullable<BaseTexture>;
  107481. private _ambientTexture;
  107482. /**
  107483. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107484. */
  107485. ambientTexture: Nullable<BaseTexture>;
  107486. private _opacityTexture;
  107487. /**
  107488. * Define the transparency of the material from a texture.
  107489. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107490. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107491. */
  107492. opacityTexture: Nullable<BaseTexture>;
  107493. private _reflectionTexture;
  107494. /**
  107495. * Define the texture used to display the reflection.
  107496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107497. */
  107498. reflectionTexture: Nullable<BaseTexture>;
  107499. private _emissiveTexture;
  107500. /**
  107501. * Define texture of the material as if self lit.
  107502. * This will be mixed in the final result even in the absence of light.
  107503. */
  107504. emissiveTexture: Nullable<BaseTexture>;
  107505. private _specularTexture;
  107506. /**
  107507. * Define how the color and intensity of the highlight given by the light in the material.
  107508. */
  107509. specularTexture: Nullable<BaseTexture>;
  107510. private _bumpTexture;
  107511. /**
  107512. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107513. * 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.
  107514. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107515. */
  107516. bumpTexture: Nullable<BaseTexture>;
  107517. private _lightmapTexture;
  107518. /**
  107519. * Complex lighting can be computationally expensive to compute at runtime.
  107520. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107521. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107522. */
  107523. lightmapTexture: Nullable<BaseTexture>;
  107524. private _refractionTexture;
  107525. /**
  107526. * Define the texture used to display the refraction.
  107527. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107528. */
  107529. refractionTexture: Nullable<BaseTexture>;
  107530. /**
  107531. * The color of the material lit by the environmental background lighting.
  107532. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107533. */
  107534. ambientColor: Color3;
  107535. /**
  107536. * The basic color of the material as viewed under a light.
  107537. */
  107538. diffuseColor: Color3;
  107539. /**
  107540. * Define how the color and intensity of the highlight given by the light in the material.
  107541. */
  107542. specularColor: Color3;
  107543. /**
  107544. * Define the color of the material as if self lit.
  107545. * This will be mixed in the final result even in the absence of light.
  107546. */
  107547. emissiveColor: Color3;
  107548. /**
  107549. * Defines how sharp are the highlights in the material.
  107550. * The bigger the value the sharper giving a more glossy feeling to the result.
  107551. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107552. */
  107553. specularPower: number;
  107554. private _useAlphaFromDiffuseTexture;
  107555. /**
  107556. * Does the transparency come from the diffuse texture alpha channel.
  107557. */
  107558. useAlphaFromDiffuseTexture: boolean;
  107559. private _useEmissiveAsIllumination;
  107560. /**
  107561. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107562. */
  107563. useEmissiveAsIllumination: boolean;
  107564. private _linkEmissiveWithDiffuse;
  107565. /**
  107566. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107567. * the emissive level when the final color is close to one.
  107568. */
  107569. linkEmissiveWithDiffuse: boolean;
  107570. private _useSpecularOverAlpha;
  107571. /**
  107572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107574. */
  107575. useSpecularOverAlpha: boolean;
  107576. private _useReflectionOverAlpha;
  107577. /**
  107578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107580. */
  107581. useReflectionOverAlpha: boolean;
  107582. private _disableLighting;
  107583. /**
  107584. * Does lights from the scene impacts this material.
  107585. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107586. */
  107587. disableLighting: boolean;
  107588. private _useObjectSpaceNormalMap;
  107589. /**
  107590. * Allows using an object space normal map (instead of tangent space).
  107591. */
  107592. useObjectSpaceNormalMap: boolean;
  107593. private _useParallax;
  107594. /**
  107595. * Is parallax enabled or not.
  107596. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107597. */
  107598. useParallax: boolean;
  107599. private _useParallaxOcclusion;
  107600. /**
  107601. * Is parallax occlusion enabled or not.
  107602. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107603. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107604. */
  107605. useParallaxOcclusion: boolean;
  107606. /**
  107607. * 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.
  107608. */
  107609. parallaxScaleBias: number;
  107610. private _roughness;
  107611. /**
  107612. * Helps to define how blurry the reflections should appears in the material.
  107613. */
  107614. roughness: number;
  107615. /**
  107616. * In case of refraction, define the value of the index of refraction.
  107617. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107618. */
  107619. indexOfRefraction: number;
  107620. /**
  107621. * Invert the refraction texture alongside the y axis.
  107622. * It can be useful with procedural textures or probe for instance.
  107623. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107624. */
  107625. invertRefractionY: boolean;
  107626. /**
  107627. * Defines the alpha limits in alpha test mode.
  107628. */
  107629. alphaCutOff: number;
  107630. private _useLightmapAsShadowmap;
  107631. /**
  107632. * In case of light mapping, define whether the map contains light or shadow informations.
  107633. */
  107634. useLightmapAsShadowmap: boolean;
  107635. private _diffuseFresnelParameters;
  107636. /**
  107637. * Define the diffuse fresnel parameters of the material.
  107638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107639. */
  107640. diffuseFresnelParameters: FresnelParameters;
  107641. private _opacityFresnelParameters;
  107642. /**
  107643. * Define the opacity fresnel parameters of the material.
  107644. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107645. */
  107646. opacityFresnelParameters: FresnelParameters;
  107647. private _reflectionFresnelParameters;
  107648. /**
  107649. * Define the reflection fresnel parameters of the material.
  107650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107651. */
  107652. reflectionFresnelParameters: FresnelParameters;
  107653. private _refractionFresnelParameters;
  107654. /**
  107655. * Define the refraction fresnel parameters of the material.
  107656. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107657. */
  107658. refractionFresnelParameters: FresnelParameters;
  107659. private _emissiveFresnelParameters;
  107660. /**
  107661. * Define the emissive fresnel parameters of the material.
  107662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107663. */
  107664. emissiveFresnelParameters: FresnelParameters;
  107665. private _useReflectionFresnelFromSpecular;
  107666. /**
  107667. * If true automatically deducts the fresnels values from the material specularity.
  107668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107669. */
  107670. useReflectionFresnelFromSpecular: boolean;
  107671. private _useGlossinessFromSpecularMapAlpha;
  107672. /**
  107673. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107674. */
  107675. useGlossinessFromSpecularMapAlpha: boolean;
  107676. private _maxSimultaneousLights;
  107677. /**
  107678. * Defines the maximum number of lights that can be used in the material
  107679. */
  107680. maxSimultaneousLights: number;
  107681. private _invertNormalMapX;
  107682. /**
  107683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107684. */
  107685. invertNormalMapX: boolean;
  107686. private _invertNormalMapY;
  107687. /**
  107688. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107689. */
  107690. invertNormalMapY: boolean;
  107691. private _twoSidedLighting;
  107692. /**
  107693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107694. */
  107695. twoSidedLighting: boolean;
  107696. /**
  107697. * Default configuration related to image processing available in the standard Material.
  107698. */
  107699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107700. /**
  107701. * Gets the image processing configuration used either in this material.
  107702. */
  107703. /**
  107704. * Sets the Default image processing configuration used either in the this material.
  107705. *
  107706. * If sets to null, the scene one is in use.
  107707. */
  107708. imageProcessingConfiguration: ImageProcessingConfiguration;
  107709. /**
  107710. * Keep track of the image processing observer to allow dispose and replace.
  107711. */
  107712. private _imageProcessingObserver;
  107713. /**
  107714. * Attaches a new image processing configuration to the Standard Material.
  107715. * @param configuration
  107716. */
  107717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107718. /**
  107719. * Gets wether the color curves effect is enabled.
  107720. */
  107721. /**
  107722. * Sets wether the color curves effect is enabled.
  107723. */
  107724. cameraColorCurvesEnabled: boolean;
  107725. /**
  107726. * Gets wether the color grading effect is enabled.
  107727. */
  107728. /**
  107729. * Gets wether the color grading effect is enabled.
  107730. */
  107731. cameraColorGradingEnabled: boolean;
  107732. /**
  107733. * Gets wether tonemapping is enabled or not.
  107734. */
  107735. /**
  107736. * Sets wether tonemapping is enabled or not
  107737. */
  107738. cameraToneMappingEnabled: boolean;
  107739. /**
  107740. * The camera exposure used on this material.
  107741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107742. * This corresponds to a photographic exposure.
  107743. */
  107744. /**
  107745. * The camera exposure used on this material.
  107746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107747. * This corresponds to a photographic exposure.
  107748. */
  107749. cameraExposure: number;
  107750. /**
  107751. * Gets The camera contrast used on this material.
  107752. */
  107753. /**
  107754. * Sets The camera contrast used on this material.
  107755. */
  107756. cameraContrast: number;
  107757. /**
  107758. * Gets the Color Grading 2D Lookup Texture.
  107759. */
  107760. /**
  107761. * Sets the Color Grading 2D Lookup Texture.
  107762. */
  107763. cameraColorGradingTexture: Nullable<BaseTexture>;
  107764. /**
  107765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107767. * 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;
  107768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107769. */
  107770. /**
  107771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107773. * 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;
  107774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107775. */
  107776. cameraColorCurves: Nullable<ColorCurves>;
  107777. /**
  107778. * Custom callback helping to override the default shader used in the material.
  107779. */
  107780. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107781. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107782. protected _worldViewProjectionMatrix: Matrix;
  107783. protected _globalAmbientColor: Color3;
  107784. protected _useLogarithmicDepth: boolean;
  107785. protected _rebuildInParallel: boolean;
  107786. /**
  107787. * Instantiates a new standard material.
  107788. * This is the default material used in Babylon. It is the best trade off between quality
  107789. * and performances.
  107790. * @see http://doc.babylonjs.com/babylon101/materials
  107791. * @param name Define the name of the material in the scene
  107792. * @param scene Define the scene the material belong to
  107793. */
  107794. constructor(name: string, scene: Scene);
  107795. /**
  107796. * Gets a boolean indicating that current material needs to register RTT
  107797. */
  107798. readonly hasRenderTargetTextures: boolean;
  107799. /**
  107800. * Gets the current class name of the material e.g. "StandardMaterial"
  107801. * Mainly use in serialization.
  107802. * @returns the class name
  107803. */
  107804. getClassName(): string;
  107805. /**
  107806. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107807. * You can try switching to logarithmic depth.
  107808. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107809. */
  107810. useLogarithmicDepth: boolean;
  107811. /**
  107812. * Specifies if the material will require alpha blending
  107813. * @returns a boolean specifying if alpha blending is needed
  107814. */
  107815. needAlphaBlending(): boolean;
  107816. /**
  107817. * Specifies if this material should be rendered in alpha test mode
  107818. * @returns a boolean specifying if an alpha test is needed.
  107819. */
  107820. needAlphaTesting(): boolean;
  107821. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107822. /**
  107823. * Get the texture used for alpha test purpose.
  107824. * @returns the diffuse texture in case of the standard material.
  107825. */
  107826. getAlphaTestTexture(): Nullable<BaseTexture>;
  107827. /**
  107828. * Get if the submesh is ready to be used and all its information available.
  107829. * Child classes can use it to update shaders
  107830. * @param mesh defines the mesh to check
  107831. * @param subMesh defines which submesh to check
  107832. * @param useInstances specifies that instances should be used
  107833. * @returns a boolean indicating that the submesh is ready or not
  107834. */
  107835. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107836. /**
  107837. * Builds the material UBO layouts.
  107838. * Used internally during the effect preparation.
  107839. */
  107840. buildUniformLayout(): void;
  107841. /**
  107842. * Unbinds the material from the mesh
  107843. */
  107844. unbind(): void;
  107845. /**
  107846. * Binds the submesh to this material by preparing the effect and shader to draw
  107847. * @param world defines the world transformation matrix
  107848. * @param mesh defines the mesh containing the submesh
  107849. * @param subMesh defines the submesh to bind the material to
  107850. */
  107851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107852. /**
  107853. * Get the list of animatables in the material.
  107854. * @returns the list of animatables object used in the material
  107855. */
  107856. getAnimatables(): IAnimatable[];
  107857. /**
  107858. * Gets the active textures from the material
  107859. * @returns an array of textures
  107860. */
  107861. getActiveTextures(): BaseTexture[];
  107862. /**
  107863. * Specifies if the material uses a texture
  107864. * @param texture defines the texture to check against the material
  107865. * @returns a boolean specifying if the material uses the texture
  107866. */
  107867. hasTexture(texture: BaseTexture): boolean;
  107868. /**
  107869. * Disposes the material
  107870. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107871. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107872. */
  107873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107874. /**
  107875. * Makes a duplicate of the material, and gives it a new name
  107876. * @param name defines the new name for the duplicated material
  107877. * @returns the cloned material
  107878. */
  107879. clone(name: string): StandardMaterial;
  107880. /**
  107881. * Serializes this material in a JSON representation
  107882. * @returns the serialized material object
  107883. */
  107884. serialize(): any;
  107885. /**
  107886. * Creates a standard material from parsed material data
  107887. * @param source defines the JSON representation of the material
  107888. * @param scene defines the hosting scene
  107889. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107890. * @returns a new standard material
  107891. */
  107892. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107893. /**
  107894. * Are diffuse textures enabled in the application.
  107895. */
  107896. static DiffuseTextureEnabled: boolean;
  107897. /**
  107898. * Are ambient textures enabled in the application.
  107899. */
  107900. static AmbientTextureEnabled: boolean;
  107901. /**
  107902. * Are opacity textures enabled in the application.
  107903. */
  107904. static OpacityTextureEnabled: boolean;
  107905. /**
  107906. * Are reflection textures enabled in the application.
  107907. */
  107908. static ReflectionTextureEnabled: boolean;
  107909. /**
  107910. * Are emissive textures enabled in the application.
  107911. */
  107912. static EmissiveTextureEnabled: boolean;
  107913. /**
  107914. * Are specular textures enabled in the application.
  107915. */
  107916. static SpecularTextureEnabled: boolean;
  107917. /**
  107918. * Are bump textures enabled in the application.
  107919. */
  107920. static BumpTextureEnabled: boolean;
  107921. /**
  107922. * Are lightmap textures enabled in the application.
  107923. */
  107924. static LightmapTextureEnabled: boolean;
  107925. /**
  107926. * Are refraction textures enabled in the application.
  107927. */
  107928. static RefractionTextureEnabled: boolean;
  107929. /**
  107930. * Are color grading textures enabled in the application.
  107931. */
  107932. static ColorGradingTextureEnabled: boolean;
  107933. /**
  107934. * Are fresnels enabled in the application.
  107935. */
  107936. static FresnelEnabled: boolean;
  107937. }
  107938. }
  107939. declare module BABYLON {
  107940. /** @hidden */
  107941. export var imageProcessingPixelShader: {
  107942. name: string;
  107943. shader: string;
  107944. };
  107945. }
  107946. declare module BABYLON {
  107947. /**
  107948. * ImageProcessingPostProcess
  107949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107950. */
  107951. export class ImageProcessingPostProcess extends PostProcess {
  107952. /**
  107953. * Default configuration related to image processing available in the PBR Material.
  107954. */
  107955. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107956. /**
  107957. * Gets the image processing configuration used either in this material.
  107958. */
  107959. /**
  107960. * Sets the Default image processing configuration used either in the this material.
  107961. *
  107962. * If sets to null, the scene one is in use.
  107963. */
  107964. imageProcessingConfiguration: ImageProcessingConfiguration;
  107965. /**
  107966. * Keep track of the image processing observer to allow dispose and replace.
  107967. */
  107968. private _imageProcessingObserver;
  107969. /**
  107970. * Attaches a new image processing configuration to the PBR Material.
  107971. * @param configuration
  107972. */
  107973. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107974. /**
  107975. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107976. */
  107977. /**
  107978. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107979. */
  107980. colorCurves: Nullable<ColorCurves>;
  107981. /**
  107982. * Gets wether the color curves effect is enabled.
  107983. */
  107984. /**
  107985. * Sets wether the color curves effect is enabled.
  107986. */
  107987. colorCurvesEnabled: boolean;
  107988. /**
  107989. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107990. */
  107991. /**
  107992. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107993. */
  107994. colorGradingTexture: Nullable<BaseTexture>;
  107995. /**
  107996. * Gets wether the color grading effect is enabled.
  107997. */
  107998. /**
  107999. * Gets wether the color grading effect is enabled.
  108000. */
  108001. colorGradingEnabled: boolean;
  108002. /**
  108003. * Gets exposure used in the effect.
  108004. */
  108005. /**
  108006. * Sets exposure used in the effect.
  108007. */
  108008. exposure: number;
  108009. /**
  108010. * Gets wether tonemapping is enabled or not.
  108011. */
  108012. /**
  108013. * Sets wether tonemapping is enabled or not
  108014. */
  108015. toneMappingEnabled: boolean;
  108016. /**
  108017. * Gets the type of tone mapping effect.
  108018. */
  108019. /**
  108020. * Sets the type of tone mapping effect.
  108021. */
  108022. toneMappingType: number;
  108023. /**
  108024. * Gets contrast used in the effect.
  108025. */
  108026. /**
  108027. * Sets contrast used in the effect.
  108028. */
  108029. contrast: number;
  108030. /**
  108031. * Gets Vignette stretch size.
  108032. */
  108033. /**
  108034. * Sets Vignette stretch size.
  108035. */
  108036. vignetteStretch: number;
  108037. /**
  108038. * Gets Vignette centre X Offset.
  108039. */
  108040. /**
  108041. * Sets Vignette centre X Offset.
  108042. */
  108043. vignetteCentreX: number;
  108044. /**
  108045. * Gets Vignette centre Y Offset.
  108046. */
  108047. /**
  108048. * Sets Vignette centre Y Offset.
  108049. */
  108050. vignetteCentreY: number;
  108051. /**
  108052. * Gets Vignette weight or intensity of the vignette effect.
  108053. */
  108054. /**
  108055. * Sets Vignette weight or intensity of the vignette effect.
  108056. */
  108057. vignetteWeight: number;
  108058. /**
  108059. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108060. * if vignetteEnabled is set to true.
  108061. */
  108062. /**
  108063. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108064. * if vignetteEnabled is set to true.
  108065. */
  108066. vignetteColor: Color4;
  108067. /**
  108068. * Gets Camera field of view used by the Vignette effect.
  108069. */
  108070. /**
  108071. * Sets Camera field of view used by the Vignette effect.
  108072. */
  108073. vignetteCameraFov: number;
  108074. /**
  108075. * Gets the vignette blend mode allowing different kind of effect.
  108076. */
  108077. /**
  108078. * Sets the vignette blend mode allowing different kind of effect.
  108079. */
  108080. vignetteBlendMode: number;
  108081. /**
  108082. * Gets wether the vignette effect is enabled.
  108083. */
  108084. /**
  108085. * Sets wether the vignette effect is enabled.
  108086. */
  108087. vignetteEnabled: boolean;
  108088. private _fromLinearSpace;
  108089. /**
  108090. * Gets wether the input of the processing is in Gamma or Linear Space.
  108091. */
  108092. /**
  108093. * Sets wether the input of the processing is in Gamma or Linear Space.
  108094. */
  108095. fromLinearSpace: boolean;
  108096. /**
  108097. * Defines cache preventing GC.
  108098. */
  108099. private _defines;
  108100. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108101. /**
  108102. * "ImageProcessingPostProcess"
  108103. * @returns "ImageProcessingPostProcess"
  108104. */
  108105. getClassName(): string;
  108106. protected _updateParameters(): void;
  108107. dispose(camera?: Camera): void;
  108108. }
  108109. }
  108110. declare module BABYLON {
  108111. /**
  108112. * Class containing static functions to help procedurally build meshes
  108113. */
  108114. export class GroundBuilder {
  108115. /**
  108116. * Creates a ground mesh
  108117. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108118. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108120. * @param name defines the name of the mesh
  108121. * @param options defines the options used to create the mesh
  108122. * @param scene defines the hosting scene
  108123. * @returns the ground mesh
  108124. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108125. */
  108126. static CreateGround(name: string, options: {
  108127. width?: number;
  108128. height?: number;
  108129. subdivisions?: number;
  108130. subdivisionsX?: number;
  108131. subdivisionsY?: number;
  108132. updatable?: boolean;
  108133. }, scene: any): Mesh;
  108134. /**
  108135. * Creates a tiled ground mesh
  108136. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108137. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108138. * * 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
  108139. * * 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
  108140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108141. * @param name defines the name of the mesh
  108142. * @param options defines the options used to create the mesh
  108143. * @param scene defines the hosting scene
  108144. * @returns the tiled ground mesh
  108145. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108146. */
  108147. static CreateTiledGround(name: string, options: {
  108148. xmin: number;
  108149. zmin: number;
  108150. xmax: number;
  108151. zmax: number;
  108152. subdivisions?: {
  108153. w: number;
  108154. h: number;
  108155. };
  108156. precision?: {
  108157. w: number;
  108158. h: number;
  108159. };
  108160. updatable?: boolean;
  108161. }, scene?: Nullable<Scene>): Mesh;
  108162. /**
  108163. * Creates a ground mesh from a height map
  108164. * * The parameter `url` sets the URL of the height map image resource.
  108165. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108166. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108167. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108168. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108169. * * 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.
  108170. * * 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).
  108171. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108173. * @param name defines the name of the mesh
  108174. * @param url defines the url to the height map
  108175. * @param options defines the options used to create the mesh
  108176. * @param scene defines the hosting scene
  108177. * @returns the ground mesh
  108178. * @see https://doc.babylonjs.com/babylon101/height_map
  108179. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108180. */
  108181. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108182. width?: number;
  108183. height?: number;
  108184. subdivisions?: number;
  108185. minHeight?: number;
  108186. maxHeight?: number;
  108187. colorFilter?: Color3;
  108188. alphaFilter?: number;
  108189. updatable?: boolean;
  108190. onReady?: (mesh: GroundMesh) => void;
  108191. }, scene?: Nullable<Scene>): GroundMesh;
  108192. }
  108193. }
  108194. declare module BABYLON {
  108195. /**
  108196. * Class containing static functions to help procedurally build meshes
  108197. */
  108198. export class TorusBuilder {
  108199. /**
  108200. * Creates a torus mesh
  108201. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108202. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108203. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108207. * @param name defines the name of the mesh
  108208. * @param options defines the options used to create the mesh
  108209. * @param scene defines the hosting scene
  108210. * @returns the torus mesh
  108211. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108212. */
  108213. static CreateTorus(name: string, options: {
  108214. diameter?: number;
  108215. thickness?: number;
  108216. tessellation?: number;
  108217. updatable?: boolean;
  108218. sideOrientation?: number;
  108219. frontUVs?: Vector4;
  108220. backUVs?: Vector4;
  108221. }, scene: any): Mesh;
  108222. }
  108223. }
  108224. declare module BABYLON {
  108225. /**
  108226. * Class containing static functions to help procedurally build meshes
  108227. */
  108228. export class CylinderBuilder {
  108229. /**
  108230. * Creates a cylinder or a cone mesh
  108231. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108232. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108233. * * 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.
  108234. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108235. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108236. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108237. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108238. * * 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).
  108239. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108240. * * 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).
  108241. * * 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
  108242. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108243. * * 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
  108244. * * 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.
  108245. * * If `enclose` is false, a ring surface is one element.
  108246. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108247. * * 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
  108248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108251. * @param name defines the name of the mesh
  108252. * @param options defines the options used to create the mesh
  108253. * @param scene defines the hosting scene
  108254. * @returns the cylinder mesh
  108255. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108256. */
  108257. static CreateCylinder(name: string, options: {
  108258. height?: number;
  108259. diameterTop?: number;
  108260. diameterBottom?: number;
  108261. diameter?: number;
  108262. tessellation?: number;
  108263. subdivisions?: number;
  108264. arc?: number;
  108265. faceColors?: Color4[];
  108266. faceUV?: Vector4[];
  108267. updatable?: boolean;
  108268. hasRings?: boolean;
  108269. enclose?: boolean;
  108270. cap?: number;
  108271. sideOrientation?: number;
  108272. frontUVs?: Vector4;
  108273. backUVs?: Vector4;
  108274. }, scene: any): Mesh;
  108275. }
  108276. }
  108277. declare module BABYLON {
  108278. /**
  108279. * Options to modify the vr teleportation behavior.
  108280. */
  108281. export interface VRTeleportationOptions {
  108282. /**
  108283. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108284. */
  108285. floorMeshName?: string;
  108286. /**
  108287. * A list of meshes to be used as the teleportation floor. (default: empty)
  108288. */
  108289. floorMeshes?: Mesh[];
  108290. }
  108291. /**
  108292. * Options to modify the vr experience helper's behavior.
  108293. */
  108294. export interface VRExperienceHelperOptions extends WebVROptions {
  108295. /**
  108296. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108297. */
  108298. createDeviceOrientationCamera?: boolean;
  108299. /**
  108300. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108301. */
  108302. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108303. /**
  108304. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108305. */
  108306. laserToggle?: boolean;
  108307. /**
  108308. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108309. */
  108310. floorMeshes?: Mesh[];
  108311. /**
  108312. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108313. */
  108314. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108315. }
  108316. /**
  108317. * Event containing information after VR has been entered
  108318. */
  108319. export class OnAfterEnteringVRObservableEvent {
  108320. /**
  108321. * If entering vr was successful
  108322. */
  108323. success: boolean;
  108324. }
  108325. /**
  108326. * Helps to quickly add VR support to an existing scene.
  108327. * See http://doc.babylonjs.com/how_to/webvr_helper
  108328. */
  108329. export class VRExperienceHelper {
  108330. /** Options to modify the vr experience helper's behavior. */
  108331. webVROptions: VRExperienceHelperOptions;
  108332. private _scene;
  108333. private _position;
  108334. private _btnVR;
  108335. private _btnVRDisplayed;
  108336. private _webVRsupported;
  108337. private _webVRready;
  108338. private _webVRrequesting;
  108339. private _webVRpresenting;
  108340. private _hasEnteredVR;
  108341. private _fullscreenVRpresenting;
  108342. private _canvas;
  108343. private _webVRCamera;
  108344. private _vrDeviceOrientationCamera;
  108345. private _deviceOrientationCamera;
  108346. private _existingCamera;
  108347. private _onKeyDown;
  108348. private _onVrDisplayPresentChange;
  108349. private _onVRDisplayChanged;
  108350. private _onVRRequestPresentStart;
  108351. private _onVRRequestPresentComplete;
  108352. /**
  108353. * 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)
  108354. */
  108355. enableGazeEvenWhenNoPointerLock: boolean;
  108356. /**
  108357. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108358. */
  108359. exitVROnDoubleTap: boolean;
  108360. /**
  108361. * Observable raised right before entering VR.
  108362. */
  108363. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108364. /**
  108365. * Observable raised when entering VR has completed.
  108366. */
  108367. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108368. /**
  108369. * Observable raised when exiting VR.
  108370. */
  108371. onExitingVRObservable: Observable<VRExperienceHelper>;
  108372. /**
  108373. * Observable raised when controller mesh is loaded.
  108374. */
  108375. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108376. /** Return this.onEnteringVRObservable
  108377. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108378. */
  108379. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108380. /** Return this.onExitingVRObservable
  108381. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108382. */
  108383. readonly onExitingVR: Observable<VRExperienceHelper>;
  108384. /** Return this.onControllerMeshLoadedObservable
  108385. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108386. */
  108387. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108388. private _rayLength;
  108389. private _useCustomVRButton;
  108390. private _teleportationRequested;
  108391. private _teleportActive;
  108392. private _floorMeshName;
  108393. private _floorMeshesCollection;
  108394. private _rotationAllowed;
  108395. private _teleportBackwardsVector;
  108396. private _teleportationTarget;
  108397. private _isDefaultTeleportationTarget;
  108398. private _postProcessMove;
  108399. private _teleportationFillColor;
  108400. private _teleportationBorderColor;
  108401. private _rotationAngle;
  108402. private _haloCenter;
  108403. private _cameraGazer;
  108404. private _padSensibilityUp;
  108405. private _padSensibilityDown;
  108406. private _leftController;
  108407. private _rightController;
  108408. /**
  108409. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108410. */
  108411. onNewMeshSelected: Observable<AbstractMesh>;
  108412. /**
  108413. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108414. * This observable will provide the mesh and the controller used to select the mesh
  108415. */
  108416. onMeshSelectedWithController: Observable<{
  108417. mesh: AbstractMesh;
  108418. controller: WebVRController;
  108419. }>;
  108420. /**
  108421. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108422. */
  108423. onNewMeshPicked: Observable<PickingInfo>;
  108424. private _circleEase;
  108425. /**
  108426. * Observable raised before camera teleportation
  108427. */
  108428. onBeforeCameraTeleport: Observable<Vector3>;
  108429. /**
  108430. * Observable raised after camera teleportation
  108431. */
  108432. onAfterCameraTeleport: Observable<Vector3>;
  108433. /**
  108434. * Observable raised when current selected mesh gets unselected
  108435. */
  108436. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108437. private _raySelectionPredicate;
  108438. /**
  108439. * To be optionaly changed by user to define custom ray selection
  108440. */
  108441. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108442. /**
  108443. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108444. */
  108445. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108446. /**
  108447. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108448. */
  108449. teleportationEnabled: boolean;
  108450. private _defaultHeight;
  108451. private _teleportationInitialized;
  108452. private _interactionsEnabled;
  108453. private _interactionsRequested;
  108454. private _displayGaze;
  108455. private _displayLaserPointer;
  108456. /**
  108457. * The mesh used to display where the user is going to teleport.
  108458. */
  108459. /**
  108460. * Sets the mesh to be used to display where the user is going to teleport.
  108461. */
  108462. teleportationTarget: Mesh;
  108463. /**
  108464. * 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
  108465. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108466. * See http://doc.babylonjs.com/resources/baking_transformations
  108467. */
  108468. gazeTrackerMesh: Mesh;
  108469. /**
  108470. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108471. */
  108472. updateGazeTrackerScale: boolean;
  108473. /**
  108474. * If the gaze trackers color should be updated when selecting meshes
  108475. */
  108476. updateGazeTrackerColor: boolean;
  108477. /**
  108478. * If the controller laser color should be updated when selecting meshes
  108479. */
  108480. updateControllerLaserColor: boolean;
  108481. /**
  108482. * The gaze tracking mesh corresponding to the left controller
  108483. */
  108484. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108485. /**
  108486. * The gaze tracking mesh corresponding to the right controller
  108487. */
  108488. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108489. /**
  108490. * If the ray of the gaze should be displayed.
  108491. */
  108492. /**
  108493. * Sets if the ray of the gaze should be displayed.
  108494. */
  108495. displayGaze: boolean;
  108496. /**
  108497. * If the ray of the LaserPointer should be displayed.
  108498. */
  108499. /**
  108500. * Sets if the ray of the LaserPointer should be displayed.
  108501. */
  108502. displayLaserPointer: boolean;
  108503. /**
  108504. * The deviceOrientationCamera used as the camera when not in VR.
  108505. */
  108506. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108507. /**
  108508. * Based on the current WebVR support, returns the current VR camera used.
  108509. */
  108510. readonly currentVRCamera: Nullable<Camera>;
  108511. /**
  108512. * The webVRCamera which is used when in VR.
  108513. */
  108514. readonly webVRCamera: WebVRFreeCamera;
  108515. /**
  108516. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108517. */
  108518. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108519. /**
  108520. * The html button that is used to trigger entering into VR.
  108521. */
  108522. readonly vrButton: Nullable<HTMLButtonElement>;
  108523. private readonly _teleportationRequestInitiated;
  108524. /**
  108525. * Defines wether or not Pointer lock should be requested when switching to
  108526. * full screen.
  108527. */
  108528. requestPointerLockOnFullScreen: boolean;
  108529. /**
  108530. * Instantiates a VRExperienceHelper.
  108531. * Helps to quickly add VR support to an existing scene.
  108532. * @param scene The scene the VRExperienceHelper belongs to.
  108533. * @param webVROptions Options to modify the vr experience helper's behavior.
  108534. */
  108535. constructor(scene: Scene,
  108536. /** Options to modify the vr experience helper's behavior. */
  108537. webVROptions?: VRExperienceHelperOptions);
  108538. private _onDefaultMeshLoaded;
  108539. private _onResize;
  108540. private _onFullscreenChange;
  108541. /**
  108542. * Gets a value indicating if we are currently in VR mode.
  108543. */
  108544. readonly isInVRMode: boolean;
  108545. private onVrDisplayPresentChange;
  108546. private onVRDisplayChanged;
  108547. private moveButtonToBottomRight;
  108548. private displayVRButton;
  108549. private updateButtonVisibility;
  108550. private _cachedAngularSensibility;
  108551. /**
  108552. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108553. * Otherwise, will use the fullscreen API.
  108554. */
  108555. enterVR(): void;
  108556. /**
  108557. * Attempt to exit VR, or fullscreen.
  108558. */
  108559. exitVR(): void;
  108560. /**
  108561. * The position of the vr experience helper.
  108562. */
  108563. /**
  108564. * Sets the position of the vr experience helper.
  108565. */
  108566. position: Vector3;
  108567. /**
  108568. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108569. */
  108570. enableInteractions(): void;
  108571. private readonly _noControllerIsActive;
  108572. private beforeRender;
  108573. private _isTeleportationFloor;
  108574. /**
  108575. * Adds a floor mesh to be used for teleportation.
  108576. * @param floorMesh the mesh to be used for teleportation.
  108577. */
  108578. addFloorMesh(floorMesh: Mesh): void;
  108579. /**
  108580. * Removes a floor mesh from being used for teleportation.
  108581. * @param floorMesh the mesh to be removed.
  108582. */
  108583. removeFloorMesh(floorMesh: Mesh): void;
  108584. /**
  108585. * Enables interactions and teleportation using the VR controllers and gaze.
  108586. * @param vrTeleportationOptions options to modify teleportation behavior.
  108587. */
  108588. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108589. private _onNewGamepadConnected;
  108590. private _tryEnableInteractionOnController;
  108591. private _onNewGamepadDisconnected;
  108592. private _enableInteractionOnController;
  108593. private _checkTeleportWithRay;
  108594. private _checkRotate;
  108595. private _checkTeleportBackwards;
  108596. private _enableTeleportationOnController;
  108597. private _createTeleportationCircles;
  108598. private _displayTeleportationTarget;
  108599. private _hideTeleportationTarget;
  108600. private _rotateCamera;
  108601. private _moveTeleportationSelectorTo;
  108602. private _workingVector;
  108603. private _workingQuaternion;
  108604. private _workingMatrix;
  108605. /**
  108606. * Teleports the users feet to the desired location
  108607. * @param location The location where the user's feet should be placed
  108608. */
  108609. teleportCamera(location: Vector3): void;
  108610. private _convertNormalToDirectionOfRay;
  108611. private _castRayAndSelectObject;
  108612. private _notifySelectedMeshUnselected;
  108613. /**
  108614. * Sets the color of the laser ray from the vr controllers.
  108615. * @param color new color for the ray.
  108616. */
  108617. changeLaserColor(color: Color3): void;
  108618. /**
  108619. * Sets the color of the ray from the vr headsets gaze.
  108620. * @param color new color for the ray.
  108621. */
  108622. changeGazeColor(color: Color3): void;
  108623. /**
  108624. * Exits VR and disposes of the vr experience helper
  108625. */
  108626. dispose(): void;
  108627. /**
  108628. * Gets the name of the VRExperienceHelper class
  108629. * @returns "VRExperienceHelper"
  108630. */
  108631. getClassName(): string;
  108632. }
  108633. }
  108634. declare module BABYLON {
  108635. /**
  108636. * Manages an XRSession to work with Babylon's engine
  108637. * @see https://doc.babylonjs.com/how_to/webxr
  108638. */
  108639. export class WebXRSessionManager implements IDisposable {
  108640. private scene;
  108641. /**
  108642. * Fires every time a new xrFrame arrives which can be used to update the camera
  108643. */
  108644. onXRFrameObservable: Observable<any>;
  108645. /**
  108646. * Fires when the xr session is ended either by the device or manually done
  108647. */
  108648. onXRSessionEnded: Observable<any>;
  108649. /**
  108650. * Underlying xr session
  108651. */
  108652. session: XRSession;
  108653. /**
  108654. * Type of reference space used when creating the session
  108655. */
  108656. referenceSpace: XRReferenceSpace;
  108657. /** @hidden */
  108658. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108659. /**
  108660. * Current XR frame
  108661. */
  108662. currentFrame: Nullable<XRFrame>;
  108663. private _xrNavigator;
  108664. private baseLayer;
  108665. /**
  108666. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108667. * @param scene The scene which the session should be created for
  108668. */
  108669. constructor(scene: Scene);
  108670. /**
  108671. * Initializes the manager
  108672. * After initialization enterXR can be called to start an XR session
  108673. * @returns Promise which resolves after it is initialized
  108674. */
  108675. initializeAsync(): Promise<void>;
  108676. /**
  108677. * Initializes an xr session
  108678. * @param xrSessionMode mode to initialize
  108679. * @returns a promise which will resolve once the session has been initialized
  108680. */
  108681. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108682. /**
  108683. * Sets the reference space on the xr session
  108684. * @param referenceSpace space to set
  108685. * @returns a promise that will resolve once the reference space has been set
  108686. */
  108687. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108688. /**
  108689. * Updates the render state of the session
  108690. * @param state state to set
  108691. * @returns a promise that resolves once the render state has been updated
  108692. */
  108693. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108694. /**
  108695. * Starts rendering to the xr layer
  108696. * @returns a promise that will resolve once rendering has started
  108697. */
  108698. startRenderingToXRAsync(): Promise<void>;
  108699. /**
  108700. * Stops the xrSession and restores the renderloop
  108701. * @returns Promise which resolves after it exits XR
  108702. */
  108703. exitXRAsync(): Promise<unknown>;
  108704. /**
  108705. * Checks if a session would be supported for the creation options specified
  108706. * @param sessionMode session mode to check if supported eg. immersive-vr
  108707. * @returns true if supported
  108708. */
  108709. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108710. /**
  108711. * @hidden
  108712. * Converts the render layer of xrSession to a render target
  108713. * @param session session to create render target for
  108714. * @param scene scene the new render target should be created for
  108715. */
  108716. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108717. /**
  108718. * Disposes of the session manager
  108719. */
  108720. dispose(): void;
  108721. }
  108722. }
  108723. declare module BABYLON {
  108724. /**
  108725. * WebXR Camera which holds the views for the xrSession
  108726. * @see https://doc.babylonjs.com/how_to/webxr
  108727. */
  108728. export class WebXRCamera extends FreeCamera {
  108729. private static _TmpMatrix;
  108730. /**
  108731. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108732. * @param name the name of the camera
  108733. * @param scene the scene to add the camera to
  108734. */
  108735. constructor(name: string, scene: Scene);
  108736. private _updateNumberOfRigCameras;
  108737. /** @hidden */
  108738. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108739. /**
  108740. * Updates the cameras position from the current pose information of the XR session
  108741. * @param xrSessionManager the session containing pose information
  108742. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108743. */
  108744. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108745. }
  108746. }
  108747. declare module BABYLON {
  108748. /**
  108749. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108750. */
  108751. export class WebXRManagedOutputCanvas implements IDisposable {
  108752. private helper;
  108753. private _canvas;
  108754. /**
  108755. * xrpresent context of the canvas which can be used to display/mirror xr content
  108756. */
  108757. canvasContext: WebGLRenderingContext;
  108758. /**
  108759. * xr layer for the canvas
  108760. */
  108761. xrLayer: Nullable<XRWebGLLayer>;
  108762. /**
  108763. * Initializes the xr layer for the session
  108764. * @param xrSession xr session
  108765. * @returns a promise that will resolve once the XR Layer has been created
  108766. */
  108767. initializeXRLayerAsync(xrSession: any): any;
  108768. /**
  108769. * Initializes the canvas to be added/removed upon entering/exiting xr
  108770. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108771. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108772. */
  108773. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108774. /**
  108775. * Disposes of the object
  108776. */
  108777. dispose(): void;
  108778. private _setManagedOutputCanvas;
  108779. private _addCanvas;
  108780. private _removeCanvas;
  108781. }
  108782. }
  108783. declare module BABYLON {
  108784. /**
  108785. * States of the webXR experience
  108786. */
  108787. export enum WebXRState {
  108788. /**
  108789. * Transitioning to being in XR mode
  108790. */
  108791. ENTERING_XR = 0,
  108792. /**
  108793. * Transitioning to non XR mode
  108794. */
  108795. EXITING_XR = 1,
  108796. /**
  108797. * In XR mode and presenting
  108798. */
  108799. IN_XR = 2,
  108800. /**
  108801. * Not entered XR mode
  108802. */
  108803. NOT_IN_XR = 3
  108804. }
  108805. /**
  108806. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108807. * @see https://doc.babylonjs.com/how_to/webxr
  108808. */
  108809. export class WebXRExperienceHelper implements IDisposable {
  108810. private scene;
  108811. /**
  108812. * 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
  108813. */
  108814. container: AbstractMesh;
  108815. /**
  108816. * Camera used to render xr content
  108817. */
  108818. camera: WebXRCamera;
  108819. /**
  108820. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108821. */
  108822. state: WebXRState;
  108823. private _setState;
  108824. private static _TmpVector;
  108825. /**
  108826. * Fires when the state of the experience helper has changed
  108827. */
  108828. onStateChangedObservable: Observable<WebXRState>;
  108829. /** Session manager used to keep track of xr session */
  108830. sessionManager: WebXRSessionManager;
  108831. private _nonVRCamera;
  108832. private _originalSceneAutoClear;
  108833. private _supported;
  108834. /**
  108835. * Creates the experience helper
  108836. * @param scene the scene to attach the experience helper to
  108837. * @returns a promise for the experience helper
  108838. */
  108839. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108840. /**
  108841. * Creates a WebXRExperienceHelper
  108842. * @param scene The scene the helper should be created in
  108843. */
  108844. private constructor();
  108845. /**
  108846. * Exits XR mode and returns the scene to its original state
  108847. * @returns promise that resolves after xr mode has exited
  108848. */
  108849. exitXRAsync(): Promise<unknown>;
  108850. /**
  108851. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108852. * @param sessionCreationOptions options for the XR session
  108853. * @param referenceSpaceType frame of reference of the XR session
  108854. * @param outputCanvas the output canvas that will be used to enter XR mode
  108855. * @returns promise that resolves after xr mode has entered
  108856. */
  108857. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108858. /**
  108859. * Updates the global position of the camera by moving the camera's container
  108860. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108861. * @param position The desired global position of the camera
  108862. */
  108863. setPositionOfCameraUsingContainer(position: Vector3): void;
  108864. /**
  108865. * Rotates the xr camera by rotating the camera's container around the camera's position
  108866. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108867. * @param rotation the desired quaternion rotation to apply to the camera
  108868. */
  108869. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108870. /**
  108871. * Disposes of the experience helper
  108872. */
  108873. dispose(): void;
  108874. }
  108875. }
  108876. declare module BABYLON {
  108877. /**
  108878. * Button which can be used to enter a different mode of XR
  108879. */
  108880. export class WebXREnterExitUIButton {
  108881. /** button element */
  108882. element: HTMLElement;
  108883. /** XR initialization options for the button */
  108884. sessionMode: XRSessionMode;
  108885. /** Reference space type */
  108886. referenceSpaceType: XRReferenceSpaceType;
  108887. /**
  108888. * Creates a WebXREnterExitUIButton
  108889. * @param element button element
  108890. * @param sessionMode XR initialization session mode
  108891. * @param referenceSpaceType the type of reference space to be used
  108892. */
  108893. constructor(
  108894. /** button element */
  108895. element: HTMLElement,
  108896. /** XR initialization options for the button */
  108897. sessionMode: XRSessionMode,
  108898. /** Reference space type */
  108899. referenceSpaceType: XRReferenceSpaceType);
  108900. /**
  108901. * Overwritable function which can be used to update the button's visuals when the state changes
  108902. * @param activeButton the current active button in the UI
  108903. */
  108904. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108905. }
  108906. /**
  108907. * Options to create the webXR UI
  108908. */
  108909. export class WebXREnterExitUIOptions {
  108910. /**
  108911. * Context to enter xr with
  108912. */
  108913. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108914. /**
  108915. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108916. */
  108917. customButtons?: Array<WebXREnterExitUIButton>;
  108918. }
  108919. /**
  108920. * UI to allow the user to enter/exit XR mode
  108921. */
  108922. export class WebXREnterExitUI implements IDisposable {
  108923. private scene;
  108924. private _overlay;
  108925. private _buttons;
  108926. private _activeButton;
  108927. /**
  108928. * Fired every time the active button is changed.
  108929. *
  108930. * When xr is entered via a button that launches xr that button will be the callback parameter
  108931. *
  108932. * When exiting xr the callback parameter will be null)
  108933. */
  108934. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108935. /**
  108936. * Creates UI to allow the user to enter/exit XR mode
  108937. * @param scene the scene to add the ui to
  108938. * @param helper the xr experience helper to enter/exit xr with
  108939. * @param options options to configure the UI
  108940. * @returns the created ui
  108941. */
  108942. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108943. private constructor();
  108944. private _updateButtons;
  108945. /**
  108946. * Disposes of the object
  108947. */
  108948. dispose(): void;
  108949. }
  108950. }
  108951. declare module BABYLON {
  108952. /**
  108953. * Represents an XR input
  108954. */
  108955. export class WebXRController {
  108956. private scene;
  108957. /** The underlying input source for the controller */
  108958. inputSource: XRInputSource;
  108959. private parentContainer;
  108960. /**
  108961. * 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
  108962. */
  108963. grip?: AbstractMesh;
  108964. /**
  108965. * Pointer which can be used to select objects or attach a visible laser to
  108966. */
  108967. pointer: AbstractMesh;
  108968. /**
  108969. * Event that fires when the controller is removed/disposed
  108970. */
  108971. onDisposeObservable: Observable<{}>;
  108972. private _tmpMatrix;
  108973. private _tmpQuaternion;
  108974. private _tmpVector;
  108975. /**
  108976. * Creates the controller
  108977. * @see https://doc.babylonjs.com/how_to/webxr
  108978. * @param scene the scene which the controller should be associated to
  108979. * @param inputSource the underlying input source for the controller
  108980. * @param parentContainer parent that the controller meshes should be children of
  108981. */
  108982. constructor(scene: Scene,
  108983. /** The underlying input source for the controller */
  108984. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108985. /**
  108986. * Updates the controller pose based on the given XRFrame
  108987. * @param xrFrame xr frame to update the pose with
  108988. * @param referenceSpace reference space to use
  108989. */
  108990. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108991. /**
  108992. * Gets a world space ray coming from the controller
  108993. * @param result the resulting ray
  108994. */
  108995. getWorldPointerRayToRef(result: Ray): void;
  108996. /**
  108997. * Disposes of the object
  108998. */
  108999. dispose(): void;
  109000. }
  109001. }
  109002. declare module BABYLON {
  109003. /**
  109004. * XR input used to track XR inputs such as controllers/rays
  109005. */
  109006. export class WebXRInput implements IDisposable {
  109007. /**
  109008. * Base experience the input listens to
  109009. */
  109010. baseExperience: WebXRExperienceHelper;
  109011. /**
  109012. * XR controllers being tracked
  109013. */
  109014. controllers: Array<WebXRController>;
  109015. private _frameObserver;
  109016. private _stateObserver;
  109017. /**
  109018. * Event when a controller has been connected/added
  109019. */
  109020. onControllerAddedObservable: Observable<WebXRController>;
  109021. /**
  109022. * Event when a controller has been removed/disconnected
  109023. */
  109024. onControllerRemovedObservable: Observable<WebXRController>;
  109025. /**
  109026. * Initializes the WebXRInput
  109027. * @param baseExperience experience helper which the input should be created for
  109028. */
  109029. constructor(
  109030. /**
  109031. * Base experience the input listens to
  109032. */
  109033. baseExperience: WebXRExperienceHelper);
  109034. private _onInputSourcesChange;
  109035. private _addAndRemoveControllers;
  109036. /**
  109037. * Disposes of the object
  109038. */
  109039. dispose(): void;
  109040. }
  109041. }
  109042. declare module BABYLON {
  109043. /**
  109044. * Enables teleportation
  109045. */
  109046. export class WebXRControllerTeleportation {
  109047. private _teleportationFillColor;
  109048. private _teleportationBorderColor;
  109049. private _tmpRay;
  109050. private _tmpVector;
  109051. /**
  109052. * Creates a WebXRControllerTeleportation
  109053. * @param input input manager to add teleportation to
  109054. * @param floorMeshes floormeshes which can be teleported to
  109055. */
  109056. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109057. }
  109058. }
  109059. declare module BABYLON {
  109060. /**
  109061. * Handles pointer input automatically for the pointer of XR controllers
  109062. */
  109063. export class WebXRControllerPointerSelection {
  109064. private static _idCounter;
  109065. private _tmpRay;
  109066. /**
  109067. * Creates a WebXRControllerPointerSelection
  109068. * @param input input manager to setup pointer selection
  109069. */
  109070. constructor(input: WebXRInput);
  109071. private _convertNormalToDirectionOfRay;
  109072. private _updatePointerDistance;
  109073. }
  109074. }
  109075. declare module BABYLON {
  109076. /**
  109077. * Class used to represent data loading progression
  109078. */
  109079. export class SceneLoaderProgressEvent {
  109080. /** defines if data length to load can be evaluated */
  109081. readonly lengthComputable: boolean;
  109082. /** defines the loaded data length */
  109083. readonly loaded: number;
  109084. /** defines the data length to load */
  109085. readonly total: number;
  109086. /**
  109087. * Create a new progress event
  109088. * @param lengthComputable defines if data length to load can be evaluated
  109089. * @param loaded defines the loaded data length
  109090. * @param total defines the data length to load
  109091. */
  109092. constructor(
  109093. /** defines if data length to load can be evaluated */
  109094. lengthComputable: boolean,
  109095. /** defines the loaded data length */
  109096. loaded: number,
  109097. /** defines the data length to load */
  109098. total: number);
  109099. /**
  109100. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109101. * @param event defines the source event
  109102. * @returns a new SceneLoaderProgressEvent
  109103. */
  109104. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109105. }
  109106. /**
  109107. * Interface used by SceneLoader plugins to define supported file extensions
  109108. */
  109109. export interface ISceneLoaderPluginExtensions {
  109110. /**
  109111. * Defines the list of supported extensions
  109112. */
  109113. [extension: string]: {
  109114. isBinary: boolean;
  109115. };
  109116. }
  109117. /**
  109118. * Interface used by SceneLoader plugin factory
  109119. */
  109120. export interface ISceneLoaderPluginFactory {
  109121. /**
  109122. * Defines the name of the factory
  109123. */
  109124. name: string;
  109125. /**
  109126. * Function called to create a new plugin
  109127. * @return the new plugin
  109128. */
  109129. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109130. /**
  109131. * Boolean indicating if the plugin can direct load specific data
  109132. */
  109133. canDirectLoad?: (data: string) => boolean;
  109134. }
  109135. /**
  109136. * Interface used to define a SceneLoader plugin
  109137. */
  109138. export interface ISceneLoaderPlugin {
  109139. /**
  109140. * The friendly name of this plugin.
  109141. */
  109142. name: string;
  109143. /**
  109144. * The file extensions supported by this plugin.
  109145. */
  109146. extensions: string | ISceneLoaderPluginExtensions;
  109147. /**
  109148. * Import meshes into a scene.
  109149. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109150. * @param scene The scene to import into
  109151. * @param data The data to import
  109152. * @param rootUrl The root url for scene and resources
  109153. * @param meshes The meshes array to import into
  109154. * @param particleSystems The particle systems array to import into
  109155. * @param skeletons The skeletons array to import into
  109156. * @param onError The callback when import fails
  109157. * @returns True if successful or false otherwise
  109158. */
  109159. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109160. /**
  109161. * Load into a scene.
  109162. * @param scene The scene to load into
  109163. * @param data The data to import
  109164. * @param rootUrl The root url for scene and resources
  109165. * @param onError The callback when import fails
  109166. * @returns true if successful or false otherwise
  109167. */
  109168. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109169. /**
  109170. * The callback that returns true if the data can be directly loaded.
  109171. */
  109172. canDirectLoad?: (data: string) => boolean;
  109173. /**
  109174. * The callback that allows custom handling of the root url based on the response url.
  109175. */
  109176. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109177. /**
  109178. * Load into an asset container.
  109179. * @param scene The scene to load into
  109180. * @param data The data to import
  109181. * @param rootUrl The root url for scene and resources
  109182. * @param onError The callback when import fails
  109183. * @returns The loaded asset container
  109184. */
  109185. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109186. }
  109187. /**
  109188. * Interface used to define an async SceneLoader plugin
  109189. */
  109190. export interface ISceneLoaderPluginAsync {
  109191. /**
  109192. * The friendly name of this plugin.
  109193. */
  109194. name: string;
  109195. /**
  109196. * The file extensions supported by this plugin.
  109197. */
  109198. extensions: string | ISceneLoaderPluginExtensions;
  109199. /**
  109200. * Import meshes into a scene.
  109201. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109202. * @param scene The scene to import into
  109203. * @param data The data to import
  109204. * @param rootUrl The root url for scene and resources
  109205. * @param onProgress The callback when the load progresses
  109206. * @param fileName Defines the name of the file to load
  109207. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109208. */
  109209. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109210. meshes: AbstractMesh[];
  109211. particleSystems: IParticleSystem[];
  109212. skeletons: Skeleton[];
  109213. animationGroups: AnimationGroup[];
  109214. }>;
  109215. /**
  109216. * Load into a scene.
  109217. * @param scene The scene to load into
  109218. * @param data The data to import
  109219. * @param rootUrl The root url for scene and resources
  109220. * @param onProgress The callback when the load progresses
  109221. * @param fileName Defines the name of the file to load
  109222. * @returns Nothing
  109223. */
  109224. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109225. /**
  109226. * The callback that returns true if the data can be directly loaded.
  109227. */
  109228. canDirectLoad?: (data: string) => boolean;
  109229. /**
  109230. * The callback that allows custom handling of the root url based on the response url.
  109231. */
  109232. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  109233. /**
  109234. * Load into an asset container.
  109235. * @param scene The scene to load into
  109236. * @param data The data to import
  109237. * @param rootUrl The root url for scene and resources
  109238. * @param onProgress The callback when the load progresses
  109239. * @param fileName Defines the name of the file to load
  109240. * @returns The loaded asset container
  109241. */
  109242. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109243. }
  109244. /**
  109245. * Class used to load scene from various file formats using registered plugins
  109246. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109247. */
  109248. export class SceneLoader {
  109249. /**
  109250. * No logging while loading
  109251. */
  109252. static readonly NO_LOGGING: number;
  109253. /**
  109254. * Minimal logging while loading
  109255. */
  109256. static readonly MINIMAL_LOGGING: number;
  109257. /**
  109258. * Summary logging while loading
  109259. */
  109260. static readonly SUMMARY_LOGGING: number;
  109261. /**
  109262. * Detailled logging while loading
  109263. */
  109264. static readonly DETAILED_LOGGING: number;
  109265. /**
  109266. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109267. */
  109268. static ForceFullSceneLoadingForIncremental: boolean;
  109269. /**
  109270. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109271. */
  109272. static ShowLoadingScreen: boolean;
  109273. /**
  109274. * Defines the current logging level (while loading the scene)
  109275. * @ignorenaming
  109276. */
  109277. static loggingLevel: number;
  109278. /**
  109279. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109280. */
  109281. static CleanBoneMatrixWeights: boolean;
  109282. /**
  109283. * Event raised when a plugin is used to load a scene
  109284. */
  109285. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109286. private static _registeredPlugins;
  109287. private static _getDefaultPlugin;
  109288. private static _getPluginForExtension;
  109289. private static _getPluginForDirectLoad;
  109290. private static _getPluginForFilename;
  109291. private static _getDirectLoad;
  109292. private static _loadData;
  109293. private static _getFileInfo;
  109294. /**
  109295. * Gets a plugin that can load the given extension
  109296. * @param extension defines the extension to load
  109297. * @returns a plugin or null if none works
  109298. */
  109299. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109300. /**
  109301. * Gets a boolean indicating that the given extension can be loaded
  109302. * @param extension defines the extension to load
  109303. * @returns true if the extension is supported
  109304. */
  109305. static IsPluginForExtensionAvailable(extension: string): boolean;
  109306. /**
  109307. * Adds a new plugin to the list of registered plugins
  109308. * @param plugin defines the plugin to add
  109309. */
  109310. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109311. /**
  109312. * Import meshes into a scene
  109313. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109314. * @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)
  109315. * @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)
  109316. * @param scene the instance of BABYLON.Scene to append to
  109317. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109318. * @param onProgress a callback with a progress event for each file being loaded
  109319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109320. * @param pluginExtension the extension used to determine the plugin
  109321. * @returns The loaded plugin
  109322. */
  109323. 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>;
  109324. /**
  109325. * Import meshes into a scene
  109326. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109327. * @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)
  109328. * @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)
  109329. * @param scene the instance of BABYLON.Scene to append to
  109330. * @param onProgress a callback with a progress event for each file being loaded
  109331. * @param pluginExtension the extension used to determine the plugin
  109332. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109333. */
  109334. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109335. meshes: AbstractMesh[];
  109336. particleSystems: IParticleSystem[];
  109337. skeletons: Skeleton[];
  109338. animationGroups: AnimationGroup[];
  109339. }>;
  109340. /**
  109341. * Load a scene
  109342. * @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)
  109343. * @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)
  109344. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109345. * @param onSuccess a callback with the scene when import succeeds
  109346. * @param onProgress a callback with a progress event for each file being loaded
  109347. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109348. * @param pluginExtension the extension used to determine the plugin
  109349. * @returns The loaded plugin
  109350. */
  109351. 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>;
  109352. /**
  109353. * Load a scene
  109354. * @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)
  109355. * @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)
  109356. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109357. * @param onProgress a callback with a progress event for each file being loaded
  109358. * @param pluginExtension the extension used to determine the plugin
  109359. * @returns The loaded scene
  109360. */
  109361. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109362. /**
  109363. * Append a scene
  109364. * @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)
  109365. * @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)
  109366. * @param scene is the instance of BABYLON.Scene to append to
  109367. * @param onSuccess a callback with the scene when import succeeds
  109368. * @param onProgress a callback with a progress event for each file being loaded
  109369. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109370. * @param pluginExtension the extension used to determine the plugin
  109371. * @returns The loaded plugin
  109372. */
  109373. 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>;
  109374. /**
  109375. * Append a scene
  109376. * @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)
  109377. * @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)
  109378. * @param scene is the instance of BABYLON.Scene to append to
  109379. * @param onProgress a callback with a progress event for each file being loaded
  109380. * @param pluginExtension the extension used to determine the plugin
  109381. * @returns The given scene
  109382. */
  109383. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109384. /**
  109385. * Load a scene into an asset container
  109386. * @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)
  109387. * @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)
  109388. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109389. * @param onSuccess a callback with the scene when import succeeds
  109390. * @param onProgress a callback with a progress event for each file being loaded
  109391. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109392. * @param pluginExtension the extension used to determine the plugin
  109393. * @returns The loaded plugin
  109394. */
  109395. 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>;
  109396. /**
  109397. * Load a scene into an asset container
  109398. * @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)
  109399. * @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)
  109400. * @param scene is the instance of Scene to append to
  109401. * @param onProgress a callback with a progress event for each file being loaded
  109402. * @param pluginExtension the extension used to determine the plugin
  109403. * @returns The loaded asset container
  109404. */
  109405. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  109406. }
  109407. }
  109408. declare module BABYLON {
  109409. /**
  109410. * Generic Controller
  109411. */
  109412. export class GenericController extends WebVRController {
  109413. /**
  109414. * Base Url for the controller model.
  109415. */
  109416. static readonly MODEL_BASE_URL: string;
  109417. /**
  109418. * File name for the controller model.
  109419. */
  109420. static readonly MODEL_FILENAME: string;
  109421. /**
  109422. * Creates a new GenericController from a gamepad
  109423. * @param vrGamepad the gamepad that the controller should be created from
  109424. */
  109425. constructor(vrGamepad: any);
  109426. /**
  109427. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109428. * @param scene scene in which to add meshes
  109429. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109430. */
  109431. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109432. /**
  109433. * Called once for each button that changed state since the last frame
  109434. * @param buttonIdx Which button index changed
  109435. * @param state New state of the button
  109436. * @param changes Which properties on the state changed since last frame
  109437. */
  109438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109439. }
  109440. }
  109441. declare module BABYLON {
  109442. /**
  109443. * Defines the WindowsMotionController object that the state of the windows motion controller
  109444. */
  109445. export class WindowsMotionController extends WebVRController {
  109446. /**
  109447. * The base url used to load the left and right controller models
  109448. */
  109449. static MODEL_BASE_URL: string;
  109450. /**
  109451. * The name of the left controller model file
  109452. */
  109453. static MODEL_LEFT_FILENAME: string;
  109454. /**
  109455. * The name of the right controller model file
  109456. */
  109457. static MODEL_RIGHT_FILENAME: string;
  109458. /**
  109459. * The controller name prefix for this controller type
  109460. */
  109461. static readonly GAMEPAD_ID_PREFIX: string;
  109462. /**
  109463. * The controller id pattern for this controller type
  109464. */
  109465. private static readonly GAMEPAD_ID_PATTERN;
  109466. private _loadedMeshInfo;
  109467. private readonly _mapping;
  109468. /**
  109469. * Fired when the trackpad on this controller is clicked
  109470. */
  109471. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109472. /**
  109473. * Fired when the trackpad on this controller is modified
  109474. */
  109475. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109476. /**
  109477. * The current x and y values of this controller's trackpad
  109478. */
  109479. trackpad: StickValues;
  109480. /**
  109481. * Creates a new WindowsMotionController from a gamepad
  109482. * @param vrGamepad the gamepad that the controller should be created from
  109483. */
  109484. constructor(vrGamepad: any);
  109485. /**
  109486. * Fired when the trigger on this controller is modified
  109487. */
  109488. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109489. /**
  109490. * Fired when the menu button on this controller is modified
  109491. */
  109492. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109493. /**
  109494. * Fired when the grip button on this controller is modified
  109495. */
  109496. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109497. /**
  109498. * Fired when the thumbstick button on this controller is modified
  109499. */
  109500. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109501. /**
  109502. * Fired when the touchpad button on this controller is modified
  109503. */
  109504. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109505. /**
  109506. * Fired when the touchpad values on this controller are modified
  109507. */
  109508. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109509. private _updateTrackpad;
  109510. /**
  109511. * Called once per frame by the engine.
  109512. */
  109513. update(): void;
  109514. /**
  109515. * Called once for each button that changed state since the last frame
  109516. * @param buttonIdx Which button index changed
  109517. * @param state New state of the button
  109518. * @param changes Which properties on the state changed since last frame
  109519. */
  109520. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109521. /**
  109522. * Moves the buttons on the controller mesh based on their current state
  109523. * @param buttonName the name of the button to move
  109524. * @param buttonValue the value of the button which determines the buttons new position
  109525. */
  109526. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109527. /**
  109528. * Moves the axis on the controller mesh based on its current state
  109529. * @param axis the index of the axis
  109530. * @param axisValue the value of the axis which determines the meshes new position
  109531. * @hidden
  109532. */
  109533. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109534. /**
  109535. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109536. * @param scene scene in which to add meshes
  109537. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109538. */
  109539. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109540. /**
  109541. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109542. * can be transformed by button presses and axes values, based on this._mapping.
  109543. *
  109544. * @param scene scene in which the meshes exist
  109545. * @param meshes list of meshes that make up the controller model to process
  109546. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109547. */
  109548. private processModel;
  109549. private createMeshInfo;
  109550. /**
  109551. * Gets the ray of the controller in the direction the controller is pointing
  109552. * @param length the length the resulting ray should be
  109553. * @returns a ray in the direction the controller is pointing
  109554. */
  109555. getForwardRay(length?: number): Ray;
  109556. /**
  109557. * Disposes of the controller
  109558. */
  109559. dispose(): void;
  109560. }
  109561. }
  109562. declare module BABYLON {
  109563. /**
  109564. * Oculus Touch Controller
  109565. */
  109566. export class OculusTouchController extends WebVRController {
  109567. /**
  109568. * Base Url for the controller model.
  109569. */
  109570. static MODEL_BASE_URL: string;
  109571. /**
  109572. * File name for the left controller model.
  109573. */
  109574. static MODEL_LEFT_FILENAME: string;
  109575. /**
  109576. * File name for the right controller model.
  109577. */
  109578. static MODEL_RIGHT_FILENAME: string;
  109579. /**
  109580. * Base Url for the Quest controller model.
  109581. */
  109582. static QUEST_MODEL_BASE_URL: string;
  109583. /**
  109584. * @hidden
  109585. * If the controllers are running on a device that needs the updated Quest controller models
  109586. */
  109587. static _IsQuest: boolean;
  109588. /**
  109589. * Fired when the secondary trigger on this controller is modified
  109590. */
  109591. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109592. /**
  109593. * Fired when the thumb rest on this controller is modified
  109594. */
  109595. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109596. /**
  109597. * Creates a new OculusTouchController from a gamepad
  109598. * @param vrGamepad the gamepad that the controller should be created from
  109599. */
  109600. constructor(vrGamepad: any);
  109601. /**
  109602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109603. * @param scene scene in which to add meshes
  109604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109605. */
  109606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109607. /**
  109608. * Fired when the A button on this controller is modified
  109609. */
  109610. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109611. /**
  109612. * Fired when the B button on this controller is modified
  109613. */
  109614. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109615. /**
  109616. * Fired when the X button on this controller is modified
  109617. */
  109618. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109619. /**
  109620. * Fired when the Y button on this controller is modified
  109621. */
  109622. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109623. /**
  109624. * Called once for each button that changed state since the last frame
  109625. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109626. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109627. * 2) secondary trigger (same)
  109628. * 3) A (right) X (left), touch, pressed = value
  109629. * 4) B / Y
  109630. * 5) thumb rest
  109631. * @param buttonIdx Which button index changed
  109632. * @param state New state of the button
  109633. * @param changes Which properties on the state changed since last frame
  109634. */
  109635. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109636. }
  109637. }
  109638. declare module BABYLON {
  109639. /**
  109640. * Vive Controller
  109641. */
  109642. export class ViveController extends WebVRController {
  109643. /**
  109644. * Base Url for the controller model.
  109645. */
  109646. static MODEL_BASE_URL: string;
  109647. /**
  109648. * File name for the controller model.
  109649. */
  109650. static MODEL_FILENAME: string;
  109651. /**
  109652. * Creates a new ViveController from a gamepad
  109653. * @param vrGamepad the gamepad that the controller should be created from
  109654. */
  109655. constructor(vrGamepad: any);
  109656. /**
  109657. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109658. * @param scene scene in which to add meshes
  109659. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109660. */
  109661. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109662. /**
  109663. * Fired when the left button on this controller is modified
  109664. */
  109665. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109666. /**
  109667. * Fired when the right button on this controller is modified
  109668. */
  109669. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109670. /**
  109671. * Fired when the menu button on this controller is modified
  109672. */
  109673. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109674. /**
  109675. * Called once for each button that changed state since the last frame
  109676. * Vive mapping:
  109677. * 0: touchpad
  109678. * 1: trigger
  109679. * 2: left AND right buttons
  109680. * 3: menu button
  109681. * @param buttonIdx Which button index changed
  109682. * @param state New state of the button
  109683. * @param changes Which properties on the state changed since last frame
  109684. */
  109685. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109686. }
  109687. }
  109688. declare module BABYLON {
  109689. /**
  109690. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109691. */
  109692. export class WebXRControllerModelLoader {
  109693. /**
  109694. * Creates the WebXRControllerModelLoader
  109695. * @param input xr input that creates the controllers
  109696. */
  109697. constructor(input: WebXRInput);
  109698. }
  109699. }
  109700. declare module BABYLON {
  109701. /**
  109702. * Contains an array of blocks representing the octree
  109703. */
  109704. export interface IOctreeContainer<T> {
  109705. /**
  109706. * Blocks within the octree
  109707. */
  109708. blocks: Array<OctreeBlock<T>>;
  109709. }
  109710. /**
  109711. * Class used to store a cell in an octree
  109712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109713. */
  109714. export class OctreeBlock<T> {
  109715. /**
  109716. * Gets the content of the current block
  109717. */
  109718. entries: T[];
  109719. /**
  109720. * Gets the list of block children
  109721. */
  109722. blocks: Array<OctreeBlock<T>>;
  109723. private _depth;
  109724. private _maxDepth;
  109725. private _capacity;
  109726. private _minPoint;
  109727. private _maxPoint;
  109728. private _boundingVectors;
  109729. private _creationFunc;
  109730. /**
  109731. * Creates a new block
  109732. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109733. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109734. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109735. * @param depth defines the current depth of this block in the octree
  109736. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109737. * @param creationFunc defines a callback to call when an element is added to the block
  109738. */
  109739. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109740. /**
  109741. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109742. */
  109743. readonly capacity: number;
  109744. /**
  109745. * Gets the minimum vector (in world space) of the block's bounding box
  109746. */
  109747. readonly minPoint: Vector3;
  109748. /**
  109749. * Gets the maximum vector (in world space) of the block's bounding box
  109750. */
  109751. readonly maxPoint: Vector3;
  109752. /**
  109753. * Add a new element to this block
  109754. * @param entry defines the element to add
  109755. */
  109756. addEntry(entry: T): void;
  109757. /**
  109758. * Remove an element from this block
  109759. * @param entry defines the element to remove
  109760. */
  109761. removeEntry(entry: T): void;
  109762. /**
  109763. * Add an array of elements to this block
  109764. * @param entries defines the array of elements to add
  109765. */
  109766. addEntries(entries: T[]): void;
  109767. /**
  109768. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109769. * @param frustumPlanes defines the frustum planes to test
  109770. * @param selection defines the array to store current content if selection is positive
  109771. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109772. */
  109773. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109774. /**
  109775. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109776. * @param sphereCenter defines the bounding sphere center
  109777. * @param sphereRadius defines the bounding sphere radius
  109778. * @param selection defines the array to store current content if selection is positive
  109779. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109780. */
  109781. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109782. /**
  109783. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109784. * @param ray defines the ray to test with
  109785. * @param selection defines the array to store current content if selection is positive
  109786. */
  109787. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109788. /**
  109789. * Subdivide the content into child blocks (this block will then be empty)
  109790. */
  109791. createInnerBlocks(): void;
  109792. /**
  109793. * @hidden
  109794. */
  109795. 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;
  109796. }
  109797. }
  109798. declare module BABYLON {
  109799. /**
  109800. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109802. */
  109803. export class Octree<T> {
  109804. /** 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.) */
  109805. maxDepth: number;
  109806. /**
  109807. * Blocks within the octree containing objects
  109808. */
  109809. blocks: Array<OctreeBlock<T>>;
  109810. /**
  109811. * Content stored in the octree
  109812. */
  109813. dynamicContent: T[];
  109814. private _maxBlockCapacity;
  109815. private _selectionContent;
  109816. private _creationFunc;
  109817. /**
  109818. * Creates a octree
  109819. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109820. * @param creationFunc function to be used to instatiate the octree
  109821. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109822. * @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.)
  109823. */
  109824. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109825. /** 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.) */
  109826. maxDepth?: number);
  109827. /**
  109828. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109829. * @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);
  109830. * @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);
  109831. * @param entries meshes to be added to the octree blocks
  109832. */
  109833. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109834. /**
  109835. * Adds a mesh to the octree
  109836. * @param entry Mesh to add to the octree
  109837. */
  109838. addMesh(entry: T): void;
  109839. /**
  109840. * Remove an element from the octree
  109841. * @param entry defines the element to remove
  109842. */
  109843. removeMesh(entry: T): void;
  109844. /**
  109845. * Selects an array of meshes within the frustum
  109846. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109847. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109848. * @returns array of meshes within the frustum
  109849. */
  109850. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109851. /**
  109852. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109853. * @param sphereCenter defines the bounding sphere center
  109854. * @param sphereRadius defines the bounding sphere radius
  109855. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109856. * @returns an array of objects that intersect the sphere
  109857. */
  109858. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109859. /**
  109860. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109861. * @param ray defines the ray to test with
  109862. * @returns array of intersected objects
  109863. */
  109864. intersectsRay(ray: Ray): SmartArray<T>;
  109865. /**
  109866. * Adds a mesh into the octree block if it intersects the block
  109867. */
  109868. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109869. /**
  109870. * Adds a submesh into the octree block if it intersects the block
  109871. */
  109872. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109873. }
  109874. }
  109875. declare module BABYLON {
  109876. interface Scene {
  109877. /**
  109878. * @hidden
  109879. * Backing Filed
  109880. */
  109881. _selectionOctree: Octree<AbstractMesh>;
  109882. /**
  109883. * Gets the octree used to boost mesh selection (picking)
  109884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109885. */
  109886. selectionOctree: Octree<AbstractMesh>;
  109887. /**
  109888. * Creates or updates the octree used to boost selection (picking)
  109889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109890. * @param maxCapacity defines the maximum capacity per leaf
  109891. * @param maxDepth defines the maximum depth of the octree
  109892. * @returns an octree of AbstractMesh
  109893. */
  109894. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109895. }
  109896. interface AbstractMesh {
  109897. /**
  109898. * @hidden
  109899. * Backing Field
  109900. */
  109901. _submeshesOctree: Octree<SubMesh>;
  109902. /**
  109903. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109904. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109905. * @param maxCapacity defines the maximum size of each block (64 by default)
  109906. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109907. * @returns the new octree
  109908. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109909. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109910. */
  109911. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109912. }
  109913. /**
  109914. * Defines the octree scene component responsible to manage any octrees
  109915. * in a given scene.
  109916. */
  109917. export class OctreeSceneComponent {
  109918. /**
  109919. * The component name help to identify the component in the list of scene components.
  109920. */
  109921. readonly name: string;
  109922. /**
  109923. * The scene the component belongs to.
  109924. */
  109925. scene: Scene;
  109926. /**
  109927. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109928. */
  109929. readonly checksIsEnabled: boolean;
  109930. /**
  109931. * Creates a new instance of the component for the given scene
  109932. * @param scene Defines the scene to register the component in
  109933. */
  109934. constructor(scene: Scene);
  109935. /**
  109936. * Registers the component in a given scene
  109937. */
  109938. register(): void;
  109939. /**
  109940. * Return the list of active meshes
  109941. * @returns the list of active meshes
  109942. */
  109943. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109944. /**
  109945. * Return the list of active sub meshes
  109946. * @param mesh The mesh to get the candidates sub meshes from
  109947. * @returns the list of active sub meshes
  109948. */
  109949. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109950. private _tempRay;
  109951. /**
  109952. * Return the list of sub meshes intersecting with a given local ray
  109953. * @param mesh defines the mesh to find the submesh for
  109954. * @param localRay defines the ray in local space
  109955. * @returns the list of intersecting sub meshes
  109956. */
  109957. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109958. /**
  109959. * Return the list of sub meshes colliding with a collider
  109960. * @param mesh defines the mesh to find the submesh for
  109961. * @param collider defines the collider to evaluate the collision against
  109962. * @returns the list of colliding sub meshes
  109963. */
  109964. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109965. /**
  109966. * Rebuilds the elements related to this component in case of
  109967. * context lost for instance.
  109968. */
  109969. rebuild(): void;
  109970. /**
  109971. * Disposes the component and the associated ressources.
  109972. */
  109973. dispose(): void;
  109974. }
  109975. }
  109976. declare module BABYLON {
  109977. /**
  109978. * Renders a layer on top of an existing scene
  109979. */
  109980. export class UtilityLayerRenderer implements IDisposable {
  109981. /** the original scene that will be rendered on top of */
  109982. originalScene: Scene;
  109983. private _pointerCaptures;
  109984. private _lastPointerEvents;
  109985. private static _DefaultUtilityLayer;
  109986. private static _DefaultKeepDepthUtilityLayer;
  109987. private _sharedGizmoLight;
  109988. private _renderCamera;
  109989. /**
  109990. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109991. * @returns the camera that is used when rendering the utility layer
  109992. */
  109993. getRenderCamera(): Nullable<Camera>;
  109994. /**
  109995. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109996. * @param cam the camera that should be used when rendering the utility layer
  109997. */
  109998. setRenderCamera(cam: Nullable<Camera>): void;
  109999. /**
  110000. * @hidden
  110001. * Light which used by gizmos to get light shading
  110002. */
  110003. _getSharedGizmoLight(): HemisphericLight;
  110004. /**
  110005. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110006. */
  110007. pickUtilitySceneFirst: boolean;
  110008. /**
  110009. * 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)
  110010. */
  110011. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110012. /**
  110013. * 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)
  110014. */
  110015. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110016. /**
  110017. * The scene that is rendered on top of the original scene
  110018. */
  110019. utilityLayerScene: Scene;
  110020. /**
  110021. * If the utility layer should automatically be rendered on top of existing scene
  110022. */
  110023. shouldRender: boolean;
  110024. /**
  110025. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110026. */
  110027. onlyCheckPointerDownEvents: boolean;
  110028. /**
  110029. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110030. */
  110031. processAllEvents: boolean;
  110032. /**
  110033. * Observable raised when the pointer move from the utility layer scene to the main scene
  110034. */
  110035. onPointerOutObservable: Observable<number>;
  110036. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110037. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110038. private _afterRenderObserver;
  110039. private _sceneDisposeObserver;
  110040. private _originalPointerObserver;
  110041. /**
  110042. * Instantiates a UtilityLayerRenderer
  110043. * @param originalScene the original scene that will be rendered on top of
  110044. * @param handleEvents boolean indicating if the utility layer should handle events
  110045. */
  110046. constructor(
  110047. /** the original scene that will be rendered on top of */
  110048. originalScene: Scene, handleEvents?: boolean);
  110049. private _notifyObservers;
  110050. /**
  110051. * Renders the utility layers scene on top of the original scene
  110052. */
  110053. render(): void;
  110054. /**
  110055. * Disposes of the renderer
  110056. */
  110057. dispose(): void;
  110058. private _updateCamera;
  110059. }
  110060. }
  110061. declare module BABYLON {
  110062. /**
  110063. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110064. */
  110065. export class Gizmo implements IDisposable {
  110066. /** The utility layer the gizmo will be added to */
  110067. gizmoLayer: UtilityLayerRenderer;
  110068. /**
  110069. * The root mesh of the gizmo
  110070. */
  110071. _rootMesh: Mesh;
  110072. private _attachedMesh;
  110073. /**
  110074. * Ratio for the scale of the gizmo (Default: 1)
  110075. */
  110076. scaleRatio: number;
  110077. /**
  110078. * If a custom mesh has been set (Default: false)
  110079. */
  110080. protected _customMeshSet: boolean;
  110081. /**
  110082. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110083. * * When set, interactions will be enabled
  110084. */
  110085. attachedMesh: Nullable<AbstractMesh>;
  110086. /**
  110087. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110088. * @param mesh The mesh to replace the default mesh of the gizmo
  110089. */
  110090. setCustomMesh(mesh: Mesh): void;
  110091. /**
  110092. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110093. */
  110094. updateGizmoRotationToMatchAttachedMesh: boolean;
  110095. /**
  110096. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110097. */
  110098. updateGizmoPositionToMatchAttachedMesh: boolean;
  110099. /**
  110100. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110101. */
  110102. updateScale: boolean;
  110103. protected _interactionsEnabled: boolean;
  110104. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110105. private _beforeRenderObserver;
  110106. private _tempVector;
  110107. /**
  110108. * Creates a gizmo
  110109. * @param gizmoLayer The utility layer the gizmo will be added to
  110110. */
  110111. constructor(
  110112. /** The utility layer the gizmo will be added to */
  110113. gizmoLayer?: UtilityLayerRenderer);
  110114. /**
  110115. * Updates the gizmo to match the attached mesh's position/rotation
  110116. */
  110117. protected _update(): void;
  110118. /**
  110119. * Disposes of the gizmo
  110120. */
  110121. dispose(): void;
  110122. }
  110123. }
  110124. declare module BABYLON {
  110125. /**
  110126. * Single plane drag gizmo
  110127. */
  110128. export class PlaneDragGizmo extends Gizmo {
  110129. /**
  110130. * Drag behavior responsible for the gizmos dragging interactions
  110131. */
  110132. dragBehavior: PointerDragBehavior;
  110133. private _pointerObserver;
  110134. /**
  110135. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110136. */
  110137. snapDistance: number;
  110138. /**
  110139. * Event that fires each time the gizmo snaps to a new location.
  110140. * * snapDistance is the the change in distance
  110141. */
  110142. onSnapObservable: Observable<{
  110143. snapDistance: number;
  110144. }>;
  110145. private _plane;
  110146. private _coloredMaterial;
  110147. private _hoverMaterial;
  110148. private _isEnabled;
  110149. private _parent;
  110150. /** @hidden */
  110151. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110152. /** @hidden */
  110153. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110154. /**
  110155. * Creates a PlaneDragGizmo
  110156. * @param gizmoLayer The utility layer the gizmo will be added to
  110157. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110158. * @param color The color of the gizmo
  110159. */
  110160. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110162. /**
  110163. * If the gizmo is enabled
  110164. */
  110165. isEnabled: boolean;
  110166. /**
  110167. * Disposes of the gizmo
  110168. */
  110169. dispose(): void;
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /**
  110174. * Gizmo that enables dragging a mesh along 3 axis
  110175. */
  110176. export class PositionGizmo extends Gizmo {
  110177. /**
  110178. * Internal gizmo used for interactions on the x axis
  110179. */
  110180. xGizmo: AxisDragGizmo;
  110181. /**
  110182. * Internal gizmo used for interactions on the y axis
  110183. */
  110184. yGizmo: AxisDragGizmo;
  110185. /**
  110186. * Internal gizmo used for interactions on the z axis
  110187. */
  110188. zGizmo: AxisDragGizmo;
  110189. /**
  110190. * Internal gizmo used for interactions on the yz plane
  110191. */
  110192. xPlaneGizmo: PlaneDragGizmo;
  110193. /**
  110194. * Internal gizmo used for interactions on the xz plane
  110195. */
  110196. yPlaneGizmo: PlaneDragGizmo;
  110197. /**
  110198. * Internal gizmo used for interactions on the xy plane
  110199. */
  110200. zPlaneGizmo: PlaneDragGizmo;
  110201. /**
  110202. * private variables
  110203. */
  110204. private _meshAttached;
  110205. private _updateGizmoRotationToMatchAttachedMesh;
  110206. private _snapDistance;
  110207. private _scaleRatio;
  110208. /** Fires an event when any of it's sub gizmos are dragged */
  110209. onDragStartObservable: Observable<unknown>;
  110210. /** Fires an event when any of it's sub gizmos are released from dragging */
  110211. onDragEndObservable: Observable<unknown>;
  110212. /**
  110213. * If set to true, planar drag is enabled
  110214. */
  110215. private _planarGizmoEnabled;
  110216. attachedMesh: Nullable<AbstractMesh>;
  110217. /**
  110218. * Creates a PositionGizmo
  110219. * @param gizmoLayer The utility layer the gizmo will be added to
  110220. */
  110221. constructor(gizmoLayer?: UtilityLayerRenderer);
  110222. /**
  110223. * If the planar drag gizmo is enabled
  110224. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110225. */
  110226. planarGizmoEnabled: boolean;
  110227. updateGizmoRotationToMatchAttachedMesh: boolean;
  110228. /**
  110229. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110230. */
  110231. snapDistance: number;
  110232. /**
  110233. * Ratio for the scale of the gizmo (Default: 1)
  110234. */
  110235. scaleRatio: number;
  110236. /**
  110237. * Disposes of the gizmo
  110238. */
  110239. dispose(): void;
  110240. /**
  110241. * CustomMeshes are not supported by this gizmo
  110242. * @param mesh The mesh to replace the default mesh of the gizmo
  110243. */
  110244. setCustomMesh(mesh: Mesh): void;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Single axis drag gizmo
  110250. */
  110251. export class AxisDragGizmo extends Gizmo {
  110252. /**
  110253. * Drag behavior responsible for the gizmos dragging interactions
  110254. */
  110255. dragBehavior: PointerDragBehavior;
  110256. private _pointerObserver;
  110257. /**
  110258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110259. */
  110260. snapDistance: number;
  110261. /**
  110262. * Event that fires each time the gizmo snaps to a new location.
  110263. * * snapDistance is the the change in distance
  110264. */
  110265. onSnapObservable: Observable<{
  110266. snapDistance: number;
  110267. }>;
  110268. private _isEnabled;
  110269. private _parent;
  110270. private _arrow;
  110271. private _coloredMaterial;
  110272. private _hoverMaterial;
  110273. /** @hidden */
  110274. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110275. /** @hidden */
  110276. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110277. /**
  110278. * Creates an AxisDragGizmo
  110279. * @param gizmoLayer The utility layer the gizmo will be added to
  110280. * @param dragAxis The axis which the gizmo will be able to drag on
  110281. * @param color The color of the gizmo
  110282. */
  110283. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110284. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110285. /**
  110286. * If the gizmo is enabled
  110287. */
  110288. isEnabled: boolean;
  110289. /**
  110290. * Disposes of the gizmo
  110291. */
  110292. dispose(): void;
  110293. }
  110294. }
  110295. declare module BABYLON.Debug {
  110296. /**
  110297. * The Axes viewer will show 3 axes in a specific point in space
  110298. */
  110299. export class AxesViewer {
  110300. private _xAxis;
  110301. private _yAxis;
  110302. private _zAxis;
  110303. private _scaleLinesFactor;
  110304. private _instanced;
  110305. /**
  110306. * Gets the hosting scene
  110307. */
  110308. scene: Scene;
  110309. /**
  110310. * Gets or sets a number used to scale line length
  110311. */
  110312. scaleLines: number;
  110313. /** Gets the node hierarchy used to render x-axis */
  110314. readonly xAxis: TransformNode;
  110315. /** Gets the node hierarchy used to render y-axis */
  110316. readonly yAxis: TransformNode;
  110317. /** Gets the node hierarchy used to render z-axis */
  110318. readonly zAxis: TransformNode;
  110319. /**
  110320. * Creates a new AxesViewer
  110321. * @param scene defines the hosting scene
  110322. * @param scaleLines defines a number used to scale line length (1 by default)
  110323. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110324. * @param xAxis defines the node hierarchy used to render the x-axis
  110325. * @param yAxis defines the node hierarchy used to render the y-axis
  110326. * @param zAxis defines the node hierarchy used to render the z-axis
  110327. */
  110328. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110329. /**
  110330. * Force the viewer to update
  110331. * @param position defines the position of the viewer
  110332. * @param xaxis defines the x axis of the viewer
  110333. * @param yaxis defines the y axis of the viewer
  110334. * @param zaxis defines the z axis of the viewer
  110335. */
  110336. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110337. /**
  110338. * Creates an instance of this axes viewer.
  110339. * @returns a new axes viewer with instanced meshes
  110340. */
  110341. createInstance(): AxesViewer;
  110342. /** Releases resources */
  110343. dispose(): void;
  110344. private static _SetRenderingGroupId;
  110345. }
  110346. }
  110347. declare module BABYLON.Debug {
  110348. /**
  110349. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110350. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110351. */
  110352. export class BoneAxesViewer extends AxesViewer {
  110353. /**
  110354. * Gets or sets the target mesh where to display the axes viewer
  110355. */
  110356. mesh: Nullable<Mesh>;
  110357. /**
  110358. * Gets or sets the target bone where to display the axes viewer
  110359. */
  110360. bone: Nullable<Bone>;
  110361. /** Gets current position */
  110362. pos: Vector3;
  110363. /** Gets direction of X axis */
  110364. xaxis: Vector3;
  110365. /** Gets direction of Y axis */
  110366. yaxis: Vector3;
  110367. /** Gets direction of Z axis */
  110368. zaxis: Vector3;
  110369. /**
  110370. * Creates a new BoneAxesViewer
  110371. * @param scene defines the hosting scene
  110372. * @param bone defines the target bone
  110373. * @param mesh defines the target mesh
  110374. * @param scaleLines defines a scaling factor for line length (1 by default)
  110375. */
  110376. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110377. /**
  110378. * Force the viewer to update
  110379. */
  110380. update(): void;
  110381. /** Releases resources */
  110382. dispose(): void;
  110383. }
  110384. }
  110385. declare module BABYLON {
  110386. /**
  110387. * Interface used to define scene explorer extensibility option
  110388. */
  110389. export interface IExplorerExtensibilityOption {
  110390. /**
  110391. * Define the option label
  110392. */
  110393. label: string;
  110394. /**
  110395. * Defines the action to execute on click
  110396. */
  110397. action: (entity: any) => void;
  110398. }
  110399. /**
  110400. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  110401. */
  110402. export interface IExplorerExtensibilityGroup {
  110403. /**
  110404. * Defines a predicate to test if a given type mut be extended
  110405. */
  110406. predicate: (entity: any) => boolean;
  110407. /**
  110408. * Gets the list of options added to a type
  110409. */
  110410. entries: IExplorerExtensibilityOption[];
  110411. }
  110412. /**
  110413. * Interface used to define the options to use to create the Inspector
  110414. */
  110415. export interface IInspectorOptions {
  110416. /**
  110417. * Display in overlay mode (default: false)
  110418. */
  110419. overlay?: boolean;
  110420. /**
  110421. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110422. */
  110423. globalRoot?: HTMLElement;
  110424. /**
  110425. * Display the Scene explorer
  110426. */
  110427. showExplorer?: boolean;
  110428. /**
  110429. * Display the property inspector
  110430. */
  110431. showInspector?: boolean;
  110432. /**
  110433. * Display in embed mode (both panes on the right)
  110434. */
  110435. embedMode?: boolean;
  110436. /**
  110437. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110438. */
  110439. handleResize?: boolean;
  110440. /**
  110441. * Allow the panes to popup (default: true)
  110442. */
  110443. enablePopup?: boolean;
  110444. /**
  110445. * Allow the panes to be closed by users (default: true)
  110446. */
  110447. enableClose?: boolean;
  110448. /**
  110449. * Optional list of extensibility entries
  110450. */
  110451. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110452. /**
  110453. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110454. */
  110455. inspectorURL?: string;
  110456. }
  110457. interface Scene {
  110458. /**
  110459. * @hidden
  110460. * Backing field
  110461. */
  110462. _debugLayer: DebugLayer;
  110463. /**
  110464. * Gets the debug layer (aka Inspector) associated with the scene
  110465. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110466. */
  110467. debugLayer: DebugLayer;
  110468. }
  110469. /**
  110470. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110471. * what is happening in your scene
  110472. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110473. */
  110474. export class DebugLayer {
  110475. /**
  110476. * Define the url to get the inspector script from.
  110477. * By default it uses the babylonjs CDN.
  110478. * @ignoreNaming
  110479. */
  110480. static InspectorURL: string;
  110481. private _scene;
  110482. private BJSINSPECTOR;
  110483. private _onPropertyChangedObservable?;
  110484. /**
  110485. * Observable triggered when a property is changed through the inspector.
  110486. */
  110487. readonly onPropertyChangedObservable: any;
  110488. /**
  110489. * Instantiates a new debug layer.
  110490. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110491. * what is happening in your scene
  110492. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110493. * @param scene Defines the scene to inspect
  110494. */
  110495. constructor(scene: Scene);
  110496. /** Creates the inspector window. */
  110497. private _createInspector;
  110498. /**
  110499. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110500. * @param entity defines the entity to select
  110501. * @param lineContainerTitle defines the specific block to highlight
  110502. */
  110503. select(entity: any, lineContainerTitle?: string): void;
  110504. /** Get the inspector from bundle or global */
  110505. private _getGlobalInspector;
  110506. /**
  110507. * Get if the inspector is visible or not.
  110508. * @returns true if visible otherwise, false
  110509. */
  110510. isVisible(): boolean;
  110511. /**
  110512. * Hide the inspector and close its window.
  110513. */
  110514. hide(): void;
  110515. /**
  110516. * Launch the debugLayer.
  110517. * @param config Define the configuration of the inspector
  110518. * @return a promise fulfilled when the debug layer is visible
  110519. */
  110520. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110521. }
  110522. }
  110523. declare module BABYLON {
  110524. /**
  110525. * Class containing static functions to help procedurally build meshes
  110526. */
  110527. export class BoxBuilder {
  110528. /**
  110529. * Creates a box mesh
  110530. * * The parameter `size` sets the size (float) of each box side (default 1)
  110531. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110532. * * 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)
  110533. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110537. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110538. * @param name defines the name of the mesh
  110539. * @param options defines the options used to create the mesh
  110540. * @param scene defines the hosting scene
  110541. * @returns the box mesh
  110542. */
  110543. static CreateBox(name: string, options: {
  110544. size?: number;
  110545. width?: number;
  110546. height?: number;
  110547. depth?: number;
  110548. faceUV?: Vector4[];
  110549. faceColors?: Color4[];
  110550. sideOrientation?: number;
  110551. frontUVs?: Vector4;
  110552. backUVs?: Vector4;
  110553. wrap?: boolean;
  110554. topBaseAt?: number;
  110555. bottomBaseAt?: number;
  110556. updatable?: boolean;
  110557. }, scene?: Nullable<Scene>): Mesh;
  110558. }
  110559. }
  110560. declare module BABYLON {
  110561. /**
  110562. * Class containing static functions to help procedurally build meshes
  110563. */
  110564. export class SphereBuilder {
  110565. /**
  110566. * Creates a sphere mesh
  110567. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110568. * * 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`)
  110569. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110570. * * 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
  110571. * * 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)
  110572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110575. * @param name defines the name of the mesh
  110576. * @param options defines the options used to create the mesh
  110577. * @param scene defines the hosting scene
  110578. * @returns the sphere mesh
  110579. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110580. */
  110581. static CreateSphere(name: string, options: {
  110582. segments?: number;
  110583. diameter?: number;
  110584. diameterX?: number;
  110585. diameterY?: number;
  110586. diameterZ?: number;
  110587. arc?: number;
  110588. slice?: number;
  110589. sideOrientation?: number;
  110590. frontUVs?: Vector4;
  110591. backUVs?: Vector4;
  110592. updatable?: boolean;
  110593. }, scene?: Nullable<Scene>): Mesh;
  110594. }
  110595. }
  110596. declare module BABYLON.Debug {
  110597. /**
  110598. * Used to show the physics impostor around the specific mesh
  110599. */
  110600. export class PhysicsViewer {
  110601. /** @hidden */
  110602. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110603. /** @hidden */
  110604. protected _meshes: Array<Nullable<AbstractMesh>>;
  110605. /** @hidden */
  110606. protected _scene: Nullable<Scene>;
  110607. /** @hidden */
  110608. protected _numMeshes: number;
  110609. /** @hidden */
  110610. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110611. private _renderFunction;
  110612. private _utilityLayer;
  110613. private _debugBoxMesh;
  110614. private _debugSphereMesh;
  110615. private _debugCylinderMesh;
  110616. private _debugMaterial;
  110617. private _debugMeshMeshes;
  110618. /**
  110619. * Creates a new PhysicsViewer
  110620. * @param scene defines the hosting scene
  110621. */
  110622. constructor(scene: Scene);
  110623. /** @hidden */
  110624. protected _updateDebugMeshes(): void;
  110625. /**
  110626. * Renders a specified physic impostor
  110627. * @param impostor defines the impostor to render
  110628. * @param targetMesh defines the mesh represented by the impostor
  110629. * @returns the new debug mesh used to render the impostor
  110630. */
  110631. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110632. /**
  110633. * Hides a specified physic impostor
  110634. * @param impostor defines the impostor to hide
  110635. */
  110636. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110637. private _getDebugMaterial;
  110638. private _getDebugBoxMesh;
  110639. private _getDebugSphereMesh;
  110640. private _getDebugCylinderMesh;
  110641. private _getDebugMeshMesh;
  110642. private _getDebugMesh;
  110643. /** Releases all resources */
  110644. dispose(): void;
  110645. }
  110646. }
  110647. declare module BABYLON {
  110648. /**
  110649. * Class containing static functions to help procedurally build meshes
  110650. */
  110651. export class LinesBuilder {
  110652. /**
  110653. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110654. * * 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
  110655. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110656. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110657. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110658. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110659. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110660. * * 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
  110661. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110664. * @param name defines the name of the new line system
  110665. * @param options defines the options used to create the line system
  110666. * @param scene defines the hosting scene
  110667. * @returns a new line system mesh
  110668. */
  110669. static CreateLineSystem(name: string, options: {
  110670. lines: Vector3[][];
  110671. updatable?: boolean;
  110672. instance?: Nullable<LinesMesh>;
  110673. colors?: Nullable<Color4[][]>;
  110674. useVertexAlpha?: boolean;
  110675. }, scene: Nullable<Scene>): LinesMesh;
  110676. /**
  110677. * Creates a line mesh
  110678. * 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
  110679. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110680. * * The parameter `points` is an array successive Vector3
  110681. * * 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
  110682. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110683. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110684. * * When updating an instance, remember that only point positions can change, not the number of points
  110685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110687. * @param name defines the name of the new line system
  110688. * @param options defines the options used to create the line system
  110689. * @param scene defines the hosting scene
  110690. * @returns a new line mesh
  110691. */
  110692. static CreateLines(name: string, options: {
  110693. points: Vector3[];
  110694. updatable?: boolean;
  110695. instance?: Nullable<LinesMesh>;
  110696. colors?: Color4[];
  110697. useVertexAlpha?: boolean;
  110698. }, scene?: Nullable<Scene>): LinesMesh;
  110699. /**
  110700. * Creates a dashed line mesh
  110701. * * 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
  110702. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110703. * * The parameter `points` is an array successive Vector3
  110704. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110705. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110706. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110707. * * 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
  110708. * * When updating an instance, remember that only point positions can change, not the number of points
  110709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110710. * @param name defines the name of the mesh
  110711. * @param options defines the options used to create the mesh
  110712. * @param scene defines the hosting scene
  110713. * @returns the dashed line mesh
  110714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110715. */
  110716. static CreateDashedLines(name: string, options: {
  110717. points: Vector3[];
  110718. dashSize?: number;
  110719. gapSize?: number;
  110720. dashNb?: number;
  110721. updatable?: boolean;
  110722. instance?: LinesMesh;
  110723. }, scene?: Nullable<Scene>): LinesMesh;
  110724. }
  110725. }
  110726. declare module BABYLON {
  110727. /**
  110728. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110729. * in order to better appreciate the issue one might have.
  110730. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110731. */
  110732. export class RayHelper {
  110733. /**
  110734. * Defines the ray we are currently tryin to visualize.
  110735. */
  110736. ray: Nullable<Ray>;
  110737. private _renderPoints;
  110738. private _renderLine;
  110739. private _renderFunction;
  110740. private _scene;
  110741. private _updateToMeshFunction;
  110742. private _attachedToMesh;
  110743. private _meshSpaceDirection;
  110744. private _meshSpaceOrigin;
  110745. /**
  110746. * Helper function to create a colored helper in a scene in one line.
  110747. * @param ray Defines the ray we are currently tryin to visualize
  110748. * @param scene Defines the scene the ray is used in
  110749. * @param color Defines the color we want to see the ray in
  110750. * @returns The newly created ray helper.
  110751. */
  110752. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110753. /**
  110754. * Instantiate a new ray helper.
  110755. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110756. * in order to better appreciate the issue one might have.
  110757. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110758. * @param ray Defines the ray we are currently tryin to visualize
  110759. */
  110760. constructor(ray: Ray);
  110761. /**
  110762. * Shows the ray we are willing to debug.
  110763. * @param scene Defines the scene the ray needs to be rendered in
  110764. * @param color Defines the color the ray needs to be rendered in
  110765. */
  110766. show(scene: Scene, color?: Color3): void;
  110767. /**
  110768. * Hides the ray we are debugging.
  110769. */
  110770. hide(): void;
  110771. private _render;
  110772. /**
  110773. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110774. * @param mesh Defines the mesh we want the helper attached to
  110775. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110776. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110777. * @param length Defines the length of the ray
  110778. */
  110779. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110780. /**
  110781. * Detach the ray helper from the mesh it has previously been attached to.
  110782. */
  110783. detachFromMesh(): void;
  110784. private _updateToMesh;
  110785. /**
  110786. * Dispose the helper and release its associated resources.
  110787. */
  110788. dispose(): void;
  110789. }
  110790. }
  110791. declare module BABYLON.Debug {
  110792. /**
  110793. * Class used to render a debug view of a given skeleton
  110794. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110795. */
  110796. export class SkeletonViewer {
  110797. /** defines the skeleton to render */
  110798. skeleton: Skeleton;
  110799. /** defines the mesh attached to the skeleton */
  110800. mesh: AbstractMesh;
  110801. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110802. autoUpdateBonesMatrices: boolean;
  110803. /** defines the rendering group id to use with the viewer */
  110804. renderingGroupId: number;
  110805. /** Gets or sets the color used to render the skeleton */
  110806. color: Color3;
  110807. private _scene;
  110808. private _debugLines;
  110809. private _debugMesh;
  110810. private _isEnabled;
  110811. private _renderFunction;
  110812. private _utilityLayer;
  110813. /**
  110814. * Returns the mesh used to render the bones
  110815. */
  110816. readonly debugMesh: Nullable<LinesMesh>;
  110817. /**
  110818. * Creates a new SkeletonViewer
  110819. * @param skeleton defines the skeleton to render
  110820. * @param mesh defines the mesh attached to the skeleton
  110821. * @param scene defines the hosting scene
  110822. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110823. * @param renderingGroupId defines the rendering group id to use with the viewer
  110824. */
  110825. constructor(
  110826. /** defines the skeleton to render */
  110827. skeleton: Skeleton,
  110828. /** defines the mesh attached to the skeleton */
  110829. mesh: AbstractMesh, scene: Scene,
  110830. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110831. autoUpdateBonesMatrices?: boolean,
  110832. /** defines the rendering group id to use with the viewer */
  110833. renderingGroupId?: number);
  110834. /** Gets or sets a boolean indicating if the viewer is enabled */
  110835. isEnabled: boolean;
  110836. private _getBonePosition;
  110837. private _getLinesForBonesWithLength;
  110838. private _getLinesForBonesNoLength;
  110839. /** Update the viewer to sync with current skeleton state */
  110840. update(): void;
  110841. /** Release associated resources */
  110842. dispose(): void;
  110843. }
  110844. }
  110845. declare module BABYLON {
  110846. /**
  110847. * Options to create the null engine
  110848. */
  110849. export class NullEngineOptions {
  110850. /**
  110851. * Render width (Default: 512)
  110852. */
  110853. renderWidth: number;
  110854. /**
  110855. * Render height (Default: 256)
  110856. */
  110857. renderHeight: number;
  110858. /**
  110859. * Texture size (Default: 512)
  110860. */
  110861. textureSize: number;
  110862. /**
  110863. * If delta time between frames should be constant
  110864. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110865. */
  110866. deterministicLockstep: boolean;
  110867. /**
  110868. * Maximum about of steps between frames (Default: 4)
  110869. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110870. */
  110871. lockstepMaxSteps: number;
  110872. }
  110873. /**
  110874. * The null engine class provides support for headless version of babylon.js.
  110875. * This can be used in server side scenario or for testing purposes
  110876. */
  110877. export class NullEngine extends Engine {
  110878. private _options;
  110879. /**
  110880. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110882. * @returns true if engine is in deterministic lock step mode
  110883. */
  110884. isDeterministicLockStep(): boolean;
  110885. /**
  110886. * Gets the max steps when engine is running in deterministic lock step
  110887. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110888. * @returns the max steps
  110889. */
  110890. getLockstepMaxSteps(): number;
  110891. /**
  110892. * Gets the current hardware scaling level.
  110893. * By default the hardware scaling level is computed from the window device ratio.
  110894. * 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.
  110895. * @returns a number indicating the current hardware scaling level
  110896. */
  110897. getHardwareScalingLevel(): number;
  110898. constructor(options?: NullEngineOptions);
  110899. /**
  110900. * Creates a vertex buffer
  110901. * @param vertices the data for the vertex buffer
  110902. * @returns the new WebGL static buffer
  110903. */
  110904. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110905. /**
  110906. * Creates a new index buffer
  110907. * @param indices defines the content of the index buffer
  110908. * @param updatable defines if the index buffer must be updatable
  110909. * @returns a new webGL buffer
  110910. */
  110911. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110912. /**
  110913. * Clear the current render buffer or the current render target (if any is set up)
  110914. * @param color defines the color to use
  110915. * @param backBuffer defines if the back buffer must be cleared
  110916. * @param depth defines if the depth buffer must be cleared
  110917. * @param stencil defines if the stencil buffer must be cleared
  110918. */
  110919. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110920. /**
  110921. * Gets the current render width
  110922. * @param useScreen defines if screen size must be used (or the current render target if any)
  110923. * @returns a number defining the current render width
  110924. */
  110925. getRenderWidth(useScreen?: boolean): number;
  110926. /**
  110927. * Gets the current render height
  110928. * @param useScreen defines if screen size must be used (or the current render target if any)
  110929. * @returns a number defining the current render height
  110930. */
  110931. getRenderHeight(useScreen?: boolean): number;
  110932. /**
  110933. * Set the WebGL's viewport
  110934. * @param viewport defines the viewport element to be used
  110935. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110936. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110937. */
  110938. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110939. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110940. /**
  110941. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110942. * @param pipelineContext defines the pipeline context to use
  110943. * @param uniformsNames defines the list of uniform names
  110944. * @returns an array of webGL uniform locations
  110945. */
  110946. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110947. /**
  110948. * Gets the lsit of active attributes for a given webGL program
  110949. * @param pipelineContext defines the pipeline context to use
  110950. * @param attributesNames defines the list of attribute names to get
  110951. * @returns an array of indices indicating the offset of each attribute
  110952. */
  110953. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110954. /**
  110955. * Binds an effect to the webGL context
  110956. * @param effect defines the effect to bind
  110957. */
  110958. bindSamplers(effect: Effect): void;
  110959. /**
  110960. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110961. * @param effect defines the effect to activate
  110962. */
  110963. enableEffect(effect: Effect): void;
  110964. /**
  110965. * Set various states to the webGL context
  110966. * @param culling defines backface culling state
  110967. * @param zOffset defines the value to apply to zOffset (0 by default)
  110968. * @param force defines if states must be applied even if cache is up to date
  110969. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110970. */
  110971. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110972. /**
  110973. * Set the value of an uniform to an array of int32
  110974. * @param uniform defines the webGL uniform location where to store the value
  110975. * @param array defines the array of int32 to store
  110976. */
  110977. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110978. /**
  110979. * Set the value of an uniform to an array of int32 (stored as vec2)
  110980. * @param uniform defines the webGL uniform location where to store the value
  110981. * @param array defines the array of int32 to store
  110982. */
  110983. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110984. /**
  110985. * Set the value of an uniform to an array of int32 (stored as vec3)
  110986. * @param uniform defines the webGL uniform location where to store the value
  110987. * @param array defines the array of int32 to store
  110988. */
  110989. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110990. /**
  110991. * Set the value of an uniform to an array of int32 (stored as vec4)
  110992. * @param uniform defines the webGL uniform location where to store the value
  110993. * @param array defines the array of int32 to store
  110994. */
  110995. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110996. /**
  110997. * Set the value of an uniform to an array of float32
  110998. * @param uniform defines the webGL uniform location where to store the value
  110999. * @param array defines the array of float32 to store
  111000. */
  111001. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111002. /**
  111003. * Set the value of an uniform to an array of float32 (stored as vec2)
  111004. * @param uniform defines the webGL uniform location where to store the value
  111005. * @param array defines the array of float32 to store
  111006. */
  111007. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111008. /**
  111009. * Set the value of an uniform to an array of float32 (stored as vec3)
  111010. * @param uniform defines the webGL uniform location where to store the value
  111011. * @param array defines the array of float32 to store
  111012. */
  111013. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111014. /**
  111015. * Set the value of an uniform to an array of float32 (stored as vec4)
  111016. * @param uniform defines the webGL uniform location where to store the value
  111017. * @param array defines the array of float32 to store
  111018. */
  111019. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111020. /**
  111021. * Set the value of an uniform to an array of number
  111022. * @param uniform defines the webGL uniform location where to store the value
  111023. * @param array defines the array of number to store
  111024. */
  111025. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111026. /**
  111027. * Set the value of an uniform to an array of number (stored as vec2)
  111028. * @param uniform defines the webGL uniform location where to store the value
  111029. * @param array defines the array of number to store
  111030. */
  111031. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111032. /**
  111033. * Set the value of an uniform to an array of number (stored as vec3)
  111034. * @param uniform defines the webGL uniform location where to store the value
  111035. * @param array defines the array of number to store
  111036. */
  111037. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111038. /**
  111039. * Set the value of an uniform to an array of number (stored as vec4)
  111040. * @param uniform defines the webGL uniform location where to store the value
  111041. * @param array defines the array of number to store
  111042. */
  111043. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111044. /**
  111045. * Set the value of an uniform to an array of float32 (stored as matrices)
  111046. * @param uniform defines the webGL uniform location where to store the value
  111047. * @param matrices defines the array of float32 to store
  111048. */
  111049. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111050. /**
  111051. * Set the value of an uniform to a matrix (3x3)
  111052. * @param uniform defines the webGL uniform location where to store the value
  111053. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111054. */
  111055. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111056. /**
  111057. * Set the value of an uniform to a matrix (2x2)
  111058. * @param uniform defines the webGL uniform location where to store the value
  111059. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111060. */
  111061. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111062. /**
  111063. * Set the value of an uniform to a number (float)
  111064. * @param uniform defines the webGL uniform location where to store the value
  111065. * @param value defines the float number to store
  111066. */
  111067. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111068. /**
  111069. * Set the value of an uniform to a vec2
  111070. * @param uniform defines the webGL uniform location where to store the value
  111071. * @param x defines the 1st component of the value
  111072. * @param y defines the 2nd component of the value
  111073. */
  111074. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111075. /**
  111076. * Set the value of an uniform to a vec3
  111077. * @param uniform defines the webGL uniform location where to store the value
  111078. * @param x defines the 1st component of the value
  111079. * @param y defines the 2nd component of the value
  111080. * @param z defines the 3rd component of the value
  111081. */
  111082. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111083. /**
  111084. * Set the value of an uniform to a boolean
  111085. * @param uniform defines the webGL uniform location where to store the value
  111086. * @param bool defines the boolean to store
  111087. */
  111088. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111089. /**
  111090. * Set the value of an uniform to a vec4
  111091. * @param uniform defines the webGL uniform location where to store the value
  111092. * @param x defines the 1st component of the value
  111093. * @param y defines the 2nd component of the value
  111094. * @param z defines the 3rd component of the value
  111095. * @param w defines the 4th component of the value
  111096. */
  111097. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111098. /**
  111099. * Sets the current alpha mode
  111100. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111101. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111102. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111103. */
  111104. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111105. /**
  111106. * Bind webGl buffers directly to the webGL context
  111107. * @param vertexBuffers defines the vertex buffer to bind
  111108. * @param indexBuffer defines the index buffer to bind
  111109. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111110. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111111. * @param effect defines the effect associated with the vertex buffer
  111112. */
  111113. bindBuffers(vertexBuffers: {
  111114. [key: string]: VertexBuffer;
  111115. }, indexBuffer: DataBuffer, effect: Effect): void;
  111116. /**
  111117. * Force the entire cache to be cleared
  111118. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111119. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111120. */
  111121. wipeCaches(bruteForce?: boolean): void;
  111122. /**
  111123. * Send a draw order
  111124. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111125. * @param indexStart defines the starting index
  111126. * @param indexCount defines the number of index to draw
  111127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111128. */
  111129. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111130. /**
  111131. * Draw a list of indexed primitives
  111132. * @param fillMode defines the primitive to use
  111133. * @param indexStart defines the starting index
  111134. * @param indexCount defines the number of index to draw
  111135. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111136. */
  111137. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111138. /**
  111139. * Draw a list of unindexed primitives
  111140. * @param fillMode defines the primitive to use
  111141. * @param verticesStart defines the index of first vertex to draw
  111142. * @param verticesCount defines the count of vertices to draw
  111143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111144. */
  111145. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111146. /** @hidden */
  111147. _createTexture(): WebGLTexture;
  111148. /** @hidden */
  111149. _releaseTexture(texture: InternalTexture): void;
  111150. /**
  111151. * Usually called from Texture.ts.
  111152. * Passed information to create a WebGLTexture
  111153. * @param urlArg defines a value which contains one of the following:
  111154. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111155. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111156. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111157. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111158. * @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)
  111159. * @param scene needed for loading to the correct scene
  111160. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111161. * @param onLoad optional callback to be called upon successful completion
  111162. * @param onError optional callback to be called upon failure
  111163. * @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
  111164. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111165. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111166. * @param forcedExtension defines the extension to use to pick the right loader
  111167. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111168. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111169. */
  111170. 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;
  111171. /**
  111172. * Creates a new render target texture
  111173. * @param size defines the size of the texture
  111174. * @param options defines the options used to create the texture
  111175. * @returns a new render target texture stored in an InternalTexture
  111176. */
  111177. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111178. /**
  111179. * Update the sampling mode of a given texture
  111180. * @param samplingMode defines the required sampling mode
  111181. * @param texture defines the texture to update
  111182. */
  111183. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111184. /**
  111185. * Binds the frame buffer to the specified texture.
  111186. * @param texture The texture to render to or null for the default canvas
  111187. * @param faceIndex The face of the texture to render to in case of cube texture
  111188. * @param requiredWidth The width of the target to render to
  111189. * @param requiredHeight The height of the target to render to
  111190. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111191. * @param depthStencilTexture The depth stencil texture to use to render
  111192. * @param lodLevel defines le lod level to bind to the frame buffer
  111193. */
  111194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111195. /**
  111196. * Unbind the current render target texture from the webGL context
  111197. * @param texture defines the render target texture to unbind
  111198. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111199. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111200. */
  111201. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111202. /**
  111203. * Creates a dynamic vertex buffer
  111204. * @param vertices the data for the dynamic vertex buffer
  111205. * @returns the new WebGL dynamic buffer
  111206. */
  111207. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111208. /**
  111209. * Update the content of a dynamic texture
  111210. * @param texture defines the texture to update
  111211. * @param canvas defines the canvas containing the source
  111212. * @param invertY defines if data must be stored with Y axis inverted
  111213. * @param premulAlpha defines if alpha is stored as premultiplied
  111214. * @param format defines the format of the data
  111215. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111216. */
  111217. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111218. /**
  111219. * Gets a boolean indicating if all created effects are ready
  111220. * @returns true if all effects are ready
  111221. */
  111222. areAllEffectsReady(): boolean;
  111223. /**
  111224. * @hidden
  111225. * Get the current error code of the webGL context
  111226. * @returns the error code
  111227. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111228. */
  111229. getError(): number;
  111230. /** @hidden */
  111231. _getUnpackAlignement(): number;
  111232. /** @hidden */
  111233. _unpackFlipY(value: boolean): void;
  111234. /**
  111235. * Update a dynamic index buffer
  111236. * @param indexBuffer defines the target index buffer
  111237. * @param indices defines the data to update
  111238. * @param offset defines the offset in the target index buffer where update should start
  111239. */
  111240. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111241. /**
  111242. * Updates a dynamic vertex buffer.
  111243. * @param vertexBuffer the vertex buffer to update
  111244. * @param vertices the data used to update the vertex buffer
  111245. * @param byteOffset the byte offset of the data (optional)
  111246. * @param byteLength the byte length of the data (optional)
  111247. */
  111248. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111249. /** @hidden */
  111250. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111251. /** @hidden */
  111252. _bindTexture(channel: number, texture: InternalTexture): void;
  111253. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111254. /**
  111255. * 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
  111256. */
  111257. releaseEffects(): void;
  111258. displayLoadingUI(): void;
  111259. hideLoadingUI(): void;
  111260. /** @hidden */
  111261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111262. /** @hidden */
  111263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111264. /** @hidden */
  111265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111266. /** @hidden */
  111267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111268. }
  111269. }
  111270. declare module BABYLON {
  111271. /** @hidden */
  111272. export class _OcclusionDataStorage {
  111273. /** @hidden */
  111274. occlusionInternalRetryCounter: number;
  111275. /** @hidden */
  111276. isOcclusionQueryInProgress: boolean;
  111277. /** @hidden */
  111278. isOccluded: boolean;
  111279. /** @hidden */
  111280. occlusionRetryCount: number;
  111281. /** @hidden */
  111282. occlusionType: number;
  111283. /** @hidden */
  111284. occlusionQueryAlgorithmType: number;
  111285. }
  111286. interface Engine {
  111287. /**
  111288. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111289. * @return the new query
  111290. */
  111291. createQuery(): WebGLQuery;
  111292. /**
  111293. * Delete and release a webGL query
  111294. * @param query defines the query to delete
  111295. * @return the current engine
  111296. */
  111297. deleteQuery(query: WebGLQuery): Engine;
  111298. /**
  111299. * Check if a given query has resolved and got its value
  111300. * @param query defines the query to check
  111301. * @returns true if the query got its value
  111302. */
  111303. isQueryResultAvailable(query: WebGLQuery): boolean;
  111304. /**
  111305. * Gets the value of a given query
  111306. * @param query defines the query to check
  111307. * @returns the value of the query
  111308. */
  111309. getQueryResult(query: WebGLQuery): number;
  111310. /**
  111311. * Initiates an occlusion query
  111312. * @param algorithmType defines the algorithm to use
  111313. * @param query defines the query to use
  111314. * @returns the current engine
  111315. * @see http://doc.babylonjs.com/features/occlusionquery
  111316. */
  111317. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111318. /**
  111319. * Ends an occlusion query
  111320. * @see http://doc.babylonjs.com/features/occlusionquery
  111321. * @param algorithmType defines the algorithm to use
  111322. * @returns the current engine
  111323. */
  111324. endOcclusionQuery(algorithmType: number): Engine;
  111325. /**
  111326. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111327. * Please note that only one query can be issued at a time
  111328. * @returns a time token used to track the time span
  111329. */
  111330. startTimeQuery(): Nullable<_TimeToken>;
  111331. /**
  111332. * Ends a time query
  111333. * @param token defines the token used to measure the time span
  111334. * @returns the time spent (in ns)
  111335. */
  111336. endTimeQuery(token: _TimeToken): int;
  111337. /** @hidden */
  111338. _currentNonTimestampToken: Nullable<_TimeToken>;
  111339. /** @hidden */
  111340. _createTimeQuery(): WebGLQuery;
  111341. /** @hidden */
  111342. _deleteTimeQuery(query: WebGLQuery): void;
  111343. /** @hidden */
  111344. _getGlAlgorithmType(algorithmType: number): number;
  111345. /** @hidden */
  111346. _getTimeQueryResult(query: WebGLQuery): any;
  111347. /** @hidden */
  111348. _getTimeQueryAvailability(query: WebGLQuery): any;
  111349. }
  111350. interface AbstractMesh {
  111351. /**
  111352. * Backing filed
  111353. * @hidden
  111354. */
  111355. __occlusionDataStorage: _OcclusionDataStorage;
  111356. /**
  111357. * Access property
  111358. * @hidden
  111359. */
  111360. _occlusionDataStorage: _OcclusionDataStorage;
  111361. /**
  111362. * 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.
  111363. * The default value is -1 which means don't break the query and wait till the result
  111364. * @see http://doc.babylonjs.com/features/occlusionquery
  111365. */
  111366. occlusionRetryCount: number;
  111367. /**
  111368. * 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:
  111369. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111370. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111371. * * 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.
  111372. * @see http://doc.babylonjs.com/features/occlusionquery
  111373. */
  111374. occlusionType: number;
  111375. /**
  111376. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111377. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111378. * * 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.
  111379. * @see http://doc.babylonjs.com/features/occlusionquery
  111380. */
  111381. occlusionQueryAlgorithmType: number;
  111382. /**
  111383. * 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
  111384. * @see http://doc.babylonjs.com/features/occlusionquery
  111385. */
  111386. isOccluded: boolean;
  111387. /**
  111388. * Flag to check the progress status of the query
  111389. * @see http://doc.babylonjs.com/features/occlusionquery
  111390. */
  111391. isOcclusionQueryInProgress: boolean;
  111392. }
  111393. }
  111394. declare module BABYLON {
  111395. /** @hidden */
  111396. export var _forceTransformFeedbackToBundle: boolean;
  111397. interface Engine {
  111398. /**
  111399. * Creates a webGL transform feedback object
  111400. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  111401. * @returns the webGL transform feedback object
  111402. */
  111403. createTransformFeedback(): WebGLTransformFeedback;
  111404. /**
  111405. * Delete a webGL transform feedback object
  111406. * @param value defines the webGL transform feedback object to delete
  111407. */
  111408. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  111409. /**
  111410. * Bind a webGL transform feedback object to the webgl context
  111411. * @param value defines the webGL transform feedback object to bind
  111412. */
  111413. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  111414. /**
  111415. * Begins a transform feedback operation
  111416. * @param usePoints defines if points or triangles must be used
  111417. */
  111418. beginTransformFeedback(usePoints: boolean): void;
  111419. /**
  111420. * Ends a transform feedback operation
  111421. */
  111422. endTransformFeedback(): void;
  111423. /**
  111424. * Specify the varyings to use with transform feedback
  111425. * @param program defines the associated webGL program
  111426. * @param value defines the list of strings representing the varying names
  111427. */
  111428. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111429. /**
  111430. * Bind a webGL buffer for a transform feedback operation
  111431. * @param value defines the webGL buffer to bind
  111432. */
  111433. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111434. }
  111435. }
  111436. declare module BABYLON {
  111437. /**
  111438. * Creation options of the multi render target texture.
  111439. */
  111440. export interface IMultiRenderTargetOptions {
  111441. /**
  111442. * Define if the texture needs to create mip maps after render.
  111443. */
  111444. generateMipMaps?: boolean;
  111445. /**
  111446. * Define the types of all the draw buffers we want to create
  111447. */
  111448. types?: number[];
  111449. /**
  111450. * Define the sampling modes of all the draw buffers we want to create
  111451. */
  111452. samplingModes?: number[];
  111453. /**
  111454. * Define if a depth buffer is required
  111455. */
  111456. generateDepthBuffer?: boolean;
  111457. /**
  111458. * Define if a stencil buffer is required
  111459. */
  111460. generateStencilBuffer?: boolean;
  111461. /**
  111462. * Define if a depth texture is required instead of a depth buffer
  111463. */
  111464. generateDepthTexture?: boolean;
  111465. /**
  111466. * Define the number of desired draw buffers
  111467. */
  111468. textureCount?: number;
  111469. /**
  111470. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111471. */
  111472. doNotChangeAspectRatio?: boolean;
  111473. /**
  111474. * Define the default type of the buffers we are creating
  111475. */
  111476. defaultType?: number;
  111477. }
  111478. /**
  111479. * A multi render target, like a render target provides the ability to render to a texture.
  111480. * Unlike the render target, it can render to several draw buffers in one draw.
  111481. * This is specially interesting in deferred rendering or for any effects requiring more than
  111482. * just one color from a single pass.
  111483. */
  111484. export class MultiRenderTarget extends RenderTargetTexture {
  111485. private _internalTextures;
  111486. private _textures;
  111487. private _multiRenderTargetOptions;
  111488. /**
  111489. * Get if draw buffers are currently supported by the used hardware and browser.
  111490. */
  111491. readonly isSupported: boolean;
  111492. /**
  111493. * Get the list of textures generated by the multi render target.
  111494. */
  111495. readonly textures: Texture[];
  111496. /**
  111497. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111498. */
  111499. readonly depthTexture: Texture;
  111500. /**
  111501. * Set the wrapping mode on U of all the textures we are rendering to.
  111502. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111503. */
  111504. wrapU: number;
  111505. /**
  111506. * Set the wrapping mode on V of all the textures we are rendering to.
  111507. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111508. */
  111509. wrapV: number;
  111510. /**
  111511. * Instantiate a new multi render target texture.
  111512. * A multi render target, like a render target provides the ability to render to a texture.
  111513. * Unlike the render target, it can render to several draw buffers in one draw.
  111514. * This is specially interesting in deferred rendering or for any effects requiring more than
  111515. * just one color from a single pass.
  111516. * @param name Define the name of the texture
  111517. * @param size Define the size of the buffers to render to
  111518. * @param count Define the number of target we are rendering into
  111519. * @param scene Define the scene the texture belongs to
  111520. * @param options Define the options used to create the multi render target
  111521. */
  111522. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111523. /** @hidden */
  111524. _rebuild(): void;
  111525. private _createInternalTextures;
  111526. private _createTextures;
  111527. /**
  111528. * Define the number of samples used if MSAA is enabled.
  111529. */
  111530. samples: number;
  111531. /**
  111532. * Resize all the textures in the multi render target.
  111533. * Be carrefull as it will recreate all the data in the new texture.
  111534. * @param size Define the new size
  111535. */
  111536. resize(size: any): void;
  111537. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111538. /**
  111539. * Dispose the render targets and their associated resources
  111540. */
  111541. dispose(): void;
  111542. /**
  111543. * Release all the underlying texture used as draw buffers.
  111544. */
  111545. releaseInternalTextures(): void;
  111546. }
  111547. }
  111548. declare module BABYLON {
  111549. interface ThinEngine {
  111550. /**
  111551. * Unbind a list of render target textures from the webGL context
  111552. * This is used only when drawBuffer extension or webGL2 are active
  111553. * @param textures defines the render target textures to unbind
  111554. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111555. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111556. */
  111557. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111558. /**
  111559. * Create a multi render target texture
  111560. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111561. * @param size defines the size of the texture
  111562. * @param options defines the creation options
  111563. * @returns the cube texture as an InternalTexture
  111564. */
  111565. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111566. /**
  111567. * Update the sample count for a given multiple render target texture
  111568. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111569. * @param textures defines the textures to update
  111570. * @param samples defines the sample count to set
  111571. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111572. */
  111573. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111574. }
  111575. }
  111576. declare module BABYLON {
  111577. /**
  111578. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111579. */
  111580. export interface CubeMapInfo {
  111581. /**
  111582. * The pixel array for the front face.
  111583. * This is stored in format, left to right, up to down format.
  111584. */
  111585. front: Nullable<ArrayBufferView>;
  111586. /**
  111587. * The pixel array for the back face.
  111588. * This is stored in format, left to right, up to down format.
  111589. */
  111590. back: Nullable<ArrayBufferView>;
  111591. /**
  111592. * The pixel array for the left face.
  111593. * This is stored in format, left to right, up to down format.
  111594. */
  111595. left: Nullable<ArrayBufferView>;
  111596. /**
  111597. * The pixel array for the right face.
  111598. * This is stored in format, left to right, up to down format.
  111599. */
  111600. right: Nullable<ArrayBufferView>;
  111601. /**
  111602. * The pixel array for the up face.
  111603. * This is stored in format, left to right, up to down format.
  111604. */
  111605. up: Nullable<ArrayBufferView>;
  111606. /**
  111607. * The pixel array for the down face.
  111608. * This is stored in format, left to right, up to down format.
  111609. */
  111610. down: Nullable<ArrayBufferView>;
  111611. /**
  111612. * The size of the cubemap stored.
  111613. *
  111614. * Each faces will be size * size pixels.
  111615. */
  111616. size: number;
  111617. /**
  111618. * The format of the texture.
  111619. *
  111620. * RGBA, RGB.
  111621. */
  111622. format: number;
  111623. /**
  111624. * The type of the texture data.
  111625. *
  111626. * UNSIGNED_INT, FLOAT.
  111627. */
  111628. type: number;
  111629. /**
  111630. * Specifies whether the texture is in gamma space.
  111631. */
  111632. gammaSpace: boolean;
  111633. }
  111634. /**
  111635. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111636. */
  111637. export class PanoramaToCubeMapTools {
  111638. private static FACE_FRONT;
  111639. private static FACE_BACK;
  111640. private static FACE_RIGHT;
  111641. private static FACE_LEFT;
  111642. private static FACE_DOWN;
  111643. private static FACE_UP;
  111644. /**
  111645. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111646. *
  111647. * @param float32Array The source data.
  111648. * @param inputWidth The width of the input panorama.
  111649. * @param inputHeight The height of the input panorama.
  111650. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111651. * @return The cubemap data
  111652. */
  111653. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111654. private static CreateCubemapTexture;
  111655. private static CalcProjectionSpherical;
  111656. }
  111657. }
  111658. declare module BABYLON {
  111659. /**
  111660. * Helper class dealing with the extraction of spherical polynomial dataArray
  111661. * from a cube map.
  111662. */
  111663. export class CubeMapToSphericalPolynomialTools {
  111664. private static FileFaces;
  111665. /**
  111666. * Converts a texture to the according Spherical Polynomial data.
  111667. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111668. *
  111669. * @param texture The texture to extract the information from.
  111670. * @return The Spherical Polynomial data.
  111671. */
  111672. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111673. /**
  111674. * Converts a cubemap to the according Spherical Polynomial data.
  111675. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111676. *
  111677. * @param cubeInfo The Cube map to extract the information from.
  111678. * @return The Spherical Polynomial data.
  111679. */
  111680. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. interface BaseTexture {
  111685. /**
  111686. * Get the polynomial representation of the texture data.
  111687. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111688. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111689. */
  111690. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111691. }
  111692. }
  111693. declare module BABYLON {
  111694. /** @hidden */
  111695. export var rgbdEncodePixelShader: {
  111696. name: string;
  111697. shader: string;
  111698. };
  111699. }
  111700. declare module BABYLON {
  111701. /** @hidden */
  111702. export var rgbdDecodePixelShader: {
  111703. name: string;
  111704. shader: string;
  111705. };
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * Raw texture data and descriptor sufficient for WebGL texture upload
  111710. */
  111711. export interface EnvironmentTextureInfo {
  111712. /**
  111713. * Version of the environment map
  111714. */
  111715. version: number;
  111716. /**
  111717. * Width of image
  111718. */
  111719. width: number;
  111720. /**
  111721. * Irradiance information stored in the file.
  111722. */
  111723. irradiance: any;
  111724. /**
  111725. * Specular information stored in the file.
  111726. */
  111727. specular: any;
  111728. }
  111729. /**
  111730. * Defines One Image in the file. It requires only the position in the file
  111731. * as well as the length.
  111732. */
  111733. interface BufferImageData {
  111734. /**
  111735. * Length of the image data.
  111736. */
  111737. length: number;
  111738. /**
  111739. * Position of the data from the null terminator delimiting the end of the JSON.
  111740. */
  111741. position: number;
  111742. }
  111743. /**
  111744. * Defines the specular data enclosed in the file.
  111745. * This corresponds to the version 1 of the data.
  111746. */
  111747. export interface EnvironmentTextureSpecularInfoV1 {
  111748. /**
  111749. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111750. */
  111751. specularDataPosition?: number;
  111752. /**
  111753. * This contains all the images data needed to reconstruct the cubemap.
  111754. */
  111755. mipmaps: Array<BufferImageData>;
  111756. /**
  111757. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111758. */
  111759. lodGenerationScale: number;
  111760. }
  111761. /**
  111762. * Sets of helpers addressing the serialization and deserialization of environment texture
  111763. * stored in a BabylonJS env file.
  111764. * Those files are usually stored as .env files.
  111765. */
  111766. export class EnvironmentTextureTools {
  111767. /**
  111768. * Magic number identifying the env file.
  111769. */
  111770. private static _MagicBytes;
  111771. /**
  111772. * Gets the environment info from an env file.
  111773. * @param data The array buffer containing the .env bytes.
  111774. * @returns the environment file info (the json header) if successfully parsed.
  111775. */
  111776. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111777. /**
  111778. * Creates an environment texture from a loaded cube texture.
  111779. * @param texture defines the cube texture to convert in env file
  111780. * @return a promise containing the environment data if succesfull.
  111781. */
  111782. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111783. /**
  111784. * Creates a JSON representation of the spherical data.
  111785. * @param texture defines the texture containing the polynomials
  111786. * @return the JSON representation of the spherical info
  111787. */
  111788. private static _CreateEnvTextureIrradiance;
  111789. /**
  111790. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111791. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111792. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111793. * @return the views described by info providing access to the underlying buffer
  111794. */
  111795. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111796. /**
  111797. * Uploads the texture info contained in the env file to the GPU.
  111798. * @param texture defines the internal texture to upload to
  111799. * @param arrayBuffer defines the buffer cotaining the data to load
  111800. * @param info defines the texture info retrieved through the GetEnvInfo method
  111801. * @returns a promise
  111802. */
  111803. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111804. private static _OnImageReadyAsync;
  111805. /**
  111806. * Uploads the levels of image data to the GPU.
  111807. * @param texture defines the internal texture to upload to
  111808. * @param imageData defines the array buffer views of image data [mipmap][face]
  111809. * @returns a promise
  111810. */
  111811. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111812. /**
  111813. * Uploads spherical polynomials information to the texture.
  111814. * @param texture defines the texture we are trying to upload the information to
  111815. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111816. */
  111817. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111818. /** @hidden */
  111819. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111820. }
  111821. }
  111822. declare module BABYLON {
  111823. /**
  111824. * Contains position and normal vectors for a vertex
  111825. */
  111826. export class PositionNormalVertex {
  111827. /** the position of the vertex (defaut: 0,0,0) */
  111828. position: Vector3;
  111829. /** the normal of the vertex (defaut: 0,1,0) */
  111830. normal: Vector3;
  111831. /**
  111832. * Creates a PositionNormalVertex
  111833. * @param position the position of the vertex (defaut: 0,0,0)
  111834. * @param normal the normal of the vertex (defaut: 0,1,0)
  111835. */
  111836. constructor(
  111837. /** the position of the vertex (defaut: 0,0,0) */
  111838. position?: Vector3,
  111839. /** the normal of the vertex (defaut: 0,1,0) */
  111840. normal?: Vector3);
  111841. /**
  111842. * Clones the PositionNormalVertex
  111843. * @returns the cloned PositionNormalVertex
  111844. */
  111845. clone(): PositionNormalVertex;
  111846. }
  111847. /**
  111848. * Contains position, normal and uv vectors for a vertex
  111849. */
  111850. export class PositionNormalTextureVertex {
  111851. /** the position of the vertex (defaut: 0,0,0) */
  111852. position: Vector3;
  111853. /** the normal of the vertex (defaut: 0,1,0) */
  111854. normal: Vector3;
  111855. /** the uv of the vertex (default: 0,0) */
  111856. uv: Vector2;
  111857. /**
  111858. * Creates a PositionNormalTextureVertex
  111859. * @param position the position of the vertex (defaut: 0,0,0)
  111860. * @param normal the normal of the vertex (defaut: 0,1,0)
  111861. * @param uv the uv of the vertex (default: 0,0)
  111862. */
  111863. constructor(
  111864. /** the position of the vertex (defaut: 0,0,0) */
  111865. position?: Vector3,
  111866. /** the normal of the vertex (defaut: 0,1,0) */
  111867. normal?: Vector3,
  111868. /** the uv of the vertex (default: 0,0) */
  111869. uv?: Vector2);
  111870. /**
  111871. * Clones the PositionNormalTextureVertex
  111872. * @returns the cloned PositionNormalTextureVertex
  111873. */
  111874. clone(): PositionNormalTextureVertex;
  111875. }
  111876. }
  111877. declare module BABYLON {
  111878. /** @hidden */
  111879. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111880. private _genericAttributeLocation;
  111881. private _varyingLocationCount;
  111882. private _varyingLocationMap;
  111883. private _replacements;
  111884. private _textureCount;
  111885. private _uniforms;
  111886. lineProcessor(line: string): string;
  111887. attributeProcessor(attribute: string): string;
  111888. varyingProcessor(varying: string, isFragment: boolean): string;
  111889. uniformProcessor(uniform: string): string;
  111890. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111891. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111892. }
  111893. }
  111894. declare module BABYLON {
  111895. /**
  111896. * Container for accessors for natively-stored mesh data buffers.
  111897. */
  111898. class NativeDataBuffer extends DataBuffer {
  111899. /**
  111900. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111901. */
  111902. nativeIndexBuffer?: any;
  111903. /**
  111904. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111905. */
  111906. nativeVertexBuffer?: any;
  111907. }
  111908. /** @hidden */
  111909. export class NativeEngine extends Engine {
  111910. private readonly _native;
  111911. getHardwareScalingLevel(): number;
  111912. constructor();
  111913. /**
  111914. * Can be used to override the current requestAnimationFrame requester.
  111915. * @hidden
  111916. */
  111917. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111918. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111919. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111920. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111921. recordVertexArrayObject(vertexBuffers: {
  111922. [key: string]: VertexBuffer;
  111923. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111924. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111925. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111926. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111927. /**
  111928. * Draw a list of indexed primitives
  111929. * @param fillMode defines the primitive to use
  111930. * @param indexStart defines the starting index
  111931. * @param indexCount defines the number of index to draw
  111932. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111933. */
  111934. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111935. /**
  111936. * Draw a list of unindexed primitives
  111937. * @param fillMode defines the primitive to use
  111938. * @param verticesStart defines the index of first vertex to draw
  111939. * @param verticesCount defines the count of vertices to draw
  111940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111941. */
  111942. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111943. createPipelineContext(): IPipelineContext;
  111944. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111945. /** @hidden */
  111946. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111947. /** @hidden */
  111948. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111949. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111951. protected _setProgram(program: WebGLProgram): void;
  111952. _releaseEffect(effect: Effect): void;
  111953. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111954. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111955. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111956. bindSamplers(effect: Effect): void;
  111957. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111958. getRenderWidth(useScreen?: boolean): number;
  111959. getRenderHeight(useScreen?: boolean): number;
  111960. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111961. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111962. /**
  111963. * Set the z offset to apply to current rendering
  111964. * @param value defines the offset to apply
  111965. */
  111966. setZOffset(value: number): void;
  111967. /**
  111968. * Gets the current value of the zOffset
  111969. * @returns the current zOffset state
  111970. */
  111971. getZOffset(): number;
  111972. /**
  111973. * Enable or disable depth buffering
  111974. * @param enable defines the state to set
  111975. */
  111976. setDepthBuffer(enable: boolean): void;
  111977. /**
  111978. * Gets a boolean indicating if depth writing is enabled
  111979. * @returns the current depth writing state
  111980. */
  111981. getDepthWrite(): boolean;
  111982. /**
  111983. * Enable or disable depth writing
  111984. * @param enable defines the state to set
  111985. */
  111986. setDepthWrite(enable: boolean): void;
  111987. /**
  111988. * Enable or disable color writing
  111989. * @param enable defines the state to set
  111990. */
  111991. setColorWrite(enable: boolean): void;
  111992. /**
  111993. * Gets a boolean indicating if color writing is enabled
  111994. * @returns the current color writing state
  111995. */
  111996. getColorWrite(): boolean;
  111997. /**
  111998. * Sets alpha constants used by some alpha blending modes
  111999. * @param r defines the red component
  112000. * @param g defines the green component
  112001. * @param b defines the blue component
  112002. * @param a defines the alpha component
  112003. */
  112004. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112005. /**
  112006. * Sets the current alpha mode
  112007. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112008. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112009. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112010. */
  112011. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112012. /**
  112013. * Gets the current alpha mode
  112014. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112015. * @returns the current alpha mode
  112016. */
  112017. getAlphaMode(): number;
  112018. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112019. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112020. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112021. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112022. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112023. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112024. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112025. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112026. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112027. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112028. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112029. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112030. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112031. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112032. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112033. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112034. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112035. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112036. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112037. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112038. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112039. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112040. wipeCaches(bruteForce?: boolean): void;
  112041. _createTexture(): WebGLTexture;
  112042. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112043. /**
  112044. * Usually called from BABYLON.Texture.ts.
  112045. * Passed information to create a WebGLTexture
  112046. * @param urlArg defines a value which contains one of the following:
  112047. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112048. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112049. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112050. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112051. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112052. * @param scene needed for loading to the correct scene
  112053. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112054. * @param onLoad optional callback to be called upon successful completion
  112055. * @param onError optional callback to be called upon failure
  112056. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112057. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112058. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112059. * @param forcedExtension defines the extension to use to pick the right loader
  112060. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112061. */
  112062. 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;
  112063. /**
  112064. * Creates a cube texture
  112065. * @param rootUrl defines the url where the files to load is located
  112066. * @param scene defines the current scene
  112067. * @param files defines the list of files to load (1 per face)
  112068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112069. * @param onLoad defines an optional callback raised when the texture is loaded
  112070. * @param onError defines an optional callback raised if there is an issue to load the texture
  112071. * @param format defines the format of the data
  112072. * @param forcedExtension defines the extension to use to pick the right loader
  112073. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112074. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112075. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112076. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112077. * @returns the cube texture as an InternalTexture
  112078. */
  112079. 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;
  112080. private _getSamplingFilter;
  112081. private static _GetNativeTextureFormat;
  112082. createRenderTargetTexture(size: number | {
  112083. width: number;
  112084. height: number;
  112085. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112087. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112089. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112090. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112091. /**
  112092. * Updates a dynamic vertex buffer.
  112093. * @param vertexBuffer the vertex buffer to update
  112094. * @param data the data used to update the vertex buffer
  112095. * @param byteOffset the byte offset of the data (optional)
  112096. * @param byteLength the byte length of the data (optional)
  112097. */
  112098. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112099. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112100. private _updateAnisotropicLevel;
  112101. private _getAddressMode;
  112102. /** @hidden */
  112103. _bindTexture(channel: number, texture: InternalTexture): void;
  112104. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112105. releaseEffects(): void;
  112106. /** @hidden */
  112107. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112108. /** @hidden */
  112109. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112110. /** @hidden */
  112111. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112112. /** @hidden */
  112113. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112114. }
  112115. }
  112116. declare module BABYLON {
  112117. /**
  112118. * Gather the list of clipboard event types as constants.
  112119. */
  112120. export class ClipboardEventTypes {
  112121. /**
  112122. * The clipboard event is fired when a copy command is active (pressed).
  112123. */
  112124. static readonly COPY: number;
  112125. /**
  112126. * The clipboard event is fired when a cut command is active (pressed).
  112127. */
  112128. static readonly CUT: number;
  112129. /**
  112130. * The clipboard event is fired when a paste command is active (pressed).
  112131. */
  112132. static readonly PASTE: number;
  112133. }
  112134. /**
  112135. * This class is used to store clipboard related info for the onClipboardObservable event.
  112136. */
  112137. export class ClipboardInfo {
  112138. /**
  112139. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112140. */
  112141. type: number;
  112142. /**
  112143. * Defines the related dom event
  112144. */
  112145. event: ClipboardEvent;
  112146. /**
  112147. *Creates an instance of ClipboardInfo.
  112148. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112149. * @param event Defines the related dom event
  112150. */
  112151. constructor(
  112152. /**
  112153. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112154. */
  112155. type: number,
  112156. /**
  112157. * Defines the related dom event
  112158. */
  112159. event: ClipboardEvent);
  112160. /**
  112161. * Get the clipboard event's type from the keycode.
  112162. * @param keyCode Defines the keyCode for the current keyboard event.
  112163. * @return {number}
  112164. */
  112165. static GetTypeFromCharacter(keyCode: number): number;
  112166. }
  112167. }
  112168. declare module BABYLON {
  112169. /**
  112170. * Google Daydream controller
  112171. */
  112172. export class DaydreamController extends WebVRController {
  112173. /**
  112174. * Base Url for the controller model.
  112175. */
  112176. static MODEL_BASE_URL: string;
  112177. /**
  112178. * File name for the controller model.
  112179. */
  112180. static MODEL_FILENAME: string;
  112181. /**
  112182. * Gamepad Id prefix used to identify Daydream Controller.
  112183. */
  112184. static readonly GAMEPAD_ID_PREFIX: string;
  112185. /**
  112186. * Creates a new DaydreamController from a gamepad
  112187. * @param vrGamepad the gamepad that the controller should be created from
  112188. */
  112189. constructor(vrGamepad: any);
  112190. /**
  112191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112192. * @param scene scene in which to add meshes
  112193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112194. */
  112195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112196. /**
  112197. * Called once for each button that changed state since the last frame
  112198. * @param buttonIdx Which button index changed
  112199. * @param state New state of the button
  112200. * @param changes Which properties on the state changed since last frame
  112201. */
  112202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112203. }
  112204. }
  112205. declare module BABYLON {
  112206. /**
  112207. * Gear VR Controller
  112208. */
  112209. export class GearVRController extends WebVRController {
  112210. /**
  112211. * Base Url for the controller model.
  112212. */
  112213. static MODEL_BASE_URL: string;
  112214. /**
  112215. * File name for the controller model.
  112216. */
  112217. static MODEL_FILENAME: string;
  112218. /**
  112219. * Gamepad Id prefix used to identify this controller.
  112220. */
  112221. static readonly GAMEPAD_ID_PREFIX: string;
  112222. private readonly _buttonIndexToObservableNameMap;
  112223. /**
  112224. * Creates a new GearVRController from a gamepad
  112225. * @param vrGamepad the gamepad that the controller should be created from
  112226. */
  112227. constructor(vrGamepad: any);
  112228. /**
  112229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112230. * @param scene scene in which to add meshes
  112231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112232. */
  112233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112234. /**
  112235. * Called once for each button that changed state since the last frame
  112236. * @param buttonIdx Which button index changed
  112237. * @param state New state of the button
  112238. * @param changes Which properties on the state changed since last frame
  112239. */
  112240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112241. }
  112242. }
  112243. declare module BABYLON {
  112244. /**
  112245. * Class containing static functions to help procedurally build meshes
  112246. */
  112247. export class PolyhedronBuilder {
  112248. /**
  112249. * Creates a polyhedron mesh
  112250. * * 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
  112251. * * The parameter `size` (positive float, default 1) sets the polygon size
  112252. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112253. * * 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`
  112254. * * 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
  112255. * * 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)`)
  112256. * * 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
  112257. * * 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
  112258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112261. * @param name defines the name of the mesh
  112262. * @param options defines the options used to create the mesh
  112263. * @param scene defines the hosting scene
  112264. * @returns the polyhedron mesh
  112265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112266. */
  112267. static CreatePolyhedron(name: string, options: {
  112268. type?: number;
  112269. size?: number;
  112270. sizeX?: number;
  112271. sizeY?: number;
  112272. sizeZ?: number;
  112273. custom?: any;
  112274. faceUV?: Vector4[];
  112275. faceColors?: Color4[];
  112276. flat?: boolean;
  112277. updatable?: boolean;
  112278. sideOrientation?: number;
  112279. frontUVs?: Vector4;
  112280. backUVs?: Vector4;
  112281. }, scene?: Nullable<Scene>): Mesh;
  112282. }
  112283. }
  112284. declare module BABYLON {
  112285. /**
  112286. * Gizmo that enables scaling a mesh along 3 axis
  112287. */
  112288. export class ScaleGizmo extends Gizmo {
  112289. /**
  112290. * Internal gizmo used for interactions on the x axis
  112291. */
  112292. xGizmo: AxisScaleGizmo;
  112293. /**
  112294. * Internal gizmo used for interactions on the y axis
  112295. */
  112296. yGizmo: AxisScaleGizmo;
  112297. /**
  112298. * Internal gizmo used for interactions on the z axis
  112299. */
  112300. zGizmo: AxisScaleGizmo;
  112301. /**
  112302. * Internal gizmo used to scale all axis equally
  112303. */
  112304. uniformScaleGizmo: AxisScaleGizmo;
  112305. private _meshAttached;
  112306. private _updateGizmoRotationToMatchAttachedMesh;
  112307. private _snapDistance;
  112308. private _scaleRatio;
  112309. private _uniformScalingMesh;
  112310. private _octahedron;
  112311. /** Fires an event when any of it's sub gizmos are dragged */
  112312. onDragStartObservable: Observable<unknown>;
  112313. /** Fires an event when any of it's sub gizmos are released from dragging */
  112314. onDragEndObservable: Observable<unknown>;
  112315. attachedMesh: Nullable<AbstractMesh>;
  112316. /**
  112317. * Creates a ScaleGizmo
  112318. * @param gizmoLayer The utility layer the gizmo will be added to
  112319. */
  112320. constructor(gizmoLayer?: UtilityLayerRenderer);
  112321. updateGizmoRotationToMatchAttachedMesh: boolean;
  112322. /**
  112323. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112324. */
  112325. snapDistance: number;
  112326. /**
  112327. * Ratio for the scale of the gizmo (Default: 1)
  112328. */
  112329. scaleRatio: number;
  112330. /**
  112331. * Disposes of the gizmo
  112332. */
  112333. dispose(): void;
  112334. }
  112335. }
  112336. declare module BABYLON {
  112337. /**
  112338. * Single axis scale gizmo
  112339. */
  112340. export class AxisScaleGizmo extends Gizmo {
  112341. /**
  112342. * Drag behavior responsible for the gizmos dragging interactions
  112343. */
  112344. dragBehavior: PointerDragBehavior;
  112345. private _pointerObserver;
  112346. /**
  112347. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112348. */
  112349. snapDistance: number;
  112350. /**
  112351. * Event that fires each time the gizmo snaps to a new location.
  112352. * * snapDistance is the the change in distance
  112353. */
  112354. onSnapObservable: Observable<{
  112355. snapDistance: number;
  112356. }>;
  112357. /**
  112358. * If the scaling operation should be done on all axis (default: false)
  112359. */
  112360. uniformScaling: boolean;
  112361. private _isEnabled;
  112362. private _parent;
  112363. private _arrow;
  112364. private _coloredMaterial;
  112365. private _hoverMaterial;
  112366. /**
  112367. * Creates an AxisScaleGizmo
  112368. * @param gizmoLayer The utility layer the gizmo will be added to
  112369. * @param dragAxis The axis which the gizmo will be able to scale on
  112370. * @param color The color of the gizmo
  112371. */
  112372. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  112373. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112374. /**
  112375. * If the gizmo is enabled
  112376. */
  112377. isEnabled: boolean;
  112378. /**
  112379. * Disposes of the gizmo
  112380. */
  112381. dispose(): void;
  112382. /**
  112383. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112384. * @param mesh The mesh to replace the default mesh of the gizmo
  112385. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  112386. */
  112387. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  112388. }
  112389. }
  112390. declare module BABYLON {
  112391. /**
  112392. * Bounding box gizmo
  112393. */
  112394. export class BoundingBoxGizmo extends Gizmo {
  112395. private _lineBoundingBox;
  112396. private _rotateSpheresParent;
  112397. private _scaleBoxesParent;
  112398. private _boundingDimensions;
  112399. private _renderObserver;
  112400. private _pointerObserver;
  112401. private _scaleDragSpeed;
  112402. private _tmpQuaternion;
  112403. private _tmpVector;
  112404. private _tmpRotationMatrix;
  112405. /**
  112406. * 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)
  112407. */
  112408. ignoreChildren: boolean;
  112409. /**
  112410. * 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)
  112411. */
  112412. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  112413. /**
  112414. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  112415. */
  112416. rotationSphereSize: number;
  112417. /**
  112418. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  112419. */
  112420. scaleBoxSize: number;
  112421. /**
  112422. * 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)
  112423. */
  112424. fixedDragMeshScreenSize: boolean;
  112425. /**
  112426. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  112427. */
  112428. fixedDragMeshScreenSizeDistanceFactor: number;
  112429. /**
  112430. * Fired when a rotation sphere or scale box is dragged
  112431. */
  112432. onDragStartObservable: Observable<{}>;
  112433. /**
  112434. * Fired when a scale box is dragged
  112435. */
  112436. onScaleBoxDragObservable: Observable<{}>;
  112437. /**
  112438. * Fired when a scale box drag is ended
  112439. */
  112440. onScaleBoxDragEndObservable: Observable<{}>;
  112441. /**
  112442. * Fired when a rotation sphere is dragged
  112443. */
  112444. onRotationSphereDragObservable: Observable<{}>;
  112445. /**
  112446. * Fired when a rotation sphere drag is ended
  112447. */
  112448. onRotationSphereDragEndObservable: Observable<{}>;
  112449. /**
  112450. * 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)
  112451. */
  112452. scalePivot: Nullable<Vector3>;
  112453. /**
  112454. * Mesh used as a pivot to rotate the attached mesh
  112455. */
  112456. private _anchorMesh;
  112457. private _existingMeshScale;
  112458. private _dragMesh;
  112459. private pointerDragBehavior;
  112460. private coloredMaterial;
  112461. private hoverColoredMaterial;
  112462. /**
  112463. * Sets the color of the bounding box gizmo
  112464. * @param color the color to set
  112465. */
  112466. setColor(color: Color3): void;
  112467. /**
  112468. * Creates an BoundingBoxGizmo
  112469. * @param gizmoLayer The utility layer the gizmo will be added to
  112470. * @param color The color of the gizmo
  112471. */
  112472. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112473. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112474. private _selectNode;
  112475. /**
  112476. * Updates the bounding box information for the Gizmo
  112477. */
  112478. updateBoundingBox(): void;
  112479. private _updateRotationSpheres;
  112480. private _updateScaleBoxes;
  112481. /**
  112482. * Enables rotation on the specified axis and disables rotation on the others
  112483. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112484. */
  112485. setEnabledRotationAxis(axis: string): void;
  112486. /**
  112487. * Enables/disables scaling
  112488. * @param enable if scaling should be enabled
  112489. */
  112490. setEnabledScaling(enable: boolean): void;
  112491. private _updateDummy;
  112492. /**
  112493. * Enables a pointer drag behavior on the bounding box of the gizmo
  112494. */
  112495. enableDragBehavior(): void;
  112496. /**
  112497. * Disposes of the gizmo
  112498. */
  112499. dispose(): void;
  112500. /**
  112501. * 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)
  112502. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112503. * @returns the bounding box mesh with the passed in mesh as a child
  112504. */
  112505. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112506. /**
  112507. * CustomMeshes are not supported by this gizmo
  112508. * @param mesh The mesh to replace the default mesh of the gizmo
  112509. */
  112510. setCustomMesh(mesh: Mesh): void;
  112511. }
  112512. }
  112513. declare module BABYLON {
  112514. /**
  112515. * Single plane rotation gizmo
  112516. */
  112517. export class PlaneRotationGizmo extends Gizmo {
  112518. /**
  112519. * Drag behavior responsible for the gizmos dragging interactions
  112520. */
  112521. dragBehavior: PointerDragBehavior;
  112522. private _pointerObserver;
  112523. /**
  112524. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112525. */
  112526. snapDistance: number;
  112527. /**
  112528. * Event that fires each time the gizmo snaps to a new location.
  112529. * * snapDistance is the the change in distance
  112530. */
  112531. onSnapObservable: Observable<{
  112532. snapDistance: number;
  112533. }>;
  112534. private _isEnabled;
  112535. private _parent;
  112536. /**
  112537. * Creates a PlaneRotationGizmo
  112538. * @param gizmoLayer The utility layer the gizmo will be added to
  112539. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112540. * @param color The color of the gizmo
  112541. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112542. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112543. */
  112544. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112545. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112546. /**
  112547. * If the gizmo is enabled
  112548. */
  112549. isEnabled: boolean;
  112550. /**
  112551. * Disposes of the gizmo
  112552. */
  112553. dispose(): void;
  112554. }
  112555. }
  112556. declare module BABYLON {
  112557. /**
  112558. * Gizmo that enables rotating a mesh along 3 axis
  112559. */
  112560. export class RotationGizmo extends Gizmo {
  112561. /**
  112562. * Internal gizmo used for interactions on the x axis
  112563. */
  112564. xGizmo: PlaneRotationGizmo;
  112565. /**
  112566. * Internal gizmo used for interactions on the y axis
  112567. */
  112568. yGizmo: PlaneRotationGizmo;
  112569. /**
  112570. * Internal gizmo used for interactions on the z axis
  112571. */
  112572. zGizmo: PlaneRotationGizmo;
  112573. /** Fires an event when any of it's sub gizmos are dragged */
  112574. onDragStartObservable: Observable<unknown>;
  112575. /** Fires an event when any of it's sub gizmos are released from dragging */
  112576. onDragEndObservable: Observable<unknown>;
  112577. private _meshAttached;
  112578. attachedMesh: Nullable<AbstractMesh>;
  112579. /**
  112580. * Creates a RotationGizmo
  112581. * @param gizmoLayer The utility layer the gizmo will be added to
  112582. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112583. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112584. */
  112585. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112586. updateGizmoRotationToMatchAttachedMesh: boolean;
  112587. /**
  112588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112589. */
  112590. snapDistance: number;
  112591. /**
  112592. * Ratio for the scale of the gizmo (Default: 1)
  112593. */
  112594. scaleRatio: number;
  112595. /**
  112596. * Disposes of the gizmo
  112597. */
  112598. dispose(): void;
  112599. /**
  112600. * CustomMeshes are not supported by this gizmo
  112601. * @param mesh The mesh to replace the default mesh of the gizmo
  112602. */
  112603. setCustomMesh(mesh: Mesh): void;
  112604. }
  112605. }
  112606. declare module BABYLON {
  112607. /**
  112608. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112609. */
  112610. export class GizmoManager implements IDisposable {
  112611. private scene;
  112612. /**
  112613. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112614. */
  112615. gizmos: {
  112616. positionGizmo: Nullable<PositionGizmo>;
  112617. rotationGizmo: Nullable<RotationGizmo>;
  112618. scaleGizmo: Nullable<ScaleGizmo>;
  112619. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112620. };
  112621. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112622. clearGizmoOnEmptyPointerEvent: boolean;
  112623. /** Fires an event when the manager is attached to a mesh */
  112624. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112625. private _gizmosEnabled;
  112626. private _pointerObserver;
  112627. private _attachedMesh;
  112628. private _boundingBoxColor;
  112629. private _defaultUtilityLayer;
  112630. private _defaultKeepDepthUtilityLayer;
  112631. /**
  112632. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112633. */
  112634. boundingBoxDragBehavior: SixDofDragBehavior;
  112635. /**
  112636. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112637. */
  112638. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112639. /**
  112640. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112641. */
  112642. usePointerToAttachGizmos: boolean;
  112643. /**
  112644. * Utility layer that the bounding box gizmo belongs to
  112645. */
  112646. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112647. /**
  112648. * Utility layer that all gizmos besides bounding box belong to
  112649. */
  112650. readonly utilityLayer: UtilityLayerRenderer;
  112651. /**
  112652. * Instatiates a gizmo manager
  112653. * @param scene the scene to overlay the gizmos on top of
  112654. */
  112655. constructor(scene: Scene);
  112656. /**
  112657. * Attaches a set of gizmos to the specified mesh
  112658. * @param mesh The mesh the gizmo's should be attached to
  112659. */
  112660. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112661. /**
  112662. * If the position gizmo is enabled
  112663. */
  112664. positionGizmoEnabled: boolean;
  112665. /**
  112666. * If the rotation gizmo is enabled
  112667. */
  112668. rotationGizmoEnabled: boolean;
  112669. /**
  112670. * If the scale gizmo is enabled
  112671. */
  112672. scaleGizmoEnabled: boolean;
  112673. /**
  112674. * If the boundingBox gizmo is enabled
  112675. */
  112676. boundingBoxGizmoEnabled: boolean;
  112677. /**
  112678. * Disposes of the gizmo manager
  112679. */
  112680. dispose(): void;
  112681. }
  112682. }
  112683. declare module BABYLON {
  112684. /**
  112685. * A directional light is defined by a direction (what a surprise!).
  112686. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112687. * 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.
  112688. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112689. */
  112690. export class DirectionalLight extends ShadowLight {
  112691. private _shadowFrustumSize;
  112692. /**
  112693. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112694. */
  112695. /**
  112696. * Specifies a fix frustum size for the shadow generation.
  112697. */
  112698. shadowFrustumSize: number;
  112699. private _shadowOrthoScale;
  112700. /**
  112701. * Gets the shadow projection scale against the optimal computed one.
  112702. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112703. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112704. */
  112705. /**
  112706. * Sets the shadow projection scale against the optimal computed one.
  112707. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112708. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112709. */
  112710. shadowOrthoScale: number;
  112711. /**
  112712. * Automatically compute the projection matrix to best fit (including all the casters)
  112713. * on each frame.
  112714. */
  112715. autoUpdateExtends: boolean;
  112716. private _orthoLeft;
  112717. private _orthoRight;
  112718. private _orthoTop;
  112719. private _orthoBottom;
  112720. /**
  112721. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112722. * The directional light is emitted from everywhere in the given direction.
  112723. * It can cast shadows.
  112724. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112725. * @param name The friendly name of the light
  112726. * @param direction The direction of the light
  112727. * @param scene The scene the light belongs to
  112728. */
  112729. constructor(name: string, direction: Vector3, scene: Scene);
  112730. /**
  112731. * Returns the string "DirectionalLight".
  112732. * @return The class name
  112733. */
  112734. getClassName(): string;
  112735. /**
  112736. * Returns the integer 1.
  112737. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112738. */
  112739. getTypeID(): number;
  112740. /**
  112741. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112742. * Returns the DirectionalLight Shadow projection matrix.
  112743. */
  112744. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112745. /**
  112746. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112747. * Returns the DirectionalLight Shadow projection matrix.
  112748. */
  112749. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112750. /**
  112751. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112752. * Returns the DirectionalLight Shadow projection matrix.
  112753. */
  112754. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112755. protected _buildUniformLayout(): void;
  112756. /**
  112757. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112758. * @param effect The effect to update
  112759. * @param lightIndex The index of the light in the effect to update
  112760. * @returns The directional light
  112761. */
  112762. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112763. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112764. /**
  112765. * Gets the minZ used for shadow according to both the scene and the light.
  112766. *
  112767. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112768. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112769. * @param activeCamera The camera we are returning the min for
  112770. * @returns the depth min z
  112771. */
  112772. getDepthMinZ(activeCamera: Camera): number;
  112773. /**
  112774. * Gets the maxZ used for shadow according to both the scene and the light.
  112775. *
  112776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112778. * @param activeCamera The camera we are returning the max for
  112779. * @returns the depth max z
  112780. */
  112781. getDepthMaxZ(activeCamera: Camera): number;
  112782. /**
  112783. * Prepares the list of defines specific to the light type.
  112784. * @param defines the list of defines
  112785. * @param lightIndex defines the index of the light for the effect
  112786. */
  112787. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112788. }
  112789. }
  112790. declare module BABYLON {
  112791. /**
  112792. * Class containing static functions to help procedurally build meshes
  112793. */
  112794. export class HemisphereBuilder {
  112795. /**
  112796. * Creates a hemisphere mesh
  112797. * @param name defines the name of the mesh
  112798. * @param options defines the options used to create the mesh
  112799. * @param scene defines the hosting scene
  112800. * @returns the hemisphere mesh
  112801. */
  112802. static CreateHemisphere(name: string, options: {
  112803. segments?: number;
  112804. diameter?: number;
  112805. sideOrientation?: number;
  112806. }, scene: any): Mesh;
  112807. }
  112808. }
  112809. declare module BABYLON {
  112810. /**
  112811. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112812. * These values define a cone of light starting from the position, emitting toward the direction.
  112813. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112814. * and the exponent defines the speed of the decay of the light with distance (reach).
  112815. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112816. */
  112817. export class SpotLight extends ShadowLight {
  112818. private _angle;
  112819. private _innerAngle;
  112820. private _cosHalfAngle;
  112821. private _lightAngleScale;
  112822. private _lightAngleOffset;
  112823. /**
  112824. * Gets the cone angle of the spot light in Radians.
  112825. */
  112826. /**
  112827. * Sets the cone angle of the spot light in Radians.
  112828. */
  112829. angle: number;
  112830. /**
  112831. * Only used in gltf falloff mode, this defines the angle where
  112832. * the directional falloff will start before cutting at angle which could be seen
  112833. * as outer angle.
  112834. */
  112835. /**
  112836. * Only used in gltf falloff mode, this defines the angle where
  112837. * the directional falloff will start before cutting at angle which could be seen
  112838. * as outer angle.
  112839. */
  112840. innerAngle: number;
  112841. private _shadowAngleScale;
  112842. /**
  112843. * Allows scaling the angle of the light for shadow generation only.
  112844. */
  112845. /**
  112846. * Allows scaling the angle of the light for shadow generation only.
  112847. */
  112848. shadowAngleScale: number;
  112849. /**
  112850. * The light decay speed with the distance from the emission spot.
  112851. */
  112852. exponent: number;
  112853. private _projectionTextureMatrix;
  112854. /**
  112855. * Allows reading the projecton texture
  112856. */
  112857. readonly projectionTextureMatrix: Matrix;
  112858. protected _projectionTextureLightNear: number;
  112859. /**
  112860. * Gets the near clip of the Spotlight for texture projection.
  112861. */
  112862. /**
  112863. * Sets the near clip of the Spotlight for texture projection.
  112864. */
  112865. projectionTextureLightNear: number;
  112866. protected _projectionTextureLightFar: number;
  112867. /**
  112868. * Gets the far clip of the Spotlight for texture projection.
  112869. */
  112870. /**
  112871. * Sets the far clip of the Spotlight for texture projection.
  112872. */
  112873. projectionTextureLightFar: number;
  112874. protected _projectionTextureUpDirection: Vector3;
  112875. /**
  112876. * Gets the Up vector of the Spotlight for texture projection.
  112877. */
  112878. /**
  112879. * Sets the Up vector of the Spotlight for texture projection.
  112880. */
  112881. projectionTextureUpDirection: Vector3;
  112882. private _projectionTexture;
  112883. /**
  112884. * Gets the projection texture of the light.
  112885. */
  112886. /**
  112887. * Sets the projection texture of the light.
  112888. */
  112889. projectionTexture: Nullable<BaseTexture>;
  112890. private _projectionTextureViewLightDirty;
  112891. private _projectionTextureProjectionLightDirty;
  112892. private _projectionTextureDirty;
  112893. private _projectionTextureViewTargetVector;
  112894. private _projectionTextureViewLightMatrix;
  112895. private _projectionTextureProjectionLightMatrix;
  112896. private _projectionTextureScalingMatrix;
  112897. /**
  112898. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112899. * It can cast shadows.
  112900. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112901. * @param name The light friendly name
  112902. * @param position The position of the spot light in the scene
  112903. * @param direction The direction of the light in the scene
  112904. * @param angle The cone angle of the light in Radians
  112905. * @param exponent The light decay speed with the distance from the emission spot
  112906. * @param scene The scene the lights belongs to
  112907. */
  112908. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112909. /**
  112910. * Returns the string "SpotLight".
  112911. * @returns the class name
  112912. */
  112913. getClassName(): string;
  112914. /**
  112915. * Returns the integer 2.
  112916. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112917. */
  112918. getTypeID(): number;
  112919. /**
  112920. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112921. */
  112922. protected _setDirection(value: Vector3): void;
  112923. /**
  112924. * Overrides the position setter to recompute the projection texture view light Matrix.
  112925. */
  112926. protected _setPosition(value: Vector3): void;
  112927. /**
  112928. * 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.
  112929. * Returns the SpotLight.
  112930. */
  112931. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112932. protected _computeProjectionTextureViewLightMatrix(): void;
  112933. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112934. /**
  112935. * Main function for light texture projection matrix computing.
  112936. */
  112937. protected _computeProjectionTextureMatrix(): void;
  112938. protected _buildUniformLayout(): void;
  112939. private _computeAngleValues;
  112940. /**
  112941. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112942. * @param effect The effect to update
  112943. * @param lightIndex The index of the light in the effect to update
  112944. * @returns The spot light
  112945. */
  112946. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112947. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112948. /**
  112949. * Disposes the light and the associated resources.
  112950. */
  112951. dispose(): void;
  112952. /**
  112953. * Prepares the list of defines specific to the light type.
  112954. * @param defines the list of defines
  112955. * @param lightIndex defines the index of the light for the effect
  112956. */
  112957. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112958. }
  112959. }
  112960. declare module BABYLON {
  112961. /**
  112962. * Gizmo that enables viewing a light
  112963. */
  112964. export class LightGizmo extends Gizmo {
  112965. private _lightMesh;
  112966. private _material;
  112967. private cachedPosition;
  112968. private cachedForward;
  112969. /**
  112970. * Creates a LightGizmo
  112971. * @param gizmoLayer The utility layer the gizmo will be added to
  112972. */
  112973. constructor(gizmoLayer?: UtilityLayerRenderer);
  112974. private _light;
  112975. /**
  112976. * The light that the gizmo is attached to
  112977. */
  112978. light: Nullable<Light>;
  112979. /**
  112980. * Gets the material used to render the light gizmo
  112981. */
  112982. readonly material: StandardMaterial;
  112983. /**
  112984. * @hidden
  112985. * Updates the gizmo to match the attached mesh's position/rotation
  112986. */
  112987. protected _update(): void;
  112988. private static _Scale;
  112989. /**
  112990. * Creates the lines for a light mesh
  112991. */
  112992. private static _createLightLines;
  112993. /**
  112994. * Disposes of the light gizmo
  112995. */
  112996. dispose(): void;
  112997. private static _CreateHemisphericLightMesh;
  112998. private static _CreatePointLightMesh;
  112999. private static _CreateSpotLightMesh;
  113000. private static _CreateDirectionalLightMesh;
  113001. }
  113002. }
  113003. declare module BABYLON {
  113004. /** @hidden */
  113005. export var backgroundFragmentDeclaration: {
  113006. name: string;
  113007. shader: string;
  113008. };
  113009. }
  113010. declare module BABYLON {
  113011. /** @hidden */
  113012. export var backgroundUboDeclaration: {
  113013. name: string;
  113014. shader: string;
  113015. };
  113016. }
  113017. declare module BABYLON {
  113018. /** @hidden */
  113019. export var backgroundPixelShader: {
  113020. name: string;
  113021. shader: string;
  113022. };
  113023. }
  113024. declare module BABYLON {
  113025. /** @hidden */
  113026. export var backgroundVertexDeclaration: {
  113027. name: string;
  113028. shader: string;
  113029. };
  113030. }
  113031. declare module BABYLON {
  113032. /** @hidden */
  113033. export var backgroundVertexShader: {
  113034. name: string;
  113035. shader: string;
  113036. };
  113037. }
  113038. declare module BABYLON {
  113039. /**
  113040. * Background material used to create an efficient environement around your scene.
  113041. */
  113042. export class BackgroundMaterial extends PushMaterial {
  113043. /**
  113044. * Standard reflectance value at parallel view angle.
  113045. */
  113046. static StandardReflectance0: number;
  113047. /**
  113048. * Standard reflectance value at grazing angle.
  113049. */
  113050. static StandardReflectance90: number;
  113051. protected _primaryColor: Color3;
  113052. /**
  113053. * Key light Color (multiply against the environement texture)
  113054. */
  113055. primaryColor: Color3;
  113056. protected __perceptualColor: Nullable<Color3>;
  113057. /**
  113058. * Experimental Internal Use Only.
  113059. *
  113060. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113061. * This acts as a helper to set the primary color to a more "human friendly" value.
  113062. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113063. * output color as close as possible from the chosen value.
  113064. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113065. * part of lighting setup.)
  113066. */
  113067. _perceptualColor: Nullable<Color3>;
  113068. protected _primaryColorShadowLevel: float;
  113069. /**
  113070. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113071. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113072. */
  113073. primaryColorShadowLevel: float;
  113074. protected _primaryColorHighlightLevel: float;
  113075. /**
  113076. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113077. * The primary color is used at the level chosen to define what the white area would look.
  113078. */
  113079. primaryColorHighlightLevel: float;
  113080. protected _reflectionTexture: Nullable<BaseTexture>;
  113081. /**
  113082. * Reflection Texture used in the material.
  113083. * Should be author in a specific way for the best result (refer to the documentation).
  113084. */
  113085. reflectionTexture: Nullable<BaseTexture>;
  113086. protected _reflectionBlur: float;
  113087. /**
  113088. * Reflection Texture level of blur.
  113089. *
  113090. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113091. * texture twice.
  113092. */
  113093. reflectionBlur: float;
  113094. protected _diffuseTexture: Nullable<BaseTexture>;
  113095. /**
  113096. * Diffuse Texture used in the material.
  113097. * Should be author in a specific way for the best result (refer to the documentation).
  113098. */
  113099. diffuseTexture: Nullable<BaseTexture>;
  113100. protected _shadowLights: Nullable<IShadowLight[]>;
  113101. /**
  113102. * Specify the list of lights casting shadow on the material.
  113103. * All scene shadow lights will be included if null.
  113104. */
  113105. shadowLights: Nullable<IShadowLight[]>;
  113106. protected _shadowLevel: float;
  113107. /**
  113108. * Helps adjusting the shadow to a softer level if required.
  113109. * 0 means black shadows and 1 means no shadows.
  113110. */
  113111. shadowLevel: float;
  113112. protected _sceneCenter: Vector3;
  113113. /**
  113114. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113115. * It is usually zero but might be interesting to modify according to your setup.
  113116. */
  113117. sceneCenter: Vector3;
  113118. protected _opacityFresnel: boolean;
  113119. /**
  113120. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113121. * This helps ensuring a nice transition when the camera goes under the ground.
  113122. */
  113123. opacityFresnel: boolean;
  113124. protected _reflectionFresnel: boolean;
  113125. /**
  113126. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113127. * This helps adding a mirror texture on the ground.
  113128. */
  113129. reflectionFresnel: boolean;
  113130. protected _reflectionFalloffDistance: number;
  113131. /**
  113132. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113133. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113134. */
  113135. reflectionFalloffDistance: number;
  113136. protected _reflectionAmount: number;
  113137. /**
  113138. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113139. */
  113140. reflectionAmount: number;
  113141. protected _reflectionReflectance0: number;
  113142. /**
  113143. * This specifies the weight of the reflection at grazing angle.
  113144. */
  113145. reflectionReflectance0: number;
  113146. protected _reflectionReflectance90: number;
  113147. /**
  113148. * This specifies the weight of the reflection at a perpendicular point of view.
  113149. */
  113150. reflectionReflectance90: number;
  113151. /**
  113152. * Sets the reflection reflectance fresnel values according to the default standard
  113153. * empirically know to work well :-)
  113154. */
  113155. reflectionStandardFresnelWeight: number;
  113156. protected _useRGBColor: boolean;
  113157. /**
  113158. * Helps to directly use the maps channels instead of their level.
  113159. */
  113160. useRGBColor: boolean;
  113161. protected _enableNoise: boolean;
  113162. /**
  113163. * This helps reducing the banding effect that could occur on the background.
  113164. */
  113165. enableNoise: boolean;
  113166. /**
  113167. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113168. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113169. * Recommended to be keep at 1.0 except for special cases.
  113170. */
  113171. fovMultiplier: number;
  113172. private _fovMultiplier;
  113173. /**
  113174. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113175. */
  113176. useEquirectangularFOV: boolean;
  113177. private _maxSimultaneousLights;
  113178. /**
  113179. * Number of Simultaneous lights allowed on the material.
  113180. */
  113181. maxSimultaneousLights: int;
  113182. /**
  113183. * Default configuration related to image processing available in the Background Material.
  113184. */
  113185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113186. /**
  113187. * Keep track of the image processing observer to allow dispose and replace.
  113188. */
  113189. private _imageProcessingObserver;
  113190. /**
  113191. * Attaches a new image processing configuration to the PBR Material.
  113192. * @param configuration (if null the scene configuration will be use)
  113193. */
  113194. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113195. /**
  113196. * Gets the image processing configuration used either in this material.
  113197. */
  113198. /**
  113199. * Sets the Default image processing configuration used either in the this material.
  113200. *
  113201. * If sets to null, the scene one is in use.
  113202. */
  113203. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113204. /**
  113205. * Gets wether the color curves effect is enabled.
  113206. */
  113207. /**
  113208. * Sets wether the color curves effect is enabled.
  113209. */
  113210. cameraColorCurvesEnabled: boolean;
  113211. /**
  113212. * Gets wether the color grading effect is enabled.
  113213. */
  113214. /**
  113215. * Gets wether the color grading effect is enabled.
  113216. */
  113217. cameraColorGradingEnabled: boolean;
  113218. /**
  113219. * Gets wether tonemapping is enabled or not.
  113220. */
  113221. /**
  113222. * Sets wether tonemapping is enabled or not
  113223. */
  113224. cameraToneMappingEnabled: boolean;
  113225. /**
  113226. * The camera exposure used on this material.
  113227. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113228. * This corresponds to a photographic exposure.
  113229. */
  113230. /**
  113231. * The camera exposure used on this material.
  113232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113233. * This corresponds to a photographic exposure.
  113234. */
  113235. cameraExposure: float;
  113236. /**
  113237. * Gets The camera contrast used on this material.
  113238. */
  113239. /**
  113240. * Sets The camera contrast used on this material.
  113241. */
  113242. cameraContrast: float;
  113243. /**
  113244. * Gets the Color Grading 2D Lookup Texture.
  113245. */
  113246. /**
  113247. * Sets the Color Grading 2D Lookup Texture.
  113248. */
  113249. cameraColorGradingTexture: Nullable<BaseTexture>;
  113250. /**
  113251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113253. * 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;
  113254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113255. */
  113256. /**
  113257. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113258. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113259. * 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;
  113260. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113261. */
  113262. cameraColorCurves: Nullable<ColorCurves>;
  113263. /**
  113264. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113265. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113266. */
  113267. switchToBGR: boolean;
  113268. private _renderTargets;
  113269. private _reflectionControls;
  113270. private _white;
  113271. private _primaryShadowColor;
  113272. private _primaryHighlightColor;
  113273. /**
  113274. * Instantiates a Background Material in the given scene
  113275. * @param name The friendly name of the material
  113276. * @param scene The scene to add the material to
  113277. */
  113278. constructor(name: string, scene: Scene);
  113279. /**
  113280. * Gets a boolean indicating that current material needs to register RTT
  113281. */
  113282. readonly hasRenderTargetTextures: boolean;
  113283. /**
  113284. * The entire material has been created in order to prevent overdraw.
  113285. * @returns false
  113286. */
  113287. needAlphaTesting(): boolean;
  113288. /**
  113289. * The entire material has been created in order to prevent overdraw.
  113290. * @returns true if blending is enable
  113291. */
  113292. needAlphaBlending(): boolean;
  113293. /**
  113294. * Checks wether the material is ready to be rendered for a given mesh.
  113295. * @param mesh The mesh to render
  113296. * @param subMesh The submesh to check against
  113297. * @param useInstances Specify wether or not the material is used with instances
  113298. * @returns true if all the dependencies are ready (Textures, Effects...)
  113299. */
  113300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113301. /**
  113302. * Compute the primary color according to the chosen perceptual color.
  113303. */
  113304. private _computePrimaryColorFromPerceptualColor;
  113305. /**
  113306. * Compute the highlights and shadow colors according to their chosen levels.
  113307. */
  113308. private _computePrimaryColors;
  113309. /**
  113310. * Build the uniform buffer used in the material.
  113311. */
  113312. buildUniformLayout(): void;
  113313. /**
  113314. * Unbind the material.
  113315. */
  113316. unbind(): void;
  113317. /**
  113318. * Bind only the world matrix to the material.
  113319. * @param world The world matrix to bind.
  113320. */
  113321. bindOnlyWorldMatrix(world: Matrix): void;
  113322. /**
  113323. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113324. * @param world The world matrix to bind.
  113325. * @param subMesh The submesh to bind for.
  113326. */
  113327. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113328. /**
  113329. * Checks to see if a texture is used in the material.
  113330. * @param texture - Base texture to use.
  113331. * @returns - Boolean specifying if a texture is used in the material.
  113332. */
  113333. hasTexture(texture: BaseTexture): boolean;
  113334. /**
  113335. * Dispose the material.
  113336. * @param forceDisposeEffect Force disposal of the associated effect.
  113337. * @param forceDisposeTextures Force disposal of the associated textures.
  113338. */
  113339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113340. /**
  113341. * Clones the material.
  113342. * @param name The cloned name.
  113343. * @returns The cloned material.
  113344. */
  113345. clone(name: string): BackgroundMaterial;
  113346. /**
  113347. * Serializes the current material to its JSON representation.
  113348. * @returns The JSON representation.
  113349. */
  113350. serialize(): any;
  113351. /**
  113352. * Gets the class name of the material
  113353. * @returns "BackgroundMaterial"
  113354. */
  113355. getClassName(): string;
  113356. /**
  113357. * Parse a JSON input to create back a background material.
  113358. * @param source The JSON data to parse
  113359. * @param scene The scene to create the parsed material in
  113360. * @param rootUrl The root url of the assets the material depends upon
  113361. * @returns the instantiated BackgroundMaterial.
  113362. */
  113363. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113364. }
  113365. }
  113366. declare module BABYLON {
  113367. /**
  113368. * Represents the different options available during the creation of
  113369. * a Environment helper.
  113370. *
  113371. * This can control the default ground, skybox and image processing setup of your scene.
  113372. */
  113373. export interface IEnvironmentHelperOptions {
  113374. /**
  113375. * Specifies wether or not to create a ground.
  113376. * True by default.
  113377. */
  113378. createGround: boolean;
  113379. /**
  113380. * Specifies the ground size.
  113381. * 15 by default.
  113382. */
  113383. groundSize: number;
  113384. /**
  113385. * The texture used on the ground for the main color.
  113386. * Comes from the BabylonJS CDN by default.
  113387. *
  113388. * Remarks: Can be either a texture or a url.
  113389. */
  113390. groundTexture: string | BaseTexture;
  113391. /**
  113392. * The color mixed in the ground texture by default.
  113393. * BabylonJS clearColor by default.
  113394. */
  113395. groundColor: Color3;
  113396. /**
  113397. * Specifies the ground opacity.
  113398. * 1 by default.
  113399. */
  113400. groundOpacity: number;
  113401. /**
  113402. * Enables the ground to receive shadows.
  113403. * True by default.
  113404. */
  113405. enableGroundShadow: boolean;
  113406. /**
  113407. * Helps preventing the shadow to be fully black on the ground.
  113408. * 0.5 by default.
  113409. */
  113410. groundShadowLevel: number;
  113411. /**
  113412. * Creates a mirror texture attach to the ground.
  113413. * false by default.
  113414. */
  113415. enableGroundMirror: boolean;
  113416. /**
  113417. * Specifies the ground mirror size ratio.
  113418. * 0.3 by default as the default kernel is 64.
  113419. */
  113420. groundMirrorSizeRatio: number;
  113421. /**
  113422. * Specifies the ground mirror blur kernel size.
  113423. * 64 by default.
  113424. */
  113425. groundMirrorBlurKernel: number;
  113426. /**
  113427. * Specifies the ground mirror visibility amount.
  113428. * 1 by default
  113429. */
  113430. groundMirrorAmount: number;
  113431. /**
  113432. * Specifies the ground mirror reflectance weight.
  113433. * This uses the standard weight of the background material to setup the fresnel effect
  113434. * of the mirror.
  113435. * 1 by default.
  113436. */
  113437. groundMirrorFresnelWeight: number;
  113438. /**
  113439. * Specifies the ground mirror Falloff distance.
  113440. * This can helps reducing the size of the reflection.
  113441. * 0 by Default.
  113442. */
  113443. groundMirrorFallOffDistance: number;
  113444. /**
  113445. * Specifies the ground mirror texture type.
  113446. * Unsigned Int by Default.
  113447. */
  113448. groundMirrorTextureType: number;
  113449. /**
  113450. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  113451. * the shown objects.
  113452. */
  113453. groundYBias: number;
  113454. /**
  113455. * Specifies wether or not to create a skybox.
  113456. * True by default.
  113457. */
  113458. createSkybox: boolean;
  113459. /**
  113460. * Specifies the skybox size.
  113461. * 20 by default.
  113462. */
  113463. skyboxSize: number;
  113464. /**
  113465. * The texture used on the skybox for the main color.
  113466. * Comes from the BabylonJS CDN by default.
  113467. *
  113468. * Remarks: Can be either a texture or a url.
  113469. */
  113470. skyboxTexture: string | BaseTexture;
  113471. /**
  113472. * The color mixed in the skybox texture by default.
  113473. * BabylonJS clearColor by default.
  113474. */
  113475. skyboxColor: Color3;
  113476. /**
  113477. * The background rotation around the Y axis of the scene.
  113478. * This helps aligning the key lights of your scene with the background.
  113479. * 0 by default.
  113480. */
  113481. backgroundYRotation: number;
  113482. /**
  113483. * Compute automatically the size of the elements to best fit with the scene.
  113484. */
  113485. sizeAuto: boolean;
  113486. /**
  113487. * Default position of the rootMesh if autoSize is not true.
  113488. */
  113489. rootPosition: Vector3;
  113490. /**
  113491. * Sets up the image processing in the scene.
  113492. * true by default.
  113493. */
  113494. setupImageProcessing: boolean;
  113495. /**
  113496. * The texture used as your environment texture in the scene.
  113497. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113498. *
  113499. * Remarks: Can be either a texture or a url.
  113500. */
  113501. environmentTexture: string | BaseTexture;
  113502. /**
  113503. * The value of the exposure to apply to the scene.
  113504. * 0.6 by default if setupImageProcessing is true.
  113505. */
  113506. cameraExposure: number;
  113507. /**
  113508. * The value of the contrast to apply to the scene.
  113509. * 1.6 by default if setupImageProcessing is true.
  113510. */
  113511. cameraContrast: number;
  113512. /**
  113513. * Specifies wether or not tonemapping should be enabled in the scene.
  113514. * true by default if setupImageProcessing is true.
  113515. */
  113516. toneMappingEnabled: boolean;
  113517. }
  113518. /**
  113519. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113520. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113521. * It also helps with the default setup of your imageProcessing configuration.
  113522. */
  113523. export class EnvironmentHelper {
  113524. /**
  113525. * Default ground texture URL.
  113526. */
  113527. private static _groundTextureCDNUrl;
  113528. /**
  113529. * Default skybox texture URL.
  113530. */
  113531. private static _skyboxTextureCDNUrl;
  113532. /**
  113533. * Default environment texture URL.
  113534. */
  113535. private static _environmentTextureCDNUrl;
  113536. /**
  113537. * Creates the default options for the helper.
  113538. */
  113539. private static _getDefaultOptions;
  113540. private _rootMesh;
  113541. /**
  113542. * Gets the root mesh created by the helper.
  113543. */
  113544. readonly rootMesh: Mesh;
  113545. private _skybox;
  113546. /**
  113547. * Gets the skybox created by the helper.
  113548. */
  113549. readonly skybox: Nullable<Mesh>;
  113550. private _skyboxTexture;
  113551. /**
  113552. * Gets the skybox texture created by the helper.
  113553. */
  113554. readonly skyboxTexture: Nullable<BaseTexture>;
  113555. private _skyboxMaterial;
  113556. /**
  113557. * Gets the skybox material created by the helper.
  113558. */
  113559. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113560. private _ground;
  113561. /**
  113562. * Gets the ground mesh created by the helper.
  113563. */
  113564. readonly ground: Nullable<Mesh>;
  113565. private _groundTexture;
  113566. /**
  113567. * Gets the ground texture created by the helper.
  113568. */
  113569. readonly groundTexture: Nullable<BaseTexture>;
  113570. private _groundMirror;
  113571. /**
  113572. * Gets the ground mirror created by the helper.
  113573. */
  113574. readonly groundMirror: Nullable<MirrorTexture>;
  113575. /**
  113576. * Gets the ground mirror render list to helps pushing the meshes
  113577. * you wish in the ground reflection.
  113578. */
  113579. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113580. private _groundMaterial;
  113581. /**
  113582. * Gets the ground material created by the helper.
  113583. */
  113584. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113585. /**
  113586. * Stores the creation options.
  113587. */
  113588. private readonly _scene;
  113589. private _options;
  113590. /**
  113591. * This observable will be notified with any error during the creation of the environment,
  113592. * mainly texture creation errors.
  113593. */
  113594. onErrorObservable: Observable<{
  113595. message?: string;
  113596. exception?: any;
  113597. }>;
  113598. /**
  113599. * constructor
  113600. * @param options Defines the options we want to customize the helper
  113601. * @param scene The scene to add the material to
  113602. */
  113603. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113604. /**
  113605. * Updates the background according to the new options
  113606. * @param options
  113607. */
  113608. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113609. /**
  113610. * Sets the primary color of all the available elements.
  113611. * @param color the main color to affect to the ground and the background
  113612. */
  113613. setMainColor(color: Color3): void;
  113614. /**
  113615. * Setup the image processing according to the specified options.
  113616. */
  113617. private _setupImageProcessing;
  113618. /**
  113619. * Setup the environment texture according to the specified options.
  113620. */
  113621. private _setupEnvironmentTexture;
  113622. /**
  113623. * Setup the background according to the specified options.
  113624. */
  113625. private _setupBackground;
  113626. /**
  113627. * Get the scene sizes according to the setup.
  113628. */
  113629. private _getSceneSize;
  113630. /**
  113631. * Setup the ground according to the specified options.
  113632. */
  113633. private _setupGround;
  113634. /**
  113635. * Setup the ground material according to the specified options.
  113636. */
  113637. private _setupGroundMaterial;
  113638. /**
  113639. * Setup the ground diffuse texture according to the specified options.
  113640. */
  113641. private _setupGroundDiffuseTexture;
  113642. /**
  113643. * Setup the ground mirror texture according to the specified options.
  113644. */
  113645. private _setupGroundMirrorTexture;
  113646. /**
  113647. * Setup the ground to receive the mirror texture.
  113648. */
  113649. private _setupMirrorInGroundMaterial;
  113650. /**
  113651. * Setup the skybox according to the specified options.
  113652. */
  113653. private _setupSkybox;
  113654. /**
  113655. * Setup the skybox material according to the specified options.
  113656. */
  113657. private _setupSkyboxMaterial;
  113658. /**
  113659. * Setup the skybox reflection texture according to the specified options.
  113660. */
  113661. private _setupSkyboxReflectionTexture;
  113662. private _errorHandler;
  113663. /**
  113664. * Dispose all the elements created by the Helper.
  113665. */
  113666. dispose(): void;
  113667. }
  113668. }
  113669. declare module BABYLON {
  113670. /**
  113671. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113672. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113673. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113674. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113675. */
  113676. export class PhotoDome extends TransformNode {
  113677. /**
  113678. * Define the image as a Monoscopic panoramic 360 image.
  113679. */
  113680. static readonly MODE_MONOSCOPIC: number;
  113681. /**
  113682. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113683. */
  113684. static readonly MODE_TOPBOTTOM: number;
  113685. /**
  113686. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113687. */
  113688. static readonly MODE_SIDEBYSIDE: number;
  113689. private _useDirectMapping;
  113690. /**
  113691. * The texture being displayed on the sphere
  113692. */
  113693. protected _photoTexture: Texture;
  113694. /**
  113695. * Gets or sets the texture being displayed on the sphere
  113696. */
  113697. photoTexture: Texture;
  113698. /**
  113699. * Observable raised when an error occured while loading the 360 image
  113700. */
  113701. onLoadErrorObservable: Observable<string>;
  113702. /**
  113703. * The skybox material
  113704. */
  113705. protected _material: BackgroundMaterial;
  113706. /**
  113707. * The surface used for the skybox
  113708. */
  113709. protected _mesh: Mesh;
  113710. /**
  113711. * Gets the mesh used for the skybox.
  113712. */
  113713. readonly mesh: Mesh;
  113714. /**
  113715. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113716. * Also see the options.resolution property.
  113717. */
  113718. fovMultiplier: number;
  113719. private _imageMode;
  113720. /**
  113721. * Gets or set the current video mode for the video. It can be:
  113722. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113723. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113724. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113725. */
  113726. imageMode: number;
  113727. /**
  113728. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113729. * @param name Element's name, child elements will append suffixes for their own names.
  113730. * @param urlsOfPhoto defines the url of the photo to display
  113731. * @param options defines an object containing optional or exposed sub element properties
  113732. * @param onError defines a callback called when an error occured while loading the texture
  113733. */
  113734. constructor(name: string, urlOfPhoto: string, options: {
  113735. resolution?: number;
  113736. size?: number;
  113737. useDirectMapping?: boolean;
  113738. faceForward?: boolean;
  113739. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113740. private _onBeforeCameraRenderObserver;
  113741. private _changeImageMode;
  113742. /**
  113743. * Releases resources associated with this node.
  113744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113746. */
  113747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113748. }
  113749. }
  113750. declare module BABYLON {
  113751. /**
  113752. * Class used to host RGBD texture specific utilities
  113753. */
  113754. export class RGBDTextureTools {
  113755. /**
  113756. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113757. * @param texture the texture to expand.
  113758. */
  113759. static ExpandRGBDTexture(texture: Texture): void;
  113760. }
  113761. }
  113762. declare module BABYLON {
  113763. /**
  113764. * Class used to host texture specific utilities
  113765. */
  113766. export class BRDFTextureTools {
  113767. /**
  113768. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113769. * @param scene defines the hosting scene
  113770. * @returns the environment BRDF texture
  113771. */
  113772. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113773. private static _environmentBRDFBase64Texture;
  113774. }
  113775. }
  113776. declare module BABYLON {
  113777. /**
  113778. * @hidden
  113779. */
  113780. export interface IMaterialClearCoatDefines {
  113781. CLEARCOAT: boolean;
  113782. CLEARCOAT_DEFAULTIOR: boolean;
  113783. CLEARCOAT_TEXTURE: boolean;
  113784. CLEARCOAT_TEXTUREDIRECTUV: number;
  113785. CLEARCOAT_BUMP: boolean;
  113786. CLEARCOAT_BUMPDIRECTUV: number;
  113787. CLEARCOAT_TINT: boolean;
  113788. CLEARCOAT_TINT_TEXTURE: boolean;
  113789. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113790. /** @hidden */
  113791. _areTexturesDirty: boolean;
  113792. }
  113793. /**
  113794. * Define the code related to the clear coat parameters of the pbr material.
  113795. */
  113796. export class PBRClearCoatConfiguration {
  113797. /**
  113798. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113799. * The default fits with a polyurethane material.
  113800. */
  113801. private static readonly _DefaultIndexOfRefraction;
  113802. private _isEnabled;
  113803. /**
  113804. * Defines if the clear coat is enabled in the material.
  113805. */
  113806. isEnabled: boolean;
  113807. /**
  113808. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113809. */
  113810. intensity: number;
  113811. /**
  113812. * Defines the clear coat layer roughness.
  113813. */
  113814. roughness: number;
  113815. private _indexOfRefraction;
  113816. /**
  113817. * Defines the index of refraction of the clear coat.
  113818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113819. * The default fits with a polyurethane material.
  113820. * Changing the default value is more performance intensive.
  113821. */
  113822. indexOfRefraction: number;
  113823. private _texture;
  113824. /**
  113825. * Stores the clear coat values in a texture.
  113826. */
  113827. texture: Nullable<BaseTexture>;
  113828. private _bumpTexture;
  113829. /**
  113830. * Define the clear coat specific bump texture.
  113831. */
  113832. bumpTexture: Nullable<BaseTexture>;
  113833. private _isTintEnabled;
  113834. /**
  113835. * Defines if the clear coat tint is enabled in the material.
  113836. */
  113837. isTintEnabled: boolean;
  113838. /**
  113839. * Defines the clear coat tint of the material.
  113840. * This is only use if tint is enabled
  113841. */
  113842. tintColor: Color3;
  113843. /**
  113844. * Defines the distance at which the tint color should be found in the
  113845. * clear coat media.
  113846. * This is only use if tint is enabled
  113847. */
  113848. tintColorAtDistance: number;
  113849. /**
  113850. * Defines the clear coat layer thickness.
  113851. * This is only use if tint is enabled
  113852. */
  113853. tintThickness: number;
  113854. private _tintTexture;
  113855. /**
  113856. * Stores the clear tint values in a texture.
  113857. * rgb is tint
  113858. * a is a thickness factor
  113859. */
  113860. tintTexture: Nullable<BaseTexture>;
  113861. /** @hidden */
  113862. private _internalMarkAllSubMeshesAsTexturesDirty;
  113863. /** @hidden */
  113864. _markAllSubMeshesAsTexturesDirty(): void;
  113865. /**
  113866. * Instantiate a new istance of clear coat configuration.
  113867. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113868. */
  113869. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113870. /**
  113871. * Gets wehter the submesh is ready to be used or not.
  113872. * @param defines the list of "defines" to update.
  113873. * @param scene defines the scene the material belongs to.
  113874. * @param engine defines the engine the material belongs to.
  113875. * @param disableBumpMap defines wether the material disables bump or not.
  113876. * @returns - boolean indicating that the submesh is ready or not.
  113877. */
  113878. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113879. /**
  113880. * Checks to see if a texture is used in the material.
  113881. * @param defines the list of "defines" to update.
  113882. * @param scene defines the scene to the material belongs to.
  113883. */
  113884. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113885. /**
  113886. * Binds the material data.
  113887. * @param uniformBuffer defines the Uniform buffer to fill in.
  113888. * @param scene defines the scene the material belongs to.
  113889. * @param engine defines the engine the material belongs to.
  113890. * @param disableBumpMap defines wether the material disables bump or not.
  113891. * @param isFrozen defines wether the material is frozen or not.
  113892. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113893. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113894. */
  113895. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113896. /**
  113897. * Checks to see if a texture is used in the material.
  113898. * @param texture - Base texture to use.
  113899. * @returns - Boolean specifying if a texture is used in the material.
  113900. */
  113901. hasTexture(texture: BaseTexture): boolean;
  113902. /**
  113903. * Returns an array of the actively used textures.
  113904. * @param activeTextures Array of BaseTextures
  113905. */
  113906. getActiveTextures(activeTextures: BaseTexture[]): void;
  113907. /**
  113908. * Returns the animatable textures.
  113909. * @param animatables Array of animatable textures.
  113910. */
  113911. getAnimatables(animatables: IAnimatable[]): void;
  113912. /**
  113913. * Disposes the resources of the material.
  113914. * @param forceDisposeTextures - Forces the disposal of all textures.
  113915. */
  113916. dispose(forceDisposeTextures?: boolean): void;
  113917. /**
  113918. * Get the current class name of the texture useful for serialization or dynamic coding.
  113919. * @returns "PBRClearCoatConfiguration"
  113920. */
  113921. getClassName(): string;
  113922. /**
  113923. * Add fallbacks to the effect fallbacks list.
  113924. * @param defines defines the Base texture to use.
  113925. * @param fallbacks defines the current fallback list.
  113926. * @param currentRank defines the current fallback rank.
  113927. * @returns the new fallback rank.
  113928. */
  113929. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113930. /**
  113931. * Add the required uniforms to the current list.
  113932. * @param uniforms defines the current uniform list.
  113933. */
  113934. static AddUniforms(uniforms: string[]): void;
  113935. /**
  113936. * Add the required samplers to the current list.
  113937. * @param samplers defines the current sampler list.
  113938. */
  113939. static AddSamplers(samplers: string[]): void;
  113940. /**
  113941. * Add the required uniforms to the current buffer.
  113942. * @param uniformBuffer defines the current uniform buffer.
  113943. */
  113944. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113945. /**
  113946. * Makes a duplicate of the current configuration into another one.
  113947. * @param clearCoatConfiguration define the config where to copy the info
  113948. */
  113949. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113950. /**
  113951. * Serializes this clear coat configuration.
  113952. * @returns - An object with the serialized config.
  113953. */
  113954. serialize(): any;
  113955. /**
  113956. * Parses a anisotropy Configuration from a serialized object.
  113957. * @param source - Serialized object.
  113958. * @param scene Defines the scene we are parsing for
  113959. * @param rootUrl Defines the rootUrl to load from
  113960. */
  113961. parse(source: any, scene: Scene, rootUrl: string): void;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. /**
  113966. * @hidden
  113967. */
  113968. export interface IMaterialAnisotropicDefines {
  113969. ANISOTROPIC: boolean;
  113970. ANISOTROPIC_TEXTURE: boolean;
  113971. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113972. MAINUV1: boolean;
  113973. _areTexturesDirty: boolean;
  113974. _needUVs: boolean;
  113975. }
  113976. /**
  113977. * Define the code related to the anisotropic parameters of the pbr material.
  113978. */
  113979. export class PBRAnisotropicConfiguration {
  113980. private _isEnabled;
  113981. /**
  113982. * Defines if the anisotropy is enabled in the material.
  113983. */
  113984. isEnabled: boolean;
  113985. /**
  113986. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113987. */
  113988. intensity: number;
  113989. /**
  113990. * Defines if the effect is along the tangents, bitangents or in between.
  113991. * By default, the effect is "strectching" the highlights along the tangents.
  113992. */
  113993. direction: Vector2;
  113994. private _texture;
  113995. /**
  113996. * Stores the anisotropy values in a texture.
  113997. * rg is direction (like normal from -1 to 1)
  113998. * b is a intensity
  113999. */
  114000. texture: Nullable<BaseTexture>;
  114001. /** @hidden */
  114002. private _internalMarkAllSubMeshesAsTexturesDirty;
  114003. /** @hidden */
  114004. _markAllSubMeshesAsTexturesDirty(): void;
  114005. /**
  114006. * Instantiate a new istance of anisotropy configuration.
  114007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114008. */
  114009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114010. /**
  114011. * Specifies that the submesh is ready to be used.
  114012. * @param defines the list of "defines" to update.
  114013. * @param scene defines the scene the material belongs to.
  114014. * @returns - boolean indicating that the submesh is ready or not.
  114015. */
  114016. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114017. /**
  114018. * Checks to see if a texture is used in the material.
  114019. * @param defines the list of "defines" to update.
  114020. * @param mesh the mesh we are preparing the defines for.
  114021. * @param scene defines the scene the material belongs to.
  114022. */
  114023. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114024. /**
  114025. * Binds the material data.
  114026. * @param uniformBuffer defines the Uniform buffer to fill in.
  114027. * @param scene defines the scene the material belongs to.
  114028. * @param isFrozen defines wether the material is frozen or not.
  114029. */
  114030. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114031. /**
  114032. * Checks to see if a texture is used in the material.
  114033. * @param texture - Base texture to use.
  114034. * @returns - Boolean specifying if a texture is used in the material.
  114035. */
  114036. hasTexture(texture: BaseTexture): boolean;
  114037. /**
  114038. * Returns an array of the actively used textures.
  114039. * @param activeTextures Array of BaseTextures
  114040. */
  114041. getActiveTextures(activeTextures: BaseTexture[]): void;
  114042. /**
  114043. * Returns the animatable textures.
  114044. * @param animatables Array of animatable textures.
  114045. */
  114046. getAnimatables(animatables: IAnimatable[]): void;
  114047. /**
  114048. * Disposes the resources of the material.
  114049. * @param forceDisposeTextures - Forces the disposal of all textures.
  114050. */
  114051. dispose(forceDisposeTextures?: boolean): void;
  114052. /**
  114053. * Get the current class name of the texture useful for serialization or dynamic coding.
  114054. * @returns "PBRAnisotropicConfiguration"
  114055. */
  114056. getClassName(): string;
  114057. /**
  114058. * Add fallbacks to the effect fallbacks list.
  114059. * @param defines defines the Base texture to use.
  114060. * @param fallbacks defines the current fallback list.
  114061. * @param currentRank defines the current fallback rank.
  114062. * @returns the new fallback rank.
  114063. */
  114064. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114065. /**
  114066. * Add the required uniforms to the current list.
  114067. * @param uniforms defines the current uniform list.
  114068. */
  114069. static AddUniforms(uniforms: string[]): void;
  114070. /**
  114071. * Add the required uniforms to the current buffer.
  114072. * @param uniformBuffer defines the current uniform buffer.
  114073. */
  114074. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114075. /**
  114076. * Add the required samplers to the current list.
  114077. * @param samplers defines the current sampler list.
  114078. */
  114079. static AddSamplers(samplers: string[]): void;
  114080. /**
  114081. * Makes a duplicate of the current configuration into another one.
  114082. * @param anisotropicConfiguration define the config where to copy the info
  114083. */
  114084. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114085. /**
  114086. * Serializes this anisotropy configuration.
  114087. * @returns - An object with the serialized config.
  114088. */
  114089. serialize(): any;
  114090. /**
  114091. * Parses a anisotropy Configuration from a serialized object.
  114092. * @param source - Serialized object.
  114093. * @param scene Defines the scene we are parsing for
  114094. * @param rootUrl Defines the rootUrl to load from
  114095. */
  114096. parse(source: any, scene: Scene, rootUrl: string): void;
  114097. }
  114098. }
  114099. declare module BABYLON {
  114100. /**
  114101. * @hidden
  114102. */
  114103. export interface IMaterialBRDFDefines {
  114104. BRDF_V_HEIGHT_CORRELATED: boolean;
  114105. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114106. SPHERICAL_HARMONICS: boolean;
  114107. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114108. /** @hidden */
  114109. _areMiscDirty: boolean;
  114110. }
  114111. /**
  114112. * Define the code related to the BRDF parameters of the pbr material.
  114113. */
  114114. export class PBRBRDFConfiguration {
  114115. /**
  114116. * Default value used for the energy conservation.
  114117. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114118. */
  114119. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114120. /**
  114121. * Default value used for the Smith Visibility Height Correlated mode.
  114122. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114123. */
  114124. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114125. /**
  114126. * Default value used for the IBL diffuse part.
  114127. * This can help switching back to the polynomials mode globally which is a tiny bit
  114128. * less GPU intensive at the drawback of a lower quality.
  114129. */
  114130. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114131. /**
  114132. * Default value used for activating energy conservation for the specular workflow.
  114133. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114134. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114135. */
  114136. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114137. private _useEnergyConservation;
  114138. /**
  114139. * Defines if the material uses energy conservation.
  114140. */
  114141. useEnergyConservation: boolean;
  114142. private _useSmithVisibilityHeightCorrelated;
  114143. /**
  114144. * LEGACY Mode set to false
  114145. * Defines if the material uses height smith correlated visibility term.
  114146. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114147. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114148. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114149. * Not relying on height correlated will also disable energy conservation.
  114150. */
  114151. useSmithVisibilityHeightCorrelated: boolean;
  114152. private _useSphericalHarmonics;
  114153. /**
  114154. * LEGACY Mode set to false
  114155. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114156. * diffuse part of the IBL.
  114157. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114158. * to the ground truth.
  114159. */
  114160. useSphericalHarmonics: boolean;
  114161. private _useSpecularGlossinessInputEnergyConservation;
  114162. /**
  114163. * Defines if the material uses energy conservation, when the specular workflow is active.
  114164. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114165. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114166. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114167. */
  114168. useSpecularGlossinessInputEnergyConservation: boolean;
  114169. /** @hidden */
  114170. private _internalMarkAllSubMeshesAsMiscDirty;
  114171. /** @hidden */
  114172. _markAllSubMeshesAsMiscDirty(): void;
  114173. /**
  114174. * Instantiate a new istance of clear coat configuration.
  114175. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114176. */
  114177. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114178. /**
  114179. * Checks to see if a texture is used in the material.
  114180. * @param defines the list of "defines" to update.
  114181. */
  114182. prepareDefines(defines: IMaterialBRDFDefines): void;
  114183. /**
  114184. * Get the current class name of the texture useful for serialization or dynamic coding.
  114185. * @returns "PBRClearCoatConfiguration"
  114186. */
  114187. getClassName(): string;
  114188. /**
  114189. * Makes a duplicate of the current configuration into another one.
  114190. * @param brdfConfiguration define the config where to copy the info
  114191. */
  114192. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114193. /**
  114194. * Serializes this BRDF configuration.
  114195. * @returns - An object with the serialized config.
  114196. */
  114197. serialize(): any;
  114198. /**
  114199. * Parses a anisotropy Configuration from a serialized object.
  114200. * @param source - Serialized object.
  114201. * @param scene Defines the scene we are parsing for
  114202. * @param rootUrl Defines the rootUrl to load from
  114203. */
  114204. parse(source: any, scene: Scene, rootUrl: string): void;
  114205. }
  114206. }
  114207. declare module BABYLON {
  114208. /**
  114209. * @hidden
  114210. */
  114211. export interface IMaterialSheenDefines {
  114212. SHEEN: boolean;
  114213. SHEEN_TEXTURE: boolean;
  114214. SHEEN_TEXTUREDIRECTUV: number;
  114215. SHEEN_LINKWITHALBEDO: boolean;
  114216. /** @hidden */
  114217. _areTexturesDirty: boolean;
  114218. }
  114219. /**
  114220. * Define the code related to the Sheen parameters of the pbr material.
  114221. */
  114222. export class PBRSheenConfiguration {
  114223. private _isEnabled;
  114224. /**
  114225. * Defines if the material uses sheen.
  114226. */
  114227. isEnabled: boolean;
  114228. private _linkSheenWithAlbedo;
  114229. /**
  114230. * Defines if the sheen is linked to the sheen color.
  114231. */
  114232. linkSheenWithAlbedo: boolean;
  114233. /**
  114234. * Defines the sheen intensity.
  114235. */
  114236. intensity: number;
  114237. /**
  114238. * Defines the sheen color.
  114239. */
  114240. color: Color3;
  114241. private _texture;
  114242. /**
  114243. * Stores the sheen tint values in a texture.
  114244. * rgb is tint
  114245. * a is a intensity
  114246. */
  114247. texture: Nullable<BaseTexture>;
  114248. /** @hidden */
  114249. private _internalMarkAllSubMeshesAsTexturesDirty;
  114250. /** @hidden */
  114251. _markAllSubMeshesAsTexturesDirty(): void;
  114252. /**
  114253. * Instantiate a new istance of clear coat configuration.
  114254. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114255. */
  114256. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114257. /**
  114258. * Specifies that the submesh is ready to be used.
  114259. * @param defines the list of "defines" to update.
  114260. * @param scene defines the scene the material belongs to.
  114261. * @returns - boolean indicating that the submesh is ready or not.
  114262. */
  114263. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114264. /**
  114265. * Checks to see if a texture is used in the material.
  114266. * @param defines the list of "defines" to update.
  114267. * @param scene defines the scene the material belongs to.
  114268. */
  114269. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114270. /**
  114271. * Binds the material data.
  114272. * @param uniformBuffer defines the Uniform buffer to fill in.
  114273. * @param scene defines the scene the material belongs to.
  114274. * @param isFrozen defines wether the material is frozen or not.
  114275. */
  114276. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114277. /**
  114278. * Checks to see if a texture is used in the material.
  114279. * @param texture - Base texture to use.
  114280. * @returns - Boolean specifying if a texture is used in the material.
  114281. */
  114282. hasTexture(texture: BaseTexture): boolean;
  114283. /**
  114284. * Returns an array of the actively used textures.
  114285. * @param activeTextures Array of BaseTextures
  114286. */
  114287. getActiveTextures(activeTextures: BaseTexture[]): void;
  114288. /**
  114289. * Returns the animatable textures.
  114290. * @param animatables Array of animatable textures.
  114291. */
  114292. getAnimatables(animatables: IAnimatable[]): void;
  114293. /**
  114294. * Disposes the resources of the material.
  114295. * @param forceDisposeTextures - Forces the disposal of all textures.
  114296. */
  114297. dispose(forceDisposeTextures?: boolean): void;
  114298. /**
  114299. * Get the current class name of the texture useful for serialization or dynamic coding.
  114300. * @returns "PBRSheenConfiguration"
  114301. */
  114302. getClassName(): string;
  114303. /**
  114304. * Add fallbacks to the effect fallbacks list.
  114305. * @param defines defines the Base texture to use.
  114306. * @param fallbacks defines the current fallback list.
  114307. * @param currentRank defines the current fallback rank.
  114308. * @returns the new fallback rank.
  114309. */
  114310. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114311. /**
  114312. * Add the required uniforms to the current list.
  114313. * @param uniforms defines the current uniform list.
  114314. */
  114315. static AddUniforms(uniforms: string[]): void;
  114316. /**
  114317. * Add the required uniforms to the current buffer.
  114318. * @param uniformBuffer defines the current uniform buffer.
  114319. */
  114320. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114321. /**
  114322. * Add the required samplers to the current list.
  114323. * @param samplers defines the current sampler list.
  114324. */
  114325. static AddSamplers(samplers: string[]): void;
  114326. /**
  114327. * Makes a duplicate of the current configuration into another one.
  114328. * @param sheenConfiguration define the config where to copy the info
  114329. */
  114330. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114331. /**
  114332. * Serializes this BRDF configuration.
  114333. * @returns - An object with the serialized config.
  114334. */
  114335. serialize(): any;
  114336. /**
  114337. * Parses a anisotropy Configuration from a serialized object.
  114338. * @param source - Serialized object.
  114339. * @param scene Defines the scene we are parsing for
  114340. * @param rootUrl Defines the rootUrl to load from
  114341. */
  114342. parse(source: any, scene: Scene, rootUrl: string): void;
  114343. }
  114344. }
  114345. declare module BABYLON {
  114346. /**
  114347. * @hidden
  114348. */
  114349. export interface IMaterialSubSurfaceDefines {
  114350. SUBSURFACE: boolean;
  114351. SS_REFRACTION: boolean;
  114352. SS_TRANSLUCENCY: boolean;
  114353. SS_SCATERRING: boolean;
  114354. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114355. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114356. SS_REFRACTIONMAP_3D: boolean;
  114357. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114358. SS_LODINREFRACTIONALPHA: boolean;
  114359. SS_GAMMAREFRACTION: boolean;
  114360. SS_RGBDREFRACTION: boolean;
  114361. SS_LINEARSPECULARREFRACTION: boolean;
  114362. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114363. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114364. /** @hidden */
  114365. _areTexturesDirty: boolean;
  114366. }
  114367. /**
  114368. * Define the code related to the sub surface parameters of the pbr material.
  114369. */
  114370. export class PBRSubSurfaceConfiguration {
  114371. private _isRefractionEnabled;
  114372. /**
  114373. * Defines if the refraction is enabled in the material.
  114374. */
  114375. isRefractionEnabled: boolean;
  114376. private _isTranslucencyEnabled;
  114377. /**
  114378. * Defines if the translucency is enabled in the material.
  114379. */
  114380. isTranslucencyEnabled: boolean;
  114381. private _isScatteringEnabled;
  114382. /**
  114383. * Defines the refraction intensity of the material.
  114384. * The refraction when enabled replaces the Diffuse part of the material.
  114385. * The intensity helps transitionning between diffuse and refraction.
  114386. */
  114387. refractionIntensity: number;
  114388. /**
  114389. * Defines the translucency intensity of the material.
  114390. * When translucency has been enabled, this defines how much of the "translucency"
  114391. * is addded to the diffuse part of the material.
  114392. */
  114393. translucencyIntensity: number;
  114394. /**
  114395. * Defines the scattering intensity of the material.
  114396. * When scattering has been enabled, this defines how much of the "scattered light"
  114397. * is addded to the diffuse part of the material.
  114398. */
  114399. scatteringIntensity: number;
  114400. private _thicknessTexture;
  114401. /**
  114402. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  114403. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  114404. * 0 would mean minimumThickness
  114405. * 1 would mean maximumThickness
  114406. * The other channels might be use as a mask to vary the different effects intensity.
  114407. */
  114408. thicknessTexture: Nullable<BaseTexture>;
  114409. private _refractionTexture;
  114410. /**
  114411. * Defines the texture to use for refraction.
  114412. */
  114413. refractionTexture: Nullable<BaseTexture>;
  114414. private _indexOfRefraction;
  114415. /**
  114416. * Defines the index of refraction used in the material.
  114417. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  114418. */
  114419. indexOfRefraction: number;
  114420. private _invertRefractionY;
  114421. /**
  114422. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114423. */
  114424. invertRefractionY: boolean;
  114425. private _linkRefractionWithTransparency;
  114426. /**
  114427. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114428. * Materials half opaque for instance using refraction could benefit from this control.
  114429. */
  114430. linkRefractionWithTransparency: boolean;
  114431. /**
  114432. * Defines the minimum thickness stored in the thickness map.
  114433. * If no thickness map is defined, this value will be used to simulate thickness.
  114434. */
  114435. minimumThickness: number;
  114436. /**
  114437. * Defines the maximum thickness stored in the thickness map.
  114438. */
  114439. maximumThickness: number;
  114440. /**
  114441. * Defines the volume tint of the material.
  114442. * This is used for both translucency and scattering.
  114443. */
  114444. tintColor: Color3;
  114445. /**
  114446. * Defines the distance at which the tint color should be found in the media.
  114447. * This is used for refraction only.
  114448. */
  114449. tintColorAtDistance: number;
  114450. /**
  114451. * Defines how far each channel transmit through the media.
  114452. * It is defined as a color to simplify it selection.
  114453. */
  114454. diffusionDistance: Color3;
  114455. private _useMaskFromThicknessTexture;
  114456. /**
  114457. * Stores the intensity of the different subsurface effects in the thickness texture.
  114458. * * the green channel is the translucency intensity.
  114459. * * the blue channel is the scattering intensity.
  114460. * * the alpha channel is the refraction intensity.
  114461. */
  114462. useMaskFromThicknessTexture: boolean;
  114463. /** @hidden */
  114464. private _internalMarkAllSubMeshesAsTexturesDirty;
  114465. /** @hidden */
  114466. _markAllSubMeshesAsTexturesDirty(): void;
  114467. /**
  114468. * Instantiate a new istance of sub surface configuration.
  114469. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114470. */
  114471. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114472. /**
  114473. * Gets wehter the submesh is ready to be used or not.
  114474. * @param defines the list of "defines" to update.
  114475. * @param scene defines the scene the material belongs to.
  114476. * @returns - boolean indicating that the submesh is ready or not.
  114477. */
  114478. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114479. /**
  114480. * Checks to see if a texture is used in the material.
  114481. * @param defines the list of "defines" to update.
  114482. * @param scene defines the scene to the material belongs to.
  114483. */
  114484. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114485. /**
  114486. * Binds the material data.
  114487. * @param uniformBuffer defines the Uniform buffer to fill in.
  114488. * @param scene defines the scene the material belongs to.
  114489. * @param engine defines the engine the material belongs to.
  114490. * @param isFrozen defines wether the material is frozen or not.
  114491. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114492. */
  114493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114494. /**
  114495. * Unbinds the material from the mesh.
  114496. * @param activeEffect defines the effect that should be unbound from.
  114497. * @returns true if unbound, otherwise false
  114498. */
  114499. unbind(activeEffect: Effect): boolean;
  114500. /**
  114501. * Returns the texture used for refraction or null if none is used.
  114502. * @param scene defines the scene the material belongs to.
  114503. * @returns - Refraction texture if present. If no refraction texture and refraction
  114504. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114505. */
  114506. private _getRefractionTexture;
  114507. /**
  114508. * Returns true if alpha blending should be disabled.
  114509. */
  114510. readonly disableAlphaBlending: boolean;
  114511. /**
  114512. * Fills the list of render target textures.
  114513. * @param renderTargets the list of render targets to update
  114514. */
  114515. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114516. /**
  114517. * Checks to see if a texture is used in the material.
  114518. * @param texture - Base texture to use.
  114519. * @returns - Boolean specifying if a texture is used in the material.
  114520. */
  114521. hasTexture(texture: BaseTexture): boolean;
  114522. /**
  114523. * Gets a boolean indicating that current material needs to register RTT
  114524. * @returns true if this uses a render target otherwise false.
  114525. */
  114526. hasRenderTargetTextures(): boolean;
  114527. /**
  114528. * Returns an array of the actively used textures.
  114529. * @param activeTextures Array of BaseTextures
  114530. */
  114531. getActiveTextures(activeTextures: BaseTexture[]): void;
  114532. /**
  114533. * Returns the animatable textures.
  114534. * @param animatables Array of animatable textures.
  114535. */
  114536. getAnimatables(animatables: IAnimatable[]): void;
  114537. /**
  114538. * Disposes the resources of the material.
  114539. * @param forceDisposeTextures - Forces the disposal of all textures.
  114540. */
  114541. dispose(forceDisposeTextures?: boolean): void;
  114542. /**
  114543. * Get the current class name of the texture useful for serialization or dynamic coding.
  114544. * @returns "PBRSubSurfaceConfiguration"
  114545. */
  114546. getClassName(): string;
  114547. /**
  114548. * Add fallbacks to the effect fallbacks list.
  114549. * @param defines defines the Base texture to use.
  114550. * @param fallbacks defines the current fallback list.
  114551. * @param currentRank defines the current fallback rank.
  114552. * @returns the new fallback rank.
  114553. */
  114554. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114555. /**
  114556. * Add the required uniforms to the current list.
  114557. * @param uniforms defines the current uniform list.
  114558. */
  114559. static AddUniforms(uniforms: string[]): void;
  114560. /**
  114561. * Add the required samplers to the current list.
  114562. * @param samplers defines the current sampler list.
  114563. */
  114564. static AddSamplers(samplers: string[]): void;
  114565. /**
  114566. * Add the required uniforms to the current buffer.
  114567. * @param uniformBuffer defines the current uniform buffer.
  114568. */
  114569. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114570. /**
  114571. * Makes a duplicate of the current configuration into another one.
  114572. * @param configuration define the config where to copy the info
  114573. */
  114574. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114575. /**
  114576. * Serializes this Sub Surface configuration.
  114577. * @returns - An object with the serialized config.
  114578. */
  114579. serialize(): any;
  114580. /**
  114581. * Parses a anisotropy Configuration from a serialized object.
  114582. * @param source - Serialized object.
  114583. * @param scene Defines the scene we are parsing for
  114584. * @param rootUrl Defines the rootUrl to load from
  114585. */
  114586. parse(source: any, scene: Scene, rootUrl: string): void;
  114587. }
  114588. }
  114589. declare module BABYLON {
  114590. /** @hidden */
  114591. export var pbrFragmentDeclaration: {
  114592. name: string;
  114593. shader: string;
  114594. };
  114595. }
  114596. declare module BABYLON {
  114597. /** @hidden */
  114598. export var pbrUboDeclaration: {
  114599. name: string;
  114600. shader: string;
  114601. };
  114602. }
  114603. declare module BABYLON {
  114604. /** @hidden */
  114605. export var pbrFragmentExtraDeclaration: {
  114606. name: string;
  114607. shader: string;
  114608. };
  114609. }
  114610. declare module BABYLON {
  114611. /** @hidden */
  114612. export var pbrFragmentSamplersDeclaration: {
  114613. name: string;
  114614. shader: string;
  114615. };
  114616. }
  114617. declare module BABYLON {
  114618. /** @hidden */
  114619. export var pbrHelperFunctions: {
  114620. name: string;
  114621. shader: string;
  114622. };
  114623. }
  114624. declare module BABYLON {
  114625. /** @hidden */
  114626. export var harmonicsFunctions: {
  114627. name: string;
  114628. shader: string;
  114629. };
  114630. }
  114631. declare module BABYLON {
  114632. /** @hidden */
  114633. export var pbrDirectLightingSetupFunctions: {
  114634. name: string;
  114635. shader: string;
  114636. };
  114637. }
  114638. declare module BABYLON {
  114639. /** @hidden */
  114640. export var pbrDirectLightingFalloffFunctions: {
  114641. name: string;
  114642. shader: string;
  114643. };
  114644. }
  114645. declare module BABYLON {
  114646. /** @hidden */
  114647. export var pbrBRDFFunctions: {
  114648. name: string;
  114649. shader: string;
  114650. };
  114651. }
  114652. declare module BABYLON {
  114653. /** @hidden */
  114654. export var pbrDirectLightingFunctions: {
  114655. name: string;
  114656. shader: string;
  114657. };
  114658. }
  114659. declare module BABYLON {
  114660. /** @hidden */
  114661. export var pbrIBLFunctions: {
  114662. name: string;
  114663. shader: string;
  114664. };
  114665. }
  114666. declare module BABYLON {
  114667. /** @hidden */
  114668. export var pbrDebug: {
  114669. name: string;
  114670. shader: string;
  114671. };
  114672. }
  114673. declare module BABYLON {
  114674. /** @hidden */
  114675. export var pbrPixelShader: {
  114676. name: string;
  114677. shader: string;
  114678. };
  114679. }
  114680. declare module BABYLON {
  114681. /** @hidden */
  114682. export var pbrVertexDeclaration: {
  114683. name: string;
  114684. shader: string;
  114685. };
  114686. }
  114687. declare module BABYLON {
  114688. /** @hidden */
  114689. export var pbrVertexShader: {
  114690. name: string;
  114691. shader: string;
  114692. };
  114693. }
  114694. declare module BABYLON {
  114695. /**
  114696. * Manages the defines for the PBR Material.
  114697. * @hidden
  114698. */
  114699. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114700. PBR: boolean;
  114701. MAINUV1: boolean;
  114702. MAINUV2: boolean;
  114703. UV1: boolean;
  114704. UV2: boolean;
  114705. ALBEDO: boolean;
  114706. ALBEDODIRECTUV: number;
  114707. VERTEXCOLOR: boolean;
  114708. AMBIENT: boolean;
  114709. AMBIENTDIRECTUV: number;
  114710. AMBIENTINGRAYSCALE: boolean;
  114711. OPACITY: boolean;
  114712. VERTEXALPHA: boolean;
  114713. OPACITYDIRECTUV: number;
  114714. OPACITYRGB: boolean;
  114715. ALPHATEST: boolean;
  114716. DEPTHPREPASS: boolean;
  114717. ALPHABLEND: boolean;
  114718. ALPHAFROMALBEDO: boolean;
  114719. ALPHATESTVALUE: string;
  114720. SPECULAROVERALPHA: boolean;
  114721. RADIANCEOVERALPHA: boolean;
  114722. ALPHAFRESNEL: boolean;
  114723. LINEARALPHAFRESNEL: boolean;
  114724. PREMULTIPLYALPHA: boolean;
  114725. EMISSIVE: boolean;
  114726. EMISSIVEDIRECTUV: number;
  114727. REFLECTIVITY: boolean;
  114728. REFLECTIVITYDIRECTUV: number;
  114729. SPECULARTERM: boolean;
  114730. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114731. MICROSURFACEAUTOMATIC: boolean;
  114732. LODBASEDMICROSFURACE: boolean;
  114733. MICROSURFACEMAP: boolean;
  114734. MICROSURFACEMAPDIRECTUV: number;
  114735. METALLICWORKFLOW: boolean;
  114736. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114737. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114738. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114739. AOSTOREINMETALMAPRED: boolean;
  114740. ENVIRONMENTBRDF: boolean;
  114741. ENVIRONMENTBRDF_RGBD: boolean;
  114742. NORMAL: boolean;
  114743. TANGENT: boolean;
  114744. BUMP: boolean;
  114745. BUMPDIRECTUV: number;
  114746. OBJECTSPACE_NORMALMAP: boolean;
  114747. PARALLAX: boolean;
  114748. PARALLAXOCCLUSION: boolean;
  114749. NORMALXYSCALE: boolean;
  114750. LIGHTMAP: boolean;
  114751. LIGHTMAPDIRECTUV: number;
  114752. USELIGHTMAPASSHADOWMAP: boolean;
  114753. GAMMALIGHTMAP: boolean;
  114754. RGBDLIGHTMAP: boolean;
  114755. REFLECTION: boolean;
  114756. REFLECTIONMAP_3D: boolean;
  114757. REFLECTIONMAP_SPHERICAL: boolean;
  114758. REFLECTIONMAP_PLANAR: boolean;
  114759. REFLECTIONMAP_CUBIC: boolean;
  114760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114761. REFLECTIONMAP_PROJECTION: boolean;
  114762. REFLECTIONMAP_SKYBOX: boolean;
  114763. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114764. REFLECTIONMAP_EXPLICIT: boolean;
  114765. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114766. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114767. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114768. INVERTCUBICMAP: boolean;
  114769. USESPHERICALFROMREFLECTIONMAP: boolean;
  114770. USEIRRADIANCEMAP: boolean;
  114771. SPHERICAL_HARMONICS: boolean;
  114772. USESPHERICALINVERTEX: boolean;
  114773. REFLECTIONMAP_OPPOSITEZ: boolean;
  114774. LODINREFLECTIONALPHA: boolean;
  114775. GAMMAREFLECTION: boolean;
  114776. RGBDREFLECTION: boolean;
  114777. LINEARSPECULARREFLECTION: boolean;
  114778. RADIANCEOCCLUSION: boolean;
  114779. HORIZONOCCLUSION: boolean;
  114780. INSTANCES: boolean;
  114781. NUM_BONE_INFLUENCERS: number;
  114782. BonesPerMesh: number;
  114783. BONETEXTURE: boolean;
  114784. NONUNIFORMSCALING: boolean;
  114785. MORPHTARGETS: boolean;
  114786. MORPHTARGETS_NORMAL: boolean;
  114787. MORPHTARGETS_TANGENT: boolean;
  114788. MORPHTARGETS_UV: boolean;
  114789. NUM_MORPH_INFLUENCERS: number;
  114790. IMAGEPROCESSING: boolean;
  114791. VIGNETTE: boolean;
  114792. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114793. VIGNETTEBLENDMODEOPAQUE: boolean;
  114794. TONEMAPPING: boolean;
  114795. TONEMAPPING_ACES: boolean;
  114796. CONTRAST: boolean;
  114797. COLORCURVES: boolean;
  114798. COLORGRADING: boolean;
  114799. COLORGRADING3D: boolean;
  114800. SAMPLER3DGREENDEPTH: boolean;
  114801. SAMPLER3DBGRMAP: boolean;
  114802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114803. EXPOSURE: boolean;
  114804. MULTIVIEW: boolean;
  114805. USEPHYSICALLIGHTFALLOFF: boolean;
  114806. USEGLTFLIGHTFALLOFF: boolean;
  114807. TWOSIDEDLIGHTING: boolean;
  114808. SHADOWFLOAT: boolean;
  114809. CLIPPLANE: boolean;
  114810. CLIPPLANE2: boolean;
  114811. CLIPPLANE3: boolean;
  114812. CLIPPLANE4: boolean;
  114813. POINTSIZE: boolean;
  114814. FOG: boolean;
  114815. LOGARITHMICDEPTH: boolean;
  114816. FORCENORMALFORWARD: boolean;
  114817. SPECULARAA: boolean;
  114818. CLEARCOAT: boolean;
  114819. CLEARCOAT_DEFAULTIOR: boolean;
  114820. CLEARCOAT_TEXTURE: boolean;
  114821. CLEARCOAT_TEXTUREDIRECTUV: number;
  114822. CLEARCOAT_BUMP: boolean;
  114823. CLEARCOAT_BUMPDIRECTUV: number;
  114824. CLEARCOAT_TINT: boolean;
  114825. CLEARCOAT_TINT_TEXTURE: boolean;
  114826. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114827. ANISOTROPIC: boolean;
  114828. ANISOTROPIC_TEXTURE: boolean;
  114829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114830. BRDF_V_HEIGHT_CORRELATED: boolean;
  114831. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114832. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114833. SHEEN: boolean;
  114834. SHEEN_TEXTURE: boolean;
  114835. SHEEN_TEXTUREDIRECTUV: number;
  114836. SHEEN_LINKWITHALBEDO: boolean;
  114837. SUBSURFACE: boolean;
  114838. SS_REFRACTION: boolean;
  114839. SS_TRANSLUCENCY: boolean;
  114840. SS_SCATERRING: boolean;
  114841. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114842. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114843. SS_REFRACTIONMAP_3D: boolean;
  114844. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114845. SS_LODINREFRACTIONALPHA: boolean;
  114846. SS_GAMMAREFRACTION: boolean;
  114847. SS_RGBDREFRACTION: boolean;
  114848. SS_LINEARSPECULARREFRACTION: boolean;
  114849. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114850. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114851. UNLIT: boolean;
  114852. DEBUGMODE: number;
  114853. /**
  114854. * Initializes the PBR Material defines.
  114855. */
  114856. constructor();
  114857. /**
  114858. * Resets the PBR Material defines.
  114859. */
  114860. reset(): void;
  114861. }
  114862. /**
  114863. * The Physically based material base class of BJS.
  114864. *
  114865. * This offers the main features of a standard PBR material.
  114866. * For more information, please refer to the documentation :
  114867. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114868. */
  114869. export abstract class PBRBaseMaterial extends PushMaterial {
  114870. /**
  114871. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114872. */
  114873. static readonly PBRMATERIAL_OPAQUE: number;
  114874. /**
  114875. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114876. */
  114877. static readonly PBRMATERIAL_ALPHATEST: number;
  114878. /**
  114879. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114880. */
  114881. static readonly PBRMATERIAL_ALPHABLEND: number;
  114882. /**
  114883. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114884. * They are also discarded below the alpha cutoff threshold to improve performances.
  114885. */
  114886. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114887. /**
  114888. * Defines the default value of how much AO map is occluding the analytical lights
  114889. * (point spot...).
  114890. */
  114891. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114892. /**
  114893. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114894. */
  114895. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114896. /**
  114897. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114898. * to enhance interoperability with other engines.
  114899. */
  114900. static readonly LIGHTFALLOFF_GLTF: number;
  114901. /**
  114902. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114903. * to enhance interoperability with other materials.
  114904. */
  114905. static readonly LIGHTFALLOFF_STANDARD: number;
  114906. /**
  114907. * Intensity of the direct lights e.g. the four lights available in your scene.
  114908. * This impacts both the direct diffuse and specular highlights.
  114909. */
  114910. protected _directIntensity: number;
  114911. /**
  114912. * Intensity of the emissive part of the material.
  114913. * This helps controlling the emissive effect without modifying the emissive color.
  114914. */
  114915. protected _emissiveIntensity: number;
  114916. /**
  114917. * Intensity of the environment e.g. how much the environment will light the object
  114918. * either through harmonics for rough material or through the refelction for shiny ones.
  114919. */
  114920. protected _environmentIntensity: number;
  114921. /**
  114922. * This is a special control allowing the reduction of the specular highlights coming from the
  114923. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114924. */
  114925. protected _specularIntensity: number;
  114926. /**
  114927. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114928. */
  114929. private _lightingInfos;
  114930. /**
  114931. * Debug Control allowing disabling the bump map on this material.
  114932. */
  114933. protected _disableBumpMap: boolean;
  114934. /**
  114935. * AKA Diffuse Texture in standard nomenclature.
  114936. */
  114937. protected _albedoTexture: Nullable<BaseTexture>;
  114938. /**
  114939. * AKA Occlusion Texture in other nomenclature.
  114940. */
  114941. protected _ambientTexture: Nullable<BaseTexture>;
  114942. /**
  114943. * AKA Occlusion Texture Intensity in other nomenclature.
  114944. */
  114945. protected _ambientTextureStrength: number;
  114946. /**
  114947. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114948. * 1 means it completely occludes it
  114949. * 0 mean it has no impact
  114950. */
  114951. protected _ambientTextureImpactOnAnalyticalLights: number;
  114952. /**
  114953. * Stores the alpha values in a texture.
  114954. */
  114955. protected _opacityTexture: Nullable<BaseTexture>;
  114956. /**
  114957. * Stores the reflection values in a texture.
  114958. */
  114959. protected _reflectionTexture: Nullable<BaseTexture>;
  114960. /**
  114961. * Stores the emissive values in a texture.
  114962. */
  114963. protected _emissiveTexture: Nullable<BaseTexture>;
  114964. /**
  114965. * AKA Specular texture in other nomenclature.
  114966. */
  114967. protected _reflectivityTexture: Nullable<BaseTexture>;
  114968. /**
  114969. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114970. */
  114971. protected _metallicTexture: Nullable<BaseTexture>;
  114972. /**
  114973. * Specifies the metallic scalar of the metallic/roughness workflow.
  114974. * Can also be used to scale the metalness values of the metallic texture.
  114975. */
  114976. protected _metallic: Nullable<number>;
  114977. /**
  114978. * Specifies the roughness scalar of the metallic/roughness workflow.
  114979. * Can also be used to scale the roughness values of the metallic texture.
  114980. */
  114981. protected _roughness: Nullable<number>;
  114982. /**
  114983. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114984. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114985. */
  114986. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114987. /**
  114988. * Stores surface normal data used to displace a mesh in a texture.
  114989. */
  114990. protected _bumpTexture: Nullable<BaseTexture>;
  114991. /**
  114992. * Stores the pre-calculated light information of a mesh in a texture.
  114993. */
  114994. protected _lightmapTexture: Nullable<BaseTexture>;
  114995. /**
  114996. * The color of a material in ambient lighting.
  114997. */
  114998. protected _ambientColor: Color3;
  114999. /**
  115000. * AKA Diffuse Color in other nomenclature.
  115001. */
  115002. protected _albedoColor: Color3;
  115003. /**
  115004. * AKA Specular Color in other nomenclature.
  115005. */
  115006. protected _reflectivityColor: Color3;
  115007. /**
  115008. * The color applied when light is reflected from a material.
  115009. */
  115010. protected _reflectionColor: Color3;
  115011. /**
  115012. * The color applied when light is emitted from a material.
  115013. */
  115014. protected _emissiveColor: Color3;
  115015. /**
  115016. * AKA Glossiness in other nomenclature.
  115017. */
  115018. protected _microSurface: number;
  115019. /**
  115020. * Specifies that the material will use the light map as a show map.
  115021. */
  115022. protected _useLightmapAsShadowmap: boolean;
  115023. /**
  115024. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115025. * makes the reflect vector face the model (under horizon).
  115026. */
  115027. protected _useHorizonOcclusion: boolean;
  115028. /**
  115029. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115030. * too much the area relying on ambient texture to define their ambient occlusion.
  115031. */
  115032. protected _useRadianceOcclusion: boolean;
  115033. /**
  115034. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115035. */
  115036. protected _useAlphaFromAlbedoTexture: boolean;
  115037. /**
  115038. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115039. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115040. */
  115041. protected _useSpecularOverAlpha: boolean;
  115042. /**
  115043. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115044. */
  115045. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115046. /**
  115047. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115048. */
  115049. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115050. /**
  115051. * Specifies if the metallic texture contains the roughness information in its green channel.
  115052. */
  115053. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115054. /**
  115055. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115056. */
  115057. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115058. /**
  115059. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115060. */
  115061. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115062. /**
  115063. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115064. */
  115065. protected _useAmbientInGrayScale: boolean;
  115066. /**
  115067. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115068. * The material will try to infer what glossiness each pixel should be.
  115069. */
  115070. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115071. /**
  115072. * Defines the falloff type used in this material.
  115073. * It by default is Physical.
  115074. */
  115075. protected _lightFalloff: number;
  115076. /**
  115077. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115078. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115079. */
  115080. protected _useRadianceOverAlpha: boolean;
  115081. /**
  115082. * Allows using an object space normal map (instead of tangent space).
  115083. */
  115084. protected _useObjectSpaceNormalMap: boolean;
  115085. /**
  115086. * Allows using the bump map in parallax mode.
  115087. */
  115088. protected _useParallax: boolean;
  115089. /**
  115090. * Allows using the bump map in parallax occlusion mode.
  115091. */
  115092. protected _useParallaxOcclusion: boolean;
  115093. /**
  115094. * Controls the scale bias of the parallax mode.
  115095. */
  115096. protected _parallaxScaleBias: number;
  115097. /**
  115098. * If sets to true, disables all the lights affecting the material.
  115099. */
  115100. protected _disableLighting: boolean;
  115101. /**
  115102. * Number of Simultaneous lights allowed on the material.
  115103. */
  115104. protected _maxSimultaneousLights: number;
  115105. /**
  115106. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115107. */
  115108. protected _invertNormalMapX: boolean;
  115109. /**
  115110. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115111. */
  115112. protected _invertNormalMapY: boolean;
  115113. /**
  115114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115115. */
  115116. protected _twoSidedLighting: boolean;
  115117. /**
  115118. * Defines the alpha limits in alpha test mode.
  115119. */
  115120. protected _alphaCutOff: number;
  115121. /**
  115122. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115123. */
  115124. protected _forceAlphaTest: boolean;
  115125. /**
  115126. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115127. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115128. */
  115129. protected _useAlphaFresnel: boolean;
  115130. /**
  115131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115132. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115133. */
  115134. protected _useLinearAlphaFresnel: boolean;
  115135. /**
  115136. * The transparency mode of the material.
  115137. */
  115138. protected _transparencyMode: Nullable<number>;
  115139. /**
  115140. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115141. * from cos thetav and roughness:
  115142. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115143. */
  115144. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115145. /**
  115146. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115147. */
  115148. protected _forceIrradianceInFragment: boolean;
  115149. /**
  115150. * Force normal to face away from face.
  115151. */
  115152. protected _forceNormalForward: boolean;
  115153. /**
  115154. * Enables specular anti aliasing in the PBR shader.
  115155. * It will both interacts on the Geometry for analytical and IBL lighting.
  115156. * It also prefilter the roughness map based on the bump values.
  115157. */
  115158. protected _enableSpecularAntiAliasing: boolean;
  115159. /**
  115160. * Default configuration related to image processing available in the PBR Material.
  115161. */
  115162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115163. /**
  115164. * Keep track of the image processing observer to allow dispose and replace.
  115165. */
  115166. private _imageProcessingObserver;
  115167. /**
  115168. * Attaches a new image processing configuration to the PBR Material.
  115169. * @param configuration
  115170. */
  115171. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115172. /**
  115173. * Stores the available render targets.
  115174. */
  115175. private _renderTargets;
  115176. /**
  115177. * Sets the global ambient color for the material used in lighting calculations.
  115178. */
  115179. private _globalAmbientColor;
  115180. /**
  115181. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115182. */
  115183. private _useLogarithmicDepth;
  115184. /**
  115185. * If set to true, no lighting calculations will be applied.
  115186. */
  115187. private _unlit;
  115188. private _debugMode;
  115189. /**
  115190. * @hidden
  115191. * This is reserved for the inspector.
  115192. * Defines the material debug mode.
  115193. * It helps seeing only some components of the material while troubleshooting.
  115194. */
  115195. debugMode: number;
  115196. /**
  115197. * @hidden
  115198. * This is reserved for the inspector.
  115199. * Specify from where on screen the debug mode should start.
  115200. * The value goes from -1 (full screen) to 1 (not visible)
  115201. * It helps with side by side comparison against the final render
  115202. * This defaults to -1
  115203. */
  115204. private debugLimit;
  115205. /**
  115206. * @hidden
  115207. * This is reserved for the inspector.
  115208. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115209. * You can use the factor to better multiply the final value.
  115210. */
  115211. private debugFactor;
  115212. /**
  115213. * Defines the clear coat layer parameters for the material.
  115214. */
  115215. readonly clearCoat: PBRClearCoatConfiguration;
  115216. /**
  115217. * Defines the anisotropic parameters for the material.
  115218. */
  115219. readonly anisotropy: PBRAnisotropicConfiguration;
  115220. /**
  115221. * Defines the BRDF parameters for the material.
  115222. */
  115223. readonly brdf: PBRBRDFConfiguration;
  115224. /**
  115225. * Defines the Sheen parameters for the material.
  115226. */
  115227. readonly sheen: PBRSheenConfiguration;
  115228. /**
  115229. * Defines the SubSurface parameters for the material.
  115230. */
  115231. readonly subSurface: PBRSubSurfaceConfiguration;
  115232. /**
  115233. * Custom callback helping to override the default shader used in the material.
  115234. */
  115235. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115236. protected _rebuildInParallel: boolean;
  115237. /**
  115238. * Instantiates a new PBRMaterial instance.
  115239. *
  115240. * @param name The material name
  115241. * @param scene The scene the material will be use in.
  115242. */
  115243. constructor(name: string, scene: Scene);
  115244. /**
  115245. * Gets a boolean indicating that current material needs to register RTT
  115246. */
  115247. readonly hasRenderTargetTextures: boolean;
  115248. /**
  115249. * Gets the name of the material class.
  115250. */
  115251. getClassName(): string;
  115252. /**
  115253. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115254. */
  115255. /**
  115256. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115257. */
  115258. useLogarithmicDepth: boolean;
  115259. /**
  115260. * Gets the current transparency mode.
  115261. */
  115262. /**
  115263. * Sets the transparency mode of the material.
  115264. *
  115265. * | Value | Type | Description |
  115266. * | ----- | ----------------------------------- | ----------- |
  115267. * | 0 | OPAQUE | |
  115268. * | 1 | ALPHATEST | |
  115269. * | 2 | ALPHABLEND | |
  115270. * | 3 | ALPHATESTANDBLEND | |
  115271. *
  115272. */
  115273. transparencyMode: Nullable<number>;
  115274. /**
  115275. * Returns true if alpha blending should be disabled.
  115276. */
  115277. private readonly _disableAlphaBlending;
  115278. /**
  115279. * Specifies whether or not this material should be rendered in alpha blend mode.
  115280. */
  115281. needAlphaBlending(): boolean;
  115282. /**
  115283. * Specifies if the mesh will require alpha blending.
  115284. * @param mesh - BJS mesh.
  115285. */
  115286. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115287. /**
  115288. * Specifies whether or not this material should be rendered in alpha test mode.
  115289. */
  115290. needAlphaTesting(): boolean;
  115291. /**
  115292. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115293. */
  115294. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115295. /**
  115296. * Gets the texture used for the alpha test.
  115297. */
  115298. getAlphaTestTexture(): Nullable<BaseTexture>;
  115299. /**
  115300. * Specifies that the submesh is ready to be used.
  115301. * @param mesh - BJS mesh.
  115302. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115303. * @param useInstances - Specifies that instances should be used.
  115304. * @returns - boolean indicating that the submesh is ready or not.
  115305. */
  115306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115307. /**
  115308. * Specifies if the material uses metallic roughness workflow.
  115309. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115310. */
  115311. isMetallicWorkflow(): boolean;
  115312. private _prepareEffect;
  115313. private _prepareDefines;
  115314. /**
  115315. * Force shader compilation
  115316. */
  115317. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  115318. clipPlane: boolean;
  115319. }>): void;
  115320. /**
  115321. * Initializes the uniform buffer layout for the shader.
  115322. */
  115323. buildUniformLayout(): void;
  115324. /**
  115325. * Unbinds the material from the mesh
  115326. */
  115327. unbind(): void;
  115328. /**
  115329. * Binds the submesh data.
  115330. * @param world - The world matrix.
  115331. * @param mesh - The BJS mesh.
  115332. * @param subMesh - A submesh of the BJS mesh.
  115333. */
  115334. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115335. /**
  115336. * Returns the animatable textures.
  115337. * @returns - Array of animatable textures.
  115338. */
  115339. getAnimatables(): IAnimatable[];
  115340. /**
  115341. * Returns the texture used for reflections.
  115342. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115343. */
  115344. private _getReflectionTexture;
  115345. /**
  115346. * Returns an array of the actively used textures.
  115347. * @returns - Array of BaseTextures
  115348. */
  115349. getActiveTextures(): BaseTexture[];
  115350. /**
  115351. * Checks to see if a texture is used in the material.
  115352. * @param texture - Base texture to use.
  115353. * @returns - Boolean specifying if a texture is used in the material.
  115354. */
  115355. hasTexture(texture: BaseTexture): boolean;
  115356. /**
  115357. * Disposes the resources of the material.
  115358. * @param forceDisposeEffect - Forces the disposal of effects.
  115359. * @param forceDisposeTextures - Forces the disposal of all textures.
  115360. */
  115361. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115362. }
  115363. }
  115364. declare module BABYLON {
  115365. /**
  115366. * The Physically based material of BJS.
  115367. *
  115368. * This offers the main features of a standard PBR material.
  115369. * For more information, please refer to the documentation :
  115370. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115371. */
  115372. export class PBRMaterial extends PBRBaseMaterial {
  115373. /**
  115374. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115375. */
  115376. static readonly PBRMATERIAL_OPAQUE: number;
  115377. /**
  115378. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115379. */
  115380. static readonly PBRMATERIAL_ALPHATEST: number;
  115381. /**
  115382. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115383. */
  115384. static readonly PBRMATERIAL_ALPHABLEND: number;
  115385. /**
  115386. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115387. * They are also discarded below the alpha cutoff threshold to improve performances.
  115388. */
  115389. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115390. /**
  115391. * Defines the default value of how much AO map is occluding the analytical lights
  115392. * (point spot...).
  115393. */
  115394. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115395. /**
  115396. * Intensity of the direct lights e.g. the four lights available in your scene.
  115397. * This impacts both the direct diffuse and specular highlights.
  115398. */
  115399. directIntensity: number;
  115400. /**
  115401. * Intensity of the emissive part of the material.
  115402. * This helps controlling the emissive effect without modifying the emissive color.
  115403. */
  115404. emissiveIntensity: number;
  115405. /**
  115406. * Intensity of the environment e.g. how much the environment will light the object
  115407. * either through harmonics for rough material or through the refelction for shiny ones.
  115408. */
  115409. environmentIntensity: number;
  115410. /**
  115411. * This is a special control allowing the reduction of the specular highlights coming from the
  115412. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115413. */
  115414. specularIntensity: number;
  115415. /**
  115416. * Debug Control allowing disabling the bump map on this material.
  115417. */
  115418. disableBumpMap: boolean;
  115419. /**
  115420. * AKA Diffuse Texture in standard nomenclature.
  115421. */
  115422. albedoTexture: BaseTexture;
  115423. /**
  115424. * AKA Occlusion Texture in other nomenclature.
  115425. */
  115426. ambientTexture: BaseTexture;
  115427. /**
  115428. * AKA Occlusion Texture Intensity in other nomenclature.
  115429. */
  115430. ambientTextureStrength: number;
  115431. /**
  115432. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115433. * 1 means it completely occludes it
  115434. * 0 mean it has no impact
  115435. */
  115436. ambientTextureImpactOnAnalyticalLights: number;
  115437. /**
  115438. * Stores the alpha values in a texture.
  115439. */
  115440. opacityTexture: BaseTexture;
  115441. /**
  115442. * Stores the reflection values in a texture.
  115443. */
  115444. reflectionTexture: Nullable<BaseTexture>;
  115445. /**
  115446. * Stores the emissive values in a texture.
  115447. */
  115448. emissiveTexture: BaseTexture;
  115449. /**
  115450. * AKA Specular texture in other nomenclature.
  115451. */
  115452. reflectivityTexture: BaseTexture;
  115453. /**
  115454. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115455. */
  115456. metallicTexture: BaseTexture;
  115457. /**
  115458. * Specifies the metallic scalar of the metallic/roughness workflow.
  115459. * Can also be used to scale the metalness values of the metallic texture.
  115460. */
  115461. metallic: Nullable<number>;
  115462. /**
  115463. * Specifies the roughness scalar of the metallic/roughness workflow.
  115464. * Can also be used to scale the roughness values of the metallic texture.
  115465. */
  115466. roughness: Nullable<number>;
  115467. /**
  115468. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115469. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115470. */
  115471. microSurfaceTexture: BaseTexture;
  115472. /**
  115473. * Stores surface normal data used to displace a mesh in a texture.
  115474. */
  115475. bumpTexture: BaseTexture;
  115476. /**
  115477. * Stores the pre-calculated light information of a mesh in a texture.
  115478. */
  115479. lightmapTexture: BaseTexture;
  115480. /**
  115481. * Stores the refracted light information in a texture.
  115482. */
  115483. refractionTexture: Nullable<BaseTexture>;
  115484. /**
  115485. * The color of a material in ambient lighting.
  115486. */
  115487. ambientColor: Color3;
  115488. /**
  115489. * AKA Diffuse Color in other nomenclature.
  115490. */
  115491. albedoColor: Color3;
  115492. /**
  115493. * AKA Specular Color in other nomenclature.
  115494. */
  115495. reflectivityColor: Color3;
  115496. /**
  115497. * The color reflected from the material.
  115498. */
  115499. reflectionColor: Color3;
  115500. /**
  115501. * The color emitted from the material.
  115502. */
  115503. emissiveColor: Color3;
  115504. /**
  115505. * AKA Glossiness in other nomenclature.
  115506. */
  115507. microSurface: number;
  115508. /**
  115509. * source material index of refraction (IOR)' / 'destination material IOR.
  115510. */
  115511. indexOfRefraction: number;
  115512. /**
  115513. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115514. */
  115515. invertRefractionY: boolean;
  115516. /**
  115517. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115518. * Materials half opaque for instance using refraction could benefit from this control.
  115519. */
  115520. linkRefractionWithTransparency: boolean;
  115521. /**
  115522. * If true, the light map contains occlusion information instead of lighting info.
  115523. */
  115524. useLightmapAsShadowmap: boolean;
  115525. /**
  115526. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115527. */
  115528. useAlphaFromAlbedoTexture: boolean;
  115529. /**
  115530. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115531. */
  115532. forceAlphaTest: boolean;
  115533. /**
  115534. * Defines the alpha limits in alpha test mode.
  115535. */
  115536. alphaCutOff: number;
  115537. /**
  115538. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115539. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115540. */
  115541. useSpecularOverAlpha: boolean;
  115542. /**
  115543. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115544. */
  115545. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115546. /**
  115547. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115548. */
  115549. useRoughnessFromMetallicTextureAlpha: boolean;
  115550. /**
  115551. * Specifies if the metallic texture contains the roughness information in its green channel.
  115552. */
  115553. useRoughnessFromMetallicTextureGreen: boolean;
  115554. /**
  115555. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115556. */
  115557. useMetallnessFromMetallicTextureBlue: boolean;
  115558. /**
  115559. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115560. */
  115561. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115562. /**
  115563. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115564. */
  115565. useAmbientInGrayScale: boolean;
  115566. /**
  115567. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115568. * The material will try to infer what glossiness each pixel should be.
  115569. */
  115570. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115571. /**
  115572. * BJS is using an harcoded light falloff based on a manually sets up range.
  115573. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115574. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115575. */
  115576. /**
  115577. * BJS is using an harcoded light falloff based on a manually sets up range.
  115578. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115579. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115580. */
  115581. usePhysicalLightFalloff: boolean;
  115582. /**
  115583. * In order to support the falloff compatibility with gltf, a special mode has been added
  115584. * to reproduce the gltf light falloff.
  115585. */
  115586. /**
  115587. * In order to support the falloff compatibility with gltf, a special mode has been added
  115588. * to reproduce the gltf light falloff.
  115589. */
  115590. useGLTFLightFalloff: boolean;
  115591. /**
  115592. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115593. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115594. */
  115595. useRadianceOverAlpha: boolean;
  115596. /**
  115597. * Allows using an object space normal map (instead of tangent space).
  115598. */
  115599. useObjectSpaceNormalMap: boolean;
  115600. /**
  115601. * Allows using the bump map in parallax mode.
  115602. */
  115603. useParallax: boolean;
  115604. /**
  115605. * Allows using the bump map in parallax occlusion mode.
  115606. */
  115607. useParallaxOcclusion: boolean;
  115608. /**
  115609. * Controls the scale bias of the parallax mode.
  115610. */
  115611. parallaxScaleBias: number;
  115612. /**
  115613. * If sets to true, disables all the lights affecting the material.
  115614. */
  115615. disableLighting: boolean;
  115616. /**
  115617. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115618. */
  115619. forceIrradianceInFragment: boolean;
  115620. /**
  115621. * Number of Simultaneous lights allowed on the material.
  115622. */
  115623. maxSimultaneousLights: number;
  115624. /**
  115625. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115626. */
  115627. invertNormalMapX: boolean;
  115628. /**
  115629. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115630. */
  115631. invertNormalMapY: boolean;
  115632. /**
  115633. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115634. */
  115635. twoSidedLighting: boolean;
  115636. /**
  115637. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115638. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115639. */
  115640. useAlphaFresnel: boolean;
  115641. /**
  115642. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115643. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115644. */
  115645. useLinearAlphaFresnel: boolean;
  115646. /**
  115647. * Let user defines the brdf lookup texture used for IBL.
  115648. * A default 8bit version is embedded but you could point at :
  115649. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115650. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115651. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115652. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115653. */
  115654. environmentBRDFTexture: Nullable<BaseTexture>;
  115655. /**
  115656. * Force normal to face away from face.
  115657. */
  115658. forceNormalForward: boolean;
  115659. /**
  115660. * Enables specular anti aliasing in the PBR shader.
  115661. * It will both interacts on the Geometry for analytical and IBL lighting.
  115662. * It also prefilter the roughness map based on the bump values.
  115663. */
  115664. enableSpecularAntiAliasing: boolean;
  115665. /**
  115666. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115667. * makes the reflect vector face the model (under horizon).
  115668. */
  115669. useHorizonOcclusion: boolean;
  115670. /**
  115671. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115672. * too much the area relying on ambient texture to define their ambient occlusion.
  115673. */
  115674. useRadianceOcclusion: boolean;
  115675. /**
  115676. * If set to true, no lighting calculations will be applied.
  115677. */
  115678. unlit: boolean;
  115679. /**
  115680. * Gets the image processing configuration used either in this material.
  115681. */
  115682. /**
  115683. * Sets the Default image processing configuration used either in the this material.
  115684. *
  115685. * If sets to null, the scene one is in use.
  115686. */
  115687. imageProcessingConfiguration: ImageProcessingConfiguration;
  115688. /**
  115689. * Gets wether the color curves effect is enabled.
  115690. */
  115691. /**
  115692. * Sets wether the color curves effect is enabled.
  115693. */
  115694. cameraColorCurvesEnabled: boolean;
  115695. /**
  115696. * Gets wether the color grading effect is enabled.
  115697. */
  115698. /**
  115699. * Gets wether the color grading effect is enabled.
  115700. */
  115701. cameraColorGradingEnabled: boolean;
  115702. /**
  115703. * Gets wether tonemapping is enabled or not.
  115704. */
  115705. /**
  115706. * Sets wether tonemapping is enabled or not
  115707. */
  115708. cameraToneMappingEnabled: boolean;
  115709. /**
  115710. * The camera exposure used on this material.
  115711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115712. * This corresponds to a photographic exposure.
  115713. */
  115714. /**
  115715. * The camera exposure used on this material.
  115716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115717. * This corresponds to a photographic exposure.
  115718. */
  115719. cameraExposure: number;
  115720. /**
  115721. * Gets The camera contrast used on this material.
  115722. */
  115723. /**
  115724. * Sets The camera contrast used on this material.
  115725. */
  115726. cameraContrast: number;
  115727. /**
  115728. * Gets the Color Grading 2D Lookup Texture.
  115729. */
  115730. /**
  115731. * Sets the Color Grading 2D Lookup Texture.
  115732. */
  115733. cameraColorGradingTexture: Nullable<BaseTexture>;
  115734. /**
  115735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115737. * 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;
  115738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115739. */
  115740. /**
  115741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115743. * 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;
  115744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115745. */
  115746. cameraColorCurves: Nullable<ColorCurves>;
  115747. /**
  115748. * Instantiates a new PBRMaterial instance.
  115749. *
  115750. * @param name The material name
  115751. * @param scene The scene the material will be use in.
  115752. */
  115753. constructor(name: string, scene: Scene);
  115754. /**
  115755. * Returns the name of this material class.
  115756. */
  115757. getClassName(): string;
  115758. /**
  115759. * Makes a duplicate of the current material.
  115760. * @param name - name to use for the new material.
  115761. */
  115762. clone(name: string): PBRMaterial;
  115763. /**
  115764. * Serializes this PBR Material.
  115765. * @returns - An object with the serialized material.
  115766. */
  115767. serialize(): any;
  115768. /**
  115769. * Parses a PBR Material from a serialized object.
  115770. * @param source - Serialized object.
  115771. * @param scene - BJS scene instance.
  115772. * @param rootUrl - url for the scene object
  115773. * @returns - PBRMaterial
  115774. */
  115775. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115776. }
  115777. }
  115778. declare module BABYLON {
  115779. /**
  115780. * Direct draw surface info
  115781. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115782. */
  115783. export interface DDSInfo {
  115784. /**
  115785. * Width of the texture
  115786. */
  115787. width: number;
  115788. /**
  115789. * Width of the texture
  115790. */
  115791. height: number;
  115792. /**
  115793. * Number of Mipmaps for the texture
  115794. * @see https://en.wikipedia.org/wiki/Mipmap
  115795. */
  115796. mipmapCount: number;
  115797. /**
  115798. * If the textures format is a known fourCC format
  115799. * @see https://www.fourcc.org/
  115800. */
  115801. isFourCC: boolean;
  115802. /**
  115803. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115804. */
  115805. isRGB: boolean;
  115806. /**
  115807. * If the texture is a lumincance format
  115808. */
  115809. isLuminance: boolean;
  115810. /**
  115811. * If this is a cube texture
  115812. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115813. */
  115814. isCube: boolean;
  115815. /**
  115816. * If the texture is a compressed format eg. FOURCC_DXT1
  115817. */
  115818. isCompressed: boolean;
  115819. /**
  115820. * The dxgiFormat of the texture
  115821. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115822. */
  115823. dxgiFormat: number;
  115824. /**
  115825. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115826. */
  115827. textureType: number;
  115828. /**
  115829. * Sphericle polynomial created for the dds texture
  115830. */
  115831. sphericalPolynomial?: SphericalPolynomial;
  115832. }
  115833. /**
  115834. * Class used to provide DDS decompression tools
  115835. */
  115836. export class DDSTools {
  115837. /**
  115838. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115839. */
  115840. static StoreLODInAlphaChannel: boolean;
  115841. /**
  115842. * Gets DDS information from an array buffer
  115843. * @param arrayBuffer defines the array buffer to read data from
  115844. * @returns the DDS information
  115845. */
  115846. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115847. private static _FloatView;
  115848. private static _Int32View;
  115849. private static _ToHalfFloat;
  115850. private static _FromHalfFloat;
  115851. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115852. private static _GetHalfFloatRGBAArrayBuffer;
  115853. private static _GetFloatRGBAArrayBuffer;
  115854. private static _GetFloatAsUIntRGBAArrayBuffer;
  115855. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115856. private static _GetRGBAArrayBuffer;
  115857. private static _ExtractLongWordOrder;
  115858. private static _GetRGBArrayBuffer;
  115859. private static _GetLuminanceArrayBuffer;
  115860. /**
  115861. * Uploads DDS Levels to a Babylon Texture
  115862. * @hidden
  115863. */
  115864. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115865. }
  115866. interface ThinEngine {
  115867. /**
  115868. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115869. * @param rootUrl defines the url where the file to load is located
  115870. * @param scene defines the current scene
  115871. * @param lodScale defines scale to apply to the mip map selection
  115872. * @param lodOffset defines offset to apply to the mip map selection
  115873. * @param onLoad defines an optional callback raised when the texture is loaded
  115874. * @param onError defines an optional callback raised if there is an issue to load the texture
  115875. * @param format defines the format of the data
  115876. * @param forcedExtension defines the extension to use to pick the right loader
  115877. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115878. * @returns the cube texture as an InternalTexture
  115879. */
  115880. 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;
  115881. }
  115882. }
  115883. declare module BABYLON {
  115884. /**
  115885. * Implementation of the DDS Texture Loader.
  115886. * @hidden
  115887. */
  115888. export class _DDSTextureLoader implements IInternalTextureLoader {
  115889. /**
  115890. * Defines wether the loader supports cascade loading the different faces.
  115891. */
  115892. readonly supportCascades: boolean;
  115893. /**
  115894. * This returns if the loader support the current file information.
  115895. * @param extension defines the file extension of the file being loaded
  115896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115897. * @param fallback defines the fallback internal texture if any
  115898. * @param isBase64 defines whether the texture is encoded as a base64
  115899. * @param isBuffer defines whether the texture data are stored as a buffer
  115900. * @returns true if the loader can load the specified file
  115901. */
  115902. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115903. /**
  115904. * Transform the url before loading if required.
  115905. * @param rootUrl the url of the texture
  115906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115907. * @returns the transformed texture
  115908. */
  115909. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115910. /**
  115911. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115912. * @param rootUrl the url of the texture
  115913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115914. * @returns the fallback texture
  115915. */
  115916. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115917. /**
  115918. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115919. * @param data contains the texture data
  115920. * @param texture defines the BabylonJS internal texture
  115921. * @param createPolynomials will be true if polynomials have been requested
  115922. * @param onLoad defines the callback to trigger once the texture is ready
  115923. * @param onError defines the callback to trigger in case of error
  115924. */
  115925. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115926. /**
  115927. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115928. * @param data contains the texture data
  115929. * @param texture defines the BabylonJS internal texture
  115930. * @param callback defines the method to call once ready to upload
  115931. */
  115932. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115933. }
  115934. }
  115935. declare module BABYLON {
  115936. /**
  115937. * Implementation of the ENV Texture Loader.
  115938. * @hidden
  115939. */
  115940. export class _ENVTextureLoader implements IInternalTextureLoader {
  115941. /**
  115942. * Defines wether the loader supports cascade loading the different faces.
  115943. */
  115944. readonly supportCascades: boolean;
  115945. /**
  115946. * This returns if the loader support the current file information.
  115947. * @param extension defines the file extension of the file being loaded
  115948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115949. * @param fallback defines the fallback internal texture if any
  115950. * @param isBase64 defines whether the texture is encoded as a base64
  115951. * @param isBuffer defines whether the texture data are stored as a buffer
  115952. * @returns true if the loader can load the specified file
  115953. */
  115954. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115955. /**
  115956. * Transform the url before loading if required.
  115957. * @param rootUrl the url of the texture
  115958. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115959. * @returns the transformed texture
  115960. */
  115961. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115962. /**
  115963. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115964. * @param rootUrl the url of the texture
  115965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115966. * @returns the fallback texture
  115967. */
  115968. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115969. /**
  115970. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115971. * @param data contains the texture data
  115972. * @param texture defines the BabylonJS internal texture
  115973. * @param createPolynomials will be true if polynomials have been requested
  115974. * @param onLoad defines the callback to trigger once the texture is ready
  115975. * @param onError defines the callback to trigger in case of error
  115976. */
  115977. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115978. /**
  115979. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115980. * @param data contains the texture data
  115981. * @param texture defines the BabylonJS internal texture
  115982. * @param callback defines the method to call once ready to upload
  115983. */
  115984. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115985. }
  115986. }
  115987. declare module BABYLON {
  115988. /**
  115989. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115990. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115991. */
  115992. export class KhronosTextureContainer {
  115993. /** contents of the KTX container file */
  115994. arrayBuffer: any;
  115995. private static HEADER_LEN;
  115996. private static COMPRESSED_2D;
  115997. private static COMPRESSED_3D;
  115998. private static TEX_2D;
  115999. private static TEX_3D;
  116000. /**
  116001. * Gets the openGL type
  116002. */
  116003. glType: number;
  116004. /**
  116005. * Gets the openGL type size
  116006. */
  116007. glTypeSize: number;
  116008. /**
  116009. * Gets the openGL format
  116010. */
  116011. glFormat: number;
  116012. /**
  116013. * Gets the openGL internal format
  116014. */
  116015. glInternalFormat: number;
  116016. /**
  116017. * Gets the base internal format
  116018. */
  116019. glBaseInternalFormat: number;
  116020. /**
  116021. * Gets image width in pixel
  116022. */
  116023. pixelWidth: number;
  116024. /**
  116025. * Gets image height in pixel
  116026. */
  116027. pixelHeight: number;
  116028. /**
  116029. * Gets image depth in pixels
  116030. */
  116031. pixelDepth: number;
  116032. /**
  116033. * Gets the number of array elements
  116034. */
  116035. numberOfArrayElements: number;
  116036. /**
  116037. * Gets the number of faces
  116038. */
  116039. numberOfFaces: number;
  116040. /**
  116041. * Gets the number of mipmap levels
  116042. */
  116043. numberOfMipmapLevels: number;
  116044. /**
  116045. * Gets the bytes of key value data
  116046. */
  116047. bytesOfKeyValueData: number;
  116048. /**
  116049. * Gets the load type
  116050. */
  116051. loadType: number;
  116052. /**
  116053. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116054. */
  116055. isInvalid: boolean;
  116056. /**
  116057. * Creates a new KhronosTextureContainer
  116058. * @param arrayBuffer contents of the KTX container file
  116059. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116060. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116061. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116062. */
  116063. constructor(
  116064. /** contents of the KTX container file */
  116065. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116066. /**
  116067. * Uploads KTX content to a Babylon Texture.
  116068. * It is assumed that the texture has already been created & is currently bound
  116069. * @hidden
  116070. */
  116071. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116072. private _upload2DCompressedLevels;
  116073. }
  116074. }
  116075. declare module BABYLON {
  116076. /**
  116077. * Implementation of the KTX Texture Loader.
  116078. * @hidden
  116079. */
  116080. export class _KTXTextureLoader implements IInternalTextureLoader {
  116081. /**
  116082. * Defines wether the loader supports cascade loading the different faces.
  116083. */
  116084. readonly supportCascades: boolean;
  116085. /**
  116086. * This returns if the loader support the current file information.
  116087. * @param extension defines the file extension of the file being loaded
  116088. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116089. * @param fallback defines the fallback internal texture if any
  116090. * @param isBase64 defines whether the texture is encoded as a base64
  116091. * @param isBuffer defines whether the texture data are stored as a buffer
  116092. * @returns true if the loader can load the specified file
  116093. */
  116094. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116095. /**
  116096. * Transform the url before loading if required.
  116097. * @param rootUrl the url of the texture
  116098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116099. * @returns the transformed texture
  116100. */
  116101. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116102. /**
  116103. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116104. * @param rootUrl the url of the texture
  116105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116106. * @returns the fallback texture
  116107. */
  116108. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116109. /**
  116110. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116111. * @param data contains the texture data
  116112. * @param texture defines the BabylonJS internal texture
  116113. * @param createPolynomials will be true if polynomials have been requested
  116114. * @param onLoad defines the callback to trigger once the texture is ready
  116115. * @param onError defines the callback to trigger in case of error
  116116. */
  116117. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116118. /**
  116119. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116120. * @param data contains the texture data
  116121. * @param texture defines the BabylonJS internal texture
  116122. * @param callback defines the method to call once ready to upload
  116123. */
  116124. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116125. }
  116126. }
  116127. declare module BABYLON {
  116128. /**
  116129. * Options for the default xr helper
  116130. */
  116131. export class WebXRDefaultExperienceOptions {
  116132. /**
  116133. * Floor meshes that should be used for teleporting
  116134. */
  116135. floorMeshes: Array<AbstractMesh>;
  116136. }
  116137. /**
  116138. * Default experience which provides a similar setup to the previous webVRExperience
  116139. */
  116140. export class WebXRDefaultExperience {
  116141. /**
  116142. * Base experience
  116143. */
  116144. baseExperience: WebXRExperienceHelper;
  116145. /**
  116146. * Input experience extension
  116147. */
  116148. input: WebXRInput;
  116149. /**
  116150. * Loads the controller models
  116151. */
  116152. controllerModelLoader: WebXRControllerModelLoader;
  116153. /**
  116154. * Enables laser pointer and selection
  116155. */
  116156. pointerSelection: WebXRControllerPointerSelection;
  116157. /**
  116158. * Enables teleportation
  116159. */
  116160. teleportation: WebXRControllerTeleportation;
  116161. /**
  116162. * Enables ui for enetering/exiting xr
  116163. */
  116164. enterExitUI: WebXREnterExitUI;
  116165. /**
  116166. * Default output canvas xr should render to
  116167. */
  116168. outputCanvas: WebXRManagedOutputCanvas;
  116169. /**
  116170. * Creates the default xr experience
  116171. * @param scene scene
  116172. * @param options options for basic configuration
  116173. * @returns resulting WebXRDefaultExperience
  116174. */
  116175. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116176. private constructor();
  116177. /**
  116178. * DIsposes of the experience helper
  116179. */
  116180. dispose(): void;
  116181. }
  116182. }
  116183. declare module BABYLON {
  116184. /** @hidden */
  116185. export var _forceSceneHelpersToBundle: boolean;
  116186. interface Scene {
  116187. /**
  116188. * Creates a default light for the scene.
  116189. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116190. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116191. */
  116192. createDefaultLight(replace?: boolean): void;
  116193. /**
  116194. * Creates a default camera for the scene.
  116195. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116196. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116197. * @param replace has default false, when true replaces the active camera in the scene
  116198. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116199. */
  116200. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116201. /**
  116202. * Creates a default camera and a default light.
  116203. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116204. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116205. * @param replace has the default false, when true replaces the active camera/light in the scene
  116206. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116207. */
  116208. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116209. /**
  116210. * Creates a new sky box
  116211. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116212. * @param environmentTexture defines the texture to use as environment texture
  116213. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116214. * @param scale defines the overall scale of the skybox
  116215. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116216. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116217. * @returns a new mesh holding the sky box
  116218. */
  116219. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116220. /**
  116221. * Creates a new environment
  116222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116223. * @param options defines the options you can use to configure the environment
  116224. * @returns the new EnvironmentHelper
  116225. */
  116226. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116227. /**
  116228. * Creates a new VREXperienceHelper
  116229. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116230. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116231. * @returns a new VREXperienceHelper
  116232. */
  116233. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116234. /**
  116235. * Creates a new WebXRDefaultExperience
  116236. * @see http://doc.babylonjs.com/how_to/webxr
  116237. * @param options experience options
  116238. * @returns a promise for a new WebXRDefaultExperience
  116239. */
  116240. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116241. }
  116242. }
  116243. declare module BABYLON {
  116244. /**
  116245. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116246. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116247. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116248. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116249. */
  116250. export class VideoDome extends TransformNode {
  116251. /**
  116252. * Define the video source as a Monoscopic panoramic 360 video.
  116253. */
  116254. static readonly MODE_MONOSCOPIC: number;
  116255. /**
  116256. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116257. */
  116258. static readonly MODE_TOPBOTTOM: number;
  116259. /**
  116260. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116261. */
  116262. static readonly MODE_SIDEBYSIDE: number;
  116263. private _halfDome;
  116264. private _useDirectMapping;
  116265. /**
  116266. * The video texture being displayed on the sphere
  116267. */
  116268. protected _videoTexture: VideoTexture;
  116269. /**
  116270. * Gets the video texture being displayed on the sphere
  116271. */
  116272. readonly videoTexture: VideoTexture;
  116273. /**
  116274. * The skybox material
  116275. */
  116276. protected _material: BackgroundMaterial;
  116277. /**
  116278. * The surface used for the skybox
  116279. */
  116280. protected _mesh: Mesh;
  116281. /**
  116282. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116283. */
  116284. private _halfDomeMask;
  116285. /**
  116286. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116287. * Also see the options.resolution property.
  116288. */
  116289. fovMultiplier: number;
  116290. private _videoMode;
  116291. /**
  116292. * Gets or set the current video mode for the video. It can be:
  116293. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116294. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116295. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116296. */
  116297. videoMode: number;
  116298. /**
  116299. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116300. *
  116301. */
  116302. /**
  116303. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116304. */
  116305. halfDome: boolean;
  116306. /**
  116307. * Oberserver used in Stereoscopic VR Mode.
  116308. */
  116309. private _onBeforeCameraRenderObserver;
  116310. /**
  116311. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116312. * @param name Element's name, child elements will append suffixes for their own names.
  116313. * @param urlsOrVideo defines the url(s) or the video element to use
  116314. * @param options An object containing optional or exposed sub element properties
  116315. */
  116316. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116317. resolution?: number;
  116318. clickToPlay?: boolean;
  116319. autoPlay?: boolean;
  116320. loop?: boolean;
  116321. size?: number;
  116322. poster?: string;
  116323. faceForward?: boolean;
  116324. useDirectMapping?: boolean;
  116325. halfDomeMode?: boolean;
  116326. }, scene: Scene);
  116327. private _changeVideoMode;
  116328. /**
  116329. * Releases resources associated with this node.
  116330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116332. */
  116333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116334. }
  116335. }
  116336. declare module BABYLON {
  116337. /**
  116338. * This class can be used to get instrumentation data from a Babylon engine
  116339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116340. */
  116341. export class EngineInstrumentation implements IDisposable {
  116342. /**
  116343. * Define the instrumented engine.
  116344. */
  116345. engine: Engine;
  116346. private _captureGPUFrameTime;
  116347. private _gpuFrameTimeToken;
  116348. private _gpuFrameTime;
  116349. private _captureShaderCompilationTime;
  116350. private _shaderCompilationTime;
  116351. private _onBeginFrameObserver;
  116352. private _onEndFrameObserver;
  116353. private _onBeforeShaderCompilationObserver;
  116354. private _onAfterShaderCompilationObserver;
  116355. /**
  116356. * Gets the perf counter used for GPU frame time
  116357. */
  116358. readonly gpuFrameTimeCounter: PerfCounter;
  116359. /**
  116360. * Gets the GPU frame time capture status
  116361. */
  116362. /**
  116363. * Enable or disable the GPU frame time capture
  116364. */
  116365. captureGPUFrameTime: boolean;
  116366. /**
  116367. * Gets the perf counter used for shader compilation time
  116368. */
  116369. readonly shaderCompilationTimeCounter: PerfCounter;
  116370. /**
  116371. * Gets the shader compilation time capture status
  116372. */
  116373. /**
  116374. * Enable or disable the shader compilation time capture
  116375. */
  116376. captureShaderCompilationTime: boolean;
  116377. /**
  116378. * Instantiates a new engine instrumentation.
  116379. * This class can be used to get instrumentation data from a Babylon engine
  116380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116381. * @param engine Defines the engine to instrument
  116382. */
  116383. constructor(
  116384. /**
  116385. * Define the instrumented engine.
  116386. */
  116387. engine: Engine);
  116388. /**
  116389. * Dispose and release associated resources.
  116390. */
  116391. dispose(): void;
  116392. }
  116393. }
  116394. declare module BABYLON {
  116395. /**
  116396. * This class can be used to get instrumentation data from a Babylon engine
  116397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116398. */
  116399. export class SceneInstrumentation implements IDisposable {
  116400. /**
  116401. * Defines the scene to instrument
  116402. */
  116403. scene: Scene;
  116404. private _captureActiveMeshesEvaluationTime;
  116405. private _activeMeshesEvaluationTime;
  116406. private _captureRenderTargetsRenderTime;
  116407. private _renderTargetsRenderTime;
  116408. private _captureFrameTime;
  116409. private _frameTime;
  116410. private _captureRenderTime;
  116411. private _renderTime;
  116412. private _captureInterFrameTime;
  116413. private _interFrameTime;
  116414. private _captureParticlesRenderTime;
  116415. private _particlesRenderTime;
  116416. private _captureSpritesRenderTime;
  116417. private _spritesRenderTime;
  116418. private _capturePhysicsTime;
  116419. private _physicsTime;
  116420. private _captureAnimationsTime;
  116421. private _animationsTime;
  116422. private _captureCameraRenderTime;
  116423. private _cameraRenderTime;
  116424. private _onBeforeActiveMeshesEvaluationObserver;
  116425. private _onAfterActiveMeshesEvaluationObserver;
  116426. private _onBeforeRenderTargetsRenderObserver;
  116427. private _onAfterRenderTargetsRenderObserver;
  116428. private _onAfterRenderObserver;
  116429. private _onBeforeDrawPhaseObserver;
  116430. private _onAfterDrawPhaseObserver;
  116431. private _onBeforeAnimationsObserver;
  116432. private _onBeforeParticlesRenderingObserver;
  116433. private _onAfterParticlesRenderingObserver;
  116434. private _onBeforeSpritesRenderingObserver;
  116435. private _onAfterSpritesRenderingObserver;
  116436. private _onBeforePhysicsObserver;
  116437. private _onAfterPhysicsObserver;
  116438. private _onAfterAnimationsObserver;
  116439. private _onBeforeCameraRenderObserver;
  116440. private _onAfterCameraRenderObserver;
  116441. /**
  116442. * Gets the perf counter used for active meshes evaluation time
  116443. */
  116444. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  116445. /**
  116446. * Gets the active meshes evaluation time capture status
  116447. */
  116448. /**
  116449. * Enable or disable the active meshes evaluation time capture
  116450. */
  116451. captureActiveMeshesEvaluationTime: boolean;
  116452. /**
  116453. * Gets the perf counter used for render targets render time
  116454. */
  116455. readonly renderTargetsRenderTimeCounter: PerfCounter;
  116456. /**
  116457. * Gets the render targets render time capture status
  116458. */
  116459. /**
  116460. * Enable or disable the render targets render time capture
  116461. */
  116462. captureRenderTargetsRenderTime: boolean;
  116463. /**
  116464. * Gets the perf counter used for particles render time
  116465. */
  116466. readonly particlesRenderTimeCounter: PerfCounter;
  116467. /**
  116468. * Gets the particles render time capture status
  116469. */
  116470. /**
  116471. * Enable or disable the particles render time capture
  116472. */
  116473. captureParticlesRenderTime: boolean;
  116474. /**
  116475. * Gets the perf counter used for sprites render time
  116476. */
  116477. readonly spritesRenderTimeCounter: PerfCounter;
  116478. /**
  116479. * Gets the sprites render time capture status
  116480. */
  116481. /**
  116482. * Enable or disable the sprites render time capture
  116483. */
  116484. captureSpritesRenderTime: boolean;
  116485. /**
  116486. * Gets the perf counter used for physics time
  116487. */
  116488. readonly physicsTimeCounter: PerfCounter;
  116489. /**
  116490. * Gets the physics time capture status
  116491. */
  116492. /**
  116493. * Enable or disable the physics time capture
  116494. */
  116495. capturePhysicsTime: boolean;
  116496. /**
  116497. * Gets the perf counter used for animations time
  116498. */
  116499. readonly animationsTimeCounter: PerfCounter;
  116500. /**
  116501. * Gets the animations time capture status
  116502. */
  116503. /**
  116504. * Enable or disable the animations time capture
  116505. */
  116506. captureAnimationsTime: boolean;
  116507. /**
  116508. * Gets the perf counter used for frame time capture
  116509. */
  116510. readonly frameTimeCounter: PerfCounter;
  116511. /**
  116512. * Gets the frame time capture status
  116513. */
  116514. /**
  116515. * Enable or disable the frame time capture
  116516. */
  116517. captureFrameTime: boolean;
  116518. /**
  116519. * Gets the perf counter used for inter-frames time capture
  116520. */
  116521. readonly interFrameTimeCounter: PerfCounter;
  116522. /**
  116523. * Gets the inter-frames time capture status
  116524. */
  116525. /**
  116526. * Enable or disable the inter-frames time capture
  116527. */
  116528. captureInterFrameTime: boolean;
  116529. /**
  116530. * Gets the perf counter used for render time capture
  116531. */
  116532. readonly renderTimeCounter: PerfCounter;
  116533. /**
  116534. * Gets the render time capture status
  116535. */
  116536. /**
  116537. * Enable or disable the render time capture
  116538. */
  116539. captureRenderTime: boolean;
  116540. /**
  116541. * Gets the perf counter used for camera render time capture
  116542. */
  116543. readonly cameraRenderTimeCounter: PerfCounter;
  116544. /**
  116545. * Gets the camera render time capture status
  116546. */
  116547. /**
  116548. * Enable or disable the camera render time capture
  116549. */
  116550. captureCameraRenderTime: boolean;
  116551. /**
  116552. * Gets the perf counter used for draw calls
  116553. */
  116554. readonly drawCallsCounter: PerfCounter;
  116555. /**
  116556. * Instantiates a new scene instrumentation.
  116557. * This class can be used to get instrumentation data from a Babylon engine
  116558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116559. * @param scene Defines the scene to instrument
  116560. */
  116561. constructor(
  116562. /**
  116563. * Defines the scene to instrument
  116564. */
  116565. scene: Scene);
  116566. /**
  116567. * Dispose and release associated resources.
  116568. */
  116569. dispose(): void;
  116570. }
  116571. }
  116572. declare module BABYLON {
  116573. /** @hidden */
  116574. export var glowMapGenerationPixelShader: {
  116575. name: string;
  116576. shader: string;
  116577. };
  116578. }
  116579. declare module BABYLON {
  116580. /** @hidden */
  116581. export var glowMapGenerationVertexShader: {
  116582. name: string;
  116583. shader: string;
  116584. };
  116585. }
  116586. declare module BABYLON {
  116587. /**
  116588. * Effect layer options. This helps customizing the behaviour
  116589. * of the effect layer.
  116590. */
  116591. export interface IEffectLayerOptions {
  116592. /**
  116593. * Multiplication factor apply to the canvas size to compute the render target size
  116594. * used to generated the objects (the smaller the faster).
  116595. */
  116596. mainTextureRatio: number;
  116597. /**
  116598. * Enforces a fixed size texture to ensure effect stability across devices.
  116599. */
  116600. mainTextureFixedSize?: number;
  116601. /**
  116602. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116603. */
  116604. alphaBlendingMode: number;
  116605. /**
  116606. * The camera attached to the layer.
  116607. */
  116608. camera: Nullable<Camera>;
  116609. /**
  116610. * The rendering group to draw the layer in.
  116611. */
  116612. renderingGroupId: number;
  116613. }
  116614. /**
  116615. * The effect layer Helps adding post process effect blended with the main pass.
  116616. *
  116617. * This can be for instance use to generate glow or higlight effects on the scene.
  116618. *
  116619. * The effect layer class can not be used directly and is intented to inherited from to be
  116620. * customized per effects.
  116621. */
  116622. export abstract class EffectLayer {
  116623. private _vertexBuffers;
  116624. private _indexBuffer;
  116625. private _cachedDefines;
  116626. private _effectLayerMapGenerationEffect;
  116627. private _effectLayerOptions;
  116628. private _mergeEffect;
  116629. protected _scene: Scene;
  116630. protected _engine: Engine;
  116631. protected _maxSize: number;
  116632. protected _mainTextureDesiredSize: ISize;
  116633. protected _mainTexture: RenderTargetTexture;
  116634. protected _shouldRender: boolean;
  116635. protected _postProcesses: PostProcess[];
  116636. protected _textures: BaseTexture[];
  116637. protected _emissiveTextureAndColor: {
  116638. texture: Nullable<BaseTexture>;
  116639. color: Color4;
  116640. };
  116641. /**
  116642. * The name of the layer
  116643. */
  116644. name: string;
  116645. /**
  116646. * The clear color of the texture used to generate the glow map.
  116647. */
  116648. neutralColor: Color4;
  116649. /**
  116650. * Specifies wether the highlight layer is enabled or not.
  116651. */
  116652. isEnabled: boolean;
  116653. /**
  116654. * Gets the camera attached to the layer.
  116655. */
  116656. readonly camera: Nullable<Camera>;
  116657. /**
  116658. * Gets the rendering group id the layer should render in.
  116659. */
  116660. renderingGroupId: number;
  116661. /**
  116662. * An event triggered when the effect layer has been disposed.
  116663. */
  116664. onDisposeObservable: Observable<EffectLayer>;
  116665. /**
  116666. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116667. */
  116668. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116669. /**
  116670. * An event triggered when the generated texture is being merged in the scene.
  116671. */
  116672. onBeforeComposeObservable: Observable<EffectLayer>;
  116673. /**
  116674. * An event triggered when the generated texture has been merged in the scene.
  116675. */
  116676. onAfterComposeObservable: Observable<EffectLayer>;
  116677. /**
  116678. * An event triggered when the efffect layer changes its size.
  116679. */
  116680. onSizeChangedObservable: Observable<EffectLayer>;
  116681. /** @hidden */
  116682. static _SceneComponentInitialization: (scene: Scene) => void;
  116683. /**
  116684. * Instantiates a new effect Layer and references it in the scene.
  116685. * @param name The name of the layer
  116686. * @param scene The scene to use the layer in
  116687. */
  116688. constructor(
  116689. /** The Friendly of the effect in the scene */
  116690. name: string, scene: Scene);
  116691. /**
  116692. * Get the effect name of the layer.
  116693. * @return The effect name
  116694. */
  116695. abstract getEffectName(): string;
  116696. /**
  116697. * Checks for the readiness of the element composing the layer.
  116698. * @param subMesh the mesh to check for
  116699. * @param useInstances specify wether or not to use instances to render the mesh
  116700. * @return true if ready otherwise, false
  116701. */
  116702. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116703. /**
  116704. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116705. * @returns true if the effect requires stencil during the main canvas render pass.
  116706. */
  116707. abstract needStencil(): boolean;
  116708. /**
  116709. * Create the merge effect. This is the shader use to blit the information back
  116710. * to the main canvas at the end of the scene rendering.
  116711. * @returns The effect containing the shader used to merge the effect on the main canvas
  116712. */
  116713. protected abstract _createMergeEffect(): Effect;
  116714. /**
  116715. * Creates the render target textures and post processes used in the effect layer.
  116716. */
  116717. protected abstract _createTextureAndPostProcesses(): void;
  116718. /**
  116719. * Implementation specific of rendering the generating effect on the main canvas.
  116720. * @param effect The effect used to render through
  116721. */
  116722. protected abstract _internalRender(effect: Effect): void;
  116723. /**
  116724. * Sets the required values for both the emissive texture and and the main color.
  116725. */
  116726. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116727. /**
  116728. * Free any resources and references associated to a mesh.
  116729. * Internal use
  116730. * @param mesh The mesh to free.
  116731. */
  116732. abstract _disposeMesh(mesh: Mesh): void;
  116733. /**
  116734. * Serializes this layer (Glow or Highlight for example)
  116735. * @returns a serialized layer object
  116736. */
  116737. abstract serialize?(): any;
  116738. /**
  116739. * Initializes the effect layer with the required options.
  116740. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116741. */
  116742. protected _init(options: Partial<IEffectLayerOptions>): void;
  116743. /**
  116744. * Generates the index buffer of the full screen quad blending to the main canvas.
  116745. */
  116746. private _generateIndexBuffer;
  116747. /**
  116748. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116749. */
  116750. private _generateVertexBuffer;
  116751. /**
  116752. * Sets the main texture desired size which is the closest power of two
  116753. * of the engine canvas size.
  116754. */
  116755. private _setMainTextureSize;
  116756. /**
  116757. * Creates the main texture for the effect layer.
  116758. */
  116759. protected _createMainTexture(): void;
  116760. /**
  116761. * Adds specific effects defines.
  116762. * @param defines The defines to add specifics to.
  116763. */
  116764. protected _addCustomEffectDefines(defines: string[]): void;
  116765. /**
  116766. * Checks for the readiness of the element composing the layer.
  116767. * @param subMesh the mesh to check for
  116768. * @param useInstances specify wether or not to use instances to render the mesh
  116769. * @param emissiveTexture the associated emissive texture used to generate the glow
  116770. * @return true if ready otherwise, false
  116771. */
  116772. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116773. /**
  116774. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116775. */
  116776. render(): void;
  116777. /**
  116778. * Determine if a given mesh will be used in the current effect.
  116779. * @param mesh mesh to test
  116780. * @returns true if the mesh will be used
  116781. */
  116782. hasMesh(mesh: AbstractMesh): boolean;
  116783. /**
  116784. * Returns true if the layer contains information to display, otherwise false.
  116785. * @returns true if the glow layer should be rendered
  116786. */
  116787. shouldRender(): boolean;
  116788. /**
  116789. * Returns true if the mesh should render, otherwise false.
  116790. * @param mesh The mesh to render
  116791. * @returns true if it should render otherwise false
  116792. */
  116793. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116794. /**
  116795. * Returns true if the mesh can be rendered, otherwise false.
  116796. * @param mesh The mesh to render
  116797. * @param material The material used on the mesh
  116798. * @returns true if it can be rendered otherwise false
  116799. */
  116800. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116801. /**
  116802. * Returns true if the mesh should render, otherwise false.
  116803. * @param mesh The mesh to render
  116804. * @returns true if it should render otherwise false
  116805. */
  116806. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116807. /**
  116808. * Renders the submesh passed in parameter to the generation map.
  116809. */
  116810. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116811. /**
  116812. * Rebuild the required buffers.
  116813. * @hidden Internal use only.
  116814. */
  116815. _rebuild(): void;
  116816. /**
  116817. * Dispose only the render target textures and post process.
  116818. */
  116819. private _disposeTextureAndPostProcesses;
  116820. /**
  116821. * Dispose the highlight layer and free resources.
  116822. */
  116823. dispose(): void;
  116824. /**
  116825. * Gets the class name of the effect layer
  116826. * @returns the string with the class name of the effect layer
  116827. */
  116828. getClassName(): string;
  116829. /**
  116830. * Creates an effect layer from parsed effect layer data
  116831. * @param parsedEffectLayer defines effect layer data
  116832. * @param scene defines the current scene
  116833. * @param rootUrl defines the root URL containing the effect layer information
  116834. * @returns a parsed effect Layer
  116835. */
  116836. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116837. }
  116838. }
  116839. declare module BABYLON {
  116840. interface AbstractScene {
  116841. /**
  116842. * The list of effect layers (highlights/glow) added to the scene
  116843. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116844. * @see http://doc.babylonjs.com/how_to/glow_layer
  116845. */
  116846. effectLayers: Array<EffectLayer>;
  116847. /**
  116848. * Removes the given effect layer from this scene.
  116849. * @param toRemove defines the effect layer to remove
  116850. * @returns the index of the removed effect layer
  116851. */
  116852. removeEffectLayer(toRemove: EffectLayer): number;
  116853. /**
  116854. * Adds the given effect layer to this scene
  116855. * @param newEffectLayer defines the effect layer to add
  116856. */
  116857. addEffectLayer(newEffectLayer: EffectLayer): void;
  116858. }
  116859. /**
  116860. * Defines the layer scene component responsible to manage any effect layers
  116861. * in a given scene.
  116862. */
  116863. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116864. /**
  116865. * The component name helpfull to identify the component in the list of scene components.
  116866. */
  116867. readonly name: string;
  116868. /**
  116869. * The scene the component belongs to.
  116870. */
  116871. scene: Scene;
  116872. private _engine;
  116873. private _renderEffects;
  116874. private _needStencil;
  116875. private _previousStencilState;
  116876. /**
  116877. * Creates a new instance of the component for the given scene
  116878. * @param scene Defines the scene to register the component in
  116879. */
  116880. constructor(scene: Scene);
  116881. /**
  116882. * Registers the component in a given scene
  116883. */
  116884. register(): void;
  116885. /**
  116886. * Rebuilds the elements related to this component in case of
  116887. * context lost for instance.
  116888. */
  116889. rebuild(): void;
  116890. /**
  116891. * Serializes the component data to the specified json object
  116892. * @param serializationObject The object to serialize to
  116893. */
  116894. serialize(serializationObject: any): void;
  116895. /**
  116896. * Adds all the elements from the container to the scene
  116897. * @param container the container holding the elements
  116898. */
  116899. addFromContainer(container: AbstractScene): void;
  116900. /**
  116901. * Removes all the elements in the container from the scene
  116902. * @param container contains the elements to remove
  116903. * @param dispose if the removed element should be disposed (default: false)
  116904. */
  116905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116906. /**
  116907. * Disposes the component and the associated ressources.
  116908. */
  116909. dispose(): void;
  116910. private _isReadyForMesh;
  116911. private _renderMainTexture;
  116912. private _setStencil;
  116913. private _setStencilBack;
  116914. private _draw;
  116915. private _drawCamera;
  116916. private _drawRenderingGroup;
  116917. }
  116918. }
  116919. declare module BABYLON {
  116920. /** @hidden */
  116921. export var glowMapMergePixelShader: {
  116922. name: string;
  116923. shader: string;
  116924. };
  116925. }
  116926. declare module BABYLON {
  116927. /** @hidden */
  116928. export var glowMapMergeVertexShader: {
  116929. name: string;
  116930. shader: string;
  116931. };
  116932. }
  116933. declare module BABYLON {
  116934. interface AbstractScene {
  116935. /**
  116936. * Return a the first highlight layer of the scene with a given name.
  116937. * @param name The name of the highlight layer to look for.
  116938. * @return The highlight layer if found otherwise null.
  116939. */
  116940. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116941. }
  116942. /**
  116943. * Glow layer options. This helps customizing the behaviour
  116944. * of the glow layer.
  116945. */
  116946. export interface IGlowLayerOptions {
  116947. /**
  116948. * Multiplication factor apply to the canvas size to compute the render target size
  116949. * used to generated the glowing objects (the smaller the faster).
  116950. */
  116951. mainTextureRatio: number;
  116952. /**
  116953. * Enforces a fixed size texture to ensure resize independant blur.
  116954. */
  116955. mainTextureFixedSize?: number;
  116956. /**
  116957. * How big is the kernel of the blur texture.
  116958. */
  116959. blurKernelSize: number;
  116960. /**
  116961. * The camera attached to the layer.
  116962. */
  116963. camera: Nullable<Camera>;
  116964. /**
  116965. * Enable MSAA by chosing the number of samples.
  116966. */
  116967. mainTextureSamples?: number;
  116968. /**
  116969. * The rendering group to draw the layer in.
  116970. */
  116971. renderingGroupId: number;
  116972. }
  116973. /**
  116974. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116975. *
  116976. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116977. * glowy meshes to your scene.
  116978. *
  116979. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116980. */
  116981. export class GlowLayer extends EffectLayer {
  116982. /**
  116983. * Effect Name of the layer.
  116984. */
  116985. static readonly EffectName: string;
  116986. /**
  116987. * The default blur kernel size used for the glow.
  116988. */
  116989. static DefaultBlurKernelSize: number;
  116990. /**
  116991. * The default texture size ratio used for the glow.
  116992. */
  116993. static DefaultTextureRatio: number;
  116994. /**
  116995. * Sets the kernel size of the blur.
  116996. */
  116997. /**
  116998. * Gets the kernel size of the blur.
  116999. */
  117000. blurKernelSize: number;
  117001. /**
  117002. * Sets the glow intensity.
  117003. */
  117004. /**
  117005. * Gets the glow intensity.
  117006. */
  117007. intensity: number;
  117008. private _options;
  117009. private _intensity;
  117010. private _horizontalBlurPostprocess1;
  117011. private _verticalBlurPostprocess1;
  117012. private _horizontalBlurPostprocess2;
  117013. private _verticalBlurPostprocess2;
  117014. private _blurTexture1;
  117015. private _blurTexture2;
  117016. private _postProcesses1;
  117017. private _postProcesses2;
  117018. private _includedOnlyMeshes;
  117019. private _excludedMeshes;
  117020. /**
  117021. * Callback used to let the user override the color selection on a per mesh basis
  117022. */
  117023. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117024. /**
  117025. * Callback used to let the user override the texture selection on a per mesh basis
  117026. */
  117027. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117028. /**
  117029. * Instantiates a new glow Layer and references it to the scene.
  117030. * @param name The name of the layer
  117031. * @param scene The scene to use the layer in
  117032. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117033. */
  117034. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117035. /**
  117036. * Get the effect name of the layer.
  117037. * @return The effect name
  117038. */
  117039. getEffectName(): string;
  117040. /**
  117041. * Create the merge effect. This is the shader use to blit the information back
  117042. * to the main canvas at the end of the scene rendering.
  117043. */
  117044. protected _createMergeEffect(): Effect;
  117045. /**
  117046. * Creates the render target textures and post processes used in the glow layer.
  117047. */
  117048. protected _createTextureAndPostProcesses(): void;
  117049. /**
  117050. * Checks for the readiness of the element composing the layer.
  117051. * @param subMesh the mesh to check for
  117052. * @param useInstances specify wether or not to use instances to render the mesh
  117053. * @param emissiveTexture the associated emissive texture used to generate the glow
  117054. * @return true if ready otherwise, false
  117055. */
  117056. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117057. /**
  117058. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117059. */
  117060. needStencil(): boolean;
  117061. /**
  117062. * Returns true if the mesh can be rendered, otherwise false.
  117063. * @param mesh The mesh to render
  117064. * @param material The material used on the mesh
  117065. * @returns true if it can be rendered otherwise false
  117066. */
  117067. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117068. /**
  117069. * Implementation specific of rendering the generating effect on the main canvas.
  117070. * @param effect The effect used to render through
  117071. */
  117072. protected _internalRender(effect: Effect): void;
  117073. /**
  117074. * Sets the required values for both the emissive texture and and the main color.
  117075. */
  117076. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117077. /**
  117078. * Returns true if the mesh should render, otherwise false.
  117079. * @param mesh The mesh to render
  117080. * @returns true if it should render otherwise false
  117081. */
  117082. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117083. /**
  117084. * Adds specific effects defines.
  117085. * @param defines The defines to add specifics to.
  117086. */
  117087. protected _addCustomEffectDefines(defines: string[]): void;
  117088. /**
  117089. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117090. * @param mesh The mesh to exclude from the glow layer
  117091. */
  117092. addExcludedMesh(mesh: Mesh): void;
  117093. /**
  117094. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117095. * @param mesh The mesh to remove
  117096. */
  117097. removeExcludedMesh(mesh: Mesh): void;
  117098. /**
  117099. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117100. * @param mesh The mesh to include in the glow layer
  117101. */
  117102. addIncludedOnlyMesh(mesh: Mesh): void;
  117103. /**
  117104. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117105. * @param mesh The mesh to remove
  117106. */
  117107. removeIncludedOnlyMesh(mesh: Mesh): void;
  117108. /**
  117109. * Determine if a given mesh will be used in the glow layer
  117110. * @param mesh The mesh to test
  117111. * @returns true if the mesh will be highlighted by the current glow layer
  117112. */
  117113. hasMesh(mesh: AbstractMesh): boolean;
  117114. /**
  117115. * Free any resources and references associated to a mesh.
  117116. * Internal use
  117117. * @param mesh The mesh to free.
  117118. * @hidden
  117119. */
  117120. _disposeMesh(mesh: Mesh): void;
  117121. /**
  117122. * Gets the class name of the effect layer
  117123. * @returns the string with the class name of the effect layer
  117124. */
  117125. getClassName(): string;
  117126. /**
  117127. * Serializes this glow layer
  117128. * @returns a serialized glow layer object
  117129. */
  117130. serialize(): any;
  117131. /**
  117132. * Creates a Glow Layer from parsed glow layer data
  117133. * @param parsedGlowLayer defines glow layer data
  117134. * @param scene defines the current scene
  117135. * @param rootUrl defines the root URL containing the glow layer information
  117136. * @returns a parsed Glow Layer
  117137. */
  117138. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117139. }
  117140. }
  117141. declare module BABYLON {
  117142. /** @hidden */
  117143. export var glowBlurPostProcessPixelShader: {
  117144. name: string;
  117145. shader: string;
  117146. };
  117147. }
  117148. declare module BABYLON {
  117149. interface AbstractScene {
  117150. /**
  117151. * Return a the first highlight layer of the scene with a given name.
  117152. * @param name The name of the highlight layer to look for.
  117153. * @return The highlight layer if found otherwise null.
  117154. */
  117155. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117156. }
  117157. /**
  117158. * Highlight layer options. This helps customizing the behaviour
  117159. * of the highlight layer.
  117160. */
  117161. export interface IHighlightLayerOptions {
  117162. /**
  117163. * Multiplication factor apply to the canvas size to compute the render target size
  117164. * used to generated the glowing objects (the smaller the faster).
  117165. */
  117166. mainTextureRatio: number;
  117167. /**
  117168. * Enforces a fixed size texture to ensure resize independant blur.
  117169. */
  117170. mainTextureFixedSize?: number;
  117171. /**
  117172. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117173. * of the picture to blur (the smaller the faster).
  117174. */
  117175. blurTextureSizeRatio: number;
  117176. /**
  117177. * How big in texel of the blur texture is the vertical blur.
  117178. */
  117179. blurVerticalSize: number;
  117180. /**
  117181. * How big in texel of the blur texture is the horizontal blur.
  117182. */
  117183. blurHorizontalSize: number;
  117184. /**
  117185. * Alpha blending mode used to apply the blur. Default is combine.
  117186. */
  117187. alphaBlendingMode: number;
  117188. /**
  117189. * The camera attached to the layer.
  117190. */
  117191. camera: Nullable<Camera>;
  117192. /**
  117193. * Should we display highlight as a solid stroke?
  117194. */
  117195. isStroke?: boolean;
  117196. /**
  117197. * The rendering group to draw the layer in.
  117198. */
  117199. renderingGroupId: number;
  117200. }
  117201. /**
  117202. * The highlight layer Helps adding a glow effect around a mesh.
  117203. *
  117204. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  117205. * glowy meshes to your scene.
  117206. *
  117207. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117208. */
  117209. export class HighlightLayer extends EffectLayer {
  117210. name: string;
  117211. /**
  117212. * Effect Name of the highlight layer.
  117213. */
  117214. static readonly EffectName: string;
  117215. /**
  117216. * The neutral color used during the preparation of the glow effect.
  117217. * This is black by default as the blend operation is a blend operation.
  117218. */
  117219. static NeutralColor: Color4;
  117220. /**
  117221. * Stencil value used for glowing meshes.
  117222. */
  117223. static GlowingMeshStencilReference: number;
  117224. /**
  117225. * Stencil value used for the other meshes in the scene.
  117226. */
  117227. static NormalMeshStencilReference: number;
  117228. /**
  117229. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117230. */
  117231. innerGlow: boolean;
  117232. /**
  117233. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117234. */
  117235. outerGlow: boolean;
  117236. /**
  117237. * Specifies the horizontal size of the blur.
  117238. */
  117239. /**
  117240. * Gets the horizontal size of the blur.
  117241. */
  117242. blurHorizontalSize: number;
  117243. /**
  117244. * Specifies the vertical size of the blur.
  117245. */
  117246. /**
  117247. * Gets the vertical size of the blur.
  117248. */
  117249. blurVerticalSize: number;
  117250. /**
  117251. * An event triggered when the highlight layer is being blurred.
  117252. */
  117253. onBeforeBlurObservable: Observable<HighlightLayer>;
  117254. /**
  117255. * An event triggered when the highlight layer has been blurred.
  117256. */
  117257. onAfterBlurObservable: Observable<HighlightLayer>;
  117258. private _instanceGlowingMeshStencilReference;
  117259. private _options;
  117260. private _downSamplePostprocess;
  117261. private _horizontalBlurPostprocess;
  117262. private _verticalBlurPostprocess;
  117263. private _blurTexture;
  117264. private _meshes;
  117265. private _excludedMeshes;
  117266. /**
  117267. * Instantiates a new highlight Layer and references it to the scene..
  117268. * @param name The name of the layer
  117269. * @param scene The scene to use the layer in
  117270. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117271. */
  117272. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117273. /**
  117274. * Get the effect name of the layer.
  117275. * @return The effect name
  117276. */
  117277. getEffectName(): string;
  117278. /**
  117279. * Create the merge effect. This is the shader use to blit the information back
  117280. * to the main canvas at the end of the scene rendering.
  117281. */
  117282. protected _createMergeEffect(): Effect;
  117283. /**
  117284. * Creates the render target textures and post processes used in the highlight layer.
  117285. */
  117286. protected _createTextureAndPostProcesses(): void;
  117287. /**
  117288. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117289. */
  117290. needStencil(): boolean;
  117291. /**
  117292. * Checks for the readiness of the element composing the layer.
  117293. * @param subMesh the mesh to check for
  117294. * @param useInstances specify wether or not to use instances to render the mesh
  117295. * @param emissiveTexture the associated emissive texture used to generate the glow
  117296. * @return true if ready otherwise, false
  117297. */
  117298. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117299. /**
  117300. * Implementation specific of rendering the generating effect on the main canvas.
  117301. * @param effect The effect used to render through
  117302. */
  117303. protected _internalRender(effect: Effect): void;
  117304. /**
  117305. * Returns true if the layer contains information to display, otherwise false.
  117306. */
  117307. shouldRender(): boolean;
  117308. /**
  117309. * Returns true if the mesh should render, otherwise false.
  117310. * @param mesh The mesh to render
  117311. * @returns true if it should render otherwise false
  117312. */
  117313. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117314. /**
  117315. * Sets the required values for both the emissive texture and and the main color.
  117316. */
  117317. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117318. /**
  117319. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117320. * @param mesh The mesh to exclude from the highlight layer
  117321. */
  117322. addExcludedMesh(mesh: Mesh): void;
  117323. /**
  117324. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117325. * @param mesh The mesh to highlight
  117326. */
  117327. removeExcludedMesh(mesh: Mesh): void;
  117328. /**
  117329. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117330. * @param mesh mesh to test
  117331. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117332. */
  117333. hasMesh(mesh: AbstractMesh): boolean;
  117334. /**
  117335. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117336. * @param mesh The mesh to highlight
  117337. * @param color The color of the highlight
  117338. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117339. */
  117340. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117341. /**
  117342. * Remove a mesh from the highlight layer in order to make it stop glowing.
  117343. * @param mesh The mesh to highlight
  117344. */
  117345. removeMesh(mesh: Mesh): void;
  117346. /**
  117347. * Force the stencil to the normal expected value for none glowing parts
  117348. */
  117349. private _defaultStencilReference;
  117350. /**
  117351. * Free any resources and references associated to a mesh.
  117352. * Internal use
  117353. * @param mesh The mesh to free.
  117354. * @hidden
  117355. */
  117356. _disposeMesh(mesh: Mesh): void;
  117357. /**
  117358. * Dispose the highlight layer and free resources.
  117359. */
  117360. dispose(): void;
  117361. /**
  117362. * Gets the class name of the effect layer
  117363. * @returns the string with the class name of the effect layer
  117364. */
  117365. getClassName(): string;
  117366. /**
  117367. * Serializes this Highlight layer
  117368. * @returns a serialized Highlight layer object
  117369. */
  117370. serialize(): any;
  117371. /**
  117372. * Creates a Highlight layer from parsed Highlight layer data
  117373. * @param parsedHightlightLayer defines the Highlight layer data
  117374. * @param scene defines the current scene
  117375. * @param rootUrl defines the root URL containing the Highlight layer information
  117376. * @returns a parsed Highlight layer
  117377. */
  117378. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  117379. }
  117380. }
  117381. declare module BABYLON {
  117382. interface AbstractScene {
  117383. /**
  117384. * The list of layers (background and foreground) of the scene
  117385. */
  117386. layers: Array<Layer>;
  117387. }
  117388. /**
  117389. * Defines the layer scene component responsible to manage any layers
  117390. * in a given scene.
  117391. */
  117392. export class LayerSceneComponent implements ISceneComponent {
  117393. /**
  117394. * The component name helpfull to identify the component in the list of scene components.
  117395. */
  117396. readonly name: string;
  117397. /**
  117398. * The scene the component belongs to.
  117399. */
  117400. scene: Scene;
  117401. private _engine;
  117402. /**
  117403. * Creates a new instance of the component for the given scene
  117404. * @param scene Defines the scene to register the component in
  117405. */
  117406. constructor(scene: Scene);
  117407. /**
  117408. * Registers the component in a given scene
  117409. */
  117410. register(): void;
  117411. /**
  117412. * Rebuilds the elements related to this component in case of
  117413. * context lost for instance.
  117414. */
  117415. rebuild(): void;
  117416. /**
  117417. * Disposes the component and the associated ressources.
  117418. */
  117419. dispose(): void;
  117420. private _draw;
  117421. private _drawCameraPredicate;
  117422. private _drawCameraBackground;
  117423. private _drawCameraForeground;
  117424. private _drawRenderTargetPredicate;
  117425. private _drawRenderTargetBackground;
  117426. private _drawRenderTargetForeground;
  117427. /**
  117428. * Adds all the elements from the container to the scene
  117429. * @param container the container holding the elements
  117430. */
  117431. addFromContainer(container: AbstractScene): void;
  117432. /**
  117433. * Removes all the elements in the container from the scene
  117434. * @param container contains the elements to remove
  117435. * @param dispose if the removed element should be disposed (default: false)
  117436. */
  117437. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117438. }
  117439. }
  117440. declare module BABYLON {
  117441. /** @hidden */
  117442. export var layerPixelShader: {
  117443. name: string;
  117444. shader: string;
  117445. };
  117446. }
  117447. declare module BABYLON {
  117448. /** @hidden */
  117449. export var layerVertexShader: {
  117450. name: string;
  117451. shader: string;
  117452. };
  117453. }
  117454. declare module BABYLON {
  117455. /**
  117456. * This represents a full screen 2d layer.
  117457. * This can be useful to display a picture in the background of your scene for instance.
  117458. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117459. */
  117460. export class Layer {
  117461. /**
  117462. * Define the name of the layer.
  117463. */
  117464. name: string;
  117465. /**
  117466. * Define the texture the layer should display.
  117467. */
  117468. texture: Nullable<Texture>;
  117469. /**
  117470. * Is the layer in background or foreground.
  117471. */
  117472. isBackground: boolean;
  117473. /**
  117474. * Define the color of the layer (instead of texture).
  117475. */
  117476. color: Color4;
  117477. /**
  117478. * Define the scale of the layer in order to zoom in out of the texture.
  117479. */
  117480. scale: Vector2;
  117481. /**
  117482. * Define an offset for the layer in order to shift the texture.
  117483. */
  117484. offset: Vector2;
  117485. /**
  117486. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117487. */
  117488. alphaBlendingMode: number;
  117489. /**
  117490. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117491. * Alpha test will not mix with the background color in case of transparency.
  117492. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117493. */
  117494. alphaTest: boolean;
  117495. /**
  117496. * Define a mask to restrict the layer to only some of the scene cameras.
  117497. */
  117498. layerMask: number;
  117499. /**
  117500. * Define the list of render target the layer is visible into.
  117501. */
  117502. renderTargetTextures: RenderTargetTexture[];
  117503. /**
  117504. * Define if the layer is only used in renderTarget or if it also
  117505. * renders in the main frame buffer of the canvas.
  117506. */
  117507. renderOnlyInRenderTargetTextures: boolean;
  117508. private _scene;
  117509. private _vertexBuffers;
  117510. private _indexBuffer;
  117511. private _effect;
  117512. private _alphaTestEffect;
  117513. /**
  117514. * An event triggered when the layer is disposed.
  117515. */
  117516. onDisposeObservable: Observable<Layer>;
  117517. private _onDisposeObserver;
  117518. /**
  117519. * Back compatibility with callback before the onDisposeObservable existed.
  117520. * The set callback will be triggered when the layer has been disposed.
  117521. */
  117522. onDispose: () => void;
  117523. /**
  117524. * An event triggered before rendering the scene
  117525. */
  117526. onBeforeRenderObservable: Observable<Layer>;
  117527. private _onBeforeRenderObserver;
  117528. /**
  117529. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117530. * The set callback will be triggered just before rendering the layer.
  117531. */
  117532. onBeforeRender: () => void;
  117533. /**
  117534. * An event triggered after rendering the scene
  117535. */
  117536. onAfterRenderObservable: Observable<Layer>;
  117537. private _onAfterRenderObserver;
  117538. /**
  117539. * Back compatibility with callback before the onAfterRenderObservable existed.
  117540. * The set callback will be triggered just after rendering the layer.
  117541. */
  117542. onAfterRender: () => void;
  117543. /**
  117544. * Instantiates a new layer.
  117545. * This represents a full screen 2d layer.
  117546. * This can be useful to display a picture in the background of your scene for instance.
  117547. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117548. * @param name Define the name of the layer in the scene
  117549. * @param imgUrl Define the url of the texture to display in the layer
  117550. * @param scene Define the scene the layer belongs to
  117551. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117552. * @param color Defines a color for the layer
  117553. */
  117554. constructor(
  117555. /**
  117556. * Define the name of the layer.
  117557. */
  117558. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117559. private _createIndexBuffer;
  117560. /** @hidden */
  117561. _rebuild(): void;
  117562. /**
  117563. * Renders the layer in the scene.
  117564. */
  117565. render(): void;
  117566. /**
  117567. * Disposes and releases the associated ressources.
  117568. */
  117569. dispose(): void;
  117570. }
  117571. }
  117572. declare module BABYLON {
  117573. /** @hidden */
  117574. export var lensFlarePixelShader: {
  117575. name: string;
  117576. shader: string;
  117577. };
  117578. }
  117579. declare module BABYLON {
  117580. /** @hidden */
  117581. export var lensFlareVertexShader: {
  117582. name: string;
  117583. shader: string;
  117584. };
  117585. }
  117586. declare module BABYLON {
  117587. /**
  117588. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117589. * It is usually composed of several `lensFlare`.
  117590. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117591. */
  117592. export class LensFlareSystem {
  117593. /**
  117594. * Define the name of the lens flare system
  117595. */
  117596. name: string;
  117597. /**
  117598. * List of lens flares used in this system.
  117599. */
  117600. lensFlares: LensFlare[];
  117601. /**
  117602. * Define a limit from the border the lens flare can be visible.
  117603. */
  117604. borderLimit: number;
  117605. /**
  117606. * Define a viewport border we do not want to see the lens flare in.
  117607. */
  117608. viewportBorder: number;
  117609. /**
  117610. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117611. */
  117612. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117613. /**
  117614. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117615. */
  117616. layerMask: number;
  117617. /**
  117618. * Define the id of the lens flare system in the scene.
  117619. * (equal to name by default)
  117620. */
  117621. id: string;
  117622. private _scene;
  117623. private _emitter;
  117624. private _vertexBuffers;
  117625. private _indexBuffer;
  117626. private _effect;
  117627. private _positionX;
  117628. private _positionY;
  117629. private _isEnabled;
  117630. /** @hidden */
  117631. static _SceneComponentInitialization: (scene: Scene) => void;
  117632. /**
  117633. * Instantiates a lens flare system.
  117634. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117635. * It is usually composed of several `lensFlare`.
  117636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117637. * @param name Define the name of the lens flare system in the scene
  117638. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117639. * @param scene Define the scene the lens flare system belongs to
  117640. */
  117641. constructor(
  117642. /**
  117643. * Define the name of the lens flare system
  117644. */
  117645. name: string, emitter: any, scene: Scene);
  117646. /**
  117647. * Define if the lens flare system is enabled.
  117648. */
  117649. isEnabled: boolean;
  117650. /**
  117651. * Get the scene the effects belongs to.
  117652. * @returns the scene holding the lens flare system
  117653. */
  117654. getScene(): Scene;
  117655. /**
  117656. * Get the emitter of the lens flare system.
  117657. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117658. * @returns the emitter of the lens flare system
  117659. */
  117660. getEmitter(): any;
  117661. /**
  117662. * Set the emitter of the lens flare system.
  117663. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117664. * @param newEmitter Define the new emitter of the system
  117665. */
  117666. setEmitter(newEmitter: any): void;
  117667. /**
  117668. * Get the lens flare system emitter position.
  117669. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117670. * @returns the position
  117671. */
  117672. getEmitterPosition(): Vector3;
  117673. /**
  117674. * @hidden
  117675. */
  117676. computeEffectivePosition(globalViewport: Viewport): boolean;
  117677. /** @hidden */
  117678. _isVisible(): boolean;
  117679. /**
  117680. * @hidden
  117681. */
  117682. render(): boolean;
  117683. /**
  117684. * Dispose and release the lens flare with its associated resources.
  117685. */
  117686. dispose(): void;
  117687. /**
  117688. * Parse a lens flare system from a JSON repressentation
  117689. * @param parsedLensFlareSystem Define the JSON to parse
  117690. * @param scene Define the scene the parsed system should be instantiated in
  117691. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117692. * @returns the parsed system
  117693. */
  117694. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117695. /**
  117696. * Serialize the current Lens Flare System into a JSON representation.
  117697. * @returns the serialized JSON
  117698. */
  117699. serialize(): any;
  117700. }
  117701. }
  117702. declare module BABYLON {
  117703. /**
  117704. * This represents one of the lens effect in a `lensFlareSystem`.
  117705. * It controls one of the indiviual texture used in the effect.
  117706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117707. */
  117708. export class LensFlare {
  117709. /**
  117710. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117711. */
  117712. size: number;
  117713. /**
  117714. * 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.
  117715. */
  117716. position: number;
  117717. /**
  117718. * Define the lens color.
  117719. */
  117720. color: Color3;
  117721. /**
  117722. * Define the lens texture.
  117723. */
  117724. texture: Nullable<Texture>;
  117725. /**
  117726. * Define the alpha mode to render this particular lens.
  117727. */
  117728. alphaMode: number;
  117729. private _system;
  117730. /**
  117731. * Creates a new Lens Flare.
  117732. * This represents one of the lens effect in a `lensFlareSystem`.
  117733. * It controls one of the indiviual texture used in the effect.
  117734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117735. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117736. * @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.
  117737. * @param color Define the lens color
  117738. * @param imgUrl Define the lens texture url
  117739. * @param system Define the `lensFlareSystem` this flare is part of
  117740. * @returns The newly created Lens Flare
  117741. */
  117742. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117743. /**
  117744. * Instantiates a new Lens Flare.
  117745. * This represents one of the lens effect in a `lensFlareSystem`.
  117746. * It controls one of the indiviual texture used in the effect.
  117747. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117748. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117749. * @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.
  117750. * @param color Define the lens color
  117751. * @param imgUrl Define the lens texture url
  117752. * @param system Define the `lensFlareSystem` this flare is part of
  117753. */
  117754. constructor(
  117755. /**
  117756. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117757. */
  117758. size: number,
  117759. /**
  117760. * 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.
  117761. */
  117762. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117763. /**
  117764. * Dispose and release the lens flare with its associated resources.
  117765. */
  117766. dispose(): void;
  117767. }
  117768. }
  117769. declare module BABYLON {
  117770. interface AbstractScene {
  117771. /**
  117772. * The list of lens flare system added to the scene
  117773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117774. */
  117775. lensFlareSystems: Array<LensFlareSystem>;
  117776. /**
  117777. * Removes the given lens flare system from this scene.
  117778. * @param toRemove The lens flare system to remove
  117779. * @returns The index of the removed lens flare system
  117780. */
  117781. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117782. /**
  117783. * Adds the given lens flare system to this scene
  117784. * @param newLensFlareSystem The lens flare system to add
  117785. */
  117786. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117787. /**
  117788. * Gets a lens flare system using its name
  117789. * @param name defines the name to look for
  117790. * @returns the lens flare system or null if not found
  117791. */
  117792. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117793. /**
  117794. * Gets a lens flare system using its id
  117795. * @param id defines the id to look for
  117796. * @returns the lens flare system or null if not found
  117797. */
  117798. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117799. }
  117800. /**
  117801. * Defines the lens flare scene component responsible to manage any lens flares
  117802. * in a given scene.
  117803. */
  117804. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117805. /**
  117806. * The component name helpfull to identify the component in the list of scene components.
  117807. */
  117808. readonly name: string;
  117809. /**
  117810. * The scene the component belongs to.
  117811. */
  117812. scene: Scene;
  117813. /**
  117814. * Creates a new instance of the component for the given scene
  117815. * @param scene Defines the scene to register the component in
  117816. */
  117817. constructor(scene: Scene);
  117818. /**
  117819. * Registers the component in a given scene
  117820. */
  117821. register(): void;
  117822. /**
  117823. * Rebuilds the elements related to this component in case of
  117824. * context lost for instance.
  117825. */
  117826. rebuild(): void;
  117827. /**
  117828. * Adds all the elements from the container to the scene
  117829. * @param container the container holding the elements
  117830. */
  117831. addFromContainer(container: AbstractScene): void;
  117832. /**
  117833. * Removes all the elements in the container from the scene
  117834. * @param container contains the elements to remove
  117835. * @param dispose if the removed element should be disposed (default: false)
  117836. */
  117837. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117838. /**
  117839. * Serializes the component data to the specified json object
  117840. * @param serializationObject The object to serialize to
  117841. */
  117842. serialize(serializationObject: any): void;
  117843. /**
  117844. * Disposes the component and the associated ressources.
  117845. */
  117846. dispose(): void;
  117847. private _draw;
  117848. }
  117849. }
  117850. declare module BABYLON {
  117851. /**
  117852. * Defines the shadow generator component responsible to manage any shadow generators
  117853. * in a given scene.
  117854. */
  117855. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117856. /**
  117857. * The component name helpfull to identify the component in the list of scene components.
  117858. */
  117859. readonly name: string;
  117860. /**
  117861. * The scene the component belongs to.
  117862. */
  117863. scene: Scene;
  117864. /**
  117865. * Creates a new instance of the component for the given scene
  117866. * @param scene Defines the scene to register the component in
  117867. */
  117868. constructor(scene: Scene);
  117869. /**
  117870. * Registers the component in a given scene
  117871. */
  117872. register(): void;
  117873. /**
  117874. * Rebuilds the elements related to this component in case of
  117875. * context lost for instance.
  117876. */
  117877. rebuild(): void;
  117878. /**
  117879. * Serializes the component data to the specified json object
  117880. * @param serializationObject The object to serialize to
  117881. */
  117882. serialize(serializationObject: any): void;
  117883. /**
  117884. * Adds all the elements from the container to the scene
  117885. * @param container the container holding the elements
  117886. */
  117887. addFromContainer(container: AbstractScene): void;
  117888. /**
  117889. * Removes all the elements in the container from the scene
  117890. * @param container contains the elements to remove
  117891. * @param dispose if the removed element should be disposed (default: false)
  117892. */
  117893. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117894. /**
  117895. * Rebuilds the elements related to this component in case of
  117896. * context lost for instance.
  117897. */
  117898. dispose(): void;
  117899. private _gatherRenderTargets;
  117900. }
  117901. }
  117902. declare module BABYLON {
  117903. /**
  117904. * A point light is a light defined by an unique point in world space.
  117905. * The light is emitted in every direction from this point.
  117906. * A good example of a point light is a standard light bulb.
  117907. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117908. */
  117909. export class PointLight extends ShadowLight {
  117910. private _shadowAngle;
  117911. /**
  117912. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117913. * This specifies what angle the shadow will use to be created.
  117914. *
  117915. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117916. */
  117917. /**
  117918. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117919. * This specifies what angle the shadow will use to be created.
  117920. *
  117921. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117922. */
  117923. shadowAngle: number;
  117924. /**
  117925. * Gets the direction if it has been set.
  117926. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117927. */
  117928. /**
  117929. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117930. */
  117931. direction: Vector3;
  117932. /**
  117933. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117934. * A PointLight emits the light in every direction.
  117935. * It can cast shadows.
  117936. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117937. * ```javascript
  117938. * var pointLight = new PointLight("pl", camera.position, scene);
  117939. * ```
  117940. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117941. * @param name The light friendly name
  117942. * @param position The position of the point light in the scene
  117943. * @param scene The scene the lights belongs to
  117944. */
  117945. constructor(name: string, position: Vector3, scene: Scene);
  117946. /**
  117947. * Returns the string "PointLight"
  117948. * @returns the class name
  117949. */
  117950. getClassName(): string;
  117951. /**
  117952. * Returns the integer 0.
  117953. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117954. */
  117955. getTypeID(): number;
  117956. /**
  117957. * Specifies wether or not the shadowmap should be a cube texture.
  117958. * @returns true if the shadowmap needs to be a cube texture.
  117959. */
  117960. needCube(): boolean;
  117961. /**
  117962. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117963. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117964. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117965. */
  117966. getShadowDirection(faceIndex?: number): Vector3;
  117967. /**
  117968. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117969. * - fov = PI / 2
  117970. * - aspect ratio : 1.0
  117971. * - z-near and far equal to the active camera minZ and maxZ.
  117972. * Returns the PointLight.
  117973. */
  117974. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117975. protected _buildUniformLayout(): void;
  117976. /**
  117977. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117978. * @param effect The effect to update
  117979. * @param lightIndex The index of the light in the effect to update
  117980. * @returns The point light
  117981. */
  117982. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117983. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117984. /**
  117985. * Prepares the list of defines specific to the light type.
  117986. * @param defines the list of defines
  117987. * @param lightIndex defines the index of the light for the effect
  117988. */
  117989. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117990. }
  117991. }
  117992. declare module BABYLON {
  117993. /**
  117994. * Header information of HDR texture files.
  117995. */
  117996. export interface HDRInfo {
  117997. /**
  117998. * The height of the texture in pixels.
  117999. */
  118000. height: number;
  118001. /**
  118002. * The width of the texture in pixels.
  118003. */
  118004. width: number;
  118005. /**
  118006. * The index of the beginning of the data in the binary file.
  118007. */
  118008. dataPosition: number;
  118009. }
  118010. /**
  118011. * This groups tools to convert HDR texture to native colors array.
  118012. */
  118013. export class HDRTools {
  118014. private static Ldexp;
  118015. private static Rgbe2float;
  118016. private static readStringLine;
  118017. /**
  118018. * Reads header information from an RGBE texture stored in a native array.
  118019. * More information on this format are available here:
  118020. * https://en.wikipedia.org/wiki/RGBE_image_format
  118021. *
  118022. * @param uint8array The binary file stored in native array.
  118023. * @return The header information.
  118024. */
  118025. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118026. /**
  118027. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118028. * This RGBE texture needs to store the information as a panorama.
  118029. *
  118030. * More information on this format are available here:
  118031. * https://en.wikipedia.org/wiki/RGBE_image_format
  118032. *
  118033. * @param buffer The binary file stored in an array buffer.
  118034. * @param size The expected size of the extracted cubemap.
  118035. * @return The Cube Map information.
  118036. */
  118037. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118038. /**
  118039. * Returns the pixels data extracted from an RGBE texture.
  118040. * This pixels will be stored left to right up to down in the R G B order in one array.
  118041. *
  118042. * More information on this format are available here:
  118043. * https://en.wikipedia.org/wiki/RGBE_image_format
  118044. *
  118045. * @param uint8array The binary file stored in an array buffer.
  118046. * @param hdrInfo The header information of the file.
  118047. * @return The pixels data in RGB right to left up to down order.
  118048. */
  118049. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118050. private static RGBE_ReadPixels_RLE;
  118051. }
  118052. }
  118053. declare module BABYLON {
  118054. /**
  118055. * This represents a texture coming from an HDR input.
  118056. *
  118057. * The only supported format is currently panorama picture stored in RGBE format.
  118058. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118059. */
  118060. export class HDRCubeTexture extends BaseTexture {
  118061. private static _facesMapping;
  118062. private _generateHarmonics;
  118063. private _noMipmap;
  118064. private _textureMatrix;
  118065. private _size;
  118066. private _onLoad;
  118067. private _onError;
  118068. /**
  118069. * The texture URL.
  118070. */
  118071. url: string;
  118072. /**
  118073. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118074. */
  118075. coordinatesMode: number;
  118076. protected _isBlocking: boolean;
  118077. /**
  118078. * Sets wether or not the texture is blocking during loading.
  118079. */
  118080. /**
  118081. * Gets wether or not the texture is blocking during loading.
  118082. */
  118083. isBlocking: boolean;
  118084. protected _rotationY: number;
  118085. /**
  118086. * Sets texture matrix rotation angle around Y axis in radians.
  118087. */
  118088. /**
  118089. * Gets texture matrix rotation angle around Y axis radians.
  118090. */
  118091. rotationY: number;
  118092. /**
  118093. * Gets or sets the center of the bounding box associated with the cube texture
  118094. * It must define where the camera used to render the texture was set
  118095. */
  118096. boundingBoxPosition: Vector3;
  118097. private _boundingBoxSize;
  118098. /**
  118099. * Gets or sets the size of the bounding box associated with the cube texture
  118100. * When defined, the cubemap will switch to local mode
  118101. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118102. * @example https://www.babylonjs-playground.com/#RNASML
  118103. */
  118104. boundingBoxSize: Vector3;
  118105. /**
  118106. * Instantiates an HDRTexture from the following parameters.
  118107. *
  118108. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118109. * @param scene The scene the texture will be used in
  118110. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118111. * @param noMipmap Forces to not generate the mipmap if true
  118112. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118113. * @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)
  118114. * @param reserved Reserved flag for internal use.
  118115. */
  118116. 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>);
  118117. /**
  118118. * Get the current class name of the texture useful for serialization or dynamic coding.
  118119. * @returns "HDRCubeTexture"
  118120. */
  118121. getClassName(): string;
  118122. /**
  118123. * Occurs when the file is raw .hdr file.
  118124. */
  118125. private loadTexture;
  118126. clone(): HDRCubeTexture;
  118127. delayLoad(): void;
  118128. /**
  118129. * Get the texture reflection matrix used to rotate/transform the reflection.
  118130. * @returns the reflection matrix
  118131. */
  118132. getReflectionTextureMatrix(): Matrix;
  118133. /**
  118134. * Set the texture reflection matrix used to rotate/transform the reflection.
  118135. * @param value Define the reflection matrix to set
  118136. */
  118137. setReflectionTextureMatrix(value: Matrix): void;
  118138. /**
  118139. * Parses a JSON representation of an HDR Texture in order to create the texture
  118140. * @param parsedTexture Define the JSON representation
  118141. * @param scene Define the scene the texture should be created in
  118142. * @param rootUrl Define the root url in case we need to load relative dependencies
  118143. * @returns the newly created texture after parsing
  118144. */
  118145. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118146. serialize(): any;
  118147. }
  118148. }
  118149. declare module BABYLON {
  118150. /**
  118151. * Class used to control physics engine
  118152. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118153. */
  118154. export class PhysicsEngine implements IPhysicsEngine {
  118155. private _physicsPlugin;
  118156. /**
  118157. * Global value used to control the smallest number supported by the simulation
  118158. */
  118159. static Epsilon: number;
  118160. private _impostors;
  118161. private _joints;
  118162. /**
  118163. * Gets the gravity vector used by the simulation
  118164. */
  118165. gravity: Vector3;
  118166. /**
  118167. * Factory used to create the default physics plugin.
  118168. * @returns The default physics plugin
  118169. */
  118170. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118171. /**
  118172. * Creates a new Physics Engine
  118173. * @param gravity defines the gravity vector used by the simulation
  118174. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118175. */
  118176. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118177. /**
  118178. * Sets the gravity vector used by the simulation
  118179. * @param gravity defines the gravity vector to use
  118180. */
  118181. setGravity(gravity: Vector3): void;
  118182. /**
  118183. * Set the time step of the physics engine.
  118184. * Default is 1/60.
  118185. * To slow it down, enter 1/600 for example.
  118186. * To speed it up, 1/30
  118187. * @param newTimeStep defines the new timestep to apply to this world.
  118188. */
  118189. setTimeStep(newTimeStep?: number): void;
  118190. /**
  118191. * Get the time step of the physics engine.
  118192. * @returns the current time step
  118193. */
  118194. getTimeStep(): number;
  118195. /**
  118196. * Release all resources
  118197. */
  118198. dispose(): void;
  118199. /**
  118200. * Gets the name of the current physics plugin
  118201. * @returns the name of the plugin
  118202. */
  118203. getPhysicsPluginName(): string;
  118204. /**
  118205. * Adding a new impostor for the impostor tracking.
  118206. * This will be done by the impostor itself.
  118207. * @param impostor the impostor to add
  118208. */
  118209. addImpostor(impostor: PhysicsImpostor): void;
  118210. /**
  118211. * Remove an impostor from the engine.
  118212. * This impostor and its mesh will not longer be updated by the physics engine.
  118213. * @param impostor the impostor to remove
  118214. */
  118215. removeImpostor(impostor: PhysicsImpostor): void;
  118216. /**
  118217. * Add a joint to the physics engine
  118218. * @param mainImpostor defines the main impostor to which the joint is added.
  118219. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118220. * @param joint defines the joint that will connect both impostors.
  118221. */
  118222. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118223. /**
  118224. * Removes a joint from the simulation
  118225. * @param mainImpostor defines the impostor used with the joint
  118226. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118227. * @param joint defines the joint to remove
  118228. */
  118229. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118230. /**
  118231. * Called by the scene. No need to call it.
  118232. * @param delta defines the timespam between frames
  118233. */
  118234. _step(delta: number): void;
  118235. /**
  118236. * Gets the current plugin used to run the simulation
  118237. * @returns current plugin
  118238. */
  118239. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118240. /**
  118241. * Gets the list of physic impostors
  118242. * @returns an array of PhysicsImpostor
  118243. */
  118244. getImpostors(): Array<PhysicsImpostor>;
  118245. /**
  118246. * Gets the impostor for a physics enabled object
  118247. * @param object defines the object impersonated by the impostor
  118248. * @returns the PhysicsImpostor or null if not found
  118249. */
  118250. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118251. /**
  118252. * Gets the impostor for a physics body object
  118253. * @param body defines physics body used by the impostor
  118254. * @returns the PhysicsImpostor or null if not found
  118255. */
  118256. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118257. /**
  118258. * Does a raycast in the physics world
  118259. * @param from when should the ray start?
  118260. * @param to when should the ray end?
  118261. * @returns PhysicsRaycastResult
  118262. */
  118263. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118264. }
  118265. }
  118266. declare module BABYLON {
  118267. /** @hidden */
  118268. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118269. private _useDeltaForWorldStep;
  118270. world: any;
  118271. name: string;
  118272. private _physicsMaterials;
  118273. private _fixedTimeStep;
  118274. private _cannonRaycastResult;
  118275. private _raycastResult;
  118276. private _physicsBodysToRemoveAfterStep;
  118277. BJSCANNON: any;
  118278. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118279. setGravity(gravity: Vector3): void;
  118280. setTimeStep(timeStep: number): void;
  118281. getTimeStep(): number;
  118282. executeStep(delta: number): void;
  118283. private _removeMarkedPhysicsBodiesFromWorld;
  118284. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118285. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118286. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118287. private _processChildMeshes;
  118288. removePhysicsBody(impostor: PhysicsImpostor): void;
  118289. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118290. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118291. private _addMaterial;
  118292. private _checkWithEpsilon;
  118293. private _createShape;
  118294. private _createHeightmap;
  118295. private _minus90X;
  118296. private _plus90X;
  118297. private _tmpPosition;
  118298. private _tmpDeltaPosition;
  118299. private _tmpUnityRotation;
  118300. private _updatePhysicsBodyTransformation;
  118301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118303. isSupported(): boolean;
  118304. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118305. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118307. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118309. getBodyMass(impostor: PhysicsImpostor): number;
  118310. getBodyFriction(impostor: PhysicsImpostor): number;
  118311. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118312. getBodyRestitution(impostor: PhysicsImpostor): number;
  118313. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118314. sleepBody(impostor: PhysicsImpostor): void;
  118315. wakeUpBody(impostor: PhysicsImpostor): void;
  118316. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118317. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118318. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118319. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118320. getRadius(impostor: PhysicsImpostor): number;
  118321. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118322. dispose(): void;
  118323. private _extendNamespace;
  118324. /**
  118325. * Does a raycast in the physics world
  118326. * @param from when should the ray start?
  118327. * @param to when should the ray end?
  118328. * @returns PhysicsRaycastResult
  118329. */
  118330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118331. }
  118332. }
  118333. declare module BABYLON {
  118334. /** @hidden */
  118335. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118336. world: any;
  118337. name: string;
  118338. BJSOIMO: any;
  118339. private _raycastResult;
  118340. constructor(iterations?: number, oimoInjection?: any);
  118341. setGravity(gravity: Vector3): void;
  118342. setTimeStep(timeStep: number): void;
  118343. getTimeStep(): number;
  118344. private _tmpImpostorsArray;
  118345. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118346. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118347. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118348. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118349. private _tmpPositionVector;
  118350. removePhysicsBody(impostor: PhysicsImpostor): void;
  118351. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118352. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118353. isSupported(): boolean;
  118354. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118358. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118361. getBodyMass(impostor: PhysicsImpostor): number;
  118362. getBodyFriction(impostor: PhysicsImpostor): number;
  118363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118364. getBodyRestitution(impostor: PhysicsImpostor): number;
  118365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118366. sleepBody(impostor: PhysicsImpostor): void;
  118367. wakeUpBody(impostor: PhysicsImpostor): void;
  118368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118369. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  118370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  118371. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118372. getRadius(impostor: PhysicsImpostor): number;
  118373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118374. dispose(): void;
  118375. /**
  118376. * Does a raycast in the physics world
  118377. * @param from when should the ray start?
  118378. * @param to when should the ray end?
  118379. * @returns PhysicsRaycastResult
  118380. */
  118381. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118382. }
  118383. }
  118384. declare module BABYLON {
  118385. /**
  118386. * Class containing static functions to help procedurally build meshes
  118387. */
  118388. export class RibbonBuilder {
  118389. /**
  118390. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118391. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118392. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118393. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118394. * * 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
  118395. * * 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
  118396. * * 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
  118397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118400. * * 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
  118401. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118402. * * 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
  118403. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118405. * @param name defines the name of the mesh
  118406. * @param options defines the options used to create the mesh
  118407. * @param scene defines the hosting scene
  118408. * @returns the ribbon mesh
  118409. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118411. */
  118412. static CreateRibbon(name: string, options: {
  118413. pathArray: Vector3[][];
  118414. closeArray?: boolean;
  118415. closePath?: boolean;
  118416. offset?: number;
  118417. updatable?: boolean;
  118418. sideOrientation?: number;
  118419. frontUVs?: Vector4;
  118420. backUVs?: Vector4;
  118421. instance?: Mesh;
  118422. invertUV?: boolean;
  118423. uvs?: Vector2[];
  118424. colors?: Color4[];
  118425. }, scene?: Nullable<Scene>): Mesh;
  118426. }
  118427. }
  118428. declare module BABYLON {
  118429. /**
  118430. * Class containing static functions to help procedurally build meshes
  118431. */
  118432. export class ShapeBuilder {
  118433. /**
  118434. * 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.
  118435. * * 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.
  118436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118437. * * 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.
  118438. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118439. * * 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
  118440. * * 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
  118441. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118444. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118446. * @param name defines the name of the mesh
  118447. * @param options defines the options used to create the mesh
  118448. * @param scene defines the hosting scene
  118449. * @returns the extruded shape mesh
  118450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118452. */
  118453. static ExtrudeShape(name: string, options: {
  118454. shape: Vector3[];
  118455. path: Vector3[];
  118456. scale?: number;
  118457. rotation?: number;
  118458. cap?: number;
  118459. updatable?: boolean;
  118460. sideOrientation?: number;
  118461. frontUVs?: Vector4;
  118462. backUVs?: Vector4;
  118463. instance?: Mesh;
  118464. invertUV?: boolean;
  118465. }, scene?: Nullable<Scene>): Mesh;
  118466. /**
  118467. * Creates an custom extruded shape mesh.
  118468. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118469. * * 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.
  118470. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118471. * * 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
  118472. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118473. * * 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
  118474. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118475. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118476. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118477. * * 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
  118478. * * 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
  118479. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118484. * @param name defines the name of the mesh
  118485. * @param options defines the options used to create the mesh
  118486. * @param scene defines the hosting scene
  118487. * @returns the custom extruded shape mesh
  118488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118489. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118491. */
  118492. static ExtrudeShapeCustom(name: string, options: {
  118493. shape: Vector3[];
  118494. path: Vector3[];
  118495. scaleFunction?: any;
  118496. rotationFunction?: any;
  118497. ribbonCloseArray?: boolean;
  118498. ribbonClosePath?: boolean;
  118499. cap?: number;
  118500. updatable?: boolean;
  118501. sideOrientation?: number;
  118502. frontUVs?: Vector4;
  118503. backUVs?: Vector4;
  118504. instance?: Mesh;
  118505. invertUV?: boolean;
  118506. }, scene?: Nullable<Scene>): Mesh;
  118507. private static _ExtrudeShapeGeneric;
  118508. }
  118509. }
  118510. declare module BABYLON {
  118511. /**
  118512. * AmmoJS Physics plugin
  118513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118514. * @see https://github.com/kripken/ammo.js/
  118515. */
  118516. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118517. private _useDeltaForWorldStep;
  118518. /**
  118519. * Reference to the Ammo library
  118520. */
  118521. bjsAMMO: any;
  118522. /**
  118523. * Created ammoJS world which physics bodies are added to
  118524. */
  118525. world: any;
  118526. /**
  118527. * Name of the plugin
  118528. */
  118529. name: string;
  118530. private _timeStep;
  118531. private _fixedTimeStep;
  118532. private _maxSteps;
  118533. private _tmpQuaternion;
  118534. private _tmpAmmoTransform;
  118535. private _tmpAmmoQuaternion;
  118536. private _tmpAmmoConcreteContactResultCallback;
  118537. private _collisionConfiguration;
  118538. private _dispatcher;
  118539. private _overlappingPairCache;
  118540. private _solver;
  118541. private _softBodySolver;
  118542. private _tmpAmmoVectorA;
  118543. private _tmpAmmoVectorB;
  118544. private _tmpAmmoVectorC;
  118545. private _tmpAmmoVectorD;
  118546. private _tmpContactCallbackResult;
  118547. private _tmpAmmoVectorRCA;
  118548. private _tmpAmmoVectorRCB;
  118549. private _raycastResult;
  118550. private static readonly DISABLE_COLLISION_FLAG;
  118551. private static readonly KINEMATIC_FLAG;
  118552. private static readonly DISABLE_DEACTIVATION_FLAG;
  118553. /**
  118554. * Initializes the ammoJS plugin
  118555. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118556. * @param ammoInjection can be used to inject your own ammo reference
  118557. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118558. */
  118559. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118560. /**
  118561. * Sets the gravity of the physics world (m/(s^2))
  118562. * @param gravity Gravity to set
  118563. */
  118564. setGravity(gravity: Vector3): void;
  118565. /**
  118566. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118567. * @param timeStep timestep to use in seconds
  118568. */
  118569. setTimeStep(timeStep: number): void;
  118570. /**
  118571. * 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)
  118572. * @param fixedTimeStep fixedTimeStep to use in seconds
  118573. */
  118574. setFixedTimeStep(fixedTimeStep: number): void;
  118575. /**
  118576. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118577. * @param maxSteps the maximum number of steps by the physics engine per frame
  118578. */
  118579. setMaxSteps(maxSteps: number): void;
  118580. /**
  118581. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118582. * @returns the current timestep in seconds
  118583. */
  118584. getTimeStep(): number;
  118585. private _isImpostorInContact;
  118586. private _isImpostorPairInContact;
  118587. private _stepSimulation;
  118588. /**
  118589. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118590. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118591. * After the step the babylon meshes are set to the position of the physics imposters
  118592. * @param delta amount of time to step forward
  118593. * @param impostors array of imposters to update before/after the step
  118594. */
  118595. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118596. /**
  118597. * Update babylon mesh to match physics world object
  118598. * @param impostor imposter to match
  118599. */
  118600. private _afterSoftStep;
  118601. /**
  118602. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118603. * @param impostor imposter to match
  118604. */
  118605. private _ropeStep;
  118606. /**
  118607. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118608. * @param impostor imposter to match
  118609. */
  118610. private _softbodyOrClothStep;
  118611. private _tmpVector;
  118612. private _tmpMatrix;
  118613. /**
  118614. * Applies an impulse on the imposter
  118615. * @param impostor imposter to apply impulse to
  118616. * @param force amount of force to be applied to the imposter
  118617. * @param contactPoint the location to apply the impulse on the imposter
  118618. */
  118619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118620. /**
  118621. * Applies a force on the imposter
  118622. * @param impostor imposter to apply force
  118623. * @param force amount of force to be applied to the imposter
  118624. * @param contactPoint the location to apply the force on the imposter
  118625. */
  118626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118627. /**
  118628. * Creates a physics body using the plugin
  118629. * @param impostor the imposter to create the physics body on
  118630. */
  118631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118632. /**
  118633. * Removes the physics body from the imposter and disposes of the body's memory
  118634. * @param impostor imposter to remove the physics body from
  118635. */
  118636. removePhysicsBody(impostor: PhysicsImpostor): void;
  118637. /**
  118638. * Generates a joint
  118639. * @param impostorJoint the imposter joint to create the joint with
  118640. */
  118641. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118642. /**
  118643. * Removes a joint
  118644. * @param impostorJoint the imposter joint to remove the joint from
  118645. */
  118646. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118647. private _addMeshVerts;
  118648. /**
  118649. * Initialise the soft body vertices to match its object's (mesh) vertices
  118650. * Softbody vertices (nodes) are in world space and to match this
  118651. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118652. * @param impostor to create the softbody for
  118653. */
  118654. private _softVertexData;
  118655. /**
  118656. * Create an impostor's soft body
  118657. * @param impostor to create the softbody for
  118658. */
  118659. private _createSoftbody;
  118660. /**
  118661. * Create cloth for an impostor
  118662. * @param impostor to create the softbody for
  118663. */
  118664. private _createCloth;
  118665. /**
  118666. * Create rope for an impostor
  118667. * @param impostor to create the softbody for
  118668. */
  118669. private _createRope;
  118670. private _addHullVerts;
  118671. private _createShape;
  118672. /**
  118673. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118674. * @param impostor imposter containing the physics body and babylon object
  118675. */
  118676. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118677. /**
  118678. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118679. * @param impostor imposter containing the physics body and babylon object
  118680. * @param newPosition new position
  118681. * @param newRotation new rotation
  118682. */
  118683. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118684. /**
  118685. * If this plugin is supported
  118686. * @returns true if its supported
  118687. */
  118688. isSupported(): boolean;
  118689. /**
  118690. * Sets the linear velocity of the physics body
  118691. * @param impostor imposter to set the velocity on
  118692. * @param velocity velocity to set
  118693. */
  118694. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118695. /**
  118696. * Sets the angular velocity of the physics body
  118697. * @param impostor imposter to set the velocity on
  118698. * @param velocity velocity to set
  118699. */
  118700. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118701. /**
  118702. * gets the linear velocity
  118703. * @param impostor imposter to get linear velocity from
  118704. * @returns linear velocity
  118705. */
  118706. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118707. /**
  118708. * gets the angular velocity
  118709. * @param impostor imposter to get angular velocity from
  118710. * @returns angular velocity
  118711. */
  118712. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118713. /**
  118714. * Sets the mass of physics body
  118715. * @param impostor imposter to set the mass on
  118716. * @param mass mass to set
  118717. */
  118718. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118719. /**
  118720. * Gets the mass of the physics body
  118721. * @param impostor imposter to get the mass from
  118722. * @returns mass
  118723. */
  118724. getBodyMass(impostor: PhysicsImpostor): number;
  118725. /**
  118726. * Gets friction of the impostor
  118727. * @param impostor impostor to get friction from
  118728. * @returns friction value
  118729. */
  118730. getBodyFriction(impostor: PhysicsImpostor): number;
  118731. /**
  118732. * Sets friction of the impostor
  118733. * @param impostor impostor to set friction on
  118734. * @param friction friction value
  118735. */
  118736. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118737. /**
  118738. * Gets restitution of the impostor
  118739. * @param impostor impostor to get restitution from
  118740. * @returns restitution value
  118741. */
  118742. getBodyRestitution(impostor: PhysicsImpostor): number;
  118743. /**
  118744. * Sets resitution of the impostor
  118745. * @param impostor impostor to set resitution on
  118746. * @param restitution resitution value
  118747. */
  118748. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118749. /**
  118750. * Gets pressure inside the impostor
  118751. * @param impostor impostor to get pressure from
  118752. * @returns pressure value
  118753. */
  118754. getBodyPressure(impostor: PhysicsImpostor): number;
  118755. /**
  118756. * Sets pressure inside a soft body impostor
  118757. * Cloth and rope must remain 0 pressure
  118758. * @param impostor impostor to set pressure on
  118759. * @param pressure pressure value
  118760. */
  118761. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118762. /**
  118763. * Gets stiffness of the impostor
  118764. * @param impostor impostor to get stiffness from
  118765. * @returns pressure value
  118766. */
  118767. getBodyStiffness(impostor: PhysicsImpostor): number;
  118768. /**
  118769. * Sets stiffness of the impostor
  118770. * @param impostor impostor to set stiffness on
  118771. * @param stiffness stiffness value from 0 to 1
  118772. */
  118773. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118774. /**
  118775. * Gets velocityIterations of the impostor
  118776. * @param impostor impostor to get velocity iterations from
  118777. * @returns velocityIterations value
  118778. */
  118779. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118780. /**
  118781. * Sets velocityIterations of the impostor
  118782. * @param impostor impostor to set velocity iterations on
  118783. * @param velocityIterations velocityIterations value
  118784. */
  118785. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118786. /**
  118787. * Gets positionIterations of the impostor
  118788. * @param impostor impostor to get position iterations from
  118789. * @returns positionIterations value
  118790. */
  118791. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118792. /**
  118793. * Sets positionIterations of the impostor
  118794. * @param impostor impostor to set position on
  118795. * @param positionIterations positionIterations value
  118796. */
  118797. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118798. /**
  118799. * Append an anchor to a cloth object
  118800. * @param impostor is the cloth impostor to add anchor to
  118801. * @param otherImpostor is the rigid impostor to anchor to
  118802. * @param width ratio across width from 0 to 1
  118803. * @param height ratio up height from 0 to 1
  118804. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118805. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118806. */
  118807. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118808. /**
  118809. * Append an hook to a rope object
  118810. * @param impostor is the rope impostor to add hook to
  118811. * @param otherImpostor is the rigid impostor to hook to
  118812. * @param length ratio along the rope from 0 to 1
  118813. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118814. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118815. */
  118816. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118817. /**
  118818. * Sleeps the physics body and stops it from being active
  118819. * @param impostor impostor to sleep
  118820. */
  118821. sleepBody(impostor: PhysicsImpostor): void;
  118822. /**
  118823. * Activates the physics body
  118824. * @param impostor impostor to activate
  118825. */
  118826. wakeUpBody(impostor: PhysicsImpostor): void;
  118827. /**
  118828. * Updates the distance parameters of the joint
  118829. * @param joint joint to update
  118830. * @param maxDistance maximum distance of the joint
  118831. * @param minDistance minimum distance of the joint
  118832. */
  118833. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118834. /**
  118835. * Sets a motor on the joint
  118836. * @param joint joint to set motor on
  118837. * @param speed speed of the motor
  118838. * @param maxForce maximum force of the motor
  118839. * @param motorIndex index of the motor
  118840. */
  118841. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118842. /**
  118843. * Sets the motors limit
  118844. * @param joint joint to set limit on
  118845. * @param upperLimit upper limit
  118846. * @param lowerLimit lower limit
  118847. */
  118848. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118849. /**
  118850. * Syncs the position and rotation of a mesh with the impostor
  118851. * @param mesh mesh to sync
  118852. * @param impostor impostor to update the mesh with
  118853. */
  118854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118855. /**
  118856. * Gets the radius of the impostor
  118857. * @param impostor impostor to get radius from
  118858. * @returns the radius
  118859. */
  118860. getRadius(impostor: PhysicsImpostor): number;
  118861. /**
  118862. * Gets the box size of the impostor
  118863. * @param impostor impostor to get box size from
  118864. * @param result the resulting box size
  118865. */
  118866. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118867. /**
  118868. * Disposes of the impostor
  118869. */
  118870. dispose(): void;
  118871. /**
  118872. * Does a raycast in the physics world
  118873. * @param from when should the ray start?
  118874. * @param to when should the ray end?
  118875. * @returns PhysicsRaycastResult
  118876. */
  118877. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118878. }
  118879. }
  118880. declare module BABYLON {
  118881. interface AbstractScene {
  118882. /**
  118883. * The list of reflection probes added to the scene
  118884. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118885. */
  118886. reflectionProbes: Array<ReflectionProbe>;
  118887. /**
  118888. * Removes the given reflection probe from this scene.
  118889. * @param toRemove The reflection probe to remove
  118890. * @returns The index of the removed reflection probe
  118891. */
  118892. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118893. /**
  118894. * Adds the given reflection probe to this scene.
  118895. * @param newReflectionProbe The reflection probe to add
  118896. */
  118897. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118898. }
  118899. /**
  118900. * Class used to generate realtime reflection / refraction cube textures
  118901. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118902. */
  118903. export class ReflectionProbe {
  118904. /** defines the name of the probe */
  118905. name: string;
  118906. private _scene;
  118907. private _renderTargetTexture;
  118908. private _projectionMatrix;
  118909. private _viewMatrix;
  118910. private _target;
  118911. private _add;
  118912. private _attachedMesh;
  118913. private _invertYAxis;
  118914. /** Gets or sets probe position (center of the cube map) */
  118915. position: Vector3;
  118916. /**
  118917. * Creates a new reflection probe
  118918. * @param name defines the name of the probe
  118919. * @param size defines the texture resolution (for each face)
  118920. * @param scene defines the hosting scene
  118921. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118922. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118923. */
  118924. constructor(
  118925. /** defines the name of the probe */
  118926. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118927. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118928. samples: number;
  118929. /** Gets or sets the refresh rate to use (on every frame by default) */
  118930. refreshRate: number;
  118931. /**
  118932. * Gets the hosting scene
  118933. * @returns a Scene
  118934. */
  118935. getScene(): Scene;
  118936. /** Gets the internal CubeTexture used to render to */
  118937. readonly cubeTexture: RenderTargetTexture;
  118938. /** Gets the list of meshes to render */
  118939. readonly renderList: Nullable<AbstractMesh[]>;
  118940. /**
  118941. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118942. * @param mesh defines the mesh to attach to
  118943. */
  118944. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118945. /**
  118946. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118947. * @param renderingGroupId The rendering group id corresponding to its index
  118948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118949. */
  118950. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118951. /**
  118952. * Clean all associated resources
  118953. */
  118954. dispose(): void;
  118955. /**
  118956. * Converts the reflection probe information to a readable string for debug purpose.
  118957. * @param fullDetails Supports for multiple levels of logging within scene loading
  118958. * @returns the human readable reflection probe info
  118959. */
  118960. toString(fullDetails?: boolean): string;
  118961. /**
  118962. * Get the class name of the relfection probe.
  118963. * @returns "ReflectionProbe"
  118964. */
  118965. getClassName(): string;
  118966. /**
  118967. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118968. * @returns The JSON representation of the texture
  118969. */
  118970. serialize(): any;
  118971. /**
  118972. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118973. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118974. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118975. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118976. * @returns The parsed reflection probe if successful
  118977. */
  118978. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118979. }
  118980. }
  118981. declare module BABYLON {
  118982. /** @hidden */
  118983. export var _BabylonLoaderRegistered: boolean;
  118984. }
  118985. declare module BABYLON {
  118986. /**
  118987. * The Physically based simple base material of BJS.
  118988. *
  118989. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118990. * It is used as the base class for both the specGloss and metalRough conventions.
  118991. */
  118992. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118993. /**
  118994. * Number of Simultaneous lights allowed on the material.
  118995. */
  118996. maxSimultaneousLights: number;
  118997. /**
  118998. * If sets to true, disables all the lights affecting the material.
  118999. */
  119000. disableLighting: boolean;
  119001. /**
  119002. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119003. */
  119004. environmentTexture: BaseTexture;
  119005. /**
  119006. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119007. */
  119008. invertNormalMapX: boolean;
  119009. /**
  119010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119011. */
  119012. invertNormalMapY: boolean;
  119013. /**
  119014. * Normal map used in the model.
  119015. */
  119016. normalTexture: BaseTexture;
  119017. /**
  119018. * Emissivie color used to self-illuminate the model.
  119019. */
  119020. emissiveColor: Color3;
  119021. /**
  119022. * Emissivie texture used to self-illuminate the model.
  119023. */
  119024. emissiveTexture: BaseTexture;
  119025. /**
  119026. * Occlusion Channel Strenght.
  119027. */
  119028. occlusionStrength: number;
  119029. /**
  119030. * Occlusion Texture of the material (adding extra occlusion effects).
  119031. */
  119032. occlusionTexture: BaseTexture;
  119033. /**
  119034. * Defines the alpha limits in alpha test mode.
  119035. */
  119036. alphaCutOff: number;
  119037. /**
  119038. * Gets the current double sided mode.
  119039. */
  119040. /**
  119041. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119042. */
  119043. doubleSided: boolean;
  119044. /**
  119045. * Stores the pre-calculated light information of a mesh in a texture.
  119046. */
  119047. lightmapTexture: BaseTexture;
  119048. /**
  119049. * If true, the light map contains occlusion information instead of lighting info.
  119050. */
  119051. useLightmapAsShadowmap: boolean;
  119052. /**
  119053. * Instantiates a new PBRMaterial instance.
  119054. *
  119055. * @param name The material name
  119056. * @param scene The scene the material will be use in.
  119057. */
  119058. constructor(name: string, scene: Scene);
  119059. getClassName(): string;
  119060. }
  119061. }
  119062. declare module BABYLON {
  119063. /**
  119064. * The PBR material of BJS following the metal roughness convention.
  119065. *
  119066. * This fits to the PBR convention in the GLTF definition:
  119067. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119068. */
  119069. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119070. /**
  119071. * The base color has two different interpretations depending on the value of metalness.
  119072. * When the material is a metal, the base color is the specific measured reflectance value
  119073. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119074. * of the material.
  119075. */
  119076. baseColor: Color3;
  119077. /**
  119078. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119079. * well as opacity information in the alpha channel.
  119080. */
  119081. baseTexture: BaseTexture;
  119082. /**
  119083. * Specifies the metallic scalar value of the material.
  119084. * Can also be used to scale the metalness values of the metallic texture.
  119085. */
  119086. metallic: number;
  119087. /**
  119088. * Specifies the roughness scalar value of the material.
  119089. * Can also be used to scale the roughness values of the metallic texture.
  119090. */
  119091. roughness: number;
  119092. /**
  119093. * Texture containing both the metallic value in the B channel and the
  119094. * roughness value in the G channel to keep better precision.
  119095. */
  119096. metallicRoughnessTexture: BaseTexture;
  119097. /**
  119098. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119099. *
  119100. * @param name The material name
  119101. * @param scene The scene the material will be use in.
  119102. */
  119103. constructor(name: string, scene: Scene);
  119104. /**
  119105. * Return the currrent class name of the material.
  119106. */
  119107. getClassName(): string;
  119108. /**
  119109. * Makes a duplicate of the current material.
  119110. * @param name - name to use for the new material.
  119111. */
  119112. clone(name: string): PBRMetallicRoughnessMaterial;
  119113. /**
  119114. * Serialize the material to a parsable JSON object.
  119115. */
  119116. serialize(): any;
  119117. /**
  119118. * Parses a JSON object correponding to the serialize function.
  119119. */
  119120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119121. }
  119122. }
  119123. declare module BABYLON {
  119124. /**
  119125. * The PBR material of BJS following the specular glossiness convention.
  119126. *
  119127. * This fits to the PBR convention in the GLTF definition:
  119128. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119129. */
  119130. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119131. /**
  119132. * Specifies the diffuse color of the material.
  119133. */
  119134. diffuseColor: Color3;
  119135. /**
  119136. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119137. * channel.
  119138. */
  119139. diffuseTexture: BaseTexture;
  119140. /**
  119141. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119142. */
  119143. specularColor: Color3;
  119144. /**
  119145. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119146. */
  119147. glossiness: number;
  119148. /**
  119149. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119150. */
  119151. specularGlossinessTexture: BaseTexture;
  119152. /**
  119153. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119154. *
  119155. * @param name The material name
  119156. * @param scene The scene the material will be use in.
  119157. */
  119158. constructor(name: string, scene: Scene);
  119159. /**
  119160. * Return the currrent class name of the material.
  119161. */
  119162. getClassName(): string;
  119163. /**
  119164. * Makes a duplicate of the current material.
  119165. * @param name - name to use for the new material.
  119166. */
  119167. clone(name: string): PBRSpecularGlossinessMaterial;
  119168. /**
  119169. * Serialize the material to a parsable JSON object.
  119170. */
  119171. serialize(): any;
  119172. /**
  119173. * Parses a JSON object correponding to the serialize function.
  119174. */
  119175. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119176. }
  119177. }
  119178. declare module BABYLON {
  119179. /**
  119180. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119181. * It can help converting any input color in a desired output one. This can then be used to create effects
  119182. * from sepia, black and white to sixties or futuristic rendering...
  119183. *
  119184. * The only supported format is currently 3dl.
  119185. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119186. */
  119187. export class ColorGradingTexture extends BaseTexture {
  119188. /**
  119189. * The current texture matrix. (will always be identity in color grading texture)
  119190. */
  119191. private _textureMatrix;
  119192. /**
  119193. * The texture URL.
  119194. */
  119195. url: string;
  119196. /**
  119197. * Empty line regex stored for GC.
  119198. */
  119199. private static _noneEmptyLineRegex;
  119200. private _engine;
  119201. /**
  119202. * Instantiates a ColorGradingTexture from the following parameters.
  119203. *
  119204. * @param url The location of the color gradind data (currently only supporting 3dl)
  119205. * @param scene The scene the texture will be used in
  119206. */
  119207. constructor(url: string, scene: Scene);
  119208. /**
  119209. * Returns the texture matrix used in most of the material.
  119210. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119211. */
  119212. getTextureMatrix(): Matrix;
  119213. /**
  119214. * Occurs when the file being loaded is a .3dl LUT file.
  119215. */
  119216. private load3dlTexture;
  119217. /**
  119218. * Starts the loading process of the texture.
  119219. */
  119220. private loadTexture;
  119221. /**
  119222. * Clones the color gradind texture.
  119223. */
  119224. clone(): ColorGradingTexture;
  119225. /**
  119226. * Called during delayed load for textures.
  119227. */
  119228. delayLoad(): void;
  119229. /**
  119230. * Parses a color grading texture serialized by Babylon.
  119231. * @param parsedTexture The texture information being parsedTexture
  119232. * @param scene The scene to load the texture in
  119233. * @param rootUrl The root url of the data assets to load
  119234. * @return A color gradind texture
  119235. */
  119236. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119237. /**
  119238. * Serializes the LUT texture to json format.
  119239. */
  119240. serialize(): any;
  119241. }
  119242. }
  119243. declare module BABYLON {
  119244. /**
  119245. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119246. */
  119247. export class EquiRectangularCubeTexture extends BaseTexture {
  119248. /** The six faces of the cube. */
  119249. private static _FacesMapping;
  119250. private _noMipmap;
  119251. private _onLoad;
  119252. private _onError;
  119253. /** The size of the cubemap. */
  119254. private _size;
  119255. /** The buffer of the image. */
  119256. private _buffer;
  119257. /** The width of the input image. */
  119258. private _width;
  119259. /** The height of the input image. */
  119260. private _height;
  119261. /** The URL to the image. */
  119262. url: string;
  119263. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119264. coordinatesMode: number;
  119265. /**
  119266. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119267. * @param url The location of the image
  119268. * @param scene The scene the texture will be used in
  119269. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119270. * @param noMipmap Forces to not generate the mipmap if true
  119271. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119272. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119273. * @param onLoad — defines a callback called when texture is loaded
  119274. * @param onError — defines a callback called if there is an error
  119275. */
  119276. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119277. /**
  119278. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119279. */
  119280. private loadImage;
  119281. /**
  119282. * Convert the image buffer into a cubemap and create a CubeTexture.
  119283. */
  119284. private loadTexture;
  119285. /**
  119286. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119287. * @param buffer The ArrayBuffer that should be converted.
  119288. * @returns The buffer as Float32Array.
  119289. */
  119290. private getFloat32ArrayFromArrayBuffer;
  119291. /**
  119292. * Get the current class name of the texture useful for serialization or dynamic coding.
  119293. * @returns "EquiRectangularCubeTexture"
  119294. */
  119295. getClassName(): string;
  119296. /**
  119297. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119298. * @returns A clone of the current EquiRectangularCubeTexture.
  119299. */
  119300. clone(): EquiRectangularCubeTexture;
  119301. }
  119302. }
  119303. declare module BABYLON {
  119304. /**
  119305. * Based on jsTGALoader - Javascript loader for TGA file
  119306. * By Vincent Thibault
  119307. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119308. */
  119309. export class TGATools {
  119310. private static _TYPE_INDEXED;
  119311. private static _TYPE_RGB;
  119312. private static _TYPE_GREY;
  119313. private static _TYPE_RLE_INDEXED;
  119314. private static _TYPE_RLE_RGB;
  119315. private static _TYPE_RLE_GREY;
  119316. private static _ORIGIN_MASK;
  119317. private static _ORIGIN_SHIFT;
  119318. private static _ORIGIN_BL;
  119319. private static _ORIGIN_BR;
  119320. private static _ORIGIN_UL;
  119321. private static _ORIGIN_UR;
  119322. /**
  119323. * Gets the header of a TGA file
  119324. * @param data defines the TGA data
  119325. * @returns the header
  119326. */
  119327. static GetTGAHeader(data: Uint8Array): any;
  119328. /**
  119329. * Uploads TGA content to a Babylon Texture
  119330. * @hidden
  119331. */
  119332. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119333. /** @hidden */
  119334. 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;
  119335. /** @hidden */
  119336. 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;
  119337. /** @hidden */
  119338. 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;
  119339. /** @hidden */
  119340. 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;
  119341. /** @hidden */
  119342. 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;
  119343. /** @hidden */
  119344. 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;
  119345. }
  119346. }
  119347. declare module BABYLON {
  119348. /**
  119349. * Implementation of the TGA Texture Loader.
  119350. * @hidden
  119351. */
  119352. export class _TGATextureLoader implements IInternalTextureLoader {
  119353. /**
  119354. * Defines wether the loader supports cascade loading the different faces.
  119355. */
  119356. readonly supportCascades: boolean;
  119357. /**
  119358. * This returns if the loader support the current file information.
  119359. * @param extension defines the file extension of the file being loaded
  119360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119361. * @param fallback defines the fallback internal texture if any
  119362. * @param isBase64 defines whether the texture is encoded as a base64
  119363. * @param isBuffer defines whether the texture data are stored as a buffer
  119364. * @returns true if the loader can load the specified file
  119365. */
  119366. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119367. /**
  119368. * Transform the url before loading if required.
  119369. * @param rootUrl the url of the texture
  119370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119371. * @returns the transformed texture
  119372. */
  119373. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119374. /**
  119375. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119376. * @param rootUrl the url of the texture
  119377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119378. * @returns the fallback texture
  119379. */
  119380. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119381. /**
  119382. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119383. * @param data contains the texture data
  119384. * @param texture defines the BabylonJS internal texture
  119385. * @param createPolynomials will be true if polynomials have been requested
  119386. * @param onLoad defines the callback to trigger once the texture is ready
  119387. * @param onError defines the callback to trigger in case of error
  119388. */
  119389. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119390. /**
  119391. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119392. * @param data contains the texture data
  119393. * @param texture defines the BabylonJS internal texture
  119394. * @param callback defines the method to call once ready to upload
  119395. */
  119396. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119397. }
  119398. }
  119399. declare module BABYLON {
  119400. /**
  119401. * Info about the .basis files
  119402. */
  119403. class BasisFileInfo {
  119404. /**
  119405. * If the file has alpha
  119406. */
  119407. hasAlpha: boolean;
  119408. /**
  119409. * Info about each image of the basis file
  119410. */
  119411. images: Array<{
  119412. levels: Array<{
  119413. width: number;
  119414. height: number;
  119415. transcodedPixels: ArrayBufferView;
  119416. }>;
  119417. }>;
  119418. }
  119419. /**
  119420. * Result of transcoding a basis file
  119421. */
  119422. class TranscodeResult {
  119423. /**
  119424. * Info about the .basis file
  119425. */
  119426. fileInfo: BasisFileInfo;
  119427. /**
  119428. * Format to use when loading the file
  119429. */
  119430. format: number;
  119431. }
  119432. /**
  119433. * Configuration options for the Basis transcoder
  119434. */
  119435. export class BasisTranscodeConfiguration {
  119436. /**
  119437. * Supported compression formats used to determine the supported output format of the transcoder
  119438. */
  119439. supportedCompressionFormats?: {
  119440. /**
  119441. * etc1 compression format
  119442. */
  119443. etc1?: boolean;
  119444. /**
  119445. * s3tc compression format
  119446. */
  119447. s3tc?: boolean;
  119448. /**
  119449. * pvrtc compression format
  119450. */
  119451. pvrtc?: boolean;
  119452. /**
  119453. * etc2 compression format
  119454. */
  119455. etc2?: boolean;
  119456. };
  119457. /**
  119458. * If mipmap levels should be loaded for transcoded images (Default: true)
  119459. */
  119460. loadMipmapLevels?: boolean;
  119461. /**
  119462. * Index of a single image to load (Default: all images)
  119463. */
  119464. loadSingleImage?: number;
  119465. }
  119466. /**
  119467. * Used to load .Basis files
  119468. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119469. */
  119470. export class BasisTools {
  119471. private static _IgnoreSupportedFormats;
  119472. /**
  119473. * URL to use when loading the basis transcoder
  119474. */
  119475. static JSModuleURL: string;
  119476. /**
  119477. * URL to use when loading the wasm module for the transcoder
  119478. */
  119479. static WasmModuleURL: string;
  119480. /**
  119481. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119482. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119483. * @returns internal format corresponding to the Basis format
  119484. */
  119485. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119486. private static _WorkerPromise;
  119487. private static _Worker;
  119488. private static _actionId;
  119489. private static _CreateWorkerAsync;
  119490. /**
  119491. * Transcodes a loaded image file to compressed pixel data
  119492. * @param imageData image data to transcode
  119493. * @param config configuration options for the transcoding
  119494. * @returns a promise resulting in the transcoded image
  119495. */
  119496. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119497. /**
  119498. * Loads a texture from the transcode result
  119499. * @param texture texture load to
  119500. * @param transcodeResult the result of transcoding the basis file to load from
  119501. */
  119502. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119503. }
  119504. }
  119505. declare module BABYLON {
  119506. /**
  119507. * Loader for .basis file format
  119508. */
  119509. export class _BasisTextureLoader implements IInternalTextureLoader {
  119510. /**
  119511. * Defines whether the loader supports cascade loading the different faces.
  119512. */
  119513. readonly supportCascades: boolean;
  119514. /**
  119515. * This returns if the loader support the current file information.
  119516. * @param extension defines the file extension of the file being loaded
  119517. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119518. * @param fallback defines the fallback internal texture if any
  119519. * @param isBase64 defines whether the texture is encoded as a base64
  119520. * @param isBuffer defines whether the texture data are stored as a buffer
  119521. * @returns true if the loader can load the specified file
  119522. */
  119523. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119524. /**
  119525. * Transform the url before loading if required.
  119526. * @param rootUrl the url of the texture
  119527. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119528. * @returns the transformed texture
  119529. */
  119530. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119531. /**
  119532. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119533. * @param rootUrl the url of the texture
  119534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119535. * @returns the fallback texture
  119536. */
  119537. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119538. /**
  119539. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119540. * @param data contains the texture data
  119541. * @param texture defines the BabylonJS internal texture
  119542. * @param createPolynomials will be true if polynomials have been requested
  119543. * @param onLoad defines the callback to trigger once the texture is ready
  119544. * @param onError defines the callback to trigger in case of error
  119545. */
  119546. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119547. /**
  119548. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119549. * @param data contains the texture data
  119550. * @param texture defines the BabylonJS internal texture
  119551. * @param callback defines the method to call once ready to upload
  119552. */
  119553. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119554. }
  119555. }
  119556. declare module BABYLON {
  119557. /**
  119558. * 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.
  119559. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119560. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119561. */
  119562. export class CustomProceduralTexture extends ProceduralTexture {
  119563. private _animate;
  119564. private _time;
  119565. private _config;
  119566. private _texturePath;
  119567. /**
  119568. * Instantiates a new Custom Procedural Texture.
  119569. * 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.
  119570. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119571. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119572. * @param name Define the name of the texture
  119573. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119574. * @param size Define the size of the texture to create
  119575. * @param scene Define the scene the texture belongs to
  119576. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119577. * @param generateMipMaps Define if the texture should creates mip maps or not
  119578. */
  119579. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119580. private _loadJson;
  119581. /**
  119582. * Is the texture ready to be used ? (rendered at least once)
  119583. * @returns true if ready, otherwise, false.
  119584. */
  119585. isReady(): boolean;
  119586. /**
  119587. * Render the texture to its associated render target.
  119588. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119589. */
  119590. render(useCameraPostProcess?: boolean): void;
  119591. /**
  119592. * Update the list of dependant textures samplers in the shader.
  119593. */
  119594. updateTextures(): void;
  119595. /**
  119596. * Update the uniform values of the procedural texture in the shader.
  119597. */
  119598. updateShaderUniforms(): void;
  119599. /**
  119600. * Define if the texture animates or not.
  119601. */
  119602. animate: boolean;
  119603. }
  119604. }
  119605. declare module BABYLON {
  119606. /** @hidden */
  119607. export var noisePixelShader: {
  119608. name: string;
  119609. shader: string;
  119610. };
  119611. }
  119612. declare module BABYLON {
  119613. /**
  119614. * Class used to generate noise procedural textures
  119615. */
  119616. export class NoiseProceduralTexture extends ProceduralTexture {
  119617. private _time;
  119618. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119619. brightness: number;
  119620. /** Defines the number of octaves to process */
  119621. octaves: number;
  119622. /** Defines the level of persistence (0.8 by default) */
  119623. persistence: number;
  119624. /** Gets or sets animation speed factor (default is 1) */
  119625. animationSpeedFactor: number;
  119626. /**
  119627. * Creates a new NoiseProceduralTexture
  119628. * @param name defines the name fo the texture
  119629. * @param size defines the size of the texture (default is 256)
  119630. * @param scene defines the hosting scene
  119631. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119632. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119633. */
  119634. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119635. private _updateShaderUniforms;
  119636. protected _getDefines(): string;
  119637. /** Generate the current state of the procedural texture */
  119638. render(useCameraPostProcess?: boolean): void;
  119639. /**
  119640. * Serializes this noise procedural texture
  119641. * @returns a serialized noise procedural texture object
  119642. */
  119643. serialize(): any;
  119644. /**
  119645. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119646. * @param parsedTexture defines parsed texture data
  119647. * @param scene defines the current scene
  119648. * @param rootUrl defines the root URL containing noise procedural texture information
  119649. * @returns a parsed NoiseProceduralTexture
  119650. */
  119651. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119652. }
  119653. }
  119654. declare module BABYLON {
  119655. /**
  119656. * Raw cube texture where the raw buffers are passed in
  119657. */
  119658. export class RawCubeTexture extends CubeTexture {
  119659. /**
  119660. * Creates a cube texture where the raw buffers are passed in.
  119661. * @param scene defines the scene the texture is attached to
  119662. * @param data defines the array of data to use to create each face
  119663. * @param size defines the size of the textures
  119664. * @param format defines the format of the data
  119665. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119666. * @param generateMipMaps defines if the engine should generate the mip levels
  119667. * @param invertY defines if data must be stored with Y axis inverted
  119668. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119669. * @param compression defines the compression used (null by default)
  119670. */
  119671. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119672. /**
  119673. * Updates the raw cube texture.
  119674. * @param data defines the data to store
  119675. * @param format defines the data format
  119676. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119677. * @param invertY defines if data must be stored with Y axis inverted
  119678. * @param compression defines the compression used (null by default)
  119679. * @param level defines which level of the texture to update
  119680. */
  119681. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119682. /**
  119683. * Updates a raw cube texture with RGBD encoded data.
  119684. * @param data defines the array of data [mipmap][face] to use to create each face
  119685. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119688. * @returns a promsie that resolves when the operation is complete
  119689. */
  119690. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119691. /**
  119692. * Clones the raw cube texture.
  119693. * @return a new cube texture
  119694. */
  119695. clone(): CubeTexture;
  119696. /** @hidden */
  119697. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119698. }
  119699. }
  119700. declare module BABYLON {
  119701. /**
  119702. * Class used to store 3D textures containing user data
  119703. */
  119704. export class RawTexture3D extends Texture {
  119705. /** Gets or sets the texture format to use */
  119706. format: number;
  119707. private _engine;
  119708. /**
  119709. * Create a new RawTexture3D
  119710. * @param data defines the data of the texture
  119711. * @param width defines the width of the texture
  119712. * @param height defines the height of the texture
  119713. * @param depth defines the depth of the texture
  119714. * @param format defines the texture format to use
  119715. * @param scene defines the hosting scene
  119716. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119717. * @param invertY defines if texture must be stored with Y axis inverted
  119718. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119719. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119720. */
  119721. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119722. /** Gets or sets the texture format to use */
  119723. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119724. /**
  119725. * Update the texture with new data
  119726. * @param data defines the data to store in the texture
  119727. */
  119728. update(data: ArrayBufferView): void;
  119729. }
  119730. }
  119731. declare module BABYLON {
  119732. /**
  119733. * Creates a refraction texture used by refraction channel of the standard material.
  119734. * It is like a mirror but to see through a material.
  119735. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119736. */
  119737. export class RefractionTexture extends RenderTargetTexture {
  119738. /**
  119739. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119740. * 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.
  119741. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119742. */
  119743. refractionPlane: Plane;
  119744. /**
  119745. * Define how deep under the surface we should see.
  119746. */
  119747. depth: number;
  119748. /**
  119749. * Creates a refraction texture used by refraction channel of the standard material.
  119750. * It is like a mirror but to see through a material.
  119751. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119752. * @param name Define the texture name
  119753. * @param size Define the size of the underlying texture
  119754. * @param scene Define the scene the refraction belongs to
  119755. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119756. */
  119757. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119758. /**
  119759. * Clone the refraction texture.
  119760. * @returns the cloned texture
  119761. */
  119762. clone(): RefractionTexture;
  119763. /**
  119764. * Serialize the texture to a JSON representation you could use in Parse later on
  119765. * @returns the serialized JSON representation
  119766. */
  119767. serialize(): any;
  119768. }
  119769. }
  119770. declare module BABYLON {
  119771. /**
  119772. * Defines the options related to the creation of an HtmlElementTexture
  119773. */
  119774. export interface IHtmlElementTextureOptions {
  119775. /**
  119776. * Defines wether mip maps should be created or not.
  119777. */
  119778. generateMipMaps?: boolean;
  119779. /**
  119780. * Defines the sampling mode of the texture.
  119781. */
  119782. samplingMode?: number;
  119783. /**
  119784. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119785. */
  119786. engine: Nullable<ThinEngine>;
  119787. /**
  119788. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119789. */
  119790. scene: Nullable<Scene>;
  119791. }
  119792. /**
  119793. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119794. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119795. * is automatically managed.
  119796. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119797. * in your application.
  119798. *
  119799. * As the update is not automatic, you need to call them manually.
  119800. */
  119801. export class HtmlElementTexture extends BaseTexture {
  119802. /**
  119803. * The texture URL.
  119804. */
  119805. element: HTMLVideoElement | HTMLCanvasElement;
  119806. private static readonly DefaultOptions;
  119807. private _textureMatrix;
  119808. private _engine;
  119809. private _isVideo;
  119810. private _generateMipMaps;
  119811. private _samplingMode;
  119812. /**
  119813. * Instantiates a HtmlElementTexture from the following parameters.
  119814. *
  119815. * @param name Defines the name of the texture
  119816. * @param element Defines the video or canvas the texture is filled with
  119817. * @param options Defines the other none mandatory texture creation options
  119818. */
  119819. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119820. private _createInternalTexture;
  119821. /**
  119822. * Returns the texture matrix used in most of the material.
  119823. */
  119824. getTextureMatrix(): Matrix;
  119825. /**
  119826. * Updates the content of the texture.
  119827. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119828. */
  119829. update(invertY?: Nullable<boolean>): void;
  119830. }
  119831. }
  119832. declare module BABYLON {
  119833. /**
  119834. * Enum used to define the target of a block
  119835. */
  119836. export enum NodeMaterialBlockTargets {
  119837. /** Vertex shader */
  119838. Vertex = 1,
  119839. /** Fragment shader */
  119840. Fragment = 2,
  119841. /** Neutral */
  119842. Neutral = 4,
  119843. /** Vertex and Fragment */
  119844. VertexAndFragment = 3
  119845. }
  119846. }
  119847. declare module BABYLON {
  119848. /**
  119849. * Defines the kind of connection point for node based material
  119850. */
  119851. export enum NodeMaterialBlockConnectionPointTypes {
  119852. /** Float */
  119853. Float = 1,
  119854. /** Int */
  119855. Int = 2,
  119856. /** Vector2 */
  119857. Vector2 = 4,
  119858. /** Vector3 */
  119859. Vector3 = 8,
  119860. /** Vector4 */
  119861. Vector4 = 16,
  119862. /** Color3 */
  119863. Color3 = 32,
  119864. /** Color4 */
  119865. Color4 = 64,
  119866. /** Matrix */
  119867. Matrix = 128,
  119868. /** Detect type based on connection */
  119869. AutoDetect = 1024,
  119870. /** Output type that will be defined by input type */
  119871. BasedOnInput = 2048
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. /**
  119876. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119877. */
  119878. export enum NodeMaterialBlockConnectionPointMode {
  119879. /** Value is an uniform */
  119880. Uniform = 0,
  119881. /** Value is a mesh attribute */
  119882. Attribute = 1,
  119883. /** Value is a varying between vertex and fragment shaders */
  119884. Varying = 2,
  119885. /** Mode is undefined */
  119886. Undefined = 3
  119887. }
  119888. }
  119889. declare module BABYLON {
  119890. /**
  119891. * Enum used to define system values e.g. values automatically provided by the system
  119892. */
  119893. export enum NodeMaterialSystemValues {
  119894. /** World */
  119895. World = 1,
  119896. /** View */
  119897. View = 2,
  119898. /** Projection */
  119899. Projection = 3,
  119900. /** ViewProjection */
  119901. ViewProjection = 4,
  119902. /** WorldView */
  119903. WorldView = 5,
  119904. /** WorldViewProjection */
  119905. WorldViewProjection = 6,
  119906. /** CameraPosition */
  119907. CameraPosition = 7,
  119908. /** Fog Color */
  119909. FogColor = 8,
  119910. /** Delta time */
  119911. DeltaTime = 9
  119912. }
  119913. }
  119914. declare module BABYLON {
  119915. /**
  119916. * Root class for all node material optimizers
  119917. */
  119918. export class NodeMaterialOptimizer {
  119919. /**
  119920. * Function used to optimize a NodeMaterial graph
  119921. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119922. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119923. */
  119924. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119925. }
  119926. }
  119927. declare module BABYLON {
  119928. /**
  119929. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119930. */
  119931. export class TransformBlock extends NodeMaterialBlock {
  119932. /**
  119933. * Defines the value to use to complement W value to transform it to a Vector4
  119934. */
  119935. complementW: number;
  119936. /**
  119937. * Defines the value to use to complement z value to transform it to a Vector4
  119938. */
  119939. complementZ: number;
  119940. /**
  119941. * Creates a new TransformBlock
  119942. * @param name defines the block name
  119943. */
  119944. constructor(name: string);
  119945. /**
  119946. * Gets the current class name
  119947. * @returns the class name
  119948. */
  119949. getClassName(): string;
  119950. /**
  119951. * Gets the vector input
  119952. */
  119953. readonly vector: NodeMaterialConnectionPoint;
  119954. /**
  119955. * Gets the output component
  119956. */
  119957. readonly output: NodeMaterialConnectionPoint;
  119958. /**
  119959. * Gets the matrix transform input
  119960. */
  119961. readonly transform: NodeMaterialConnectionPoint;
  119962. protected _buildBlock(state: NodeMaterialBuildState): this;
  119963. serialize(): any;
  119964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119965. protected _dumpPropertiesCode(): string;
  119966. }
  119967. }
  119968. declare module BABYLON {
  119969. /**
  119970. * Block used to output the vertex position
  119971. */
  119972. export class VertexOutputBlock extends NodeMaterialBlock {
  119973. /**
  119974. * Creates a new VertexOutputBlock
  119975. * @param name defines the block name
  119976. */
  119977. constructor(name: string);
  119978. /**
  119979. * Gets the current class name
  119980. * @returns the class name
  119981. */
  119982. getClassName(): string;
  119983. /**
  119984. * Gets the vector input component
  119985. */
  119986. readonly vector: NodeMaterialConnectionPoint;
  119987. protected _buildBlock(state: NodeMaterialBuildState): this;
  119988. }
  119989. }
  119990. declare module BABYLON {
  119991. /**
  119992. * Block used to output the final color
  119993. */
  119994. export class FragmentOutputBlock extends NodeMaterialBlock {
  119995. /**
  119996. * Create a new FragmentOutputBlock
  119997. * @param name defines the block name
  119998. */
  119999. constructor(name: string);
  120000. /**
  120001. * Gets the current class name
  120002. * @returns the class name
  120003. */
  120004. getClassName(): string;
  120005. /**
  120006. * Gets the rgba input component
  120007. */
  120008. readonly rgba: NodeMaterialConnectionPoint;
  120009. /**
  120010. * Gets the rgb input component
  120011. */
  120012. readonly rgb: NodeMaterialConnectionPoint;
  120013. /**
  120014. * Gets the a input component
  120015. */
  120016. readonly a: NodeMaterialConnectionPoint;
  120017. protected _buildBlock(state: NodeMaterialBuildState): this;
  120018. }
  120019. }
  120020. declare module BABYLON {
  120021. /**
  120022. * Block used to read a reflection texture from a sampler
  120023. */
  120024. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120025. private _define3DName;
  120026. private _defineCubicName;
  120027. private _defineExplicitName;
  120028. private _defineProjectionName;
  120029. private _defineLocalCubicName;
  120030. private _defineSphericalName;
  120031. private _definePlanarName;
  120032. private _defineEquirectangularName;
  120033. private _defineMirroredEquirectangularFixedName;
  120034. private _defineEquirectangularFixedName;
  120035. private _defineSkyboxName;
  120036. private _cubeSamplerName;
  120037. private _2DSamplerName;
  120038. private _positionUVWName;
  120039. private _directionWName;
  120040. private _reflectionCoordsName;
  120041. private _reflection2DCoordsName;
  120042. private _reflectionColorName;
  120043. private _reflectionMatrixName;
  120044. /**
  120045. * Gets or sets the texture associated with the node
  120046. */
  120047. texture: Nullable<BaseTexture>;
  120048. /**
  120049. * Create a new TextureBlock
  120050. * @param name defines the block name
  120051. */
  120052. constructor(name: string);
  120053. /**
  120054. * Gets the current class name
  120055. * @returns the class name
  120056. */
  120057. getClassName(): string;
  120058. /**
  120059. * Gets the world position input component
  120060. */
  120061. readonly position: NodeMaterialConnectionPoint;
  120062. /**
  120063. * Gets the world position input component
  120064. */
  120065. readonly worldPosition: NodeMaterialConnectionPoint;
  120066. /**
  120067. * Gets the world normal input component
  120068. */
  120069. readonly worldNormal: NodeMaterialConnectionPoint;
  120070. /**
  120071. * Gets the world input component
  120072. */
  120073. readonly world: NodeMaterialConnectionPoint;
  120074. /**
  120075. * Gets the camera (or eye) position component
  120076. */
  120077. readonly cameraPosition: NodeMaterialConnectionPoint;
  120078. /**
  120079. * Gets the view input component
  120080. */
  120081. readonly view: NodeMaterialConnectionPoint;
  120082. /**
  120083. * Gets the rgb output component
  120084. */
  120085. readonly rgb: NodeMaterialConnectionPoint;
  120086. /**
  120087. * Gets the r output component
  120088. */
  120089. readonly r: NodeMaterialConnectionPoint;
  120090. /**
  120091. * Gets the g output component
  120092. */
  120093. readonly g: NodeMaterialConnectionPoint;
  120094. /**
  120095. * Gets the b output component
  120096. */
  120097. readonly b: NodeMaterialConnectionPoint;
  120098. autoConfigure(material: NodeMaterial): void;
  120099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120100. isReady(): boolean;
  120101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120102. private _injectVertexCode;
  120103. private _writeOutput;
  120104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120105. serialize(): any;
  120106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120107. }
  120108. }
  120109. declare module BABYLON {
  120110. /**
  120111. * Interface used to configure the node material editor
  120112. */
  120113. export interface INodeMaterialEditorOptions {
  120114. /** Define the URl to load node editor script */
  120115. editorURL?: string;
  120116. }
  120117. /** @hidden */
  120118. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120119. /** BONES */
  120120. NUM_BONE_INFLUENCERS: number;
  120121. BonesPerMesh: number;
  120122. BONETEXTURE: boolean;
  120123. /** MORPH TARGETS */
  120124. MORPHTARGETS: boolean;
  120125. MORPHTARGETS_NORMAL: boolean;
  120126. MORPHTARGETS_TANGENT: boolean;
  120127. MORPHTARGETS_UV: boolean;
  120128. NUM_MORPH_INFLUENCERS: number;
  120129. /** IMAGE PROCESSING */
  120130. IMAGEPROCESSING: boolean;
  120131. VIGNETTE: boolean;
  120132. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120133. VIGNETTEBLENDMODEOPAQUE: boolean;
  120134. TONEMAPPING: boolean;
  120135. TONEMAPPING_ACES: boolean;
  120136. CONTRAST: boolean;
  120137. EXPOSURE: boolean;
  120138. COLORCURVES: boolean;
  120139. COLORGRADING: boolean;
  120140. COLORGRADING3D: boolean;
  120141. SAMPLER3DGREENDEPTH: boolean;
  120142. SAMPLER3DBGRMAP: boolean;
  120143. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120144. /** MISC. */
  120145. BUMPDIRECTUV: number;
  120146. constructor();
  120147. setValue(name: string, value: boolean): void;
  120148. }
  120149. /**
  120150. * Class used to configure NodeMaterial
  120151. */
  120152. export interface INodeMaterialOptions {
  120153. /**
  120154. * Defines if blocks should emit comments
  120155. */
  120156. emitComments: boolean;
  120157. }
  120158. /**
  120159. * Class used to create a node based material built by assembling shader blocks
  120160. */
  120161. export class NodeMaterial extends PushMaterial {
  120162. private static _BuildIdGenerator;
  120163. private _options;
  120164. private _vertexCompilationState;
  120165. private _fragmentCompilationState;
  120166. private _sharedData;
  120167. private _buildId;
  120168. private _buildWasSuccessful;
  120169. private _cachedWorldViewMatrix;
  120170. private _cachedWorldViewProjectionMatrix;
  120171. private _optimizers;
  120172. private _animationFrame;
  120173. /** Define the URl to load node editor script */
  120174. static EditorURL: string;
  120175. private BJSNODEMATERIALEDITOR;
  120176. /** Get the inspector from bundle or global */
  120177. private _getGlobalNodeMaterialEditor;
  120178. /**
  120179. * 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)
  120180. */
  120181. ignoreAlpha: boolean;
  120182. /**
  120183. * Defines the maximum number of lights that can be used in the material
  120184. */
  120185. maxSimultaneousLights: number;
  120186. /**
  120187. * Observable raised when the material is built
  120188. */
  120189. onBuildObservable: Observable<NodeMaterial>;
  120190. /**
  120191. * Gets or sets the root nodes of the material vertex shader
  120192. */
  120193. _vertexOutputNodes: NodeMaterialBlock[];
  120194. /**
  120195. * Gets or sets the root nodes of the material fragment (pixel) shader
  120196. */
  120197. _fragmentOutputNodes: NodeMaterialBlock[];
  120198. /** Gets or sets options to control the node material overall behavior */
  120199. options: INodeMaterialOptions;
  120200. /**
  120201. * Default configuration related to image processing available in the standard Material.
  120202. */
  120203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120204. /**
  120205. * Gets the image processing configuration used either in this material.
  120206. */
  120207. /**
  120208. * Sets the Default image processing configuration used either in the this material.
  120209. *
  120210. * If sets to null, the scene one is in use.
  120211. */
  120212. imageProcessingConfiguration: ImageProcessingConfiguration;
  120213. /**
  120214. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120215. */
  120216. attachedBlocks: NodeMaterialBlock[];
  120217. /**
  120218. * Create a new node based material
  120219. * @param name defines the material name
  120220. * @param scene defines the hosting scene
  120221. * @param options defines creation option
  120222. */
  120223. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120224. /**
  120225. * Gets the current class name of the material e.g. "NodeMaterial"
  120226. * @returns the class name
  120227. */
  120228. getClassName(): string;
  120229. /**
  120230. * Keep track of the image processing observer to allow dispose and replace.
  120231. */
  120232. private _imageProcessingObserver;
  120233. /**
  120234. * Attaches a new image processing configuration to the Standard Material.
  120235. * @param configuration
  120236. */
  120237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120238. /**
  120239. * Get a block by its name
  120240. * @param name defines the name of the block to retrieve
  120241. * @returns the required block or null if not found
  120242. */
  120243. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120244. /**
  120245. * Get a block by its name
  120246. * @param predicate defines the predicate used to find the good candidate
  120247. * @returns the required block or null if not found
  120248. */
  120249. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120250. /**
  120251. * Get an input block by its name
  120252. * @param predicate defines the predicate used to find the good candidate
  120253. * @returns the required input block or null if not found
  120254. */
  120255. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120256. /**
  120257. * Gets the list of input blocks attached to this material
  120258. * @returns an array of InputBlocks
  120259. */
  120260. getInputBlocks(): InputBlock[];
  120261. /**
  120262. * Adds a new optimizer to the list of optimizers
  120263. * @param optimizer defines the optimizers to add
  120264. * @returns the current material
  120265. */
  120266. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120267. /**
  120268. * Remove an optimizer from the list of optimizers
  120269. * @param optimizer defines the optimizers to remove
  120270. * @returns the current material
  120271. */
  120272. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120273. /**
  120274. * Add a new block to the list of output nodes
  120275. * @param node defines the node to add
  120276. * @returns the current material
  120277. */
  120278. addOutputNode(node: NodeMaterialBlock): this;
  120279. /**
  120280. * Remove a block from the list of root nodes
  120281. * @param node defines the node to remove
  120282. * @returns the current material
  120283. */
  120284. removeOutputNode(node: NodeMaterialBlock): this;
  120285. private _addVertexOutputNode;
  120286. private _removeVertexOutputNode;
  120287. private _addFragmentOutputNode;
  120288. private _removeFragmentOutputNode;
  120289. /**
  120290. * Specifies if the material will require alpha blending
  120291. * @returns a boolean specifying if alpha blending is needed
  120292. */
  120293. needAlphaBlending(): boolean;
  120294. /**
  120295. * Specifies if this material should be rendered in alpha test mode
  120296. * @returns a boolean specifying if an alpha test is needed.
  120297. */
  120298. needAlphaTesting(): boolean;
  120299. private _initializeBlock;
  120300. private _resetDualBlocks;
  120301. /**
  120302. * Build the material and generates the inner effect
  120303. * @param verbose defines if the build should log activity
  120304. */
  120305. build(verbose?: boolean): void;
  120306. /**
  120307. * Runs an otpimization phase to try to improve the shader code
  120308. */
  120309. optimize(): void;
  120310. private _prepareDefinesForAttributes;
  120311. /**
  120312. * Get if the submesh is ready to be used and all its information available.
  120313. * Child classes can use it to update shaders
  120314. * @param mesh defines the mesh to check
  120315. * @param subMesh defines which submesh to check
  120316. * @param useInstances specifies that instances should be used
  120317. * @returns a boolean indicating that the submesh is ready or not
  120318. */
  120319. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120320. /**
  120321. * Get a string representing the shaders built by the current node graph
  120322. */
  120323. readonly compiledShaders: string;
  120324. /**
  120325. * Binds the world matrix to the material
  120326. * @param world defines the world transformation matrix
  120327. */
  120328. bindOnlyWorldMatrix(world: Matrix): void;
  120329. /**
  120330. * Binds the submesh to this material by preparing the effect and shader to draw
  120331. * @param world defines the world transformation matrix
  120332. * @param mesh defines the mesh containing the submesh
  120333. * @param subMesh defines the submesh to bind the material to
  120334. */
  120335. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120336. /**
  120337. * Gets the active textures from the material
  120338. * @returns an array of textures
  120339. */
  120340. getActiveTextures(): BaseTexture[];
  120341. /**
  120342. * Gets the list of texture blocks
  120343. * @returns an array of texture blocks
  120344. */
  120345. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  120346. /**
  120347. * Specifies if the material uses a texture
  120348. * @param texture defines the texture to check against the material
  120349. * @returns a boolean specifying if the material uses the texture
  120350. */
  120351. hasTexture(texture: BaseTexture): boolean;
  120352. /**
  120353. * Disposes the material
  120354. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  120355. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  120356. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  120357. */
  120358. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  120359. /** Creates the node editor window. */
  120360. private _createNodeEditor;
  120361. /**
  120362. * Launch the node material editor
  120363. * @param config Define the configuration of the editor
  120364. * @return a promise fulfilled when the node editor is visible
  120365. */
  120366. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  120367. /**
  120368. * Clear the current material
  120369. */
  120370. clear(): void;
  120371. /**
  120372. * Clear the current material and set it to a default state
  120373. */
  120374. setToDefault(): void;
  120375. /**
  120376. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  120377. * @param url defines the url to load from
  120378. * @returns a promise that will fullfil when the material is fully loaded
  120379. */
  120380. loadAsync(url: string): Promise<unknown>;
  120381. private _gatherBlocks;
  120382. /**
  120383. * Generate a string containing the code declaration required to create an equivalent of this material
  120384. * @returns a string
  120385. */
  120386. generateCode(): string;
  120387. /**
  120388. * Serializes this material in a JSON representation
  120389. * @returns the serialized material object
  120390. */
  120391. serialize(): any;
  120392. private _restoreConnections;
  120393. /**
  120394. * Clear the current graph and load a new one from a serialization object
  120395. * @param source defines the JSON representation of the material
  120396. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120397. */
  120398. loadFromSerialization(source: any, rootUrl?: string): void;
  120399. /**
  120400. * Creates a node material from parsed material data
  120401. * @param source defines the JSON representation of the material
  120402. * @param scene defines the hosting scene
  120403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120404. * @returns a new node material
  120405. */
  120406. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  120407. /**
  120408. * Creates a new node material set to default basic configuration
  120409. * @param name defines the name of the material
  120410. * @param scene defines the hosting scene
  120411. * @returns a new NodeMaterial
  120412. */
  120413. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  120414. }
  120415. }
  120416. declare module BABYLON {
  120417. /**
  120418. * Block used to read a texture from a sampler
  120419. */
  120420. export class TextureBlock extends NodeMaterialBlock {
  120421. private _defineName;
  120422. private _linearDefineName;
  120423. private _samplerName;
  120424. private _transformedUVName;
  120425. private _textureTransformName;
  120426. private _textureInfoName;
  120427. private _mainUVName;
  120428. private _mainUVDefineName;
  120429. /**
  120430. * Gets or sets the texture associated with the node
  120431. */
  120432. texture: Nullable<Texture>;
  120433. /**
  120434. * Create a new TextureBlock
  120435. * @param name defines the block name
  120436. */
  120437. constructor(name: string);
  120438. /**
  120439. * Gets the current class name
  120440. * @returns the class name
  120441. */
  120442. getClassName(): string;
  120443. /**
  120444. * Gets the uv input component
  120445. */
  120446. readonly uv: NodeMaterialConnectionPoint;
  120447. /**
  120448. * Gets the rgba output component
  120449. */
  120450. readonly rgba: NodeMaterialConnectionPoint;
  120451. /**
  120452. * Gets the rgb output component
  120453. */
  120454. readonly rgb: NodeMaterialConnectionPoint;
  120455. /**
  120456. * Gets the r output component
  120457. */
  120458. readonly r: NodeMaterialConnectionPoint;
  120459. /**
  120460. * Gets the g output component
  120461. */
  120462. readonly g: NodeMaterialConnectionPoint;
  120463. /**
  120464. * Gets the b output component
  120465. */
  120466. readonly b: NodeMaterialConnectionPoint;
  120467. /**
  120468. * Gets the a output component
  120469. */
  120470. readonly a: NodeMaterialConnectionPoint;
  120471. readonly target: NodeMaterialBlockTargets;
  120472. autoConfigure(material: NodeMaterial): void;
  120473. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120475. isReady(): boolean;
  120476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120477. private readonly _isMixed;
  120478. private _injectVertexCode;
  120479. private _writeOutput;
  120480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120481. protected _dumpPropertiesCode(): string;
  120482. serialize(): any;
  120483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120484. }
  120485. }
  120486. declare module BABYLON {
  120487. /**
  120488. * Class used to store shared data between 2 NodeMaterialBuildState
  120489. */
  120490. export class NodeMaterialBuildStateSharedData {
  120491. /**
  120492. * Gets the list of emitted varyings
  120493. */
  120494. temps: string[];
  120495. /**
  120496. * Gets the list of emitted varyings
  120497. */
  120498. varyings: string[];
  120499. /**
  120500. * Gets the varying declaration string
  120501. */
  120502. varyingDeclaration: string;
  120503. /**
  120504. * Input blocks
  120505. */
  120506. inputBlocks: InputBlock[];
  120507. /**
  120508. * Input blocks
  120509. */
  120510. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120511. /**
  120512. * Bindable blocks (Blocks that need to set data to the effect)
  120513. */
  120514. bindableBlocks: NodeMaterialBlock[];
  120515. /**
  120516. * List of blocks that can provide a compilation fallback
  120517. */
  120518. blocksWithFallbacks: NodeMaterialBlock[];
  120519. /**
  120520. * List of blocks that can provide a define update
  120521. */
  120522. blocksWithDefines: NodeMaterialBlock[];
  120523. /**
  120524. * List of blocks that can provide a repeatable content
  120525. */
  120526. repeatableContentBlocks: NodeMaterialBlock[];
  120527. /**
  120528. * List of blocks that can provide a dynamic list of uniforms
  120529. */
  120530. dynamicUniformBlocks: NodeMaterialBlock[];
  120531. /**
  120532. * List of blocks that can block the isReady function for the material
  120533. */
  120534. blockingBlocks: NodeMaterialBlock[];
  120535. /**
  120536. * Gets the list of animated inputs
  120537. */
  120538. animatedInputs: InputBlock[];
  120539. /**
  120540. * Build Id used to avoid multiple recompilations
  120541. */
  120542. buildId: number;
  120543. /** List of emitted variables */
  120544. variableNames: {
  120545. [key: string]: number;
  120546. };
  120547. /** List of emitted defines */
  120548. defineNames: {
  120549. [key: string]: number;
  120550. };
  120551. /** Should emit comments? */
  120552. emitComments: boolean;
  120553. /** Emit build activity */
  120554. verbose: boolean;
  120555. /** Gets or sets the hosting scene */
  120556. scene: Scene;
  120557. /**
  120558. * Gets the compilation hints emitted at compilation time
  120559. */
  120560. hints: {
  120561. needWorldViewMatrix: boolean;
  120562. needWorldViewProjectionMatrix: boolean;
  120563. needAlphaBlending: boolean;
  120564. needAlphaTesting: boolean;
  120565. };
  120566. /**
  120567. * List of compilation checks
  120568. */
  120569. checks: {
  120570. emitVertex: boolean;
  120571. emitFragment: boolean;
  120572. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120573. };
  120574. /** Creates a new shared data */
  120575. constructor();
  120576. /**
  120577. * Emits console errors and exceptions if there is a failing check
  120578. */
  120579. emitErrors(): void;
  120580. }
  120581. }
  120582. declare module BABYLON {
  120583. /**
  120584. * Class used to store node based material build state
  120585. */
  120586. export class NodeMaterialBuildState {
  120587. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120588. supportUniformBuffers: boolean;
  120589. /**
  120590. * Gets the list of emitted attributes
  120591. */
  120592. attributes: string[];
  120593. /**
  120594. * Gets the list of emitted uniforms
  120595. */
  120596. uniforms: string[];
  120597. /**
  120598. * Gets the list of emitted constants
  120599. */
  120600. constants: string[];
  120601. /**
  120602. * Gets the list of emitted samplers
  120603. */
  120604. samplers: string[];
  120605. /**
  120606. * Gets the list of emitted functions
  120607. */
  120608. functions: {
  120609. [key: string]: string;
  120610. };
  120611. /**
  120612. * Gets the list of emitted extensions
  120613. */
  120614. extensions: {
  120615. [key: string]: string;
  120616. };
  120617. /**
  120618. * Gets the target of the compilation state
  120619. */
  120620. target: NodeMaterialBlockTargets;
  120621. /**
  120622. * Gets the list of emitted counters
  120623. */
  120624. counters: {
  120625. [key: string]: number;
  120626. };
  120627. /**
  120628. * Shared data between multiple NodeMaterialBuildState instances
  120629. */
  120630. sharedData: NodeMaterialBuildStateSharedData;
  120631. /** @hidden */
  120632. _vertexState: NodeMaterialBuildState;
  120633. /** @hidden */
  120634. _attributeDeclaration: string;
  120635. /** @hidden */
  120636. _uniformDeclaration: string;
  120637. /** @hidden */
  120638. _constantDeclaration: string;
  120639. /** @hidden */
  120640. _samplerDeclaration: string;
  120641. /** @hidden */
  120642. _varyingTransfer: string;
  120643. private _repeatableContentAnchorIndex;
  120644. /** @hidden */
  120645. _builtCompilationString: string;
  120646. /**
  120647. * Gets the emitted compilation strings
  120648. */
  120649. compilationString: string;
  120650. /**
  120651. * Finalize the compilation strings
  120652. * @param state defines the current compilation state
  120653. */
  120654. finalize(state: NodeMaterialBuildState): void;
  120655. /** @hidden */
  120656. readonly _repeatableContentAnchor: string;
  120657. /** @hidden */
  120658. _getFreeVariableName(prefix: string): string;
  120659. /** @hidden */
  120660. _getFreeDefineName(prefix: string): string;
  120661. /** @hidden */
  120662. _excludeVariableName(name: string): void;
  120663. /** @hidden */
  120664. _emit2DSampler(name: string): void;
  120665. /** @hidden */
  120666. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120667. /** @hidden */
  120668. _emitExtension(name: string, extension: string): void;
  120669. /** @hidden */
  120670. _emitFunction(name: string, code: string, comments: string): void;
  120671. /** @hidden */
  120672. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120673. replaceStrings?: {
  120674. search: RegExp;
  120675. replace: string;
  120676. }[];
  120677. repeatKey?: string;
  120678. }): string;
  120679. /** @hidden */
  120680. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120681. repeatKey?: string;
  120682. removeAttributes?: boolean;
  120683. removeUniforms?: boolean;
  120684. removeVaryings?: boolean;
  120685. removeIfDef?: boolean;
  120686. replaceStrings?: {
  120687. search: RegExp;
  120688. replace: string;
  120689. }[];
  120690. }, storeKey?: string): void;
  120691. /** @hidden */
  120692. _registerTempVariable(name: string): boolean;
  120693. /** @hidden */
  120694. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120695. /** @hidden */
  120696. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120697. /** @hidden */
  120698. _emitFloat(value: number): string;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /**
  120703. * Defines a block that can be used inside a node based material
  120704. */
  120705. export class NodeMaterialBlock {
  120706. private _buildId;
  120707. private _buildTarget;
  120708. private _target;
  120709. private _isFinalMerger;
  120710. private _isInput;
  120711. /** @hidden */
  120712. _codeVariableName: string;
  120713. /** @hidden */
  120714. _inputs: NodeMaterialConnectionPoint[];
  120715. /** @hidden */
  120716. _outputs: NodeMaterialConnectionPoint[];
  120717. /** @hidden */
  120718. _preparationId: number;
  120719. /**
  120720. * Gets or sets the name of the block
  120721. */
  120722. name: string;
  120723. /**
  120724. * Gets or sets the unique id of the node
  120725. */
  120726. uniqueId: number;
  120727. /**
  120728. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120729. */
  120730. readonly isFinalMerger: boolean;
  120731. /**
  120732. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120733. */
  120734. readonly isInput: boolean;
  120735. /**
  120736. * Gets or sets the build Id
  120737. */
  120738. buildId: number;
  120739. /**
  120740. * Gets or sets the target of the block
  120741. */
  120742. target: NodeMaterialBlockTargets;
  120743. /**
  120744. * Gets the list of input points
  120745. */
  120746. readonly inputs: NodeMaterialConnectionPoint[];
  120747. /** Gets the list of output points */
  120748. readonly outputs: NodeMaterialConnectionPoint[];
  120749. /**
  120750. * Find an input by its name
  120751. * @param name defines the name of the input to look for
  120752. * @returns the input or null if not found
  120753. */
  120754. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120755. /**
  120756. * Find an output by its name
  120757. * @param name defines the name of the outputto look for
  120758. * @returns the output or null if not found
  120759. */
  120760. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120761. /**
  120762. * Creates a new NodeMaterialBlock
  120763. * @param name defines the block name
  120764. * @param target defines the target of that block (Vertex by default)
  120765. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120766. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120767. */
  120768. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120769. /**
  120770. * Initialize the block and prepare the context for build
  120771. * @param state defines the state that will be used for the build
  120772. */
  120773. initialize(state: NodeMaterialBuildState): void;
  120774. /**
  120775. * Bind data to effect. Will only be called for blocks with isBindable === true
  120776. * @param effect defines the effect to bind data to
  120777. * @param nodeMaterial defines the hosting NodeMaterial
  120778. * @param mesh defines the mesh that will be rendered
  120779. */
  120780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120781. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120782. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120783. protected _writeFloat(value: number): string;
  120784. /**
  120785. * Gets the current class name e.g. "NodeMaterialBlock"
  120786. * @returns the class name
  120787. */
  120788. getClassName(): string;
  120789. /**
  120790. * Register a new input. Must be called inside a block constructor
  120791. * @param name defines the connection point name
  120792. * @param type defines the connection point type
  120793. * @param isOptional defines a boolean indicating that this input can be omitted
  120794. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120795. * @returns the current block
  120796. */
  120797. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120798. /**
  120799. * Register a new output. Must be called inside a block constructor
  120800. * @param name defines the connection point name
  120801. * @param type defines the connection point type
  120802. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120803. * @returns the current block
  120804. */
  120805. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120806. /**
  120807. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120808. * @param forOutput defines an optional connection point to check compatibility with
  120809. * @returns the first available input or null
  120810. */
  120811. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120812. /**
  120813. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120814. * @param forBlock defines an optional block to check compatibility with
  120815. * @returns the first available input or null
  120816. */
  120817. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120818. /**
  120819. * Gets the sibling of the given output
  120820. * @param current defines the current output
  120821. * @returns the next output in the list or null
  120822. */
  120823. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120824. /**
  120825. * Connect current block with another block
  120826. * @param other defines the block to connect with
  120827. * @param options define the various options to help pick the right connections
  120828. * @returns the current block
  120829. */
  120830. connectTo(other: NodeMaterialBlock, options?: {
  120831. input?: string;
  120832. output?: string;
  120833. outputSwizzle?: string;
  120834. }): this | undefined;
  120835. protected _buildBlock(state: NodeMaterialBuildState): void;
  120836. /**
  120837. * Add uniforms, samplers and uniform buffers at compilation time
  120838. * @param state defines the state to update
  120839. * @param nodeMaterial defines the node material requesting the update
  120840. * @param defines defines the material defines to update
  120841. * @param uniformBuffers defines the list of uniform buffer names
  120842. */
  120843. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  120844. /**
  120845. * Add potential fallbacks if shader compilation fails
  120846. * @param mesh defines the mesh to be rendered
  120847. * @param fallbacks defines the current prioritized list of fallbacks
  120848. */
  120849. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120850. /**
  120851. * Initialize defines for shader compilation
  120852. * @param mesh defines the mesh to be rendered
  120853. * @param nodeMaterial defines the node material requesting the update
  120854. * @param defines defines the material defines to update
  120855. * @param useInstances specifies that instances should be used
  120856. */
  120857. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120858. /**
  120859. * Update defines for shader compilation
  120860. * @param mesh defines the mesh to be rendered
  120861. * @param nodeMaterial defines the node material requesting the update
  120862. * @param defines defines the material defines to update
  120863. * @param useInstances specifies that instances should be used
  120864. */
  120865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120866. /**
  120867. * Lets the block try to connect some inputs automatically
  120868. * @param material defines the hosting NodeMaterial
  120869. */
  120870. autoConfigure(material: NodeMaterial): void;
  120871. /**
  120872. * Function called when a block is declared as repeatable content generator
  120873. * @param vertexShaderState defines the current compilation state for the vertex shader
  120874. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120875. * @param mesh defines the mesh to be rendered
  120876. * @param defines defines the material defines to update
  120877. */
  120878. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120879. /**
  120880. * Checks if the block is ready
  120881. * @param mesh defines the mesh to be rendered
  120882. * @param nodeMaterial defines the node material requesting the update
  120883. * @param defines defines the material defines to update
  120884. * @param useInstances specifies that instances should be used
  120885. * @returns true if the block is ready
  120886. */
  120887. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120888. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120889. private _processBuild;
  120890. /**
  120891. * Compile the current node and generate the shader code
  120892. * @param state defines the current compilation state (uniforms, samplers, current string)
  120893. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120894. * @returns true if already built
  120895. */
  120896. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120897. protected _inputRename(name: string): string;
  120898. protected _outputRename(name: string): string;
  120899. protected _dumpPropertiesCode(): string;
  120900. /** @hidden */
  120901. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120902. /**
  120903. * Clone the current block to a new identical block
  120904. * @param scene defines the hosting scene
  120905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120906. * @returns a copy of the current block
  120907. */
  120908. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120909. /**
  120910. * Serializes this block in a JSON representation
  120911. * @returns the serialized block object
  120912. */
  120913. serialize(): any;
  120914. /** @hidden */
  120915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120916. }
  120917. }
  120918. declare module BABYLON {
  120919. /**
  120920. * Enum defining the type of animations supported by InputBlock
  120921. */
  120922. export enum AnimatedInputBlockTypes {
  120923. /** No animation */
  120924. None = 0,
  120925. /** Time based animation. Will only work for floats */
  120926. Time = 1
  120927. }
  120928. }
  120929. declare module BABYLON {
  120930. /**
  120931. * Block used to expose an input value
  120932. */
  120933. export class InputBlock extends NodeMaterialBlock {
  120934. private _mode;
  120935. private _associatedVariableName;
  120936. private _storedValue;
  120937. private _valueCallback;
  120938. private _type;
  120939. private _animationType;
  120940. /** Gets or set a value used to limit the range of float values */
  120941. min: number;
  120942. /** Gets or set a value used to limit the range of float values */
  120943. max: number;
  120944. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120945. matrixMode: number;
  120946. /** @hidden */
  120947. _systemValue: Nullable<NodeMaterialSystemValues>;
  120948. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120949. visibleInInspector: boolean;
  120950. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120951. isConstant: boolean;
  120952. /**
  120953. * Gets or sets the connection point type (default is float)
  120954. */
  120955. readonly type: NodeMaterialBlockConnectionPointTypes;
  120956. /**
  120957. * Creates a new InputBlock
  120958. * @param name defines the block name
  120959. * @param target defines the target of that block (Vertex by default)
  120960. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120961. */
  120962. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120963. /**
  120964. * Gets the output component
  120965. */
  120966. readonly output: NodeMaterialConnectionPoint;
  120967. /**
  120968. * Set the source of this connection point to a vertex attribute
  120969. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120970. * @returns the current connection point
  120971. */
  120972. setAsAttribute(attributeName?: string): InputBlock;
  120973. /**
  120974. * Set the source of this connection point to a system value
  120975. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120976. * @returns the current connection point
  120977. */
  120978. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120979. /**
  120980. * Gets or sets the value of that point.
  120981. * Please note that this value will be ignored if valueCallback is defined
  120982. */
  120983. value: any;
  120984. /**
  120985. * Gets or sets a callback used to get the value of that point.
  120986. * Please note that setting this value will force the connection point to ignore the value property
  120987. */
  120988. valueCallback: () => any;
  120989. /**
  120990. * Gets or sets the associated variable name in the shader
  120991. */
  120992. associatedVariableName: string;
  120993. /** Gets or sets the type of animation applied to the input */
  120994. animationType: AnimatedInputBlockTypes;
  120995. /**
  120996. * Gets a boolean indicating that this connection point not defined yet
  120997. */
  120998. readonly isUndefined: boolean;
  120999. /**
  121000. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121001. * In this case the connection point name must be the name of the uniform to use.
  121002. * Can only be set on inputs
  121003. */
  121004. isUniform: boolean;
  121005. /**
  121006. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121007. * In this case the connection point name must be the name of the attribute to use
  121008. * Can only be set on inputs
  121009. */
  121010. isAttribute: boolean;
  121011. /**
  121012. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121013. * Can only be set on exit points
  121014. */
  121015. isVarying: boolean;
  121016. /**
  121017. * Gets a boolean indicating that the current connection point is a system value
  121018. */
  121019. readonly isSystemValue: boolean;
  121020. /**
  121021. * Gets or sets the current well known value or null if not defined as a system value
  121022. */
  121023. systemValue: Nullable<NodeMaterialSystemValues>;
  121024. /**
  121025. * Gets the current class name
  121026. * @returns the class name
  121027. */
  121028. getClassName(): string;
  121029. /**
  121030. * Animate the input if animationType !== None
  121031. * @param scene defines the rendering scene
  121032. */
  121033. animate(scene: Scene): void;
  121034. private _emitDefine;
  121035. initialize(state: NodeMaterialBuildState): void;
  121036. /**
  121037. * Set the input block to its default value (based on its type)
  121038. */
  121039. setDefaultValue(): void;
  121040. private _emitConstant;
  121041. private _emit;
  121042. /** @hidden */
  121043. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121044. /** @hidden */
  121045. _transmit(effect: Effect, scene: Scene): void;
  121046. protected _buildBlock(state: NodeMaterialBuildState): void;
  121047. protected _dumpPropertiesCode(): string;
  121048. serialize(): any;
  121049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121050. }
  121051. }
  121052. declare module BABYLON {
  121053. /**
  121054. * Defines a connection point for a block
  121055. */
  121056. export class NodeMaterialConnectionPoint {
  121057. /** @hidden */
  121058. _ownerBlock: NodeMaterialBlock;
  121059. /** @hidden */
  121060. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121061. private _endpoints;
  121062. private _associatedVariableName;
  121063. /** @hidden */
  121064. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121065. /** @hidden */
  121066. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121067. private _type;
  121068. /** @hidden */
  121069. _enforceAssociatedVariableName: boolean;
  121070. /**
  121071. * Gets or sets the additional types supported by this connection point
  121072. */
  121073. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121074. /**
  121075. * Gets or sets the additional types excluded by this connection point
  121076. */
  121077. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121078. /**
  121079. * Gets or sets the associated variable name in the shader
  121080. */
  121081. associatedVariableName: string;
  121082. /**
  121083. * Gets or sets the connection point type (default is float)
  121084. */
  121085. type: NodeMaterialBlockConnectionPointTypes;
  121086. /**
  121087. * Gets or sets the connection point name
  121088. */
  121089. name: string;
  121090. /**
  121091. * Gets or sets a boolean indicating that this connection point can be omitted
  121092. */
  121093. isOptional: boolean;
  121094. /**
  121095. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121096. */
  121097. define: string;
  121098. /** Gets or sets the target of that connection point */
  121099. target: NodeMaterialBlockTargets;
  121100. /**
  121101. * Gets a boolean indicating that the current point is connected
  121102. */
  121103. readonly isConnected: boolean;
  121104. /**
  121105. * Gets a boolean indicating that the current point is connected to an input block
  121106. */
  121107. readonly isConnectedToInputBlock: boolean;
  121108. /**
  121109. * Gets a the connected input block (if any)
  121110. */
  121111. readonly connectInputBlock: Nullable<InputBlock>;
  121112. /** Get the other side of the connection (if any) */
  121113. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121114. /** Get the block that owns this connection point */
  121115. readonly ownerBlock: NodeMaterialBlock;
  121116. /** Get the block connected on the other side of this connection (if any) */
  121117. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121118. /** Get the block connected on the endpoints of this connection (if any) */
  121119. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121120. /** Gets the list of connected endpoints */
  121121. readonly endpoints: NodeMaterialConnectionPoint[];
  121122. /** Gets a boolean indicating if that output point is connected to at least one input */
  121123. readonly hasEndpoints: boolean;
  121124. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121125. readonly isConnectedInVertexShader: boolean;
  121126. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121127. readonly isConnectedInFragmentShader: boolean;
  121128. /**
  121129. * Creates a new connection point
  121130. * @param name defines the connection point name
  121131. * @param ownerBlock defines the block hosting this connection point
  121132. */
  121133. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121134. /**
  121135. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121136. * @returns the class name
  121137. */
  121138. getClassName(): string;
  121139. /**
  121140. * Gets an boolean indicating if the current point can be connected to another point
  121141. * @param connectionPoint defines the other connection point
  121142. * @returns true if the connection is possible
  121143. */
  121144. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121145. /**
  121146. * Connect this point to another connection point
  121147. * @param connectionPoint defines the other connection point
  121148. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121149. * @returns the current connection point
  121150. */
  121151. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121152. /**
  121153. * Disconnect this point from one of his endpoint
  121154. * @param endpoint defines the other connection point
  121155. * @returns the current connection point
  121156. */
  121157. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121158. /**
  121159. * Serializes this point in a JSON representation
  121160. * @returns the serialized point object
  121161. */
  121162. serialize(): any;
  121163. }
  121164. }
  121165. declare module BABYLON {
  121166. /**
  121167. * Block used to add support for vertex skinning (bones)
  121168. */
  121169. export class BonesBlock extends NodeMaterialBlock {
  121170. /**
  121171. * Creates a new BonesBlock
  121172. * @param name defines the block name
  121173. */
  121174. constructor(name: string);
  121175. /**
  121176. * Initialize the block and prepare the context for build
  121177. * @param state defines the state that will be used for the build
  121178. */
  121179. initialize(state: NodeMaterialBuildState): void;
  121180. /**
  121181. * Gets the current class name
  121182. * @returns the class name
  121183. */
  121184. getClassName(): string;
  121185. /**
  121186. * Gets the matrix indices input component
  121187. */
  121188. readonly matricesIndices: NodeMaterialConnectionPoint;
  121189. /**
  121190. * Gets the matrix weights input component
  121191. */
  121192. readonly matricesWeights: NodeMaterialConnectionPoint;
  121193. /**
  121194. * Gets the extra matrix indices input component
  121195. */
  121196. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121197. /**
  121198. * Gets the extra matrix weights input component
  121199. */
  121200. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121201. /**
  121202. * Gets the world input component
  121203. */
  121204. readonly world: NodeMaterialConnectionPoint;
  121205. /**
  121206. * Gets the output component
  121207. */
  121208. readonly output: NodeMaterialConnectionPoint;
  121209. autoConfigure(material: NodeMaterial): void;
  121210. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121213. protected _buildBlock(state: NodeMaterialBuildState): this;
  121214. }
  121215. }
  121216. declare module BABYLON {
  121217. /**
  121218. * Block used to add support for instances
  121219. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121220. */
  121221. export class InstancesBlock extends NodeMaterialBlock {
  121222. /**
  121223. * Creates a new InstancesBlock
  121224. * @param name defines the block name
  121225. */
  121226. constructor(name: string);
  121227. /**
  121228. * Gets the current class name
  121229. * @returns the class name
  121230. */
  121231. getClassName(): string;
  121232. /**
  121233. * Gets the first world row input component
  121234. */
  121235. readonly world0: NodeMaterialConnectionPoint;
  121236. /**
  121237. * Gets the second world row input component
  121238. */
  121239. readonly world1: NodeMaterialConnectionPoint;
  121240. /**
  121241. * Gets the third world row input component
  121242. */
  121243. readonly world2: NodeMaterialConnectionPoint;
  121244. /**
  121245. * Gets the forth world row input component
  121246. */
  121247. readonly world3: NodeMaterialConnectionPoint;
  121248. /**
  121249. * Gets the world input component
  121250. */
  121251. readonly world: NodeMaterialConnectionPoint;
  121252. /**
  121253. * Gets the output component
  121254. */
  121255. readonly output: NodeMaterialConnectionPoint;
  121256. autoConfigure(material: NodeMaterial): void;
  121257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121258. protected _buildBlock(state: NodeMaterialBuildState): this;
  121259. }
  121260. }
  121261. declare module BABYLON {
  121262. /**
  121263. * Block used to add morph targets support to vertex shader
  121264. */
  121265. export class MorphTargetsBlock extends NodeMaterialBlock {
  121266. private _repeatableContentAnchor;
  121267. private _repeatebleContentGenerated;
  121268. /**
  121269. * Create a new MorphTargetsBlock
  121270. * @param name defines the block name
  121271. */
  121272. constructor(name: string);
  121273. /**
  121274. * Gets the current class name
  121275. * @returns the class name
  121276. */
  121277. getClassName(): string;
  121278. /**
  121279. * Gets the position input component
  121280. */
  121281. readonly position: NodeMaterialConnectionPoint;
  121282. /**
  121283. * Gets the normal input component
  121284. */
  121285. readonly normal: NodeMaterialConnectionPoint;
  121286. /**
  121287. * Gets the tangent input component
  121288. */
  121289. readonly tangent: NodeMaterialConnectionPoint;
  121290. /**
  121291. * Gets the tangent input component
  121292. */
  121293. readonly uv: NodeMaterialConnectionPoint;
  121294. /**
  121295. * Gets the position output component
  121296. */
  121297. readonly positionOutput: NodeMaterialConnectionPoint;
  121298. /**
  121299. * Gets the normal output component
  121300. */
  121301. readonly normalOutput: NodeMaterialConnectionPoint;
  121302. /**
  121303. * Gets the tangent output component
  121304. */
  121305. readonly tangentOutput: NodeMaterialConnectionPoint;
  121306. /**
  121307. * Gets the tangent output component
  121308. */
  121309. readonly uvOutput: NodeMaterialConnectionPoint;
  121310. initialize(state: NodeMaterialBuildState): void;
  121311. autoConfigure(material: NodeMaterial): void;
  121312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121314. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121315. protected _buildBlock(state: NodeMaterialBuildState): this;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. /**
  121320. * Block used to get data information from a light
  121321. */
  121322. export class LightInformationBlock extends NodeMaterialBlock {
  121323. private _lightDataUniformName;
  121324. private _lightColorUniformName;
  121325. private _lightTypeDefineName;
  121326. /**
  121327. * Gets or sets the light associated with this block
  121328. */
  121329. light: Nullable<Light>;
  121330. /**
  121331. * Creates a new LightInformationBlock
  121332. * @param name defines the block name
  121333. */
  121334. constructor(name: string);
  121335. /**
  121336. * Gets the current class name
  121337. * @returns the class name
  121338. */
  121339. getClassName(): string;
  121340. /**
  121341. * Gets the world position input component
  121342. */
  121343. readonly worldPosition: NodeMaterialConnectionPoint;
  121344. /**
  121345. * Gets the direction output component
  121346. */
  121347. readonly direction: NodeMaterialConnectionPoint;
  121348. /**
  121349. * Gets the direction output component
  121350. */
  121351. readonly color: NodeMaterialConnectionPoint;
  121352. /**
  121353. * Gets the direction output component
  121354. */
  121355. readonly intensity: NodeMaterialConnectionPoint;
  121356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121358. protected _buildBlock(state: NodeMaterialBuildState): this;
  121359. serialize(): any;
  121360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121361. }
  121362. }
  121363. declare module BABYLON {
  121364. /**
  121365. * Block used to add image processing support to fragment shader
  121366. */
  121367. export class ImageProcessingBlock extends NodeMaterialBlock {
  121368. /**
  121369. * Create a new ImageProcessingBlock
  121370. * @param name defines the block name
  121371. */
  121372. constructor(name: string);
  121373. /**
  121374. * Gets the current class name
  121375. * @returns the class name
  121376. */
  121377. getClassName(): string;
  121378. /**
  121379. * Gets the color input component
  121380. */
  121381. readonly color: NodeMaterialConnectionPoint;
  121382. /**
  121383. * Gets the output component
  121384. */
  121385. readonly output: NodeMaterialConnectionPoint;
  121386. /**
  121387. * Initialize the block and prepare the context for build
  121388. * @param state defines the state that will be used for the build
  121389. */
  121390. initialize(state: NodeMaterialBuildState): void;
  121391. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  121392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121394. protected _buildBlock(state: NodeMaterialBuildState): this;
  121395. }
  121396. }
  121397. declare module BABYLON {
  121398. /**
  121399. * Block used to pertub normals based on a normal map
  121400. */
  121401. export class PerturbNormalBlock extends NodeMaterialBlock {
  121402. private _tangentSpaceParameterName;
  121403. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  121404. invertX: boolean;
  121405. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  121406. invertY: boolean;
  121407. /**
  121408. * Create a new PerturbNormalBlock
  121409. * @param name defines the block name
  121410. */
  121411. constructor(name: string);
  121412. /**
  121413. * Gets the current class name
  121414. * @returns the class name
  121415. */
  121416. getClassName(): string;
  121417. /**
  121418. * Gets the world position input component
  121419. */
  121420. readonly worldPosition: NodeMaterialConnectionPoint;
  121421. /**
  121422. * Gets the world normal input component
  121423. */
  121424. readonly worldNormal: NodeMaterialConnectionPoint;
  121425. /**
  121426. * Gets the uv input component
  121427. */
  121428. readonly uv: NodeMaterialConnectionPoint;
  121429. /**
  121430. * Gets the normal map color input component
  121431. */
  121432. readonly normalMapColor: NodeMaterialConnectionPoint;
  121433. /**
  121434. * Gets the strength input component
  121435. */
  121436. readonly strength: NodeMaterialConnectionPoint;
  121437. /**
  121438. * Gets the output component
  121439. */
  121440. readonly output: NodeMaterialConnectionPoint;
  121441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121443. autoConfigure(material: NodeMaterial): void;
  121444. protected _buildBlock(state: NodeMaterialBuildState): this;
  121445. protected _dumpPropertiesCode(): string;
  121446. serialize(): any;
  121447. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121448. }
  121449. }
  121450. declare module BABYLON {
  121451. /**
  121452. * Block used to discard a pixel if a value is smaller than a cutoff
  121453. */
  121454. export class DiscardBlock extends NodeMaterialBlock {
  121455. /**
  121456. * Create a new DiscardBlock
  121457. * @param name defines the block name
  121458. */
  121459. constructor(name: string);
  121460. /**
  121461. * Gets the current class name
  121462. * @returns the class name
  121463. */
  121464. getClassName(): string;
  121465. /**
  121466. * Gets the color input component
  121467. */
  121468. readonly value: NodeMaterialConnectionPoint;
  121469. /**
  121470. * Gets the cutoff input component
  121471. */
  121472. readonly cutoff: NodeMaterialConnectionPoint;
  121473. protected _buildBlock(state: NodeMaterialBuildState): this;
  121474. }
  121475. }
  121476. declare module BABYLON {
  121477. /**
  121478. * Block used to add support for scene fog
  121479. */
  121480. export class FogBlock extends NodeMaterialBlock {
  121481. private _fogDistanceName;
  121482. private _fogParameters;
  121483. /**
  121484. * Create a new FogBlock
  121485. * @param name defines the block name
  121486. */
  121487. constructor(name: string);
  121488. /**
  121489. * Gets the current class name
  121490. * @returns the class name
  121491. */
  121492. getClassName(): string;
  121493. /**
  121494. * Gets the world position input component
  121495. */
  121496. readonly worldPosition: NodeMaterialConnectionPoint;
  121497. /**
  121498. * Gets the view input component
  121499. */
  121500. readonly view: NodeMaterialConnectionPoint;
  121501. /**
  121502. * Gets the color input component
  121503. */
  121504. readonly input: NodeMaterialConnectionPoint;
  121505. /**
  121506. * Gets the fog color input component
  121507. */
  121508. readonly fogColor: NodeMaterialConnectionPoint;
  121509. /**
  121510. * Gets the output component
  121511. */
  121512. readonly output: NodeMaterialConnectionPoint;
  121513. autoConfigure(material: NodeMaterial): void;
  121514. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121516. protected _buildBlock(state: NodeMaterialBuildState): this;
  121517. }
  121518. }
  121519. declare module BABYLON {
  121520. /**
  121521. * Block used to add light in the fragment shader
  121522. */
  121523. export class LightBlock extends NodeMaterialBlock {
  121524. private _lightId;
  121525. /**
  121526. * Gets or sets the light associated with this block
  121527. */
  121528. light: Nullable<Light>;
  121529. /**
  121530. * Create a new LightBlock
  121531. * @param name defines the block name
  121532. */
  121533. constructor(name: string);
  121534. /**
  121535. * Gets the current class name
  121536. * @returns the class name
  121537. */
  121538. getClassName(): string;
  121539. /**
  121540. * Gets the world position input component
  121541. */
  121542. readonly worldPosition: NodeMaterialConnectionPoint;
  121543. /**
  121544. * Gets the world normal input component
  121545. */
  121546. readonly worldNormal: NodeMaterialConnectionPoint;
  121547. /**
  121548. * Gets the camera (or eye) position component
  121549. */
  121550. readonly cameraPosition: NodeMaterialConnectionPoint;
  121551. /**
  121552. * Gets the glossiness component
  121553. */
  121554. readonly glossiness: NodeMaterialConnectionPoint;
  121555. /**
  121556. * Gets the glossinness power component
  121557. */
  121558. readonly glossPower: NodeMaterialConnectionPoint;
  121559. /**
  121560. * Gets the diffuse color component
  121561. */
  121562. readonly diffuseColor: NodeMaterialConnectionPoint;
  121563. /**
  121564. * Gets the specular color component
  121565. */
  121566. readonly specularColor: NodeMaterialConnectionPoint;
  121567. /**
  121568. * Gets the diffuse output component
  121569. */
  121570. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121571. /**
  121572. * Gets the specular output component
  121573. */
  121574. readonly specularOutput: NodeMaterialConnectionPoint;
  121575. autoConfigure(material: NodeMaterial): void;
  121576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121577. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121579. private _injectVertexCode;
  121580. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121581. serialize(): any;
  121582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121583. }
  121584. }
  121585. declare module BABYLON {
  121586. /**
  121587. * Block used to multiply 2 values
  121588. */
  121589. export class MultiplyBlock extends NodeMaterialBlock {
  121590. /**
  121591. * Creates a new MultiplyBlock
  121592. * @param name defines the block name
  121593. */
  121594. constructor(name: string);
  121595. /**
  121596. * Gets the current class name
  121597. * @returns the class name
  121598. */
  121599. getClassName(): string;
  121600. /**
  121601. * Gets the left operand input component
  121602. */
  121603. readonly left: NodeMaterialConnectionPoint;
  121604. /**
  121605. * Gets the right operand input component
  121606. */
  121607. readonly right: NodeMaterialConnectionPoint;
  121608. /**
  121609. * Gets the output component
  121610. */
  121611. readonly output: NodeMaterialConnectionPoint;
  121612. protected _buildBlock(state: NodeMaterialBuildState): this;
  121613. }
  121614. }
  121615. declare module BABYLON {
  121616. /**
  121617. * Block used to add 2 vectors
  121618. */
  121619. export class AddBlock extends NodeMaterialBlock {
  121620. /**
  121621. * Creates a new AddBlock
  121622. * @param name defines the block name
  121623. */
  121624. constructor(name: string);
  121625. /**
  121626. * Gets the current class name
  121627. * @returns the class name
  121628. */
  121629. getClassName(): string;
  121630. /**
  121631. * Gets the left operand input component
  121632. */
  121633. readonly left: NodeMaterialConnectionPoint;
  121634. /**
  121635. * Gets the right operand input component
  121636. */
  121637. readonly right: 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 scale a vector by a float
  121648. */
  121649. export class ScaleBlock extends NodeMaterialBlock {
  121650. /**
  121651. * Creates a new ScaleBlock
  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 input component
  121662. */
  121663. readonly input: NodeMaterialConnectionPoint;
  121664. /**
  121665. * Gets the factor input component
  121666. */
  121667. readonly factor: 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 clamp a float
  121678. */
  121679. export class ClampBlock extends NodeMaterialBlock {
  121680. /** Gets or sets the minimum range */
  121681. minimum: number;
  121682. /** Gets or sets the maximum range */
  121683. maximum: number;
  121684. /**
  121685. * Creates a new ClampBlock
  121686. * @param name defines the block name
  121687. */
  121688. constructor(name: string);
  121689. /**
  121690. * Gets the current class name
  121691. * @returns the class name
  121692. */
  121693. getClassName(): string;
  121694. /**
  121695. * Gets the value input component
  121696. */
  121697. readonly value: NodeMaterialConnectionPoint;
  121698. /**
  121699. * Gets the output component
  121700. */
  121701. readonly output: NodeMaterialConnectionPoint;
  121702. protected _buildBlock(state: NodeMaterialBuildState): this;
  121703. protected _dumpPropertiesCode(): string;
  121704. serialize(): any;
  121705. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121706. }
  121707. }
  121708. declare module BABYLON {
  121709. /**
  121710. * Block used to apply a cross product between 2 vectors
  121711. */
  121712. export class CrossBlock extends NodeMaterialBlock {
  121713. /**
  121714. * Creates a new CrossBlock
  121715. * @param name defines the block name
  121716. */
  121717. constructor(name: string);
  121718. /**
  121719. * Gets the current class name
  121720. * @returns the class name
  121721. */
  121722. getClassName(): string;
  121723. /**
  121724. * Gets the left operand input component
  121725. */
  121726. readonly left: NodeMaterialConnectionPoint;
  121727. /**
  121728. * Gets the right operand input component
  121729. */
  121730. readonly right: NodeMaterialConnectionPoint;
  121731. /**
  121732. * Gets the output component
  121733. */
  121734. readonly output: NodeMaterialConnectionPoint;
  121735. protected _buildBlock(state: NodeMaterialBuildState): this;
  121736. }
  121737. }
  121738. declare module BABYLON {
  121739. /**
  121740. * Block used to apply a dot product between 2 vectors
  121741. */
  121742. export class DotBlock extends NodeMaterialBlock {
  121743. /**
  121744. * Creates a new DotBlock
  121745. * @param name defines the block name
  121746. */
  121747. constructor(name: string);
  121748. /**
  121749. * Gets the current class name
  121750. * @returns the class name
  121751. */
  121752. getClassName(): string;
  121753. /**
  121754. * Gets the left operand input component
  121755. */
  121756. readonly left: NodeMaterialConnectionPoint;
  121757. /**
  121758. * Gets the right operand input component
  121759. */
  121760. readonly right: NodeMaterialConnectionPoint;
  121761. /**
  121762. * Gets the output component
  121763. */
  121764. readonly output: NodeMaterialConnectionPoint;
  121765. protected _buildBlock(state: NodeMaterialBuildState): this;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * Block used to remap a float from a range to a new one
  121771. */
  121772. export class RemapBlock extends NodeMaterialBlock {
  121773. /**
  121774. * Gets or sets the source range
  121775. */
  121776. sourceRange: Vector2;
  121777. /**
  121778. * Gets or sets the target range
  121779. */
  121780. targetRange: Vector2;
  121781. /**
  121782. * Creates a new RemapBlock
  121783. * @param name defines the block name
  121784. */
  121785. constructor(name: string);
  121786. /**
  121787. * Gets the current class name
  121788. * @returns the class name
  121789. */
  121790. getClassName(): string;
  121791. /**
  121792. * Gets the input component
  121793. */
  121794. readonly input: NodeMaterialConnectionPoint;
  121795. /**
  121796. * Gets the source min input component
  121797. */
  121798. readonly sourceMin: NodeMaterialConnectionPoint;
  121799. /**
  121800. * Gets the source max input component
  121801. */
  121802. readonly sourceMax: NodeMaterialConnectionPoint;
  121803. /**
  121804. * Gets the target min input component
  121805. */
  121806. readonly targetMin: NodeMaterialConnectionPoint;
  121807. /**
  121808. * Gets the target max input component
  121809. */
  121810. readonly targetMax: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the output component
  121813. */
  121814. readonly output: NodeMaterialConnectionPoint;
  121815. protected _buildBlock(state: NodeMaterialBuildState): this;
  121816. protected _dumpPropertiesCode(): string;
  121817. serialize(): any;
  121818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121819. }
  121820. }
  121821. declare module BABYLON {
  121822. /**
  121823. * Block used to normalize a vector
  121824. */
  121825. export class NormalizeBlock extends NodeMaterialBlock {
  121826. /**
  121827. * Creates a new NormalizeBlock
  121828. * @param name defines the block name
  121829. */
  121830. constructor(name: string);
  121831. /**
  121832. * Gets the current class name
  121833. * @returns the class name
  121834. */
  121835. getClassName(): string;
  121836. /**
  121837. * Gets the input component
  121838. */
  121839. readonly input: NodeMaterialConnectionPoint;
  121840. /**
  121841. * Gets the output component
  121842. */
  121843. readonly output: NodeMaterialConnectionPoint;
  121844. protected _buildBlock(state: NodeMaterialBuildState): this;
  121845. }
  121846. }
  121847. declare module BABYLON {
  121848. /**
  121849. * Operations supported by the Trigonometry block
  121850. */
  121851. export enum TrigonometryBlockOperations {
  121852. /** Cos */
  121853. Cos = 0,
  121854. /** Sin */
  121855. Sin = 1,
  121856. /** Abs */
  121857. Abs = 2,
  121858. /** Exp */
  121859. Exp = 3,
  121860. /** Exp2 */
  121861. Exp2 = 4,
  121862. /** Round */
  121863. Round = 5,
  121864. /** Floor */
  121865. Floor = 6,
  121866. /** Ceiling */
  121867. Ceiling = 7,
  121868. /** Square root */
  121869. Sqrt = 8,
  121870. /** Log */
  121871. Log = 9,
  121872. /** Tangent */
  121873. Tan = 10,
  121874. /** Arc tangent */
  121875. ArcTan = 11,
  121876. /** Arc cosinus */
  121877. ArcCos = 12,
  121878. /** Arc sinus */
  121879. ArcSin = 13,
  121880. /** Fraction */
  121881. Fract = 14,
  121882. /** Sign */
  121883. Sign = 15,
  121884. /** To radians (from degrees) */
  121885. Radians = 16,
  121886. /** To degrees (from radians) */
  121887. Degrees = 17
  121888. }
  121889. /**
  121890. * Block used to apply trigonometry operation to floats
  121891. */
  121892. export class TrigonometryBlock extends NodeMaterialBlock {
  121893. /**
  121894. * Gets or sets the operation applied by the block
  121895. */
  121896. operation: TrigonometryBlockOperations;
  121897. /**
  121898. * Creates a new TrigonometryBlock
  121899. * @param name defines the block name
  121900. */
  121901. constructor(name: string);
  121902. /**
  121903. * Gets the current class name
  121904. * @returns the class name
  121905. */
  121906. getClassName(): string;
  121907. /**
  121908. * Gets the input component
  121909. */
  121910. readonly input: NodeMaterialConnectionPoint;
  121911. /**
  121912. * Gets the output component
  121913. */
  121914. readonly output: NodeMaterialConnectionPoint;
  121915. protected _buildBlock(state: NodeMaterialBuildState): this;
  121916. serialize(): any;
  121917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121918. }
  121919. }
  121920. declare module BABYLON {
  121921. /**
  121922. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121923. */
  121924. export class ColorMergerBlock extends NodeMaterialBlock {
  121925. /**
  121926. * Create a new ColorMergerBlock
  121927. * @param name defines the block name
  121928. */
  121929. constructor(name: string);
  121930. /**
  121931. * Gets the current class name
  121932. * @returns the class name
  121933. */
  121934. getClassName(): string;
  121935. /**
  121936. * Gets the r component (input)
  121937. */
  121938. readonly r: NodeMaterialConnectionPoint;
  121939. /**
  121940. * Gets the g component (input)
  121941. */
  121942. readonly g: NodeMaterialConnectionPoint;
  121943. /**
  121944. * Gets the b component (input)
  121945. */
  121946. readonly b: NodeMaterialConnectionPoint;
  121947. /**
  121948. * Gets the a component (input)
  121949. */
  121950. readonly a: NodeMaterialConnectionPoint;
  121951. /**
  121952. * Gets the rgba component (output)
  121953. */
  121954. readonly rgba: NodeMaterialConnectionPoint;
  121955. /**
  121956. * Gets the rgb component (output)
  121957. */
  121958. readonly rgb: NodeMaterialConnectionPoint;
  121959. protected _buildBlock(state: NodeMaterialBuildState): this;
  121960. }
  121961. }
  121962. declare module BABYLON {
  121963. /**
  121964. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121965. */
  121966. export class VectorMergerBlock extends NodeMaterialBlock {
  121967. /**
  121968. * Create a new VectorMergerBlock
  121969. * @param name defines the block name
  121970. */
  121971. constructor(name: string);
  121972. /**
  121973. * Gets the current class name
  121974. * @returns the class name
  121975. */
  121976. getClassName(): string;
  121977. /**
  121978. * Gets the x component (input)
  121979. */
  121980. readonly x: NodeMaterialConnectionPoint;
  121981. /**
  121982. * Gets the y component (input)
  121983. */
  121984. readonly y: NodeMaterialConnectionPoint;
  121985. /**
  121986. * Gets the z component (input)
  121987. */
  121988. readonly z: NodeMaterialConnectionPoint;
  121989. /**
  121990. * Gets the w component (input)
  121991. */
  121992. readonly w: NodeMaterialConnectionPoint;
  121993. /**
  121994. * Gets the xyzw component (output)
  121995. */
  121996. readonly xyzw: NodeMaterialConnectionPoint;
  121997. /**
  121998. * Gets the xyz component (output)
  121999. */
  122000. readonly xyz: NodeMaterialConnectionPoint;
  122001. /**
  122002. * Gets the xy component (output)
  122003. */
  122004. readonly xy: NodeMaterialConnectionPoint;
  122005. protected _buildBlock(state: NodeMaterialBuildState): this;
  122006. }
  122007. }
  122008. declare module BABYLON {
  122009. /**
  122010. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122011. */
  122012. export class ColorSplitterBlock extends NodeMaterialBlock {
  122013. /**
  122014. * Create a new ColorSplitterBlock
  122015. * @param name defines the block name
  122016. */
  122017. constructor(name: string);
  122018. /**
  122019. * Gets the current class name
  122020. * @returns the class name
  122021. */
  122022. getClassName(): string;
  122023. /**
  122024. * Gets the rgba component (input)
  122025. */
  122026. readonly rgba: NodeMaterialConnectionPoint;
  122027. /**
  122028. * Gets the rgb component (input)
  122029. */
  122030. readonly rgbIn: NodeMaterialConnectionPoint;
  122031. /**
  122032. * Gets the rgb component (output)
  122033. */
  122034. readonly rgbOut: NodeMaterialConnectionPoint;
  122035. /**
  122036. * Gets the r component (output)
  122037. */
  122038. readonly r: NodeMaterialConnectionPoint;
  122039. /**
  122040. * Gets the g component (output)
  122041. */
  122042. readonly g: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the b component (output)
  122045. */
  122046. readonly b: NodeMaterialConnectionPoint;
  122047. /**
  122048. * Gets the a component (output)
  122049. */
  122050. readonly a: NodeMaterialConnectionPoint;
  122051. protected _inputRename(name: string): string;
  122052. protected _outputRename(name: string): string;
  122053. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122054. }
  122055. }
  122056. declare module BABYLON {
  122057. /**
  122058. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122059. */
  122060. export class VectorSplitterBlock extends NodeMaterialBlock {
  122061. /**
  122062. * Create a new VectorSplitterBlock
  122063. * @param name defines the block name
  122064. */
  122065. constructor(name: string);
  122066. /**
  122067. * Gets the current class name
  122068. * @returns the class name
  122069. */
  122070. getClassName(): string;
  122071. /**
  122072. * Gets the xyzw component (input)
  122073. */
  122074. readonly xyzw: NodeMaterialConnectionPoint;
  122075. /**
  122076. * Gets the xyz component (input)
  122077. */
  122078. readonly xyzIn: NodeMaterialConnectionPoint;
  122079. /**
  122080. * Gets the xy component (input)
  122081. */
  122082. readonly xyIn: NodeMaterialConnectionPoint;
  122083. /**
  122084. * Gets the xyz component (output)
  122085. */
  122086. readonly xyzOut: NodeMaterialConnectionPoint;
  122087. /**
  122088. * Gets the xy component (output)
  122089. */
  122090. readonly xyOut: NodeMaterialConnectionPoint;
  122091. /**
  122092. * Gets the x component (output)
  122093. */
  122094. readonly x: NodeMaterialConnectionPoint;
  122095. /**
  122096. * Gets the y component (output)
  122097. */
  122098. readonly y: NodeMaterialConnectionPoint;
  122099. /**
  122100. * Gets the z component (output)
  122101. */
  122102. readonly z: NodeMaterialConnectionPoint;
  122103. /**
  122104. * Gets the w component (output)
  122105. */
  122106. readonly w: NodeMaterialConnectionPoint;
  122107. protected _inputRename(name: string): string;
  122108. protected _outputRename(name: string): string;
  122109. protected _buildBlock(state: NodeMaterialBuildState): this;
  122110. }
  122111. }
  122112. declare module BABYLON {
  122113. /**
  122114. * Block used to lerp between 2 values
  122115. */
  122116. export class LerpBlock extends NodeMaterialBlock {
  122117. /**
  122118. * Creates a new LerpBlock
  122119. * @param name defines the block name
  122120. */
  122121. constructor(name: string);
  122122. /**
  122123. * Gets the current class name
  122124. * @returns the class name
  122125. */
  122126. getClassName(): string;
  122127. /**
  122128. * Gets the left operand input component
  122129. */
  122130. readonly left: NodeMaterialConnectionPoint;
  122131. /**
  122132. * Gets the right operand input component
  122133. */
  122134. readonly right: NodeMaterialConnectionPoint;
  122135. /**
  122136. * Gets the gradient operand input component
  122137. */
  122138. readonly gradient: NodeMaterialConnectionPoint;
  122139. /**
  122140. * Gets the output component
  122141. */
  122142. readonly output: NodeMaterialConnectionPoint;
  122143. protected _buildBlock(state: NodeMaterialBuildState): this;
  122144. }
  122145. }
  122146. declare module BABYLON {
  122147. /**
  122148. * Block used to divide 2 vectors
  122149. */
  122150. export class DivideBlock extends NodeMaterialBlock {
  122151. /**
  122152. * Creates a new DivideBlock
  122153. * @param name defines the block name
  122154. */
  122155. constructor(name: string);
  122156. /**
  122157. * Gets the current class name
  122158. * @returns the class name
  122159. */
  122160. getClassName(): string;
  122161. /**
  122162. * Gets the left operand input component
  122163. */
  122164. readonly left: NodeMaterialConnectionPoint;
  122165. /**
  122166. * Gets the right operand input component
  122167. */
  122168. readonly right: NodeMaterialConnectionPoint;
  122169. /**
  122170. * Gets the output component
  122171. */
  122172. readonly output: NodeMaterialConnectionPoint;
  122173. protected _buildBlock(state: NodeMaterialBuildState): this;
  122174. }
  122175. }
  122176. declare module BABYLON {
  122177. /**
  122178. * Block used to subtract 2 vectors
  122179. */
  122180. export class SubtractBlock extends NodeMaterialBlock {
  122181. /**
  122182. * Creates a new SubtractBlock
  122183. * @param name defines the block name
  122184. */
  122185. constructor(name: string);
  122186. /**
  122187. * Gets the current class name
  122188. * @returns the class name
  122189. */
  122190. getClassName(): string;
  122191. /**
  122192. * Gets the left operand input component
  122193. */
  122194. readonly left: NodeMaterialConnectionPoint;
  122195. /**
  122196. * Gets the right operand input component
  122197. */
  122198. readonly right: NodeMaterialConnectionPoint;
  122199. /**
  122200. * Gets the output component
  122201. */
  122202. readonly output: NodeMaterialConnectionPoint;
  122203. protected _buildBlock(state: NodeMaterialBuildState): this;
  122204. }
  122205. }
  122206. declare module BABYLON {
  122207. /**
  122208. * Block used to step a value
  122209. */
  122210. export class StepBlock extends NodeMaterialBlock {
  122211. /**
  122212. * Creates a new StepBlock
  122213. * @param name defines the block name
  122214. */
  122215. constructor(name: string);
  122216. /**
  122217. * Gets the current class name
  122218. * @returns the class name
  122219. */
  122220. getClassName(): string;
  122221. /**
  122222. * Gets the value operand input component
  122223. */
  122224. readonly value: NodeMaterialConnectionPoint;
  122225. /**
  122226. * Gets the edge operand input component
  122227. */
  122228. readonly edge: NodeMaterialConnectionPoint;
  122229. /**
  122230. * Gets the output component
  122231. */
  122232. readonly output: NodeMaterialConnectionPoint;
  122233. protected _buildBlock(state: NodeMaterialBuildState): this;
  122234. }
  122235. }
  122236. declare module BABYLON {
  122237. /**
  122238. * Block used to get the opposite (1 - x) of a value
  122239. */
  122240. export class OneMinusBlock extends NodeMaterialBlock {
  122241. /**
  122242. * Creates a new OneMinusBlock
  122243. * @param name defines the block name
  122244. */
  122245. constructor(name: string);
  122246. /**
  122247. * Gets the current class name
  122248. * @returns the class name
  122249. */
  122250. getClassName(): string;
  122251. /**
  122252. * Gets the input component
  122253. */
  122254. readonly input: NodeMaterialConnectionPoint;
  122255. /**
  122256. * Gets the output component
  122257. */
  122258. readonly output: NodeMaterialConnectionPoint;
  122259. protected _buildBlock(state: NodeMaterialBuildState): this;
  122260. }
  122261. }
  122262. declare module BABYLON {
  122263. /**
  122264. * Block used to get the view direction
  122265. */
  122266. export class ViewDirectionBlock extends NodeMaterialBlock {
  122267. /**
  122268. * Creates a new ViewDirectionBlock
  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 world position component
  122279. */
  122280. readonly worldPosition: NodeMaterialConnectionPoint;
  122281. /**
  122282. * Gets the camera position component
  122283. */
  122284. readonly cameraPosition: NodeMaterialConnectionPoint;
  122285. /**
  122286. * Gets the output component
  122287. */
  122288. readonly output: NodeMaterialConnectionPoint;
  122289. autoConfigure(material: NodeMaterial): void;
  122290. protected _buildBlock(state: NodeMaterialBuildState): this;
  122291. }
  122292. }
  122293. declare module BABYLON {
  122294. /**
  122295. * Block used to compute fresnel value
  122296. */
  122297. export class FresnelBlock extends NodeMaterialBlock {
  122298. /**
  122299. * Create a new FresnelBlock
  122300. * @param name defines the block name
  122301. */
  122302. constructor(name: string);
  122303. /**
  122304. * Gets the current class name
  122305. * @returns the class name
  122306. */
  122307. getClassName(): string;
  122308. /**
  122309. * Gets the world normal input component
  122310. */
  122311. readonly worldNormal: NodeMaterialConnectionPoint;
  122312. /**
  122313. * Gets the view direction input component
  122314. */
  122315. readonly viewDirection: NodeMaterialConnectionPoint;
  122316. /**
  122317. * Gets the bias input component
  122318. */
  122319. readonly bias: NodeMaterialConnectionPoint;
  122320. /**
  122321. * Gets the camera (or eye) position component
  122322. */
  122323. readonly power: NodeMaterialConnectionPoint;
  122324. /**
  122325. * Gets the fresnel output component
  122326. */
  122327. readonly fresnel: NodeMaterialConnectionPoint;
  122328. autoConfigure(material: NodeMaterial): void;
  122329. protected _buildBlock(state: NodeMaterialBuildState): this;
  122330. }
  122331. }
  122332. declare module BABYLON {
  122333. /**
  122334. * Block used to get the max of 2 values
  122335. */
  122336. export class MaxBlock extends NodeMaterialBlock {
  122337. /**
  122338. * Creates a new MaxBlock
  122339. * @param name defines the block name
  122340. */
  122341. constructor(name: string);
  122342. /**
  122343. * Gets the current class name
  122344. * @returns the class name
  122345. */
  122346. getClassName(): string;
  122347. /**
  122348. * Gets the left operand input component
  122349. */
  122350. readonly left: NodeMaterialConnectionPoint;
  122351. /**
  122352. * Gets the right operand input component
  122353. */
  122354. readonly right: NodeMaterialConnectionPoint;
  122355. /**
  122356. * Gets the output component
  122357. */
  122358. readonly output: NodeMaterialConnectionPoint;
  122359. protected _buildBlock(state: NodeMaterialBuildState): this;
  122360. }
  122361. }
  122362. declare module BABYLON {
  122363. /**
  122364. * Block used to get the min of 2 values
  122365. */
  122366. export class MinBlock extends NodeMaterialBlock {
  122367. /**
  122368. * Creates a new MinBlock
  122369. * @param name defines the block name
  122370. */
  122371. constructor(name: string);
  122372. /**
  122373. * Gets the current class name
  122374. * @returns the class name
  122375. */
  122376. getClassName(): string;
  122377. /**
  122378. * Gets the left operand input component
  122379. */
  122380. readonly left: NodeMaterialConnectionPoint;
  122381. /**
  122382. * Gets the right operand input component
  122383. */
  122384. readonly right: NodeMaterialConnectionPoint;
  122385. /**
  122386. * Gets the output component
  122387. */
  122388. readonly output: NodeMaterialConnectionPoint;
  122389. protected _buildBlock(state: NodeMaterialBuildState): this;
  122390. }
  122391. }
  122392. declare module BABYLON {
  122393. /**
  122394. * Block used to get the distance between 2 values
  122395. */
  122396. export class DistanceBlock extends NodeMaterialBlock {
  122397. /**
  122398. * Creates a new DistanceBlock
  122399. * @param name defines the block name
  122400. */
  122401. constructor(name: string);
  122402. /**
  122403. * Gets the current class name
  122404. * @returns the class name
  122405. */
  122406. getClassName(): string;
  122407. /**
  122408. * Gets the left operand input component
  122409. */
  122410. readonly left: NodeMaterialConnectionPoint;
  122411. /**
  122412. * Gets the right operand input component
  122413. */
  122414. readonly right: NodeMaterialConnectionPoint;
  122415. /**
  122416. * Gets the output component
  122417. */
  122418. readonly output: NodeMaterialConnectionPoint;
  122419. protected _buildBlock(state: NodeMaterialBuildState): this;
  122420. }
  122421. }
  122422. declare module BABYLON {
  122423. /**
  122424. * Block used to get the length of a vector
  122425. */
  122426. export class LengthBlock extends NodeMaterialBlock {
  122427. /**
  122428. * Creates a new LengthBlock
  122429. * @param name defines the block name
  122430. */
  122431. constructor(name: string);
  122432. /**
  122433. * Gets the current class name
  122434. * @returns the class name
  122435. */
  122436. getClassName(): string;
  122437. /**
  122438. * Gets the value input component
  122439. */
  122440. readonly value: NodeMaterialConnectionPoint;
  122441. /**
  122442. * Gets the output component
  122443. */
  122444. readonly output: NodeMaterialConnectionPoint;
  122445. protected _buildBlock(state: NodeMaterialBuildState): this;
  122446. }
  122447. }
  122448. declare module BABYLON {
  122449. /**
  122450. * Block used to get negative version of a value (i.e. x * -1)
  122451. */
  122452. export class NegateBlock extends NodeMaterialBlock {
  122453. /**
  122454. * Creates a new NegateBlock
  122455. * @param name defines the block name
  122456. */
  122457. constructor(name: string);
  122458. /**
  122459. * Gets the current class name
  122460. * @returns the class name
  122461. */
  122462. getClassName(): string;
  122463. /**
  122464. * Gets the value input component
  122465. */
  122466. readonly value: NodeMaterialConnectionPoint;
  122467. /**
  122468. * Gets the output component
  122469. */
  122470. readonly output: NodeMaterialConnectionPoint;
  122471. protected _buildBlock(state: NodeMaterialBuildState): this;
  122472. }
  122473. }
  122474. declare module BABYLON {
  122475. /**
  122476. * Block used to get the value of the first parameter raised to the power of the second
  122477. */
  122478. export class PowBlock extends NodeMaterialBlock {
  122479. /**
  122480. * Creates a new PowBlock
  122481. * @param name defines the block name
  122482. */
  122483. constructor(name: string);
  122484. /**
  122485. * Gets the current class name
  122486. * @returns the class name
  122487. */
  122488. getClassName(): string;
  122489. /**
  122490. * Gets the value operand input component
  122491. */
  122492. readonly value: NodeMaterialConnectionPoint;
  122493. /**
  122494. * Gets the power operand input component
  122495. */
  122496. readonly power: NodeMaterialConnectionPoint;
  122497. /**
  122498. * Gets the output component
  122499. */
  122500. readonly output: NodeMaterialConnectionPoint;
  122501. protected _buildBlock(state: NodeMaterialBuildState): this;
  122502. }
  122503. }
  122504. declare module BABYLON {
  122505. /**
  122506. * Block used to get a random number
  122507. */
  122508. export class RandomNumberBlock extends NodeMaterialBlock {
  122509. /**
  122510. * Creates a new RandomNumberBlock
  122511. * @param name defines the block name
  122512. */
  122513. constructor(name: string);
  122514. /**
  122515. * Gets the current class name
  122516. * @returns the class name
  122517. */
  122518. getClassName(): string;
  122519. /**
  122520. * Gets the seed input component
  122521. */
  122522. readonly seed: NodeMaterialConnectionPoint;
  122523. /**
  122524. * Gets the output component
  122525. */
  122526. readonly output: NodeMaterialConnectionPoint;
  122527. protected _buildBlock(state: NodeMaterialBuildState): this;
  122528. }
  122529. }
  122530. declare module BABYLON {
  122531. /**
  122532. * Block used to compute arc tangent of 2 values
  122533. */
  122534. export class ArcTan2Block extends NodeMaterialBlock {
  122535. /**
  122536. * Creates a new ArcTan2Block
  122537. * @param name defines the block name
  122538. */
  122539. constructor(name: string);
  122540. /**
  122541. * Gets the current class name
  122542. * @returns the class name
  122543. */
  122544. getClassName(): string;
  122545. /**
  122546. * Gets the x operand input component
  122547. */
  122548. readonly x: NodeMaterialConnectionPoint;
  122549. /**
  122550. * Gets the y operand input component
  122551. */
  122552. readonly y: NodeMaterialConnectionPoint;
  122553. /**
  122554. * Gets the output component
  122555. */
  122556. readonly output: NodeMaterialConnectionPoint;
  122557. protected _buildBlock(state: NodeMaterialBuildState): this;
  122558. }
  122559. }
  122560. declare module BABYLON {
  122561. /**
  122562. * Block used to smooth step a value
  122563. */
  122564. export class SmoothStepBlock extends NodeMaterialBlock {
  122565. /**
  122566. * Creates a new SmoothStepBlock
  122567. * @param name defines the block name
  122568. */
  122569. constructor(name: string);
  122570. /**
  122571. * Gets the current class name
  122572. * @returns the class name
  122573. */
  122574. getClassName(): string;
  122575. /**
  122576. * Gets the value operand input component
  122577. */
  122578. readonly value: NodeMaterialConnectionPoint;
  122579. /**
  122580. * Gets the first edge operand input component
  122581. */
  122582. readonly edge0: NodeMaterialConnectionPoint;
  122583. /**
  122584. * Gets the second edge operand input component
  122585. */
  122586. readonly edge1: NodeMaterialConnectionPoint;
  122587. /**
  122588. * Gets the output component
  122589. */
  122590. readonly output: NodeMaterialConnectionPoint;
  122591. protected _buildBlock(state: NodeMaterialBuildState): this;
  122592. }
  122593. }
  122594. declare module BABYLON {
  122595. /**
  122596. * Block used to get the reciprocal (1 / x) of a value
  122597. */
  122598. export class ReciprocalBlock extends NodeMaterialBlock {
  122599. /**
  122600. * Creates a new ReciprocalBlock
  122601. * @param name defines the block name
  122602. */
  122603. constructor(name: string);
  122604. /**
  122605. * Gets the current class name
  122606. * @returns the class name
  122607. */
  122608. getClassName(): string;
  122609. /**
  122610. * Gets the input component
  122611. */
  122612. readonly input: NodeMaterialConnectionPoint;
  122613. /**
  122614. * Gets the output component
  122615. */
  122616. readonly output: NodeMaterialConnectionPoint;
  122617. protected _buildBlock(state: NodeMaterialBuildState): this;
  122618. }
  122619. }
  122620. declare module BABYLON {
  122621. /**
  122622. * Block used to replace a color by another one
  122623. */
  122624. export class ReplaceColorBlock extends NodeMaterialBlock {
  122625. /**
  122626. * Creates a new ReplaceColorBlock
  122627. * @param name defines the block name
  122628. */
  122629. constructor(name: string);
  122630. /**
  122631. * Gets the current class name
  122632. * @returns the class name
  122633. */
  122634. getClassName(): string;
  122635. /**
  122636. * Gets the value input component
  122637. */
  122638. readonly value: NodeMaterialConnectionPoint;
  122639. /**
  122640. * Gets the reference input component
  122641. */
  122642. readonly reference: NodeMaterialConnectionPoint;
  122643. /**
  122644. * Gets the distance input component
  122645. */
  122646. readonly distance: NodeMaterialConnectionPoint;
  122647. /**
  122648. * Gets the replacement input component
  122649. */
  122650. readonly replacement: NodeMaterialConnectionPoint;
  122651. /**
  122652. * Gets the output component
  122653. */
  122654. readonly output: NodeMaterialConnectionPoint;
  122655. protected _buildBlock(state: NodeMaterialBuildState): this;
  122656. }
  122657. }
  122658. declare module BABYLON {
  122659. /**
  122660. * Block used to posterize a value
  122661. * @see https://en.wikipedia.org/wiki/Posterization
  122662. */
  122663. export class PosterizeBlock extends NodeMaterialBlock {
  122664. /**
  122665. * Creates a new PosterizeBlock
  122666. * @param name defines the block name
  122667. */
  122668. constructor(name: string);
  122669. /**
  122670. * Gets the current class name
  122671. * @returns the class name
  122672. */
  122673. getClassName(): string;
  122674. /**
  122675. * Gets the value input component
  122676. */
  122677. readonly value: NodeMaterialConnectionPoint;
  122678. /**
  122679. * Gets the steps input component
  122680. */
  122681. readonly steps: NodeMaterialConnectionPoint;
  122682. /**
  122683. * Gets the output component
  122684. */
  122685. readonly output: NodeMaterialConnectionPoint;
  122686. protected _buildBlock(state: NodeMaterialBuildState): this;
  122687. }
  122688. }
  122689. declare module BABYLON {
  122690. /**
  122691. * Operations supported by the Wave block
  122692. */
  122693. export enum WaveBlockKind {
  122694. /** SawTooth */
  122695. SawTooth = 0,
  122696. /** Square */
  122697. Square = 1,
  122698. /** Triangle */
  122699. Triangle = 2
  122700. }
  122701. /**
  122702. * Block used to apply wave operation to floats
  122703. */
  122704. export class WaveBlock extends NodeMaterialBlock {
  122705. /**
  122706. * Gets or sets the kibnd of wave to be applied by the block
  122707. */
  122708. kind: WaveBlockKind;
  122709. /**
  122710. * Creates a new WaveBlock
  122711. * @param name defines the block name
  122712. */
  122713. constructor(name: string);
  122714. /**
  122715. * Gets the current class name
  122716. * @returns the class name
  122717. */
  122718. getClassName(): string;
  122719. /**
  122720. * Gets the input component
  122721. */
  122722. readonly input: NodeMaterialConnectionPoint;
  122723. /**
  122724. * Gets the output component
  122725. */
  122726. readonly output: NodeMaterialConnectionPoint;
  122727. protected _buildBlock(state: NodeMaterialBuildState): this;
  122728. serialize(): any;
  122729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122730. }
  122731. }
  122732. declare module BABYLON {
  122733. /**
  122734. * Class used to store a color step for the GradientBlock
  122735. */
  122736. export class GradientBlockColorStep {
  122737. /**
  122738. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122739. */
  122740. step: number;
  122741. /**
  122742. * Gets or sets the color associated with this step
  122743. */
  122744. color: Color3;
  122745. /**
  122746. * Creates a new GradientBlockColorStep
  122747. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122748. * @param color defines the color associated with this step
  122749. */
  122750. constructor(
  122751. /**
  122752. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122753. */
  122754. step: number,
  122755. /**
  122756. * Gets or sets the color associated with this step
  122757. */
  122758. color: Color3);
  122759. }
  122760. /**
  122761. * Block used to return a color from a gradient based on an input value between 0 and 1
  122762. */
  122763. export class GradientBlock extends NodeMaterialBlock {
  122764. /**
  122765. * Gets or sets the list of color steps
  122766. */
  122767. colorSteps: GradientBlockColorStep[];
  122768. /**
  122769. * Creates a new GradientBlock
  122770. * @param name defines the block name
  122771. */
  122772. constructor(name: string);
  122773. /**
  122774. * Gets the current class name
  122775. * @returns the class name
  122776. */
  122777. getClassName(): string;
  122778. /**
  122779. * Gets the gradient input component
  122780. */
  122781. readonly gradient: NodeMaterialConnectionPoint;
  122782. /**
  122783. * Gets the output component
  122784. */
  122785. readonly output: NodeMaterialConnectionPoint;
  122786. private _writeColorConstant;
  122787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122788. serialize(): any;
  122789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122790. protected _dumpPropertiesCode(): string;
  122791. }
  122792. }
  122793. declare module BABYLON {
  122794. /**
  122795. * Block used to normalize lerp between 2 values
  122796. */
  122797. export class NLerpBlock extends NodeMaterialBlock {
  122798. /**
  122799. * Creates a new NLerpBlock
  122800. * @param name defines the block name
  122801. */
  122802. constructor(name: string);
  122803. /**
  122804. * Gets the current class name
  122805. * @returns the class name
  122806. */
  122807. getClassName(): string;
  122808. /**
  122809. * Gets the left operand input component
  122810. */
  122811. readonly left: NodeMaterialConnectionPoint;
  122812. /**
  122813. * Gets the right operand input component
  122814. */
  122815. readonly right: NodeMaterialConnectionPoint;
  122816. /**
  122817. * Gets the gradient operand input component
  122818. */
  122819. readonly gradient: NodeMaterialConnectionPoint;
  122820. /**
  122821. * Gets the output component
  122822. */
  122823. readonly output: NodeMaterialConnectionPoint;
  122824. protected _buildBlock(state: NodeMaterialBuildState): this;
  122825. }
  122826. }
  122827. declare module BABYLON {
  122828. /**
  122829. * Effect Render Options
  122830. */
  122831. export interface IEffectRendererOptions {
  122832. /**
  122833. * Defines the vertices positions.
  122834. */
  122835. positions?: number[];
  122836. /**
  122837. * Defines the indices.
  122838. */
  122839. indices?: number[];
  122840. }
  122841. /**
  122842. * Helper class to render one or more effects
  122843. */
  122844. export class EffectRenderer {
  122845. private engine;
  122846. private static _DefaultOptions;
  122847. private _vertexBuffers;
  122848. private _indexBuffer;
  122849. private _ringBufferIndex;
  122850. private _ringScreenBuffer;
  122851. private _fullscreenViewport;
  122852. private _getNextFrameBuffer;
  122853. /**
  122854. * Creates an effect renderer
  122855. * @param engine the engine to use for rendering
  122856. * @param options defines the options of the effect renderer
  122857. */
  122858. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122859. /**
  122860. * Sets the current viewport in normalized coordinates 0-1
  122861. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122862. */
  122863. setViewport(viewport?: Viewport): void;
  122864. /**
  122865. * Binds the embedded attributes buffer to the effect.
  122866. * @param effect Defines the effect to bind the attributes for
  122867. */
  122868. bindBuffers(effect: Effect): void;
  122869. /**
  122870. * Sets the current effect wrapper to use during draw.
  122871. * The effect needs to be ready before calling this api.
  122872. * This also sets the default full screen position attribute.
  122873. * @param effectWrapper Defines the effect to draw with
  122874. */
  122875. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122876. /**
  122877. * Draws a full screen quad.
  122878. */
  122879. draw(): void;
  122880. /**
  122881. * renders one or more effects to a specified texture
  122882. * @param effectWrappers list of effects to renderer
  122883. * @param outputTexture texture to draw to, if null it will render to the screen
  122884. */
  122885. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122886. /**
  122887. * Disposes of the effect renderer
  122888. */
  122889. dispose(): void;
  122890. }
  122891. /**
  122892. * Options to create an EffectWrapper
  122893. */
  122894. interface EffectWrapperCreationOptions {
  122895. /**
  122896. * Engine to use to create the effect
  122897. */
  122898. engine: ThinEngine;
  122899. /**
  122900. * Fragment shader for the effect
  122901. */
  122902. fragmentShader: string;
  122903. /**
  122904. * Vertex shader for the effect
  122905. */
  122906. vertexShader?: string;
  122907. /**
  122908. * Attributes to use in the shader
  122909. */
  122910. attributeNames?: Array<string>;
  122911. /**
  122912. * Uniforms to use in the shader
  122913. */
  122914. uniformNames?: Array<string>;
  122915. /**
  122916. * Texture sampler names to use in the shader
  122917. */
  122918. samplerNames?: Array<string>;
  122919. /**
  122920. * The friendly name of the effect displayed in Spector.
  122921. */
  122922. name?: string;
  122923. }
  122924. /**
  122925. * Wraps an effect to be used for rendering
  122926. */
  122927. export class EffectWrapper {
  122928. /**
  122929. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122930. */
  122931. onApplyObservable: Observable<{}>;
  122932. /**
  122933. * The underlying effect
  122934. */
  122935. effect: Effect;
  122936. /**
  122937. * Creates an effect to be renderer
  122938. * @param creationOptions options to create the effect
  122939. */
  122940. constructor(creationOptions: EffectWrapperCreationOptions);
  122941. /**
  122942. * Disposes of the effect wrapper
  122943. */
  122944. dispose(): void;
  122945. }
  122946. }
  122947. declare module BABYLON {
  122948. /**
  122949. * Helper class to push actions to a pool of workers.
  122950. */
  122951. export class WorkerPool implements IDisposable {
  122952. private _workerInfos;
  122953. private _pendingActions;
  122954. /**
  122955. * Constructor
  122956. * @param workers Array of workers to use for actions
  122957. */
  122958. constructor(workers: Array<Worker>);
  122959. /**
  122960. * Terminates all workers and clears any pending actions.
  122961. */
  122962. dispose(): void;
  122963. /**
  122964. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122965. * pended until a worker has completed its action.
  122966. * @param action The action to perform. Call onComplete when the action is complete.
  122967. */
  122968. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122969. private _execute;
  122970. }
  122971. }
  122972. declare module BABYLON {
  122973. /**
  122974. * Configuration for Draco compression
  122975. */
  122976. export interface IDracoCompressionConfiguration {
  122977. /**
  122978. * Configuration for the decoder.
  122979. */
  122980. decoder: {
  122981. /**
  122982. * The url to the WebAssembly module.
  122983. */
  122984. wasmUrl?: string;
  122985. /**
  122986. * The url to the WebAssembly binary.
  122987. */
  122988. wasmBinaryUrl?: string;
  122989. /**
  122990. * The url to the fallback JavaScript module.
  122991. */
  122992. fallbackUrl?: string;
  122993. };
  122994. }
  122995. /**
  122996. * Draco compression (https://google.github.io/draco/)
  122997. *
  122998. * This class wraps the Draco module.
  122999. *
  123000. * **Encoder**
  123001. *
  123002. * The encoder is not currently implemented.
  123003. *
  123004. * **Decoder**
  123005. *
  123006. * 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.
  123007. *
  123008. * To update the configuration, use the following code:
  123009. * ```javascript
  123010. * DracoCompression.Configuration = {
  123011. * decoder: {
  123012. * wasmUrl: "<url to the WebAssembly library>",
  123013. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123014. * fallbackUrl: "<url to the fallback JavaScript library>",
  123015. * }
  123016. * };
  123017. * ```
  123018. *
  123019. * 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.
  123020. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123021. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123022. *
  123023. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123024. * ```javascript
  123025. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123026. * ```
  123027. *
  123028. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123029. */
  123030. export class DracoCompression implements IDisposable {
  123031. private _workerPoolPromise?;
  123032. private _decoderModulePromise?;
  123033. /**
  123034. * The configuration. Defaults to the following urls:
  123035. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123036. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123037. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123038. */
  123039. static Configuration: IDracoCompressionConfiguration;
  123040. /**
  123041. * Returns true if the decoder configuration is available.
  123042. */
  123043. static readonly DecoderAvailable: boolean;
  123044. /**
  123045. * Default number of workers to create when creating the draco compression object.
  123046. */
  123047. static DefaultNumWorkers: number;
  123048. private static GetDefaultNumWorkers;
  123049. private static _Default;
  123050. /**
  123051. * Default instance for the draco compression object.
  123052. */
  123053. static readonly Default: DracoCompression;
  123054. /**
  123055. * Constructor
  123056. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123057. */
  123058. constructor(numWorkers?: number);
  123059. /**
  123060. * Stop all async operations and release resources.
  123061. */
  123062. dispose(): void;
  123063. /**
  123064. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123065. * @returns a promise that resolves when ready
  123066. */
  123067. whenReadyAsync(): Promise<void>;
  123068. /**
  123069. * Decode Draco compressed mesh data to vertex data.
  123070. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123071. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123072. * @returns A promise that resolves with the decoded vertex data
  123073. */
  123074. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123075. [kind: string]: number;
  123076. }): Promise<VertexData>;
  123077. }
  123078. }
  123079. declare module BABYLON {
  123080. /**
  123081. * Class for building Constructive Solid Geometry
  123082. */
  123083. export class CSG {
  123084. private polygons;
  123085. /**
  123086. * The world matrix
  123087. */
  123088. matrix: Matrix;
  123089. /**
  123090. * Stores the position
  123091. */
  123092. position: Vector3;
  123093. /**
  123094. * Stores the rotation
  123095. */
  123096. rotation: Vector3;
  123097. /**
  123098. * Stores the rotation quaternion
  123099. */
  123100. rotationQuaternion: Nullable<Quaternion>;
  123101. /**
  123102. * Stores the scaling vector
  123103. */
  123104. scaling: Vector3;
  123105. /**
  123106. * Convert the Mesh to CSG
  123107. * @param mesh The Mesh to convert to CSG
  123108. * @returns A new CSG from the Mesh
  123109. */
  123110. static FromMesh(mesh: Mesh): CSG;
  123111. /**
  123112. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123113. * @param polygons Polygons used to construct a CSG solid
  123114. */
  123115. private static FromPolygons;
  123116. /**
  123117. * Clones, or makes a deep copy, of the CSG
  123118. * @returns A new CSG
  123119. */
  123120. clone(): CSG;
  123121. /**
  123122. * Unions this CSG with another CSG
  123123. * @param csg The CSG to union against this CSG
  123124. * @returns The unioned CSG
  123125. */
  123126. union(csg: CSG): CSG;
  123127. /**
  123128. * Unions this CSG with another CSG in place
  123129. * @param csg The CSG to union against this CSG
  123130. */
  123131. unionInPlace(csg: CSG): void;
  123132. /**
  123133. * Subtracts this CSG with another CSG
  123134. * @param csg The CSG to subtract against this CSG
  123135. * @returns A new CSG
  123136. */
  123137. subtract(csg: CSG): CSG;
  123138. /**
  123139. * Subtracts this CSG with another CSG in place
  123140. * @param csg The CSG to subtact against this CSG
  123141. */
  123142. subtractInPlace(csg: CSG): void;
  123143. /**
  123144. * Intersect this CSG with another CSG
  123145. * @param csg The CSG to intersect against this CSG
  123146. * @returns A new CSG
  123147. */
  123148. intersect(csg: CSG): CSG;
  123149. /**
  123150. * Intersects this CSG with another CSG in place
  123151. * @param csg The CSG to intersect against this CSG
  123152. */
  123153. intersectInPlace(csg: CSG): void;
  123154. /**
  123155. * Return a new CSG solid with solid and empty space switched. This solid is
  123156. * not modified.
  123157. * @returns A new CSG solid with solid and empty space switched
  123158. */
  123159. inverse(): CSG;
  123160. /**
  123161. * Inverses the CSG in place
  123162. */
  123163. inverseInPlace(): void;
  123164. /**
  123165. * This is used to keep meshes transformations so they can be restored
  123166. * when we build back a Babylon Mesh
  123167. * NB : All CSG operations are performed in world coordinates
  123168. * @param csg The CSG to copy the transform attributes from
  123169. * @returns This CSG
  123170. */
  123171. copyTransformAttributes(csg: CSG): CSG;
  123172. /**
  123173. * Build Raw mesh from CSG
  123174. * Coordinates here are in world space
  123175. * @param name The name of the mesh geometry
  123176. * @param scene The Scene
  123177. * @param keepSubMeshes Specifies if the submeshes should be kept
  123178. * @returns A new Mesh
  123179. */
  123180. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123181. /**
  123182. * Build Mesh from CSG taking material and transforms into account
  123183. * @param name The name of the Mesh
  123184. * @param material The material of the Mesh
  123185. * @param scene The Scene
  123186. * @param keepSubMeshes Specifies if submeshes should be kept
  123187. * @returns The new Mesh
  123188. */
  123189. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123190. }
  123191. }
  123192. declare module BABYLON {
  123193. /**
  123194. * Class used to create a trail following a mesh
  123195. */
  123196. export class TrailMesh extends Mesh {
  123197. private _generator;
  123198. private _autoStart;
  123199. private _running;
  123200. private _diameter;
  123201. private _length;
  123202. private _sectionPolygonPointsCount;
  123203. private _sectionVectors;
  123204. private _sectionNormalVectors;
  123205. private _beforeRenderObserver;
  123206. /**
  123207. * @constructor
  123208. * @param name The value used by scene.getMeshByName() to do a lookup.
  123209. * @param generator The mesh to generate a trail.
  123210. * @param scene The scene to add this mesh to.
  123211. * @param diameter Diameter of trailing mesh. Default is 1.
  123212. * @param length Length of trailing mesh. Default is 60.
  123213. * @param autoStart Automatically start trailing mesh. Default true.
  123214. */
  123215. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123216. /**
  123217. * "TrailMesh"
  123218. * @returns "TrailMesh"
  123219. */
  123220. getClassName(): string;
  123221. private _createMesh;
  123222. /**
  123223. * Start trailing mesh.
  123224. */
  123225. start(): void;
  123226. /**
  123227. * Stop trailing mesh.
  123228. */
  123229. stop(): void;
  123230. /**
  123231. * Update trailing mesh geometry.
  123232. */
  123233. update(): void;
  123234. /**
  123235. * Returns a new TrailMesh object.
  123236. * @param name is a string, the name given to the new mesh
  123237. * @param newGenerator use new generator object for cloned trail mesh
  123238. * @returns a new mesh
  123239. */
  123240. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123241. /**
  123242. * Serializes this trail mesh
  123243. * @param serializationObject object to write serialization to
  123244. */
  123245. serialize(serializationObject: any): void;
  123246. /**
  123247. * Parses a serialized trail mesh
  123248. * @param parsedMesh the serialized mesh
  123249. * @param scene the scene to create the trail mesh in
  123250. * @returns the created trail mesh
  123251. */
  123252. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123253. }
  123254. }
  123255. declare module BABYLON {
  123256. /**
  123257. * Class containing static functions to help procedurally build meshes
  123258. */
  123259. export class TiledBoxBuilder {
  123260. /**
  123261. * Creates a box mesh
  123262. * 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)
  123263. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123267. * @param name defines the name of the mesh
  123268. * @param options defines the options used to create the mesh
  123269. * @param scene defines the hosting scene
  123270. * @returns the box mesh
  123271. */
  123272. static CreateTiledBox(name: string, options: {
  123273. pattern?: number;
  123274. width?: number;
  123275. height?: number;
  123276. depth?: number;
  123277. tileSize?: number;
  123278. tileWidth?: number;
  123279. tileHeight?: number;
  123280. alignHorizontal?: number;
  123281. alignVertical?: number;
  123282. faceUV?: Vector4[];
  123283. faceColors?: Color4[];
  123284. sideOrientation?: number;
  123285. updatable?: boolean;
  123286. }, scene?: Nullable<Scene>): Mesh;
  123287. }
  123288. }
  123289. declare module BABYLON {
  123290. /**
  123291. * Class containing static functions to help procedurally build meshes
  123292. */
  123293. export class TorusKnotBuilder {
  123294. /**
  123295. * Creates a torus knot mesh
  123296. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123297. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123298. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123299. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123303. * @param name defines the name of the mesh
  123304. * @param options defines the options used to create the mesh
  123305. * @param scene defines the hosting scene
  123306. * @returns the torus knot mesh
  123307. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123308. */
  123309. static CreateTorusKnot(name: string, options: {
  123310. radius?: number;
  123311. tube?: number;
  123312. radialSegments?: number;
  123313. tubularSegments?: number;
  123314. p?: number;
  123315. q?: number;
  123316. updatable?: boolean;
  123317. sideOrientation?: number;
  123318. frontUVs?: Vector4;
  123319. backUVs?: Vector4;
  123320. }, scene: any): Mesh;
  123321. }
  123322. }
  123323. declare module BABYLON {
  123324. /**
  123325. * Polygon
  123326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  123327. */
  123328. export class Polygon {
  123329. /**
  123330. * Creates a rectangle
  123331. * @param xmin bottom X coord
  123332. * @param ymin bottom Y coord
  123333. * @param xmax top X coord
  123334. * @param ymax top Y coord
  123335. * @returns points that make the resulting rectation
  123336. */
  123337. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  123338. /**
  123339. * Creates a circle
  123340. * @param radius radius of circle
  123341. * @param cx scale in x
  123342. * @param cy scale in y
  123343. * @param numberOfSides number of sides that make up the circle
  123344. * @returns points that make the resulting circle
  123345. */
  123346. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  123347. /**
  123348. * Creates a polygon from input string
  123349. * @param input Input polygon data
  123350. * @returns the parsed points
  123351. */
  123352. static Parse(input: string): Vector2[];
  123353. /**
  123354. * Starts building a polygon from x and y coordinates
  123355. * @param x x coordinate
  123356. * @param y y coordinate
  123357. * @returns the started path2
  123358. */
  123359. static StartingAt(x: number, y: number): Path2;
  123360. }
  123361. /**
  123362. * Builds a polygon
  123363. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  123364. */
  123365. export class PolygonMeshBuilder {
  123366. private _points;
  123367. private _outlinepoints;
  123368. private _holes;
  123369. private _name;
  123370. private _scene;
  123371. private _epoints;
  123372. private _eholes;
  123373. private _addToepoint;
  123374. /**
  123375. * Babylon reference to the earcut plugin.
  123376. */
  123377. bjsEarcut: any;
  123378. /**
  123379. * Creates a PolygonMeshBuilder
  123380. * @param name name of the builder
  123381. * @param contours Path of the polygon
  123382. * @param scene scene to add to when creating the mesh
  123383. * @param earcutInjection can be used to inject your own earcut reference
  123384. */
  123385. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  123386. /**
  123387. * Adds a whole within the polygon
  123388. * @param hole Array of points defining the hole
  123389. * @returns this
  123390. */
  123391. addHole(hole: Vector2[]): PolygonMeshBuilder;
  123392. /**
  123393. * Creates the polygon
  123394. * @param updatable If the mesh should be updatable
  123395. * @param depth The depth of the mesh created
  123396. * @returns the created mesh
  123397. */
  123398. build(updatable?: boolean, depth?: number): Mesh;
  123399. /**
  123400. * Creates the polygon
  123401. * @param depth The depth of the mesh created
  123402. * @returns the created VertexData
  123403. */
  123404. buildVertexData(depth?: number): VertexData;
  123405. /**
  123406. * Adds a side to the polygon
  123407. * @param positions points that make the polygon
  123408. * @param normals normals of the polygon
  123409. * @param uvs uvs of the polygon
  123410. * @param indices indices of the polygon
  123411. * @param bounds bounds of the polygon
  123412. * @param points points of the polygon
  123413. * @param depth depth of the polygon
  123414. * @param flip flip of the polygon
  123415. */
  123416. private addSide;
  123417. }
  123418. }
  123419. declare module BABYLON {
  123420. /**
  123421. * Class containing static functions to help procedurally build meshes
  123422. */
  123423. export class PolygonBuilder {
  123424. /**
  123425. * Creates a polygon mesh
  123426. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123427. * * 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
  123428. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123431. * * Remember you can only change the shape positions, not their number when updating a polygon
  123432. * @param name defines the name of the mesh
  123433. * @param options defines the options used to create the mesh
  123434. * @param scene defines the hosting scene
  123435. * @param earcutInjection can be used to inject your own earcut reference
  123436. * @returns the polygon mesh
  123437. */
  123438. static CreatePolygon(name: string, options: {
  123439. shape: Vector3[];
  123440. holes?: Vector3[][];
  123441. depth?: number;
  123442. faceUV?: Vector4[];
  123443. faceColors?: Color4[];
  123444. updatable?: boolean;
  123445. sideOrientation?: number;
  123446. frontUVs?: Vector4;
  123447. backUVs?: Vector4;
  123448. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123449. /**
  123450. * Creates an extruded polygon mesh, with depth in the Y direction.
  123451. * * 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)
  123452. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123453. * @param name defines the name of the mesh
  123454. * @param options defines the options used to create the mesh
  123455. * @param scene defines the hosting scene
  123456. * @param earcutInjection can be used to inject your own earcut reference
  123457. * @returns the polygon mesh
  123458. */
  123459. static ExtrudePolygon(name: string, options: {
  123460. shape: Vector3[];
  123461. holes?: Vector3[][];
  123462. depth?: number;
  123463. faceUV?: Vector4[];
  123464. faceColors?: Color4[];
  123465. updatable?: boolean;
  123466. sideOrientation?: number;
  123467. frontUVs?: Vector4;
  123468. backUVs?: Vector4;
  123469. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123470. }
  123471. }
  123472. declare module BABYLON {
  123473. /**
  123474. * Class containing static functions to help procedurally build meshes
  123475. */
  123476. export class LatheBuilder {
  123477. /**
  123478. * Creates lathe mesh.
  123479. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123480. * * 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
  123481. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123482. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123483. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123484. * * 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
  123485. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123486. * * 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
  123487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123491. * @param name defines the name of the mesh
  123492. * @param options defines the options used to create the mesh
  123493. * @param scene defines the hosting scene
  123494. * @returns the lathe mesh
  123495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123496. */
  123497. static CreateLathe(name: string, options: {
  123498. shape: Vector3[];
  123499. radius?: number;
  123500. tessellation?: number;
  123501. clip?: number;
  123502. arc?: number;
  123503. closed?: boolean;
  123504. updatable?: boolean;
  123505. sideOrientation?: number;
  123506. frontUVs?: Vector4;
  123507. backUVs?: Vector4;
  123508. cap?: number;
  123509. invertUV?: boolean;
  123510. }, scene?: Nullable<Scene>): Mesh;
  123511. }
  123512. }
  123513. declare module BABYLON {
  123514. /**
  123515. * Class containing static functions to help procedurally build meshes
  123516. */
  123517. export class TiledPlaneBuilder {
  123518. /**
  123519. * Creates a tiled plane mesh
  123520. * * The parameter `pattern` will, depending on value, do nothing or
  123521. * * * flip (reflect about central vertical) alternate tiles across and up
  123522. * * * flip every tile on alternate rows
  123523. * * * rotate (180 degs) alternate tiles across and up
  123524. * * * rotate every tile on alternate rows
  123525. * * * flip and rotate alternate tiles across and up
  123526. * * * flip and rotate every tile on alternate rows
  123527. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123528. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123531. * * 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)
  123532. * * 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)
  123533. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123534. * @param name defines the name of the mesh
  123535. * @param options defines the options used to create the mesh
  123536. * @param scene defines the hosting scene
  123537. * @returns the box mesh
  123538. */
  123539. static CreateTiledPlane(name: string, options: {
  123540. pattern?: number;
  123541. tileSize?: number;
  123542. tileWidth?: number;
  123543. tileHeight?: number;
  123544. size?: number;
  123545. width?: number;
  123546. height?: number;
  123547. alignHorizontal?: number;
  123548. alignVertical?: number;
  123549. sideOrientation?: number;
  123550. frontUVs?: Vector4;
  123551. backUVs?: Vector4;
  123552. updatable?: boolean;
  123553. }, scene?: Nullable<Scene>): Mesh;
  123554. }
  123555. }
  123556. declare module BABYLON {
  123557. /**
  123558. * Class containing static functions to help procedurally build meshes
  123559. */
  123560. export class TubeBuilder {
  123561. /**
  123562. * Creates a tube mesh.
  123563. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123564. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123565. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123566. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123567. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123568. * * 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)
  123569. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123570. * * 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
  123571. * * 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
  123572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123576. * @param name defines the name of the mesh
  123577. * @param options defines the options used to create the mesh
  123578. * @param scene defines the hosting scene
  123579. * @returns the tube mesh
  123580. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123581. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123582. */
  123583. static CreateTube(name: string, options: {
  123584. path: Vector3[];
  123585. radius?: number;
  123586. tessellation?: number;
  123587. radiusFunction?: {
  123588. (i: number, distance: number): number;
  123589. };
  123590. cap?: number;
  123591. arc?: number;
  123592. updatable?: boolean;
  123593. sideOrientation?: number;
  123594. frontUVs?: Vector4;
  123595. backUVs?: Vector4;
  123596. instance?: Mesh;
  123597. invertUV?: boolean;
  123598. }, scene?: Nullable<Scene>): Mesh;
  123599. }
  123600. }
  123601. declare module BABYLON {
  123602. /**
  123603. * Class containing static functions to help procedurally build meshes
  123604. */
  123605. export class IcoSphereBuilder {
  123606. /**
  123607. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123608. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123609. * * 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`)
  123610. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123611. * * 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
  123612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123615. * @param name defines the name of the mesh
  123616. * @param options defines the options used to create the mesh
  123617. * @param scene defines the hosting scene
  123618. * @returns the icosahedron mesh
  123619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123620. */
  123621. static CreateIcoSphere(name: string, options: {
  123622. radius?: number;
  123623. radiusX?: number;
  123624. radiusY?: number;
  123625. radiusZ?: number;
  123626. flat?: boolean;
  123627. subdivisions?: number;
  123628. sideOrientation?: number;
  123629. frontUVs?: Vector4;
  123630. backUVs?: Vector4;
  123631. updatable?: boolean;
  123632. }, scene?: Nullable<Scene>): Mesh;
  123633. }
  123634. }
  123635. declare module BABYLON {
  123636. /**
  123637. * Class containing static functions to help procedurally build meshes
  123638. */
  123639. export class DecalBuilder {
  123640. /**
  123641. * Creates a decal mesh.
  123642. * 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
  123643. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123644. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123645. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123646. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123647. * @param name defines the name of the mesh
  123648. * @param sourceMesh defines the mesh where the decal must be applied
  123649. * @param options defines the options used to create the mesh
  123650. * @param scene defines the hosting scene
  123651. * @returns the decal mesh
  123652. * @see https://doc.babylonjs.com/how_to/decals
  123653. */
  123654. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123655. position?: Vector3;
  123656. normal?: Vector3;
  123657. size?: Vector3;
  123658. angle?: number;
  123659. }): Mesh;
  123660. }
  123661. }
  123662. declare module BABYLON {
  123663. /**
  123664. * Class containing static functions to help procedurally build meshes
  123665. */
  123666. export class MeshBuilder {
  123667. /**
  123668. * Creates a box mesh
  123669. * * The parameter `size` sets the size (float) of each box side (default 1)
  123670. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123671. * * 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)
  123672. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123676. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123677. * @param name defines the name of the mesh
  123678. * @param options defines the options used to create the mesh
  123679. * @param scene defines the hosting scene
  123680. * @returns the box mesh
  123681. */
  123682. static CreateBox(name: string, options: {
  123683. size?: number;
  123684. width?: number;
  123685. height?: number;
  123686. depth?: number;
  123687. faceUV?: Vector4[];
  123688. faceColors?: Color4[];
  123689. sideOrientation?: number;
  123690. frontUVs?: Vector4;
  123691. backUVs?: Vector4;
  123692. updatable?: boolean;
  123693. }, scene?: Nullable<Scene>): Mesh;
  123694. /**
  123695. * Creates a tiled box mesh
  123696. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123698. * @param name defines the name of the mesh
  123699. * @param options defines the options used to create the mesh
  123700. * @param scene defines the hosting scene
  123701. * @returns the tiled box mesh
  123702. */
  123703. static CreateTiledBox(name: string, options: {
  123704. pattern?: number;
  123705. size?: number;
  123706. width?: number;
  123707. height?: number;
  123708. depth: number;
  123709. tileSize?: number;
  123710. tileWidth?: number;
  123711. tileHeight?: number;
  123712. faceUV?: Vector4[];
  123713. faceColors?: Color4[];
  123714. alignHorizontal?: number;
  123715. alignVertical?: number;
  123716. sideOrientation?: number;
  123717. updatable?: boolean;
  123718. }, scene?: Nullable<Scene>): Mesh;
  123719. /**
  123720. * Creates a sphere mesh
  123721. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123722. * * 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`)
  123723. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123724. * * 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
  123725. * * 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)
  123726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123729. * @param name defines the name of the mesh
  123730. * @param options defines the options used to create the mesh
  123731. * @param scene defines the hosting scene
  123732. * @returns the sphere mesh
  123733. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123734. */
  123735. static CreateSphere(name: string, options: {
  123736. segments?: number;
  123737. diameter?: number;
  123738. diameterX?: number;
  123739. diameterY?: number;
  123740. diameterZ?: number;
  123741. arc?: number;
  123742. slice?: number;
  123743. sideOrientation?: number;
  123744. frontUVs?: Vector4;
  123745. backUVs?: Vector4;
  123746. updatable?: boolean;
  123747. }, scene?: Nullable<Scene>): Mesh;
  123748. /**
  123749. * Creates a plane polygonal mesh. By default, this is a disc
  123750. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123751. * * 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
  123752. * * 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
  123753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123756. * @param name defines the name of the mesh
  123757. * @param options defines the options used to create the mesh
  123758. * @param scene defines the hosting scene
  123759. * @returns the plane polygonal mesh
  123760. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123761. */
  123762. static CreateDisc(name: string, options: {
  123763. radius?: number;
  123764. tessellation?: number;
  123765. arc?: number;
  123766. updatable?: boolean;
  123767. sideOrientation?: number;
  123768. frontUVs?: Vector4;
  123769. backUVs?: Vector4;
  123770. }, scene?: Nullable<Scene>): Mesh;
  123771. /**
  123772. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123773. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123774. * * 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`)
  123775. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123776. * * 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
  123777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123780. * @param name defines the name of the mesh
  123781. * @param options defines the options used to create the mesh
  123782. * @param scene defines the hosting scene
  123783. * @returns the icosahedron mesh
  123784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123785. */
  123786. static CreateIcoSphere(name: string, options: {
  123787. radius?: number;
  123788. radiusX?: number;
  123789. radiusY?: number;
  123790. radiusZ?: number;
  123791. flat?: boolean;
  123792. subdivisions?: number;
  123793. sideOrientation?: number;
  123794. frontUVs?: Vector4;
  123795. backUVs?: Vector4;
  123796. updatable?: boolean;
  123797. }, scene?: Nullable<Scene>): Mesh;
  123798. /**
  123799. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123800. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123801. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123802. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123803. * * 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
  123804. * * 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
  123805. * * 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
  123806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123809. * * 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
  123810. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123811. * * 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
  123812. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123814. * @param name defines the name of the mesh
  123815. * @param options defines the options used to create the mesh
  123816. * @param scene defines the hosting scene
  123817. * @returns the ribbon mesh
  123818. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123820. */
  123821. static CreateRibbon(name: string, options: {
  123822. pathArray: Vector3[][];
  123823. closeArray?: boolean;
  123824. closePath?: boolean;
  123825. offset?: number;
  123826. updatable?: boolean;
  123827. sideOrientation?: number;
  123828. frontUVs?: Vector4;
  123829. backUVs?: Vector4;
  123830. instance?: Mesh;
  123831. invertUV?: boolean;
  123832. uvs?: Vector2[];
  123833. colors?: Color4[];
  123834. }, scene?: Nullable<Scene>): Mesh;
  123835. /**
  123836. * Creates a cylinder or a cone mesh
  123837. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123838. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123839. * * 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.
  123840. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123841. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123842. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123843. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123844. * * 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).
  123845. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123846. * * 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).
  123847. * * 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
  123848. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123849. * * 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
  123850. * * 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.
  123851. * * If `enclose` is false, a ring surface is one element.
  123852. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123853. * * 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
  123854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123857. * @param name defines the name of the mesh
  123858. * @param options defines the options used to create the mesh
  123859. * @param scene defines the hosting scene
  123860. * @returns the cylinder mesh
  123861. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123862. */
  123863. static CreateCylinder(name: string, options: {
  123864. height?: number;
  123865. diameterTop?: number;
  123866. diameterBottom?: number;
  123867. diameter?: number;
  123868. tessellation?: number;
  123869. subdivisions?: number;
  123870. arc?: number;
  123871. faceColors?: Color4[];
  123872. faceUV?: Vector4[];
  123873. updatable?: boolean;
  123874. hasRings?: boolean;
  123875. enclose?: boolean;
  123876. cap?: number;
  123877. sideOrientation?: number;
  123878. frontUVs?: Vector4;
  123879. backUVs?: Vector4;
  123880. }, scene?: Nullable<Scene>): Mesh;
  123881. /**
  123882. * Creates a torus mesh
  123883. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123884. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123885. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123889. * @param name defines the name of the mesh
  123890. * @param options defines the options used to create the mesh
  123891. * @param scene defines the hosting scene
  123892. * @returns the torus mesh
  123893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123894. */
  123895. static CreateTorus(name: string, options: {
  123896. diameter?: number;
  123897. thickness?: number;
  123898. tessellation?: number;
  123899. updatable?: boolean;
  123900. sideOrientation?: number;
  123901. frontUVs?: Vector4;
  123902. backUVs?: Vector4;
  123903. }, scene?: Nullable<Scene>): Mesh;
  123904. /**
  123905. * Creates a torus knot mesh
  123906. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123907. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123908. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123909. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123913. * @param name defines the name of the mesh
  123914. * @param options defines the options used to create the mesh
  123915. * @param scene defines the hosting scene
  123916. * @returns the torus knot mesh
  123917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123918. */
  123919. static CreateTorusKnot(name: string, options: {
  123920. radius?: number;
  123921. tube?: number;
  123922. radialSegments?: number;
  123923. tubularSegments?: number;
  123924. p?: number;
  123925. q?: number;
  123926. updatable?: boolean;
  123927. sideOrientation?: number;
  123928. frontUVs?: Vector4;
  123929. backUVs?: Vector4;
  123930. }, scene?: Nullable<Scene>): Mesh;
  123931. /**
  123932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123933. * * 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
  123934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123939. * * 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
  123940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123943. * @param name defines the name of the new line system
  123944. * @param options defines the options used to create the line system
  123945. * @param scene defines the hosting scene
  123946. * @returns a new line system mesh
  123947. */
  123948. static CreateLineSystem(name: string, options: {
  123949. lines: Vector3[][];
  123950. updatable?: boolean;
  123951. instance?: Nullable<LinesMesh>;
  123952. colors?: Nullable<Color4[][]>;
  123953. useVertexAlpha?: boolean;
  123954. }, scene: Nullable<Scene>): LinesMesh;
  123955. /**
  123956. * Creates a line mesh
  123957. * 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
  123958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123959. * * The parameter `points` is an array successive Vector3
  123960. * * 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
  123961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123963. * * When updating an instance, remember that only point positions can change, not the number of points
  123964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123966. * @param name defines the name of the new line system
  123967. * @param options defines the options used to create the line system
  123968. * @param scene defines the hosting scene
  123969. * @returns a new line mesh
  123970. */
  123971. static CreateLines(name: string, options: {
  123972. points: Vector3[];
  123973. updatable?: boolean;
  123974. instance?: Nullable<LinesMesh>;
  123975. colors?: Color4[];
  123976. useVertexAlpha?: boolean;
  123977. }, scene?: Nullable<Scene>): LinesMesh;
  123978. /**
  123979. * Creates a dashed line mesh
  123980. * * 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
  123981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123982. * * The parameter `points` is an array successive Vector3
  123983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123986. * * 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
  123987. * * When updating an instance, remember that only point positions can change, not the number of points
  123988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123989. * @param name defines the name of the mesh
  123990. * @param options defines the options used to create the mesh
  123991. * @param scene defines the hosting scene
  123992. * @returns the dashed line mesh
  123993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123994. */
  123995. static CreateDashedLines(name: string, options: {
  123996. points: Vector3[];
  123997. dashSize?: number;
  123998. gapSize?: number;
  123999. dashNb?: number;
  124000. updatable?: boolean;
  124001. instance?: LinesMesh;
  124002. }, scene?: Nullable<Scene>): LinesMesh;
  124003. /**
  124004. * 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.
  124005. * * 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.
  124006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124007. * * 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.
  124008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124009. * * 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
  124010. * * 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
  124011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124016. * @param name defines the name of the mesh
  124017. * @param options defines the options used to create the mesh
  124018. * @param scene defines the hosting scene
  124019. * @returns the extruded shape mesh
  124020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124022. */
  124023. static ExtrudeShape(name: string, options: {
  124024. shape: Vector3[];
  124025. path: Vector3[];
  124026. scale?: number;
  124027. rotation?: number;
  124028. cap?: number;
  124029. updatable?: boolean;
  124030. sideOrientation?: number;
  124031. frontUVs?: Vector4;
  124032. backUVs?: Vector4;
  124033. instance?: Mesh;
  124034. invertUV?: boolean;
  124035. }, scene?: Nullable<Scene>): Mesh;
  124036. /**
  124037. * Creates an custom extruded shape mesh.
  124038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124039. * * 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.
  124040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124041. * * 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
  124042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124043. * * 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
  124044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124047. * * 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
  124048. * * 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
  124049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124054. * @param name defines the name of the mesh
  124055. * @param options defines the options used to create the mesh
  124056. * @param scene defines the hosting scene
  124057. * @returns the custom extruded shape mesh
  124058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124061. */
  124062. static ExtrudeShapeCustom(name: string, options: {
  124063. shape: Vector3[];
  124064. path: Vector3[];
  124065. scaleFunction?: any;
  124066. rotationFunction?: any;
  124067. ribbonCloseArray?: boolean;
  124068. ribbonClosePath?: boolean;
  124069. cap?: number;
  124070. updatable?: boolean;
  124071. sideOrientation?: number;
  124072. frontUVs?: Vector4;
  124073. backUVs?: Vector4;
  124074. instance?: Mesh;
  124075. invertUV?: boolean;
  124076. }, scene?: Nullable<Scene>): Mesh;
  124077. /**
  124078. * Creates lathe mesh.
  124079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124080. * * 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
  124081. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124082. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124083. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124084. * * 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
  124085. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124086. * * 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
  124087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124091. * @param name defines the name of the mesh
  124092. * @param options defines the options used to create the mesh
  124093. * @param scene defines the hosting scene
  124094. * @returns the lathe mesh
  124095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124096. */
  124097. static CreateLathe(name: string, options: {
  124098. shape: Vector3[];
  124099. radius?: number;
  124100. tessellation?: number;
  124101. clip?: number;
  124102. arc?: number;
  124103. closed?: boolean;
  124104. updatable?: boolean;
  124105. sideOrientation?: number;
  124106. frontUVs?: Vector4;
  124107. backUVs?: Vector4;
  124108. cap?: number;
  124109. invertUV?: boolean;
  124110. }, scene?: Nullable<Scene>): Mesh;
  124111. /**
  124112. * Creates a tiled plane mesh
  124113. * * You can set a limited pattern arrangement with the tiles
  124114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124117. * @param name defines the name of the mesh
  124118. * @param options defines the options used to create the mesh
  124119. * @param scene defines the hosting scene
  124120. * @returns the plane mesh
  124121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124122. */
  124123. static CreateTiledPlane(name: string, options: {
  124124. pattern?: number;
  124125. tileSize?: number;
  124126. tileWidth?: number;
  124127. tileHeight?: number;
  124128. size?: number;
  124129. width?: number;
  124130. height?: number;
  124131. alignHorizontal?: number;
  124132. alignVertical?: number;
  124133. sideOrientation?: number;
  124134. frontUVs?: Vector4;
  124135. backUVs?: Vector4;
  124136. updatable?: boolean;
  124137. }, scene?: Nullable<Scene>): Mesh;
  124138. /**
  124139. * Creates a plane mesh
  124140. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124141. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124142. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124146. * @param name defines the name of the mesh
  124147. * @param options defines the options used to create the mesh
  124148. * @param scene defines the hosting scene
  124149. * @returns the plane mesh
  124150. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124151. */
  124152. static CreatePlane(name: string, options: {
  124153. size?: number;
  124154. width?: number;
  124155. height?: number;
  124156. sideOrientation?: number;
  124157. frontUVs?: Vector4;
  124158. backUVs?: Vector4;
  124159. updatable?: boolean;
  124160. sourcePlane?: Plane;
  124161. }, scene?: Nullable<Scene>): Mesh;
  124162. /**
  124163. * Creates a ground mesh
  124164. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124165. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124167. * @param name defines the name of the mesh
  124168. * @param options defines the options used to create the mesh
  124169. * @param scene defines the hosting scene
  124170. * @returns the ground mesh
  124171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124172. */
  124173. static CreateGround(name: string, options: {
  124174. width?: number;
  124175. height?: number;
  124176. subdivisions?: number;
  124177. subdivisionsX?: number;
  124178. subdivisionsY?: number;
  124179. updatable?: boolean;
  124180. }, scene?: Nullable<Scene>): Mesh;
  124181. /**
  124182. * Creates a tiled ground mesh
  124183. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124184. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124185. * * 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
  124186. * * 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
  124187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124188. * @param name defines the name of the mesh
  124189. * @param options defines the options used to create the mesh
  124190. * @param scene defines the hosting scene
  124191. * @returns the tiled ground mesh
  124192. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124193. */
  124194. static CreateTiledGround(name: string, options: {
  124195. xmin: number;
  124196. zmin: number;
  124197. xmax: number;
  124198. zmax: number;
  124199. subdivisions?: {
  124200. w: number;
  124201. h: number;
  124202. };
  124203. precision?: {
  124204. w: number;
  124205. h: number;
  124206. };
  124207. updatable?: boolean;
  124208. }, scene?: Nullable<Scene>): Mesh;
  124209. /**
  124210. * Creates a ground mesh from a height map
  124211. * * The parameter `url` sets the URL of the height map image resource.
  124212. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124213. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124214. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124215. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124216. * * 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.
  124217. * * 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).
  124218. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124220. * @param name defines the name of the mesh
  124221. * @param url defines the url to the height map
  124222. * @param options defines the options used to create the mesh
  124223. * @param scene defines the hosting scene
  124224. * @returns the ground mesh
  124225. * @see https://doc.babylonjs.com/babylon101/height_map
  124226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124227. */
  124228. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124229. width?: number;
  124230. height?: number;
  124231. subdivisions?: number;
  124232. minHeight?: number;
  124233. maxHeight?: number;
  124234. colorFilter?: Color3;
  124235. alphaFilter?: number;
  124236. updatable?: boolean;
  124237. onReady?: (mesh: GroundMesh) => void;
  124238. }, scene?: Nullable<Scene>): GroundMesh;
  124239. /**
  124240. * Creates a polygon mesh
  124241. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124242. * * 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
  124243. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124246. * * Remember you can only change the shape positions, not their number when updating a polygon
  124247. * @param name defines the name of the mesh
  124248. * @param options defines the options used to create the mesh
  124249. * @param scene defines the hosting scene
  124250. * @param earcutInjection can be used to inject your own earcut reference
  124251. * @returns the polygon mesh
  124252. */
  124253. static CreatePolygon(name: string, options: {
  124254. shape: Vector3[];
  124255. holes?: Vector3[][];
  124256. depth?: number;
  124257. faceUV?: Vector4[];
  124258. faceColors?: Color4[];
  124259. updatable?: boolean;
  124260. sideOrientation?: number;
  124261. frontUVs?: Vector4;
  124262. backUVs?: Vector4;
  124263. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124264. /**
  124265. * Creates an extruded polygon mesh, with depth in the Y direction.
  124266. * * 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)
  124267. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124268. * @param name defines the name of the mesh
  124269. * @param options defines the options used to create the mesh
  124270. * @param scene defines the hosting scene
  124271. * @param earcutInjection can be used to inject your own earcut reference
  124272. * @returns the polygon mesh
  124273. */
  124274. static ExtrudePolygon(name: string, options: {
  124275. shape: Vector3[];
  124276. holes?: Vector3[][];
  124277. depth?: number;
  124278. faceUV?: Vector4[];
  124279. faceColors?: Color4[];
  124280. updatable?: boolean;
  124281. sideOrientation?: number;
  124282. frontUVs?: Vector4;
  124283. backUVs?: Vector4;
  124284. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124285. /**
  124286. * Creates a tube mesh.
  124287. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124288. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124289. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124290. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124291. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124292. * * 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)
  124293. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124294. * * 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
  124295. * * 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
  124296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124300. * @param name defines the name of the mesh
  124301. * @param options defines the options used to create the mesh
  124302. * @param scene defines the hosting scene
  124303. * @returns the tube mesh
  124304. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124305. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124306. */
  124307. static CreateTube(name: string, options: {
  124308. path: Vector3[];
  124309. radius?: number;
  124310. tessellation?: number;
  124311. radiusFunction?: {
  124312. (i: number, distance: number): number;
  124313. };
  124314. cap?: number;
  124315. arc?: number;
  124316. updatable?: boolean;
  124317. sideOrientation?: number;
  124318. frontUVs?: Vector4;
  124319. backUVs?: Vector4;
  124320. instance?: Mesh;
  124321. invertUV?: boolean;
  124322. }, scene?: Nullable<Scene>): Mesh;
  124323. /**
  124324. * Creates a polyhedron mesh
  124325. * * 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
  124326. * * The parameter `size` (positive float, default 1) sets the polygon size
  124327. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  124328. * * 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`
  124329. * * 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
  124330. * * 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)`)
  124331. * * 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
  124332. * * 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
  124333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124336. * @param name defines the name of the mesh
  124337. * @param options defines the options used to create the mesh
  124338. * @param scene defines the hosting scene
  124339. * @returns the polyhedron mesh
  124340. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  124341. */
  124342. static CreatePolyhedron(name: string, options: {
  124343. type?: number;
  124344. size?: number;
  124345. sizeX?: number;
  124346. sizeY?: number;
  124347. sizeZ?: number;
  124348. custom?: any;
  124349. faceUV?: Vector4[];
  124350. faceColors?: Color4[];
  124351. flat?: boolean;
  124352. updatable?: boolean;
  124353. sideOrientation?: number;
  124354. frontUVs?: Vector4;
  124355. backUVs?: Vector4;
  124356. }, scene?: Nullable<Scene>): Mesh;
  124357. /**
  124358. * Creates a decal mesh.
  124359. * 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
  124360. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124361. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124362. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124363. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124364. * @param name defines the name of the mesh
  124365. * @param sourceMesh defines the mesh where the decal must be applied
  124366. * @param options defines the options used to create the mesh
  124367. * @param scene defines the hosting scene
  124368. * @returns the decal mesh
  124369. * @see https://doc.babylonjs.com/how_to/decals
  124370. */
  124371. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124372. position?: Vector3;
  124373. normal?: Vector3;
  124374. size?: Vector3;
  124375. angle?: number;
  124376. }): Mesh;
  124377. }
  124378. }
  124379. declare module BABYLON {
  124380. /**
  124381. * A simplifier interface for future simplification implementations
  124382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124383. */
  124384. export interface ISimplifier {
  124385. /**
  124386. * Simplification of a given mesh according to the given settings.
  124387. * Since this requires computation, it is assumed that the function runs async.
  124388. * @param settings The settings of the simplification, including quality and distance
  124389. * @param successCallback A callback that will be called after the mesh was simplified.
  124390. * @param errorCallback in case of an error, this callback will be called. optional.
  124391. */
  124392. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  124393. }
  124394. /**
  124395. * Expected simplification settings.
  124396. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  124397. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124398. */
  124399. export interface ISimplificationSettings {
  124400. /**
  124401. * Gets or sets the expected quality
  124402. */
  124403. quality: number;
  124404. /**
  124405. * Gets or sets the distance when this optimized version should be used
  124406. */
  124407. distance: number;
  124408. /**
  124409. * Gets an already optimized mesh
  124410. */
  124411. optimizeMesh?: boolean;
  124412. }
  124413. /**
  124414. * Class used to specify simplification options
  124415. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124416. */
  124417. export class SimplificationSettings implements ISimplificationSettings {
  124418. /** expected quality */
  124419. quality: number;
  124420. /** distance when this optimized version should be used */
  124421. distance: number;
  124422. /** already optimized mesh */
  124423. optimizeMesh?: boolean | undefined;
  124424. /**
  124425. * Creates a SimplificationSettings
  124426. * @param quality expected quality
  124427. * @param distance distance when this optimized version should be used
  124428. * @param optimizeMesh already optimized mesh
  124429. */
  124430. constructor(
  124431. /** expected quality */
  124432. quality: number,
  124433. /** distance when this optimized version should be used */
  124434. distance: number,
  124435. /** already optimized mesh */
  124436. optimizeMesh?: boolean | undefined);
  124437. }
  124438. /**
  124439. * Interface used to define a simplification task
  124440. */
  124441. export interface ISimplificationTask {
  124442. /**
  124443. * Array of settings
  124444. */
  124445. settings: Array<ISimplificationSettings>;
  124446. /**
  124447. * Simplification type
  124448. */
  124449. simplificationType: SimplificationType;
  124450. /**
  124451. * Mesh to simplify
  124452. */
  124453. mesh: Mesh;
  124454. /**
  124455. * Callback called on success
  124456. */
  124457. successCallback?: () => void;
  124458. /**
  124459. * Defines if parallel processing can be used
  124460. */
  124461. parallelProcessing: boolean;
  124462. }
  124463. /**
  124464. * Queue used to order the simplification tasks
  124465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124466. */
  124467. export class SimplificationQueue {
  124468. private _simplificationArray;
  124469. /**
  124470. * Gets a boolean indicating that the process is still running
  124471. */
  124472. running: boolean;
  124473. /**
  124474. * Creates a new queue
  124475. */
  124476. constructor();
  124477. /**
  124478. * Adds a new simplification task
  124479. * @param task defines a task to add
  124480. */
  124481. addTask(task: ISimplificationTask): void;
  124482. /**
  124483. * Execute next task
  124484. */
  124485. executeNext(): void;
  124486. /**
  124487. * Execute a simplification task
  124488. * @param task defines the task to run
  124489. */
  124490. runSimplification(task: ISimplificationTask): void;
  124491. private getSimplifier;
  124492. }
  124493. /**
  124494. * The implemented types of simplification
  124495. * At the moment only Quadratic Error Decimation is implemented
  124496. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124497. */
  124498. export enum SimplificationType {
  124499. /** Quadratic error decimation */
  124500. QUADRATIC = 0
  124501. }
  124502. }
  124503. declare module BABYLON {
  124504. interface Scene {
  124505. /** @hidden (Backing field) */
  124506. _simplificationQueue: SimplificationQueue;
  124507. /**
  124508. * Gets or sets the simplification queue attached to the scene
  124509. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124510. */
  124511. simplificationQueue: SimplificationQueue;
  124512. }
  124513. interface Mesh {
  124514. /**
  124515. * Simplify the mesh according to the given array of settings.
  124516. * Function will return immediately and will simplify async
  124517. * @param settings a collection of simplification settings
  124518. * @param parallelProcessing should all levels calculate parallel or one after the other
  124519. * @param simplificationType the type of simplification to run
  124520. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124521. * @returns the current mesh
  124522. */
  124523. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124524. }
  124525. /**
  124526. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124527. * created in a scene
  124528. */
  124529. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124530. /**
  124531. * The component name helpfull to identify the component in the list of scene components.
  124532. */
  124533. readonly name: string;
  124534. /**
  124535. * The scene the component belongs to.
  124536. */
  124537. scene: Scene;
  124538. /**
  124539. * Creates a new instance of the component for the given scene
  124540. * @param scene Defines the scene to register the component in
  124541. */
  124542. constructor(scene: Scene);
  124543. /**
  124544. * Registers the component in a given scene
  124545. */
  124546. register(): void;
  124547. /**
  124548. * Rebuilds the elements related to this component in case of
  124549. * context lost for instance.
  124550. */
  124551. rebuild(): void;
  124552. /**
  124553. * Disposes the component and the associated ressources
  124554. */
  124555. dispose(): void;
  124556. private _beforeCameraUpdate;
  124557. }
  124558. }
  124559. declare module BABYLON {
  124560. /**
  124561. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124562. */
  124563. export interface INavigationEnginePlugin {
  124564. /**
  124565. * plugin name
  124566. */
  124567. name: string;
  124568. /**
  124569. * Creates a navigation mesh
  124570. * @param meshes array of all the geometry used to compute the navigatio mesh
  124571. * @param parameters bunch of parameters used to filter geometry
  124572. */
  124573. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124574. /**
  124575. * Create a navigation mesh debug mesh
  124576. * @param scene is where the mesh will be added
  124577. * @returns debug display mesh
  124578. */
  124579. createDebugNavMesh(scene: Scene): Mesh;
  124580. /**
  124581. * Get a navigation mesh constrained position, closest to the parameter position
  124582. * @param position world position
  124583. * @returns the closest point to position constrained by the navigation mesh
  124584. */
  124585. getClosestPoint(position: Vector3): Vector3;
  124586. /**
  124587. * Get a navigation mesh constrained position, within a particular radius
  124588. * @param position world position
  124589. * @param maxRadius the maximum distance to the constrained world position
  124590. * @returns the closest point to position constrained by the navigation mesh
  124591. */
  124592. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124593. /**
  124594. * Compute the final position from a segment made of destination-position
  124595. * @param position world position
  124596. * @param destination world position
  124597. * @returns the resulting point along the navmesh
  124598. */
  124599. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124600. /**
  124601. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124602. * @param start world position
  124603. * @param end world position
  124604. * @returns array containing world position composing the path
  124605. */
  124606. computePath(start: Vector3, end: Vector3): Vector3[];
  124607. /**
  124608. * If this plugin is supported
  124609. * @returns true if plugin is supported
  124610. */
  124611. isSupported(): boolean;
  124612. /**
  124613. * Create a new Crowd so you can add agents
  124614. * @param maxAgents the maximum agent count in the crowd
  124615. * @param maxAgentRadius the maximum radius an agent can have
  124616. * @param scene to attach the crowd to
  124617. * @returns the crowd you can add agents to
  124618. */
  124619. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124620. /**
  124621. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124622. * The queries will try to find a solution within those bounds
  124623. * default is (1,1,1)
  124624. * @param extent x,y,z value that define the extent around the queries point of reference
  124625. */
  124626. setDefaultQueryExtent(extent: Vector3): void;
  124627. /**
  124628. * Get the Bounding box extent specified by setDefaultQueryExtent
  124629. * @returns the box extent values
  124630. */
  124631. getDefaultQueryExtent(): Vector3;
  124632. /**
  124633. * Release all resources
  124634. */
  124635. dispose(): void;
  124636. }
  124637. /**
  124638. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124639. */
  124640. export interface ICrowd {
  124641. /**
  124642. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124643. * You can attach anything to that node. The node position is updated in the scene update tick.
  124644. * @param pos world position that will be constrained by the navigation mesh
  124645. * @param parameters agent parameters
  124646. * @param transform hooked to the agent that will be update by the scene
  124647. * @returns agent index
  124648. */
  124649. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124650. /**
  124651. * Returns the agent position in world space
  124652. * @param index agent index returned by addAgent
  124653. * @returns world space position
  124654. */
  124655. getAgentPosition(index: number): Vector3;
  124656. /**
  124657. * Gets the agent velocity in world space
  124658. * @param index agent index returned by addAgent
  124659. * @returns world space velocity
  124660. */
  124661. getAgentVelocity(index: number): Vector3;
  124662. /**
  124663. * remove a particular agent previously created
  124664. * @param index agent index returned by addAgent
  124665. */
  124666. removeAgent(index: number): void;
  124667. /**
  124668. * get the list of all agents attached to this crowd
  124669. * @returns list of agent indices
  124670. */
  124671. getAgents(): number[];
  124672. /**
  124673. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124674. * @param deltaTime in seconds
  124675. */
  124676. update(deltaTime: number): void;
  124677. /**
  124678. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124679. * @param index agent index returned by addAgent
  124680. * @param destination targeted world position
  124681. */
  124682. agentGoto(index: number, destination: Vector3): void;
  124683. /**
  124684. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124685. * The queries will try to find a solution within those bounds
  124686. * default is (1,1,1)
  124687. * @param extent x,y,z value that define the extent around the queries point of reference
  124688. */
  124689. setDefaultQueryExtent(extent: Vector3): void;
  124690. /**
  124691. * Get the Bounding box extent specified by setDefaultQueryExtent
  124692. * @returns the box extent values
  124693. */
  124694. getDefaultQueryExtent(): Vector3;
  124695. /**
  124696. * Release all resources
  124697. */
  124698. dispose(): void;
  124699. }
  124700. /**
  124701. * Configures an agent
  124702. */
  124703. export interface IAgentParameters {
  124704. /**
  124705. * Agent radius. [Limit: >= 0]
  124706. */
  124707. radius: number;
  124708. /**
  124709. * Agent height. [Limit: > 0]
  124710. */
  124711. height: number;
  124712. /**
  124713. * Maximum allowed acceleration. [Limit: >= 0]
  124714. */
  124715. maxAcceleration: number;
  124716. /**
  124717. * Maximum allowed speed. [Limit: >= 0]
  124718. */
  124719. maxSpeed: number;
  124720. /**
  124721. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124722. */
  124723. collisionQueryRange: number;
  124724. /**
  124725. * The path visibility optimization range. [Limit: > 0]
  124726. */
  124727. pathOptimizationRange: number;
  124728. /**
  124729. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124730. */
  124731. separationWeight: number;
  124732. }
  124733. /**
  124734. * Configures the navigation mesh creation
  124735. */
  124736. export interface INavMeshParameters {
  124737. /**
  124738. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124739. */
  124740. cs: number;
  124741. /**
  124742. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124743. */
  124744. ch: number;
  124745. /**
  124746. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124747. */
  124748. walkableSlopeAngle: number;
  124749. /**
  124750. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124751. * be considered walkable. [Limit: >= 3] [Units: vx]
  124752. */
  124753. walkableHeight: number;
  124754. /**
  124755. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124756. */
  124757. walkableClimb: number;
  124758. /**
  124759. * The distance to erode/shrink the walkable area of the heightfield away from
  124760. * obstructions. [Limit: >=0] [Units: vx]
  124761. */
  124762. walkableRadius: number;
  124763. /**
  124764. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124765. */
  124766. maxEdgeLen: number;
  124767. /**
  124768. * The maximum distance a simplfied contour's border edges should deviate
  124769. * the original raw contour. [Limit: >=0] [Units: vx]
  124770. */
  124771. maxSimplificationError: number;
  124772. /**
  124773. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124774. */
  124775. minRegionArea: number;
  124776. /**
  124777. * Any regions with a span count smaller than this value will, if possible,
  124778. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124779. */
  124780. mergeRegionArea: number;
  124781. /**
  124782. * The maximum number of vertices allowed for polygons generated during the
  124783. * contour to polygon conversion process. [Limit: >= 3]
  124784. */
  124785. maxVertsPerPoly: number;
  124786. /**
  124787. * Sets the sampling distance to use when generating the detail mesh.
  124788. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124789. */
  124790. detailSampleDist: number;
  124791. /**
  124792. * The maximum distance the detail mesh surface should deviate from heightfield
  124793. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124794. */
  124795. detailSampleMaxError: number;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * RecastJS navigation plugin
  124801. */
  124802. export class RecastJSPlugin implements INavigationEnginePlugin {
  124803. /**
  124804. * Reference to the Recast library
  124805. */
  124806. bjsRECAST: any;
  124807. /**
  124808. * plugin name
  124809. */
  124810. name: string;
  124811. /**
  124812. * the first navmesh created. We might extend this to support multiple navmeshes
  124813. */
  124814. navMesh: any;
  124815. /**
  124816. * Initializes the recastJS plugin
  124817. * @param recastInjection can be used to inject your own recast reference
  124818. */
  124819. constructor(recastInjection?: any);
  124820. /**
  124821. * Creates a navigation mesh
  124822. * @param meshes array of all the geometry used to compute the navigatio mesh
  124823. * @param parameters bunch of parameters used to filter geometry
  124824. */
  124825. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124826. /**
  124827. * Create a navigation mesh debug mesh
  124828. * @param scene is where the mesh will be added
  124829. * @returns debug display mesh
  124830. */
  124831. createDebugNavMesh(scene: Scene): Mesh;
  124832. /**
  124833. * Get a navigation mesh constrained position, closest to the parameter position
  124834. * @param position world position
  124835. * @returns the closest point to position constrained by the navigation mesh
  124836. */
  124837. getClosestPoint(position: Vector3): Vector3;
  124838. /**
  124839. * Get a navigation mesh constrained position, within a particular radius
  124840. * @param position world position
  124841. * @param maxRadius the maximum distance to the constrained world position
  124842. * @returns the closest point to position constrained by the navigation mesh
  124843. */
  124844. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124845. /**
  124846. * Compute the final position from a segment made of destination-position
  124847. * @param position world position
  124848. * @param destination world position
  124849. * @returns the resulting point along the navmesh
  124850. */
  124851. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124852. /**
  124853. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124854. * @param start world position
  124855. * @param end world position
  124856. * @returns array containing world position composing the path
  124857. */
  124858. computePath(start: Vector3, end: Vector3): Vector3[];
  124859. /**
  124860. * Create a new Crowd so you can add agents
  124861. * @param maxAgents the maximum agent count in the crowd
  124862. * @param maxAgentRadius the maximum radius an agent can have
  124863. * @param scene to attach the crowd to
  124864. * @returns the crowd you can add agents to
  124865. */
  124866. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124867. /**
  124868. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124869. * The queries will try to find a solution within those bounds
  124870. * default is (1,1,1)
  124871. * @param extent x,y,z value that define the extent around the queries point of reference
  124872. */
  124873. setDefaultQueryExtent(extent: Vector3): void;
  124874. /**
  124875. * Get the Bounding box extent specified by setDefaultQueryExtent
  124876. * @returns the box extent values
  124877. */
  124878. getDefaultQueryExtent(): Vector3;
  124879. /**
  124880. * Disposes
  124881. */
  124882. dispose(): void;
  124883. /**
  124884. * If this plugin is supported
  124885. * @returns true if plugin is supported
  124886. */
  124887. isSupported(): boolean;
  124888. }
  124889. /**
  124890. * Recast detour crowd implementation
  124891. */
  124892. export class RecastJSCrowd implements ICrowd {
  124893. /**
  124894. * Recast/detour plugin
  124895. */
  124896. bjsRECASTPlugin: RecastJSPlugin;
  124897. /**
  124898. * Link to the detour crowd
  124899. */
  124900. recastCrowd: any;
  124901. /**
  124902. * One transform per agent
  124903. */
  124904. transforms: TransformNode[];
  124905. /**
  124906. * All agents created
  124907. */
  124908. agents: number[];
  124909. /**
  124910. * Link to the scene is kept to unregister the crowd from the scene
  124911. */
  124912. private _scene;
  124913. /**
  124914. * Observer for crowd updates
  124915. */
  124916. private _onBeforeAnimationsObserver;
  124917. /**
  124918. * Constructor
  124919. * @param plugin recastJS plugin
  124920. * @param maxAgents the maximum agent count in the crowd
  124921. * @param maxAgentRadius the maximum radius an agent can have
  124922. * @param scene to attach the crowd to
  124923. * @returns the crowd you can add agents to
  124924. */
  124925. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124926. /**
  124927. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124928. * You can attach anything to that node. The node position is updated in the scene update tick.
  124929. * @param pos world position that will be constrained by the navigation mesh
  124930. * @param parameters agent parameters
  124931. * @param transform hooked to the agent that will be update by the scene
  124932. * @returns agent index
  124933. */
  124934. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124935. /**
  124936. * Returns the agent position in world space
  124937. * @param index agent index returned by addAgent
  124938. * @returns world space position
  124939. */
  124940. getAgentPosition(index: number): Vector3;
  124941. /**
  124942. * Returns the agent velocity in world space
  124943. * @param index agent index returned by addAgent
  124944. * @returns world space velocity
  124945. */
  124946. getAgentVelocity(index: number): Vector3;
  124947. /**
  124948. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124949. * @param index agent index returned by addAgent
  124950. * @param destination targeted world position
  124951. */
  124952. agentGoto(index: number, destination: Vector3): void;
  124953. /**
  124954. * remove a particular agent previously created
  124955. * @param index agent index returned by addAgent
  124956. */
  124957. removeAgent(index: number): void;
  124958. /**
  124959. * get the list of all agents attached to this crowd
  124960. * @returns list of agent indices
  124961. */
  124962. getAgents(): number[];
  124963. /**
  124964. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124965. * @param deltaTime in seconds
  124966. */
  124967. update(deltaTime: number): void;
  124968. /**
  124969. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124970. * The queries will try to find a solution within those bounds
  124971. * default is (1,1,1)
  124972. * @param extent x,y,z value that define the extent around the queries point of reference
  124973. */
  124974. setDefaultQueryExtent(extent: Vector3): void;
  124975. /**
  124976. * Get the Bounding box extent specified by setDefaultQueryExtent
  124977. * @returns the box extent values
  124978. */
  124979. getDefaultQueryExtent(): Vector3;
  124980. /**
  124981. * Release all resources
  124982. */
  124983. dispose(): void;
  124984. }
  124985. }
  124986. declare module BABYLON {
  124987. /**
  124988. * Class used to enable access to IndexedDB
  124989. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124990. */
  124991. export class Database implements IOfflineProvider {
  124992. private _callbackManifestChecked;
  124993. private _currentSceneUrl;
  124994. private _db;
  124995. private _enableSceneOffline;
  124996. private _enableTexturesOffline;
  124997. private _manifestVersionFound;
  124998. private _mustUpdateRessources;
  124999. private _hasReachedQuota;
  125000. private _isSupported;
  125001. private _idbFactory;
  125002. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125003. private static IsUASupportingBlobStorage;
  125004. /**
  125005. * Gets a boolean indicating if Database storate is enabled (off by default)
  125006. */
  125007. static IDBStorageEnabled: boolean;
  125008. /**
  125009. * Gets a boolean indicating if scene must be saved in the database
  125010. */
  125011. readonly enableSceneOffline: boolean;
  125012. /**
  125013. * Gets a boolean indicating if textures must be saved in the database
  125014. */
  125015. readonly enableTexturesOffline: boolean;
  125016. /**
  125017. * Creates a new Database
  125018. * @param urlToScene defines the url to load the scene
  125019. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125020. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125021. */
  125022. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125023. private static _ParseURL;
  125024. private static _ReturnFullUrlLocation;
  125025. private _checkManifestFile;
  125026. /**
  125027. * Open the database and make it available
  125028. * @param successCallback defines the callback to call on success
  125029. * @param errorCallback defines the callback to call on error
  125030. */
  125031. open(successCallback: () => void, errorCallback: () => void): void;
  125032. /**
  125033. * Loads an image from the database
  125034. * @param url defines the url to load from
  125035. * @param image defines the target DOM image
  125036. */
  125037. loadImage(url: string, image: HTMLImageElement): void;
  125038. private _loadImageFromDBAsync;
  125039. private _saveImageIntoDBAsync;
  125040. private _checkVersionFromDB;
  125041. private _loadVersionFromDBAsync;
  125042. private _saveVersionIntoDBAsync;
  125043. /**
  125044. * Loads a file from database
  125045. * @param url defines the URL to load from
  125046. * @param sceneLoaded defines a callback to call on success
  125047. * @param progressCallBack defines a callback to call when progress changed
  125048. * @param errorCallback defines a callback to call on error
  125049. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125050. */
  125051. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125052. private _loadFileAsync;
  125053. private _saveFileAsync;
  125054. /**
  125055. * Validates if xhr data is correct
  125056. * @param xhr defines the request to validate
  125057. * @param dataType defines the expected data type
  125058. * @returns true if data is correct
  125059. */
  125060. private static _ValidateXHRData;
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /** @hidden */
  125065. export var gpuUpdateParticlesPixelShader: {
  125066. name: string;
  125067. shader: string;
  125068. };
  125069. }
  125070. declare module BABYLON {
  125071. /** @hidden */
  125072. export var gpuUpdateParticlesVertexShader: {
  125073. name: string;
  125074. shader: string;
  125075. };
  125076. }
  125077. declare module BABYLON {
  125078. /** @hidden */
  125079. export var clipPlaneFragmentDeclaration2: {
  125080. name: string;
  125081. shader: string;
  125082. };
  125083. }
  125084. declare module BABYLON {
  125085. /** @hidden */
  125086. export var gpuRenderParticlesPixelShader: {
  125087. name: string;
  125088. shader: string;
  125089. };
  125090. }
  125091. declare module BABYLON {
  125092. /** @hidden */
  125093. export var clipPlaneVertexDeclaration2: {
  125094. name: string;
  125095. shader: string;
  125096. };
  125097. }
  125098. declare module BABYLON {
  125099. /** @hidden */
  125100. export var gpuRenderParticlesVertexShader: {
  125101. name: string;
  125102. shader: string;
  125103. };
  125104. }
  125105. declare module BABYLON {
  125106. /**
  125107. * This represents a GPU particle system in Babylon
  125108. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125109. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125110. */
  125111. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125112. /**
  125113. * The layer mask we are rendering the particles through.
  125114. */
  125115. layerMask: number;
  125116. private _capacity;
  125117. private _activeCount;
  125118. private _currentActiveCount;
  125119. private _accumulatedCount;
  125120. private _renderEffect;
  125121. private _updateEffect;
  125122. private _buffer0;
  125123. private _buffer1;
  125124. private _spriteBuffer;
  125125. private _updateVAO;
  125126. private _renderVAO;
  125127. private _targetIndex;
  125128. private _sourceBuffer;
  125129. private _targetBuffer;
  125130. private _engine;
  125131. private _currentRenderId;
  125132. private _started;
  125133. private _stopped;
  125134. private _timeDelta;
  125135. private _randomTexture;
  125136. private _randomTexture2;
  125137. private _attributesStrideSize;
  125138. private _updateEffectOptions;
  125139. private _randomTextureSize;
  125140. private _actualFrame;
  125141. private readonly _rawTextureWidth;
  125142. /**
  125143. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125144. */
  125145. static readonly IsSupported: boolean;
  125146. /**
  125147. * An event triggered when the system is disposed.
  125148. */
  125149. onDisposeObservable: Observable<GPUParticleSystem>;
  125150. /**
  125151. * Gets the maximum number of particles active at the same time.
  125152. * @returns The max number of active particles.
  125153. */
  125154. getCapacity(): number;
  125155. /**
  125156. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125157. * to override the particles.
  125158. */
  125159. forceDepthWrite: boolean;
  125160. /**
  125161. * Gets or set the number of active particles
  125162. */
  125163. activeParticleCount: number;
  125164. private _preWarmDone;
  125165. /**
  125166. * Is this system ready to be used/rendered
  125167. * @return true if the system is ready
  125168. */
  125169. isReady(): boolean;
  125170. /**
  125171. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125172. * @returns True if it has been started, otherwise false.
  125173. */
  125174. isStarted(): boolean;
  125175. /**
  125176. * Starts the particle system and begins to emit
  125177. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125178. */
  125179. start(delay?: number): void;
  125180. /**
  125181. * Stops the particle system.
  125182. */
  125183. stop(): void;
  125184. /**
  125185. * Remove all active particles
  125186. */
  125187. reset(): void;
  125188. /**
  125189. * Returns the string "GPUParticleSystem"
  125190. * @returns a string containing the class name
  125191. */
  125192. getClassName(): string;
  125193. private _colorGradientsTexture;
  125194. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125195. /**
  125196. * Adds a new color gradient
  125197. * @param gradient defines the gradient to use (between 0 and 1)
  125198. * @param color1 defines the color to affect to the specified gradient
  125199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125200. * @returns the current particle system
  125201. */
  125202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125203. /**
  125204. * Remove a specific color gradient
  125205. * @param gradient defines the gradient to remove
  125206. * @returns the current particle system
  125207. */
  125208. removeColorGradient(gradient: number): GPUParticleSystem;
  125209. private _angularSpeedGradientsTexture;
  125210. private _sizeGradientsTexture;
  125211. private _velocityGradientsTexture;
  125212. private _limitVelocityGradientsTexture;
  125213. private _dragGradientsTexture;
  125214. private _addFactorGradient;
  125215. /**
  125216. * Adds a new size gradient
  125217. * @param gradient defines the gradient to use (between 0 and 1)
  125218. * @param factor defines the size factor to affect to the specified gradient
  125219. * @returns the current particle system
  125220. */
  125221. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125222. /**
  125223. * Remove a specific size gradient
  125224. * @param gradient defines the gradient to remove
  125225. * @returns the current particle system
  125226. */
  125227. removeSizeGradient(gradient: number): GPUParticleSystem;
  125228. /**
  125229. * Adds a new angular speed gradient
  125230. * @param gradient defines the gradient to use (between 0 and 1)
  125231. * @param factor defines the angular speed to affect to the specified gradient
  125232. * @returns the current particle system
  125233. */
  125234. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125235. /**
  125236. * Remove a specific angular speed gradient
  125237. * @param gradient defines the gradient to remove
  125238. * @returns the current particle system
  125239. */
  125240. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125241. /**
  125242. * Adds a new velocity gradient
  125243. * @param gradient defines the gradient to use (between 0 and 1)
  125244. * @param factor defines the velocity to affect to the specified gradient
  125245. * @returns the current particle system
  125246. */
  125247. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125248. /**
  125249. * Remove a specific velocity gradient
  125250. * @param gradient defines the gradient to remove
  125251. * @returns the current particle system
  125252. */
  125253. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125254. /**
  125255. * Adds a new limit velocity gradient
  125256. * @param gradient defines the gradient to use (between 0 and 1)
  125257. * @param factor defines the limit velocity value to affect to the specified gradient
  125258. * @returns the current particle system
  125259. */
  125260. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125261. /**
  125262. * Remove a specific limit velocity gradient
  125263. * @param gradient defines the gradient to remove
  125264. * @returns the current particle system
  125265. */
  125266. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125267. /**
  125268. * Adds a new drag gradient
  125269. * @param gradient defines the gradient to use (between 0 and 1)
  125270. * @param factor defines the drag value to affect to the specified gradient
  125271. * @returns the current particle system
  125272. */
  125273. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125274. /**
  125275. * Remove a specific drag gradient
  125276. * @param gradient defines the gradient to remove
  125277. * @returns the current particle system
  125278. */
  125279. removeDragGradient(gradient: number): GPUParticleSystem;
  125280. /**
  125281. * Not supported by GPUParticleSystem
  125282. * @param gradient defines the gradient to use (between 0 and 1)
  125283. * @param factor defines the emit rate value to affect to the specified gradient
  125284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125285. * @returns the current particle system
  125286. */
  125287. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125288. /**
  125289. * Not supported by GPUParticleSystem
  125290. * @param gradient defines the gradient to remove
  125291. * @returns the current particle system
  125292. */
  125293. removeEmitRateGradient(gradient: number): IParticleSystem;
  125294. /**
  125295. * Not supported by GPUParticleSystem
  125296. * @param gradient defines the gradient to use (between 0 and 1)
  125297. * @param factor defines the start size value to affect to the specified gradient
  125298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125299. * @returns the current particle system
  125300. */
  125301. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125302. /**
  125303. * Not supported by GPUParticleSystem
  125304. * @param gradient defines the gradient to remove
  125305. * @returns the current particle system
  125306. */
  125307. removeStartSizeGradient(gradient: number): IParticleSystem;
  125308. /**
  125309. * Not supported by GPUParticleSystem
  125310. * @param gradient defines the gradient to use (between 0 and 1)
  125311. * @param min defines the color remap minimal range
  125312. * @param max defines the color remap maximal range
  125313. * @returns the current particle system
  125314. */
  125315. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125316. /**
  125317. * Not supported by GPUParticleSystem
  125318. * @param gradient defines the gradient to remove
  125319. * @returns the current particle system
  125320. */
  125321. removeColorRemapGradient(): IParticleSystem;
  125322. /**
  125323. * Not supported by GPUParticleSystem
  125324. * @param gradient defines the gradient to use (between 0 and 1)
  125325. * @param min defines the alpha remap minimal range
  125326. * @param max defines the alpha remap maximal range
  125327. * @returns the current particle system
  125328. */
  125329. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  125330. /**
  125331. * Not supported by GPUParticleSystem
  125332. * @param gradient defines the gradient to remove
  125333. * @returns the current particle system
  125334. */
  125335. removeAlphaRemapGradient(): IParticleSystem;
  125336. /**
  125337. * Not supported by GPUParticleSystem
  125338. * @param gradient defines the gradient to use (between 0 and 1)
  125339. * @param color defines the color to affect to the specified gradient
  125340. * @returns the current particle system
  125341. */
  125342. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  125343. /**
  125344. * Not supported by GPUParticleSystem
  125345. * @param gradient defines the gradient to remove
  125346. * @returns the current particle system
  125347. */
  125348. removeRampGradient(): IParticleSystem;
  125349. /**
  125350. * Not supported by GPUParticleSystem
  125351. * @returns the list of ramp gradients
  125352. */
  125353. getRampGradients(): Nullable<Array<Color3Gradient>>;
  125354. /**
  125355. * Not supported by GPUParticleSystem
  125356. * Gets or sets a boolean indicating that ramp gradients must be used
  125357. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  125358. */
  125359. useRampGradients: boolean;
  125360. /**
  125361. * Not supported by GPUParticleSystem
  125362. * @param gradient defines the gradient to use (between 0 and 1)
  125363. * @param factor defines the life time factor to affect to the specified gradient
  125364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125365. * @returns the current particle system
  125366. */
  125367. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125368. /**
  125369. * Not supported by GPUParticleSystem
  125370. * @param gradient defines the gradient to remove
  125371. * @returns the current particle system
  125372. */
  125373. removeLifeTimeGradient(gradient: number): IParticleSystem;
  125374. /**
  125375. * Instantiates a GPU particle system.
  125376. * 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.
  125377. * @param name The name of the particle system
  125378. * @param options The options used to create the system
  125379. * @param scene The scene the particle system belongs to
  125380. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  125381. */
  125382. constructor(name: string, options: Partial<{
  125383. capacity: number;
  125384. randomTextureSize: number;
  125385. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  125386. protected _reset(): void;
  125387. private _createUpdateVAO;
  125388. private _createRenderVAO;
  125389. private _initialize;
  125390. /** @hidden */
  125391. _recreateUpdateEffect(): void;
  125392. /** @hidden */
  125393. _recreateRenderEffect(): void;
  125394. /**
  125395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  125396. * @param preWarm defines if we are in the pre-warmimg phase
  125397. */
  125398. animate(preWarm?: boolean): void;
  125399. private _createFactorGradientTexture;
  125400. private _createSizeGradientTexture;
  125401. private _createAngularSpeedGradientTexture;
  125402. private _createVelocityGradientTexture;
  125403. private _createLimitVelocityGradientTexture;
  125404. private _createDragGradientTexture;
  125405. private _createColorGradientTexture;
  125406. /**
  125407. * Renders the particle system in its current state
  125408. * @param preWarm defines if the system should only update the particles but not render them
  125409. * @returns the current number of particles
  125410. */
  125411. render(preWarm?: boolean): number;
  125412. /**
  125413. * Rebuilds the particle system
  125414. */
  125415. rebuild(): void;
  125416. private _releaseBuffers;
  125417. private _releaseVAOs;
  125418. /**
  125419. * Disposes the particle system and free the associated resources
  125420. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  125421. */
  125422. dispose(disposeTexture?: boolean): void;
  125423. /**
  125424. * Clones the particle system.
  125425. * @param name The name of the cloned object
  125426. * @param newEmitter The new emitter to use
  125427. * @returns the cloned particle system
  125428. */
  125429. clone(name: string, newEmitter: any): GPUParticleSystem;
  125430. /**
  125431. * Serializes the particle system to a JSON object.
  125432. * @returns the JSON object
  125433. */
  125434. serialize(): any;
  125435. /**
  125436. * Parses a JSON object to create a GPU particle system.
  125437. * @param parsedParticleSystem The JSON object to parse
  125438. * @param scene The scene to create the particle system in
  125439. * @param rootUrl The root url to use to load external dependencies like texture
  125440. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  125441. * @returns the parsed GPU particle system
  125442. */
  125443. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  125444. }
  125445. }
  125446. declare module BABYLON {
  125447. /**
  125448. * Represents a set of particle systems working together to create a specific effect
  125449. */
  125450. export class ParticleSystemSet implements IDisposable {
  125451. private _emitterCreationOptions;
  125452. private _emitterNode;
  125453. /**
  125454. * Gets the particle system list
  125455. */
  125456. systems: IParticleSystem[];
  125457. /**
  125458. * Gets the emitter node used with this set
  125459. */
  125460. readonly emitterNode: Nullable<TransformNode>;
  125461. /**
  125462. * Creates a new emitter mesh as a sphere
  125463. * @param options defines the options used to create the sphere
  125464. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125465. * @param scene defines the hosting scene
  125466. */
  125467. setEmitterAsSphere(options: {
  125468. diameter: number;
  125469. segments: number;
  125470. color: Color3;
  125471. }, renderingGroupId: number, scene: Scene): void;
  125472. /**
  125473. * Starts all particle systems of the set
  125474. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125475. */
  125476. start(emitter?: AbstractMesh): void;
  125477. /**
  125478. * Release all associated resources
  125479. */
  125480. dispose(): void;
  125481. /**
  125482. * Serialize the set into a JSON compatible object
  125483. * @returns a JSON compatible representation of the set
  125484. */
  125485. serialize(): any;
  125486. /**
  125487. * Parse a new ParticleSystemSet from a serialized source
  125488. * @param data defines a JSON compatible representation of the set
  125489. * @param scene defines the hosting scene
  125490. * @param gpu defines if we want GPU particles or CPU particles
  125491. * @returns a new ParticleSystemSet
  125492. */
  125493. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125494. }
  125495. }
  125496. declare module BABYLON {
  125497. /**
  125498. * This class is made for on one-liner static method to help creating particle system set.
  125499. */
  125500. export class ParticleHelper {
  125501. /**
  125502. * Gets or sets base Assets URL
  125503. */
  125504. static BaseAssetsUrl: string;
  125505. /**
  125506. * Create a default particle system that you can tweak
  125507. * @param emitter defines the emitter to use
  125508. * @param capacity defines the system capacity (default is 500 particles)
  125509. * @param scene defines the hosting scene
  125510. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125511. * @returns the new Particle system
  125512. */
  125513. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125514. /**
  125515. * This is the main static method (one-liner) of this helper to create different particle systems
  125516. * @param type This string represents the type to the particle system to create
  125517. * @param scene The scene where the particle system should live
  125518. * @param gpu If the system will use gpu
  125519. * @returns the ParticleSystemSet created
  125520. */
  125521. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125522. /**
  125523. * Static function used to export a particle system to a ParticleSystemSet variable.
  125524. * Please note that the emitter shape is not exported
  125525. * @param systems defines the particle systems to export
  125526. * @returns the created particle system set
  125527. */
  125528. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125529. }
  125530. }
  125531. declare module BABYLON {
  125532. interface Engine {
  125533. /**
  125534. * Create an effect to use with particle systems.
  125535. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125536. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125537. * @param uniformsNames defines a list of attribute names
  125538. * @param samplers defines an array of string used to represent textures
  125539. * @param defines defines the string containing the defines to use to compile the shaders
  125540. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125541. * @param onCompiled defines a function to call when the effect creation is successful
  125542. * @param onError defines a function to call when the effect creation has failed
  125543. * @returns the new Effect
  125544. */
  125545. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125546. }
  125547. interface Mesh {
  125548. /**
  125549. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125550. * @returns an array of IParticleSystem
  125551. */
  125552. getEmittedParticleSystems(): IParticleSystem[];
  125553. /**
  125554. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125555. * @returns an array of IParticleSystem
  125556. */
  125557. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125558. }
  125559. /**
  125560. * @hidden
  125561. */
  125562. export var _IDoNeedToBeInTheBuild: number;
  125563. }
  125564. declare module BABYLON {
  125565. /** Defines the 4 color options */
  125566. export enum PointColor {
  125567. /** color value */
  125568. Color = 2,
  125569. /** uv value */
  125570. UV = 1,
  125571. /** random value */
  125572. Random = 0,
  125573. /** stated value */
  125574. Stated = 3
  125575. }
  125576. /**
  125577. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  125578. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  125579. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  125580. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  125581. *
  125582. * Full documentation here : TO BE ENTERED
  125583. */
  125584. export class PointsCloudSystem implements IDisposable {
  125585. /**
  125586. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  125587. * Example : var p = SPS.particles[i];
  125588. */
  125589. particles: CloudPoint[];
  125590. /**
  125591. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  125592. */
  125593. nbParticles: number;
  125594. /**
  125595. * This a counter for your own usage. It's not set by any SPS functions.
  125596. */
  125597. counter: number;
  125598. /**
  125599. * The PCS name. This name is also given to the underlying mesh.
  125600. */
  125601. name: string;
  125602. /**
  125603. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  125604. */
  125605. mesh: Mesh;
  125606. /**
  125607. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  125608. * Please read :
  125609. */
  125610. vars: any;
  125611. /**
  125612. * @hidden
  125613. */
  125614. _size: number;
  125615. private _scene;
  125616. private _promises;
  125617. private _positions;
  125618. private _indices;
  125619. private _normals;
  125620. private _colors;
  125621. private _uvs;
  125622. private _indices32;
  125623. private _positions32;
  125624. private _colors32;
  125625. private _uvs32;
  125626. private _updatable;
  125627. private _isVisibilityBoxLocked;
  125628. private _alwaysVisible;
  125629. private _groups;
  125630. private _groupCounter;
  125631. private _computeParticleColor;
  125632. private _computeParticleTexture;
  125633. private _computeParticleRotation;
  125634. private _computeBoundingBox;
  125635. private _isReady;
  125636. /**
  125637. * Creates a PCS (Points Cloud System) object
  125638. * @param name (String) is the PCS name, this will be the underlying mesh name
  125639. * @param pointSize (number) is the size for each point
  125640. * @param scene (Scene) is the scene in which the PCS is added
  125641. * @param options defines the options of the PCS e.g.
  125642. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  125643. */
  125644. constructor(name: string, pointSize: number, scene: Scene, options?: {
  125645. updatable?: boolean;
  125646. });
  125647. /**
  125648. * Builds the PCS underlying mesh. Returns a standard Mesh.
  125649. * If no points were added to the PCS, the returned mesh is just a single point.
  125650. * @returns a promise for the created mesh
  125651. */
  125652. buildMeshAsync(): Promise<Mesh>;
  125653. /**
  125654. * @hidden
  125655. */
  125656. private _buildMesh;
  125657. private _addParticle;
  125658. private _randomUnitVector;
  125659. private _getColorIndicesForCoord;
  125660. private _setPointsColorOrUV;
  125661. private _colorFromTexture;
  125662. private _calculateDensity;
  125663. /**
  125664. * Adds points to the PCS in random positions within a unit sphere
  125665. * @param nb (positive integer) the number of particles to be created from this model
  125666. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  125667. * @returns the number of groups in the system
  125668. */
  125669. addPoints(nb: number, pointFunction?: any): number;
  125670. /**
  125671. * Adds points to the PCS from the surface of the model shape
  125672. * @param mesh is any Mesh object that will be used as a surface model for the points
  125673. * @param nb (positive integer) the number of particles to be created from this model
  125674. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  125675. * @param color (color3) to be used when colorWith is stated
  125676. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125677. * @returns the number of groups in the system
  125678. */
  125679. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125680. /**
  125681. * Adds points to the PCS inside the model shape
  125682. * @param mesh is any Mesh object that will be used as a surface model for the points
  125683. * @param nb (positive integer) the number of particles to be created from this model
  125684. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  125685. * @param color (color4) to be used when colorWith is stated
  125686. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  125687. * @returns the number of groups in the system
  125688. */
  125689. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  125690. /**
  125691. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  125692. * This method calls `updateParticle()` for each particle of the SPS.
  125693. * For an animated SPS, it is usually called within the render loop.
  125694. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  125695. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  125696. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  125697. * @returns the PCS.
  125698. */
  125699. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  125700. /**
  125701. * Disposes the PCS.
  125702. */
  125703. dispose(): void;
  125704. /**
  125705. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  125706. * doc :
  125707. * @returns the PCS.
  125708. */
  125709. refreshVisibleSize(): PointsCloudSystem;
  125710. /**
  125711. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  125712. * @param size the size (float) of the visibility box
  125713. * note : this doesn't lock the PCS mesh bounding box.
  125714. * doc :
  125715. */
  125716. setVisibilityBox(size: number): void;
  125717. /**
  125718. * Gets whether the PCS is always visible or not
  125719. * doc :
  125720. */
  125721. /**
  125722. * Sets the PCS as always visible or not
  125723. * doc :
  125724. */
  125725. isAlwaysVisible: boolean;
  125726. /**
  125727. * Tells to `setParticles()` to compute the particle rotations or not
  125728. * Default value : false. The PCS is faster when it's set to false
  125729. * Note : particle rotations are only applied to parent particles
  125730. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  125731. */
  125732. computeParticleRotation: boolean;
  125733. /**
  125734. * Tells to `setParticles()` to compute the particle colors or not.
  125735. * Default value : true. The PCS is faster when it's set to false.
  125736. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125737. */
  125738. /**
  125739. * Gets if `setParticles()` computes the particle colors or not.
  125740. * Default value : false. The PCS is faster when it's set to false.
  125741. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  125742. */
  125743. computeParticleColor: boolean;
  125744. /**
  125745. * Gets if `setParticles()` computes the particle textures or not.
  125746. * Default value : false. The PCS is faster when it's set to false.
  125747. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  125748. */
  125749. computeParticleTexture: boolean;
  125750. /**
  125751. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  125752. */
  125753. /**
  125754. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  125755. */
  125756. computeBoundingBox: boolean;
  125757. /**
  125758. * This function does nothing. It may be overwritten to set all the particle first values.
  125759. * The PCS doesn't call this function, you may have to call it by your own.
  125760. * doc :
  125761. */
  125762. initParticles(): void;
  125763. /**
  125764. * This function does nothing. It may be overwritten to recycle a particle
  125765. * The PCS doesn't call this function, you can to call it
  125766. * doc :
  125767. * @param particle The particle to recycle
  125768. * @returns the recycled particle
  125769. */
  125770. recycleParticle(particle: CloudPoint): CloudPoint;
  125771. /**
  125772. * Updates a particle : this function should be overwritten by the user.
  125773. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  125774. * doc :
  125775. * @example : just set a particle position or velocity and recycle conditions
  125776. * @param particle The particle to update
  125777. * @returns the updated particle
  125778. */
  125779. updateParticle(particle: CloudPoint): CloudPoint;
  125780. /**
  125781. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  125782. * This does nothing and may be overwritten by the user.
  125783. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125784. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125785. * @param update the boolean update value actually passed to setParticles()
  125786. */
  125787. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125788. /**
  125789. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  125790. * This will be passed three parameters.
  125791. * This does nothing and may be overwritten by the user.
  125792. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  125793. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  125794. * @param update the boolean update value actually passed to setParticles()
  125795. */
  125796. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  125797. }
  125798. }
  125799. declare module BABYLON {
  125800. /**
  125801. * Represents one particle of a points cloud system.
  125802. */
  125803. export class CloudPoint {
  125804. /**
  125805. * particle global index
  125806. */
  125807. idx: number;
  125808. /**
  125809. * The color of the particle
  125810. */
  125811. color: Nullable<Color4>;
  125812. /**
  125813. * The world space position of the particle.
  125814. */
  125815. position: Vector3;
  125816. /**
  125817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  125818. */
  125819. rotation: Vector3;
  125820. /**
  125821. * The world space rotation quaternion of the particle.
  125822. */
  125823. rotationQuaternion: Nullable<Quaternion>;
  125824. /**
  125825. * The uv of the particle.
  125826. */
  125827. uv: Nullable<Vector2>;
  125828. /**
  125829. * The current speed of the particle.
  125830. */
  125831. velocity: Vector3;
  125832. /**
  125833. * The pivot point in the particle local space.
  125834. */
  125835. pivot: Vector3;
  125836. /**
  125837. * Must the particle be translated from its pivot point in its local space ?
  125838. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  125839. * Default : false
  125840. */
  125841. translateFromPivot: boolean;
  125842. /**
  125843. * Index of this particle in the global "positions" array (Internal use)
  125844. * @hidden
  125845. */
  125846. _pos: number;
  125847. /**
  125848. * @hidden Index of this particle in the global "indices" array (Internal use)
  125849. */
  125850. _ind: number;
  125851. /**
  125852. * Group this particle belongs to
  125853. */
  125854. _group: PointsGroup;
  125855. /**
  125856. * Group id of this particle
  125857. */
  125858. groupId: number;
  125859. /**
  125860. * Index of the particle in its group id (Internal use)
  125861. */
  125862. idxInGroup: number;
  125863. /**
  125864. * @hidden Particle BoundingInfo object (Internal use)
  125865. */
  125866. _boundingInfo: BoundingInfo;
  125867. /**
  125868. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  125869. */
  125870. _pcs: PointsCloudSystem;
  125871. /**
  125872. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  125873. */
  125874. _stillInvisible: boolean;
  125875. /**
  125876. * @hidden Last computed particle rotation matrix
  125877. */
  125878. _rotationMatrix: number[];
  125879. /**
  125880. * Parent particle Id, if any.
  125881. * Default null.
  125882. */
  125883. parentId: Nullable<number>;
  125884. /**
  125885. * @hidden Internal global position in the PCS.
  125886. */
  125887. _globalPosition: Vector3;
  125888. /**
  125889. * Creates a Point Cloud object.
  125890. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  125891. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  125892. * @param group (PointsGroup) is the group the particle belongs to
  125893. * @param groupId (integer) is the group identifier in the PCS.
  125894. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  125895. * @param pcs defines the PCS it is associated to
  125896. */
  125897. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  125898. /**
  125899. * get point size
  125900. */
  125901. /**
  125902. * Set point size
  125903. */
  125904. size: Vector3;
  125905. /**
  125906. * Legacy support, changed quaternion to rotationQuaternion
  125907. */
  125908. /**
  125909. * Legacy support, changed quaternion to rotationQuaternion
  125910. */
  125911. quaternion: Nullable<Quaternion>;
  125912. /**
  125913. * Returns a boolean. True if the particle intersects a mesh, else false
  125914. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  125915. * @param target is the object (point or mesh) what the intersection is computed against
  125916. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  125917. * @returns true if it intersects
  125918. */
  125919. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  125920. /**
  125921. * get the rotation matrix of the particle
  125922. * @hidden
  125923. */
  125924. getRotationMatrix(m: Matrix): void;
  125925. }
  125926. /**
  125927. * Represents a group of points in a points cloud system
  125928. * * PCS internal tool, don't use it manually.
  125929. */
  125930. export class PointsGroup {
  125931. /**
  125932. * The group id
  125933. * @hidden
  125934. */
  125935. groupID: number;
  125936. /**
  125937. * image data for group (internal use)
  125938. * @hidden
  125939. */
  125940. _groupImageData: Nullable<ArrayBufferView>;
  125941. /**
  125942. * Image Width (internal use)
  125943. * @hidden
  125944. */
  125945. _groupImgWidth: number;
  125946. /**
  125947. * Image Height (internal use)
  125948. * @hidden
  125949. */
  125950. _groupImgHeight: number;
  125951. /**
  125952. * Custom position function (internal use)
  125953. * @hidden
  125954. */
  125955. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  125956. /**
  125957. * density per facet for surface points
  125958. * @hidden
  125959. */
  125960. _groupDensity: number[];
  125961. /**
  125962. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  125963. * PCS internal tool, don't use it manually.
  125964. * @hidden
  125965. */
  125966. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  125967. }
  125968. }
  125969. declare module BABYLON {
  125970. interface Scene {
  125971. /** @hidden (Backing field) */
  125972. _physicsEngine: Nullable<IPhysicsEngine>;
  125973. /**
  125974. * Gets the current physics engine
  125975. * @returns a IPhysicsEngine or null if none attached
  125976. */
  125977. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125978. /**
  125979. * Enables physics to the current scene
  125980. * @param gravity defines the scene's gravity for the physics engine
  125981. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125982. * @return a boolean indicating if the physics engine was initialized
  125983. */
  125984. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125985. /**
  125986. * Disables and disposes the physics engine associated with the scene
  125987. */
  125988. disablePhysicsEngine(): void;
  125989. /**
  125990. * Gets a boolean indicating if there is an active physics engine
  125991. * @returns a boolean indicating if there is an active physics engine
  125992. */
  125993. isPhysicsEnabled(): boolean;
  125994. /**
  125995. * Deletes a physics compound impostor
  125996. * @param compound defines the compound to delete
  125997. */
  125998. deleteCompoundImpostor(compound: any): void;
  125999. /**
  126000. * An event triggered when physic simulation is about to be run
  126001. */
  126002. onBeforePhysicsObservable: Observable<Scene>;
  126003. /**
  126004. * An event triggered when physic simulation has been done
  126005. */
  126006. onAfterPhysicsObservable: Observable<Scene>;
  126007. }
  126008. interface AbstractMesh {
  126009. /** @hidden */
  126010. _physicsImpostor: Nullable<PhysicsImpostor>;
  126011. /**
  126012. * Gets or sets impostor used for physic simulation
  126013. * @see http://doc.babylonjs.com/features/physics_engine
  126014. */
  126015. physicsImpostor: Nullable<PhysicsImpostor>;
  126016. /**
  126017. * Gets the current physics impostor
  126018. * @see http://doc.babylonjs.com/features/physics_engine
  126019. * @returns a physics impostor or null
  126020. */
  126021. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126022. /** Apply a physic impulse to the mesh
  126023. * @param force defines the force to apply
  126024. * @param contactPoint defines where to apply the force
  126025. * @returns the current mesh
  126026. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126027. */
  126028. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126029. /**
  126030. * Creates a physic joint between two meshes
  126031. * @param otherMesh defines the other mesh to use
  126032. * @param pivot1 defines the pivot to use on this mesh
  126033. * @param pivot2 defines the pivot to use on the other mesh
  126034. * @param options defines additional options (can be plugin dependent)
  126035. * @returns the current mesh
  126036. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126037. */
  126038. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126039. /** @hidden */
  126040. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126041. }
  126042. /**
  126043. * Defines the physics engine scene component responsible to manage a physics engine
  126044. */
  126045. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126046. /**
  126047. * The component name helpful to identify the component in the list of scene components.
  126048. */
  126049. readonly name: string;
  126050. /**
  126051. * The scene the component belongs to.
  126052. */
  126053. scene: Scene;
  126054. /**
  126055. * Creates a new instance of the component for the given scene
  126056. * @param scene Defines the scene to register the component in
  126057. */
  126058. constructor(scene: Scene);
  126059. /**
  126060. * Registers the component in a given scene
  126061. */
  126062. register(): void;
  126063. /**
  126064. * Rebuilds the elements related to this component in case of
  126065. * context lost for instance.
  126066. */
  126067. rebuild(): void;
  126068. /**
  126069. * Disposes the component and the associated ressources
  126070. */
  126071. dispose(): void;
  126072. }
  126073. }
  126074. declare module BABYLON {
  126075. /**
  126076. * A helper for physics simulations
  126077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126078. */
  126079. export class PhysicsHelper {
  126080. private _scene;
  126081. private _physicsEngine;
  126082. /**
  126083. * Initializes the Physics helper
  126084. * @param scene Babylon.js scene
  126085. */
  126086. constructor(scene: Scene);
  126087. /**
  126088. * Applies a radial explosion impulse
  126089. * @param origin the origin of the explosion
  126090. * @param radiusOrEventOptions the radius or the options of radial explosion
  126091. * @param strength the explosion strength
  126092. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126093. * @returns A physics radial explosion event, or null
  126094. */
  126095. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126096. /**
  126097. * Applies a radial explosion force
  126098. * @param origin the origin of the explosion
  126099. * @param radiusOrEventOptions the radius or the options of radial explosion
  126100. * @param strength the explosion strength
  126101. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126102. * @returns A physics radial explosion event, or null
  126103. */
  126104. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126105. /**
  126106. * Creates a gravitational field
  126107. * @param origin the origin of the explosion
  126108. * @param radiusOrEventOptions the radius or the options of radial explosion
  126109. * @param strength the explosion strength
  126110. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126111. * @returns A physics gravitational field event, or null
  126112. */
  126113. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126114. /**
  126115. * Creates a physics updraft event
  126116. * @param origin the origin of the updraft
  126117. * @param radiusOrEventOptions the radius or the options of the updraft
  126118. * @param strength the strength of the updraft
  126119. * @param height the height of the updraft
  126120. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126121. * @returns A physics updraft event, or null
  126122. */
  126123. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126124. /**
  126125. * Creates a physics vortex event
  126126. * @param origin the of the vortex
  126127. * @param radiusOrEventOptions the radius or the options of the vortex
  126128. * @param strength the strength of the vortex
  126129. * @param height the height of the vortex
  126130. * @returns a Physics vortex event, or null
  126131. * A physics vortex event or null
  126132. */
  126133. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126134. }
  126135. /**
  126136. * Represents a physics radial explosion event
  126137. */
  126138. class PhysicsRadialExplosionEvent {
  126139. private _scene;
  126140. private _options;
  126141. private _sphere;
  126142. private _dataFetched;
  126143. /**
  126144. * Initializes a radial explosioin event
  126145. * @param _scene BabylonJS scene
  126146. * @param _options The options for the vortex event
  126147. */
  126148. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126149. /**
  126150. * Returns the data related to the radial explosion event (sphere).
  126151. * @returns The radial explosion event data
  126152. */
  126153. getData(): PhysicsRadialExplosionEventData;
  126154. /**
  126155. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126156. * @param impostor A physics imposter
  126157. * @param origin the origin of the explosion
  126158. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126159. */
  126160. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126161. /**
  126162. * Triggers affecterd impostors callbacks
  126163. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126164. */
  126165. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126166. /**
  126167. * Disposes the sphere.
  126168. * @param force Specifies if the sphere should be disposed by force
  126169. */
  126170. dispose(force?: boolean): void;
  126171. /*** Helpers ***/
  126172. private _prepareSphere;
  126173. private _intersectsWithSphere;
  126174. }
  126175. /**
  126176. * Represents a gravitational field event
  126177. */
  126178. class PhysicsGravitationalFieldEvent {
  126179. private _physicsHelper;
  126180. private _scene;
  126181. private _origin;
  126182. private _options;
  126183. private _tickCallback;
  126184. private _sphere;
  126185. private _dataFetched;
  126186. /**
  126187. * Initializes the physics gravitational field event
  126188. * @param _physicsHelper A physics helper
  126189. * @param _scene BabylonJS scene
  126190. * @param _origin The origin position of the gravitational field event
  126191. * @param _options The options for the vortex event
  126192. */
  126193. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126194. /**
  126195. * Returns the data related to the gravitational field event (sphere).
  126196. * @returns A gravitational field event
  126197. */
  126198. getData(): PhysicsGravitationalFieldEventData;
  126199. /**
  126200. * Enables the gravitational field.
  126201. */
  126202. enable(): void;
  126203. /**
  126204. * Disables the gravitational field.
  126205. */
  126206. disable(): void;
  126207. /**
  126208. * Disposes the sphere.
  126209. * @param force The force to dispose from the gravitational field event
  126210. */
  126211. dispose(force?: boolean): void;
  126212. private _tick;
  126213. }
  126214. /**
  126215. * Represents a physics updraft event
  126216. */
  126217. class PhysicsUpdraftEvent {
  126218. private _scene;
  126219. private _origin;
  126220. private _options;
  126221. private _physicsEngine;
  126222. private _originTop;
  126223. private _originDirection;
  126224. private _tickCallback;
  126225. private _cylinder;
  126226. private _cylinderPosition;
  126227. private _dataFetched;
  126228. /**
  126229. * Initializes the physics updraft event
  126230. * @param _scene BabylonJS scene
  126231. * @param _origin The origin position of the updraft
  126232. * @param _options The options for the updraft event
  126233. */
  126234. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126235. /**
  126236. * Returns the data related to the updraft event (cylinder).
  126237. * @returns A physics updraft event
  126238. */
  126239. getData(): PhysicsUpdraftEventData;
  126240. /**
  126241. * Enables the updraft.
  126242. */
  126243. enable(): void;
  126244. /**
  126245. * Disables the updraft.
  126246. */
  126247. disable(): void;
  126248. /**
  126249. * Disposes the cylinder.
  126250. * @param force Specifies if the updraft should be disposed by force
  126251. */
  126252. dispose(force?: boolean): void;
  126253. private getImpostorHitData;
  126254. private _tick;
  126255. /*** Helpers ***/
  126256. private _prepareCylinder;
  126257. private _intersectsWithCylinder;
  126258. }
  126259. /**
  126260. * Represents a physics vortex event
  126261. */
  126262. class PhysicsVortexEvent {
  126263. private _scene;
  126264. private _origin;
  126265. private _options;
  126266. private _physicsEngine;
  126267. private _originTop;
  126268. private _tickCallback;
  126269. private _cylinder;
  126270. private _cylinderPosition;
  126271. private _dataFetched;
  126272. /**
  126273. * Initializes the physics vortex event
  126274. * @param _scene The BabylonJS scene
  126275. * @param _origin The origin position of the vortex
  126276. * @param _options The options for the vortex event
  126277. */
  126278. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126279. /**
  126280. * Returns the data related to the vortex event (cylinder).
  126281. * @returns The physics vortex event data
  126282. */
  126283. getData(): PhysicsVortexEventData;
  126284. /**
  126285. * Enables the vortex.
  126286. */
  126287. enable(): void;
  126288. /**
  126289. * Disables the cortex.
  126290. */
  126291. disable(): void;
  126292. /**
  126293. * Disposes the sphere.
  126294. * @param force
  126295. */
  126296. dispose(force?: boolean): void;
  126297. private getImpostorHitData;
  126298. private _tick;
  126299. /*** Helpers ***/
  126300. private _prepareCylinder;
  126301. private _intersectsWithCylinder;
  126302. }
  126303. /**
  126304. * Options fot the radial explosion event
  126305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126306. */
  126307. export class PhysicsRadialExplosionEventOptions {
  126308. /**
  126309. * The radius of the sphere for the radial explosion.
  126310. */
  126311. radius: number;
  126312. /**
  126313. * The strenth of the explosion.
  126314. */
  126315. strength: number;
  126316. /**
  126317. * The strenght of the force in correspondence to the distance of the affected object
  126318. */
  126319. falloff: PhysicsRadialImpulseFalloff;
  126320. /**
  126321. * Sphere options for the radial explosion.
  126322. */
  126323. sphere: {
  126324. segments: number;
  126325. diameter: number;
  126326. };
  126327. /**
  126328. * Sphere options for the radial explosion.
  126329. */
  126330. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  126331. }
  126332. /**
  126333. * Options fot the updraft event
  126334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126335. */
  126336. export class PhysicsUpdraftEventOptions {
  126337. /**
  126338. * The radius of the cylinder for the vortex
  126339. */
  126340. radius: number;
  126341. /**
  126342. * The strenth of the updraft.
  126343. */
  126344. strength: number;
  126345. /**
  126346. * The height of the cylinder for the updraft.
  126347. */
  126348. height: number;
  126349. /**
  126350. * The mode for the the updraft.
  126351. */
  126352. updraftMode: PhysicsUpdraftMode;
  126353. }
  126354. /**
  126355. * Options fot the vortex event
  126356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126357. */
  126358. export class PhysicsVortexEventOptions {
  126359. /**
  126360. * The radius of the cylinder for the vortex
  126361. */
  126362. radius: number;
  126363. /**
  126364. * The strenth of the vortex.
  126365. */
  126366. strength: number;
  126367. /**
  126368. * The height of the cylinder for the vortex.
  126369. */
  126370. height: number;
  126371. /**
  126372. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  126373. */
  126374. centripetalForceThreshold: number;
  126375. /**
  126376. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  126377. */
  126378. centripetalForceMultiplier: number;
  126379. /**
  126380. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  126381. */
  126382. centrifugalForceMultiplier: number;
  126383. /**
  126384. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  126385. */
  126386. updraftForceMultiplier: number;
  126387. }
  126388. /**
  126389. * The strenght of the force in correspondence to the distance of the affected object
  126390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126391. */
  126392. export enum PhysicsRadialImpulseFalloff {
  126393. /** Defines that impulse is constant in strength across it's whole radius */
  126394. Constant = 0,
  126395. /** Defines that impulse gets weaker if it's further from the origin */
  126396. Linear = 1
  126397. }
  126398. /**
  126399. * The strength of the force in correspondence to the distance of the affected object
  126400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126401. */
  126402. export enum PhysicsUpdraftMode {
  126403. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  126404. Center = 0,
  126405. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  126406. Perpendicular = 1
  126407. }
  126408. /**
  126409. * Interface for a physics hit data
  126410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126411. */
  126412. export interface PhysicsHitData {
  126413. /**
  126414. * The force applied at the contact point
  126415. */
  126416. force: Vector3;
  126417. /**
  126418. * The contact point
  126419. */
  126420. contactPoint: Vector3;
  126421. /**
  126422. * The distance from the origin to the contact point
  126423. */
  126424. distanceFromOrigin: number;
  126425. }
  126426. /**
  126427. * Interface for radial explosion event data
  126428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126429. */
  126430. export interface PhysicsRadialExplosionEventData {
  126431. /**
  126432. * A sphere used for the radial explosion event
  126433. */
  126434. sphere: Mesh;
  126435. }
  126436. /**
  126437. * Interface for gravitational field event data
  126438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126439. */
  126440. export interface PhysicsGravitationalFieldEventData {
  126441. /**
  126442. * A sphere mesh used for the gravitational field event
  126443. */
  126444. sphere: Mesh;
  126445. }
  126446. /**
  126447. * Interface for updraft event data
  126448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126449. */
  126450. export interface PhysicsUpdraftEventData {
  126451. /**
  126452. * A cylinder used for the updraft event
  126453. */
  126454. cylinder: Mesh;
  126455. }
  126456. /**
  126457. * Interface for vortex event data
  126458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126459. */
  126460. export interface PhysicsVortexEventData {
  126461. /**
  126462. * A cylinder used for the vortex event
  126463. */
  126464. cylinder: Mesh;
  126465. }
  126466. /**
  126467. * Interface for an affected physics impostor
  126468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126469. */
  126470. export interface PhysicsAffectedImpostorWithData {
  126471. /**
  126472. * The impostor affected by the effect
  126473. */
  126474. impostor: PhysicsImpostor;
  126475. /**
  126476. * The data about the hit/horce from the explosion
  126477. */
  126478. hitData: PhysicsHitData;
  126479. }
  126480. }
  126481. declare module BABYLON {
  126482. /** @hidden */
  126483. export var blackAndWhitePixelShader: {
  126484. name: string;
  126485. shader: string;
  126486. };
  126487. }
  126488. declare module BABYLON {
  126489. /**
  126490. * Post process used to render in black and white
  126491. */
  126492. export class BlackAndWhitePostProcess extends PostProcess {
  126493. /**
  126494. * Linear about to convert he result to black and white (default: 1)
  126495. */
  126496. degree: number;
  126497. /**
  126498. * Creates a black and white post process
  126499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  126500. * @param name The name of the effect.
  126501. * @param options The required width/height ratio to downsize to before computing the render pass.
  126502. * @param camera The camera to apply the render pass to.
  126503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126504. * @param engine The engine which the post process will be applied. (default: current engine)
  126505. * @param reusable If the post process can be reused on the same frame. (default: false)
  126506. */
  126507. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126508. }
  126509. }
  126510. declare module BABYLON {
  126511. /**
  126512. * This represents a set of one or more post processes in Babylon.
  126513. * A post process can be used to apply a shader to a texture after it is rendered.
  126514. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126515. */
  126516. export class PostProcessRenderEffect {
  126517. private _postProcesses;
  126518. private _getPostProcesses;
  126519. private _singleInstance;
  126520. private _cameras;
  126521. private _indicesForCamera;
  126522. /**
  126523. * Name of the effect
  126524. * @hidden
  126525. */
  126526. _name: string;
  126527. /**
  126528. * Instantiates a post process render effect.
  126529. * A post process can be used to apply a shader to a texture after it is rendered.
  126530. * @param engine The engine the effect is tied to
  126531. * @param name The name of the effect
  126532. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  126533. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  126534. */
  126535. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  126536. /**
  126537. * Checks if all the post processes in the effect are supported.
  126538. */
  126539. readonly isSupported: boolean;
  126540. /**
  126541. * Updates the current state of the effect
  126542. * @hidden
  126543. */
  126544. _update(): void;
  126545. /**
  126546. * Attaches the effect on cameras
  126547. * @param cameras The camera to attach to.
  126548. * @hidden
  126549. */
  126550. _attachCameras(cameras: Camera): void;
  126551. /**
  126552. * Attaches the effect on cameras
  126553. * @param cameras The camera to attach to.
  126554. * @hidden
  126555. */
  126556. _attachCameras(cameras: Camera[]): void;
  126557. /**
  126558. * Detaches the effect on cameras
  126559. * @param cameras The camera to detatch from.
  126560. * @hidden
  126561. */
  126562. _detachCameras(cameras: Camera): void;
  126563. /**
  126564. * Detatches the effect on cameras
  126565. * @param cameras The camera to detatch from.
  126566. * @hidden
  126567. */
  126568. _detachCameras(cameras: Camera[]): void;
  126569. /**
  126570. * Enables the effect on given cameras
  126571. * @param cameras The camera to enable.
  126572. * @hidden
  126573. */
  126574. _enable(cameras: Camera): void;
  126575. /**
  126576. * Enables the effect on given cameras
  126577. * @param cameras The camera to enable.
  126578. * @hidden
  126579. */
  126580. _enable(cameras: Nullable<Camera[]>): void;
  126581. /**
  126582. * Disables the effect on the given cameras
  126583. * @param cameras The camera to disable.
  126584. * @hidden
  126585. */
  126586. _disable(cameras: Camera): void;
  126587. /**
  126588. * Disables the effect on the given cameras
  126589. * @param cameras The camera to disable.
  126590. * @hidden
  126591. */
  126592. _disable(cameras: Nullable<Camera[]>): void;
  126593. /**
  126594. * Gets a list of the post processes contained in the effect.
  126595. * @param camera The camera to get the post processes on.
  126596. * @returns The list of the post processes in the effect.
  126597. */
  126598. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  126599. }
  126600. }
  126601. declare module BABYLON {
  126602. /** @hidden */
  126603. export var extractHighlightsPixelShader: {
  126604. name: string;
  126605. shader: string;
  126606. };
  126607. }
  126608. declare module BABYLON {
  126609. /**
  126610. * 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.
  126611. */
  126612. export class ExtractHighlightsPostProcess extends PostProcess {
  126613. /**
  126614. * The luminance threshold, pixels below this value will be set to black.
  126615. */
  126616. threshold: number;
  126617. /** @hidden */
  126618. _exposure: number;
  126619. /**
  126620. * Post process which has the input texture to be used when performing highlight extraction
  126621. * @hidden
  126622. */
  126623. _inputPostProcess: Nullable<PostProcess>;
  126624. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126625. }
  126626. }
  126627. declare module BABYLON {
  126628. /** @hidden */
  126629. export var bloomMergePixelShader: {
  126630. name: string;
  126631. shader: string;
  126632. };
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126637. */
  126638. export class BloomMergePostProcess extends PostProcess {
  126639. /** Weight of the bloom to be added to the original input. */
  126640. weight: number;
  126641. /**
  126642. * Creates a new instance of @see BloomMergePostProcess
  126643. * @param name The name of the effect.
  126644. * @param originalFromInput Post process which's input will be used for the merge.
  126645. * @param blurred Blurred highlights post process which's output will be used.
  126646. * @param weight Weight of the bloom to be added to the original input.
  126647. * @param options The required width/height ratio to downsize to before computing the render pass.
  126648. * @param camera The camera to apply the render pass to.
  126649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126650. * @param engine The engine which the post process will be applied. (default: current engine)
  126651. * @param reusable If the post process can be reused on the same frame. (default: false)
  126652. * @param textureType Type of textures used when performing the post process. (default: 0)
  126653. * @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)
  126654. */
  126655. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  126656. /** Weight of the bloom to be added to the original input. */
  126657. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126658. }
  126659. }
  126660. declare module BABYLON {
  126661. /**
  126662. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  126663. */
  126664. export class BloomEffect extends PostProcessRenderEffect {
  126665. private bloomScale;
  126666. /**
  126667. * @hidden Internal
  126668. */
  126669. _effects: Array<PostProcess>;
  126670. /**
  126671. * @hidden Internal
  126672. */
  126673. _downscale: ExtractHighlightsPostProcess;
  126674. private _blurX;
  126675. private _blurY;
  126676. private _merge;
  126677. /**
  126678. * The luminance threshold to find bright areas of the image to bloom.
  126679. */
  126680. threshold: number;
  126681. /**
  126682. * The strength of the bloom.
  126683. */
  126684. weight: number;
  126685. /**
  126686. * Specifies the size of the bloom blur kernel, relative to the final output size
  126687. */
  126688. kernel: number;
  126689. /**
  126690. * Creates a new instance of @see BloomEffect
  126691. * @param scene The scene the effect belongs to.
  126692. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  126693. * @param bloomKernel The size of the kernel to be used when applying the blur.
  126694. * @param bloomWeight The the strength of bloom.
  126695. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126696. * @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)
  126697. */
  126698. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  126699. /**
  126700. * Disposes each of the internal effects for a given camera.
  126701. * @param camera The camera to dispose the effect on.
  126702. */
  126703. disposeEffects(camera: Camera): void;
  126704. /**
  126705. * @hidden Internal
  126706. */
  126707. _updateEffects(): void;
  126708. /**
  126709. * Internal
  126710. * @returns if all the contained post processes are ready.
  126711. * @hidden
  126712. */
  126713. _isReady(): boolean;
  126714. }
  126715. }
  126716. declare module BABYLON {
  126717. /** @hidden */
  126718. export var chromaticAberrationPixelShader: {
  126719. name: string;
  126720. shader: string;
  126721. };
  126722. }
  126723. declare module BABYLON {
  126724. /**
  126725. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  126726. */
  126727. export class ChromaticAberrationPostProcess extends PostProcess {
  126728. /**
  126729. * The amount of seperation of rgb channels (default: 30)
  126730. */
  126731. aberrationAmount: number;
  126732. /**
  126733. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  126734. */
  126735. radialIntensity: number;
  126736. /**
  126737. * 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))
  126738. */
  126739. direction: Vector2;
  126740. /**
  126741. * 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))
  126742. */
  126743. centerPosition: Vector2;
  126744. /**
  126745. * Creates a new instance ChromaticAberrationPostProcess
  126746. * @param name The name of the effect.
  126747. * @param screenWidth The width of the screen to apply the effect on.
  126748. * @param screenHeight The height of the screen to apply the effect on.
  126749. * @param options The required width/height ratio to downsize to before computing the render pass.
  126750. * @param camera The camera to apply the render pass to.
  126751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126752. * @param engine The engine which the post process will be applied. (default: current engine)
  126753. * @param reusable If the post process can be reused on the same frame. (default: false)
  126754. * @param textureType Type of textures used when performing the post process. (default: 0)
  126755. * @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)
  126756. */
  126757. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126758. }
  126759. }
  126760. declare module BABYLON {
  126761. /** @hidden */
  126762. export var circleOfConfusionPixelShader: {
  126763. name: string;
  126764. shader: string;
  126765. };
  126766. }
  126767. declare module BABYLON {
  126768. /**
  126769. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  126770. */
  126771. export class CircleOfConfusionPostProcess extends PostProcess {
  126772. /**
  126773. * 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.
  126774. */
  126775. lensSize: number;
  126776. /**
  126777. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126778. */
  126779. fStop: number;
  126780. /**
  126781. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126782. */
  126783. focusDistance: number;
  126784. /**
  126785. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  126786. */
  126787. focalLength: number;
  126788. private _depthTexture;
  126789. /**
  126790. * Creates a new instance CircleOfConfusionPostProcess
  126791. * @param name The name of the effect.
  126792. * @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.
  126793. * @param options The required width/height ratio to downsize to before computing the render pass.
  126794. * @param camera The camera to apply the render pass to.
  126795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126796. * @param engine The engine which the post process will be applied. (default: current engine)
  126797. * @param reusable If the post process can be reused on the same frame. (default: false)
  126798. * @param textureType Type of textures used when performing the post process. (default: 0)
  126799. * @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)
  126800. */
  126801. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126802. /**
  126803. * 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.
  126804. */
  126805. depthTexture: RenderTargetTexture;
  126806. }
  126807. }
  126808. declare module BABYLON {
  126809. /** @hidden */
  126810. export var colorCorrectionPixelShader: {
  126811. name: string;
  126812. shader: string;
  126813. };
  126814. }
  126815. declare module BABYLON {
  126816. /**
  126817. *
  126818. * This post-process allows the modification of rendered colors by using
  126819. * a 'look-up table' (LUT). This effect is also called Color Grading.
  126820. *
  126821. * The object needs to be provided an url to a texture containing the color
  126822. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  126823. * Use an image editing software to tweak the LUT to match your needs.
  126824. *
  126825. * For an example of a color LUT, see here:
  126826. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  126827. * For explanations on color grading, see here:
  126828. * @see http://udn.epicgames.com/Three/ColorGrading.html
  126829. *
  126830. */
  126831. export class ColorCorrectionPostProcess extends PostProcess {
  126832. private _colorTableTexture;
  126833. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126834. }
  126835. }
  126836. declare module BABYLON {
  126837. /** @hidden */
  126838. export var convolutionPixelShader: {
  126839. name: string;
  126840. shader: string;
  126841. };
  126842. }
  126843. declare module BABYLON {
  126844. /**
  126845. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  126846. * input texture to perform effects such as edge detection or sharpening
  126847. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126848. */
  126849. export class ConvolutionPostProcess extends PostProcess {
  126850. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  126851. kernel: number[];
  126852. /**
  126853. * Creates a new instance ConvolutionPostProcess
  126854. * @param name The name of the effect.
  126855. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  126856. * @param options The required width/height ratio to downsize to before computing the render pass.
  126857. * @param camera The camera to apply the render pass to.
  126858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126859. * @param engine The engine which the post process will be applied. (default: current engine)
  126860. * @param reusable If the post process can be reused on the same frame. (default: false)
  126861. * @param textureType Type of textures used when performing the post process. (default: 0)
  126862. */
  126863. constructor(name: string,
  126864. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  126865. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126866. /**
  126867. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126868. */
  126869. static EdgeDetect0Kernel: number[];
  126870. /**
  126871. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126872. */
  126873. static EdgeDetect1Kernel: number[];
  126874. /**
  126875. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126876. */
  126877. static EdgeDetect2Kernel: number[];
  126878. /**
  126879. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126880. */
  126881. static SharpenKernel: number[];
  126882. /**
  126883. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126884. */
  126885. static EmbossKernel: number[];
  126886. /**
  126887. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126888. */
  126889. static GaussianKernel: number[];
  126890. }
  126891. }
  126892. declare module BABYLON {
  126893. /**
  126894. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126895. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126896. * based on samples that have a large difference in distance than the center pixel.
  126897. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126898. */
  126899. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126900. direction: Vector2;
  126901. /**
  126902. * Creates a new instance CircleOfConfusionPostProcess
  126903. * @param name The name of the effect.
  126904. * @param scene The scene the effect belongs to.
  126905. * @param direction The direction the blur should be applied.
  126906. * @param kernel The size of the kernel used to blur.
  126907. * @param options The required width/height ratio to downsize to before computing the render pass.
  126908. * @param camera The camera to apply the render pass to.
  126909. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126910. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126912. * @param engine The engine which the post process will be applied. (default: current engine)
  126913. * @param reusable If the post process can be reused on the same frame. (default: false)
  126914. * @param textureType Type of textures used when performing the post process. (default: 0)
  126915. * @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)
  126916. */
  126917. 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);
  126918. }
  126919. }
  126920. declare module BABYLON {
  126921. /** @hidden */
  126922. export var depthOfFieldMergePixelShader: {
  126923. name: string;
  126924. shader: string;
  126925. };
  126926. }
  126927. declare module BABYLON {
  126928. /**
  126929. * Options to be set when merging outputs from the default pipeline.
  126930. */
  126931. export class DepthOfFieldMergePostProcessOptions {
  126932. /**
  126933. * The original image to merge on top of
  126934. */
  126935. originalFromInput: PostProcess;
  126936. /**
  126937. * Parameters to perform the merge of the depth of field effect
  126938. */
  126939. depthOfField?: {
  126940. circleOfConfusion: PostProcess;
  126941. blurSteps: Array<PostProcess>;
  126942. };
  126943. /**
  126944. * Parameters to perform the merge of bloom effect
  126945. */
  126946. bloom?: {
  126947. blurred: PostProcess;
  126948. weight: number;
  126949. };
  126950. }
  126951. /**
  126952. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126953. */
  126954. export class DepthOfFieldMergePostProcess extends PostProcess {
  126955. private blurSteps;
  126956. /**
  126957. * Creates a new instance of DepthOfFieldMergePostProcess
  126958. * @param name The name of the effect.
  126959. * @param originalFromInput Post process which's input will be used for the merge.
  126960. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126961. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126962. * @param options The required width/height ratio to downsize to before computing the render pass.
  126963. * @param camera The camera to apply the render pass to.
  126964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126965. * @param engine The engine which the post process will be applied. (default: current engine)
  126966. * @param reusable If the post process can be reused on the same frame. (default: false)
  126967. * @param textureType Type of textures used when performing the post process. (default: 0)
  126968. * @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)
  126969. */
  126970. 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);
  126971. /**
  126972. * Updates the effect with the current post process compile time values and recompiles the shader.
  126973. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126974. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126975. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126976. * @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
  126977. * @param onCompiled Called when the shader has been compiled.
  126978. * @param onError Called if there is an error when compiling a shader.
  126979. */
  126980. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126981. }
  126982. }
  126983. declare module BABYLON {
  126984. /**
  126985. * Specifies the level of max blur that should be applied when using the depth of field effect
  126986. */
  126987. export enum DepthOfFieldEffectBlurLevel {
  126988. /**
  126989. * Subtle blur
  126990. */
  126991. Low = 0,
  126992. /**
  126993. * Medium blur
  126994. */
  126995. Medium = 1,
  126996. /**
  126997. * Large blur
  126998. */
  126999. High = 2
  127000. }
  127001. /**
  127002. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127003. */
  127004. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127005. private _circleOfConfusion;
  127006. /**
  127007. * @hidden Internal, blurs from high to low
  127008. */
  127009. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127010. private _depthOfFieldBlurY;
  127011. private _dofMerge;
  127012. /**
  127013. * @hidden Internal post processes in depth of field effect
  127014. */
  127015. _effects: Array<PostProcess>;
  127016. /**
  127017. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127018. */
  127019. focalLength: number;
  127020. /**
  127021. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127022. */
  127023. fStop: number;
  127024. /**
  127025. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127026. */
  127027. focusDistance: number;
  127028. /**
  127029. * 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.
  127030. */
  127031. lensSize: number;
  127032. /**
  127033. * Creates a new instance DepthOfFieldEffect
  127034. * @param scene The scene the effect belongs to.
  127035. * @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.
  127036. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127037. * @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)
  127038. */
  127039. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127040. /**
  127041. * Get the current class name of the current effet
  127042. * @returns "DepthOfFieldEffect"
  127043. */
  127044. getClassName(): string;
  127045. /**
  127046. * 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.
  127047. */
  127048. depthTexture: RenderTargetTexture;
  127049. /**
  127050. * Disposes each of the internal effects for a given camera.
  127051. * @param camera The camera to dispose the effect on.
  127052. */
  127053. disposeEffects(camera: Camera): void;
  127054. /**
  127055. * @hidden Internal
  127056. */
  127057. _updateEffects(): void;
  127058. /**
  127059. * Internal
  127060. * @returns if all the contained post processes are ready.
  127061. * @hidden
  127062. */
  127063. _isReady(): boolean;
  127064. }
  127065. }
  127066. declare module BABYLON {
  127067. /** @hidden */
  127068. export var displayPassPixelShader: {
  127069. name: string;
  127070. shader: string;
  127071. };
  127072. }
  127073. declare module BABYLON {
  127074. /**
  127075. * DisplayPassPostProcess which produces an output the same as it's input
  127076. */
  127077. export class DisplayPassPostProcess extends PostProcess {
  127078. /**
  127079. * Creates the DisplayPassPostProcess
  127080. * @param name The name of the effect.
  127081. * @param options The required width/height ratio to downsize to before computing the render pass.
  127082. * @param camera The camera to apply the render pass to.
  127083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127084. * @param engine The engine which the post process will be applied. (default: current engine)
  127085. * @param reusable If the post process can be reused on the same frame. (default: false)
  127086. */
  127087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127088. }
  127089. }
  127090. declare module BABYLON {
  127091. /** @hidden */
  127092. export var filterPixelShader: {
  127093. name: string;
  127094. shader: string;
  127095. };
  127096. }
  127097. declare module BABYLON {
  127098. /**
  127099. * Applies a kernel filter to the image
  127100. */
  127101. export class FilterPostProcess extends PostProcess {
  127102. /** The matrix to be applied to the image */
  127103. kernelMatrix: Matrix;
  127104. /**
  127105. *
  127106. * @param name The name of the effect.
  127107. * @param kernelMatrix The matrix to be applied to the image
  127108. * @param options The required width/height ratio to downsize to before computing the render pass.
  127109. * @param camera The camera to apply the render pass to.
  127110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127111. * @param engine The engine which the post process will be applied. (default: current engine)
  127112. * @param reusable If the post process can be reused on the same frame. (default: false)
  127113. */
  127114. constructor(name: string,
  127115. /** The matrix to be applied to the image */
  127116. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127117. }
  127118. }
  127119. declare module BABYLON {
  127120. /** @hidden */
  127121. export var fxaaPixelShader: {
  127122. name: string;
  127123. shader: string;
  127124. };
  127125. }
  127126. declare module BABYLON {
  127127. /** @hidden */
  127128. export var fxaaVertexShader: {
  127129. name: string;
  127130. shader: string;
  127131. };
  127132. }
  127133. declare module BABYLON {
  127134. /**
  127135. * Fxaa post process
  127136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127137. */
  127138. export class FxaaPostProcess extends PostProcess {
  127139. /** @hidden */
  127140. texelWidth: number;
  127141. /** @hidden */
  127142. texelHeight: number;
  127143. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127144. private _getDefines;
  127145. }
  127146. }
  127147. declare module BABYLON {
  127148. /** @hidden */
  127149. export var grainPixelShader: {
  127150. name: string;
  127151. shader: string;
  127152. };
  127153. }
  127154. declare module BABYLON {
  127155. /**
  127156. * The GrainPostProcess adds noise to the image at mid luminance levels
  127157. */
  127158. export class GrainPostProcess extends PostProcess {
  127159. /**
  127160. * The intensity of the grain added (default: 30)
  127161. */
  127162. intensity: number;
  127163. /**
  127164. * If the grain should be randomized on every frame
  127165. */
  127166. animated: boolean;
  127167. /**
  127168. * Creates a new instance of @see GrainPostProcess
  127169. * @param name The name of the effect.
  127170. * @param options The required width/height ratio to downsize to before computing the render pass.
  127171. * @param camera The camera to apply the render pass to.
  127172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127173. * @param engine The engine which the post process will be applied. (default: current engine)
  127174. * @param reusable If the post process can be reused on the same frame. (default: false)
  127175. * @param textureType Type of textures used when performing the post process. (default: 0)
  127176. * @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)
  127177. */
  127178. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127179. }
  127180. }
  127181. declare module BABYLON {
  127182. /** @hidden */
  127183. export var highlightsPixelShader: {
  127184. name: string;
  127185. shader: string;
  127186. };
  127187. }
  127188. declare module BABYLON {
  127189. /**
  127190. * Extracts highlights from the image
  127191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127192. */
  127193. export class HighlightsPostProcess extends PostProcess {
  127194. /**
  127195. * Extracts highlights from the image
  127196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127197. * @param name The name of the effect.
  127198. * @param options The required width/height ratio to downsize to before computing the render pass.
  127199. * @param camera The camera to apply the render pass to.
  127200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127201. * @param engine The engine which the post process will be applied. (default: current engine)
  127202. * @param reusable If the post process can be reused on the same frame. (default: false)
  127203. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127204. */
  127205. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127206. }
  127207. }
  127208. declare module BABYLON {
  127209. /** @hidden */
  127210. export var mrtFragmentDeclaration: {
  127211. name: string;
  127212. shader: string;
  127213. };
  127214. }
  127215. declare module BABYLON {
  127216. /** @hidden */
  127217. export var geometryPixelShader: {
  127218. name: string;
  127219. shader: string;
  127220. };
  127221. }
  127222. declare module BABYLON {
  127223. /** @hidden */
  127224. export var geometryVertexShader: {
  127225. name: string;
  127226. shader: string;
  127227. };
  127228. }
  127229. declare module BABYLON {
  127230. /** @hidden */
  127231. interface ISavedTransformationMatrix {
  127232. world: Matrix;
  127233. viewProjection: Matrix;
  127234. }
  127235. /**
  127236. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127237. */
  127238. export class GeometryBufferRenderer {
  127239. /**
  127240. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127241. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127242. */
  127243. static readonly POSITION_TEXTURE_TYPE: number;
  127244. /**
  127245. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127246. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127247. */
  127248. static readonly VELOCITY_TEXTURE_TYPE: number;
  127249. /**
  127250. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127251. * in order to compute objects velocities when enableVelocity is set to "true"
  127252. * @hidden
  127253. */
  127254. _previousTransformationMatrices: {
  127255. [index: number]: ISavedTransformationMatrix;
  127256. };
  127257. /**
  127258. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127259. * in order to compute objects velocities when enableVelocity is set to "true"
  127260. * @hidden
  127261. */
  127262. _previousBonesTransformationMatrices: {
  127263. [index: number]: Float32Array;
  127264. };
  127265. /**
  127266. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127267. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127268. */
  127269. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127270. private _scene;
  127271. private _multiRenderTarget;
  127272. private _ratio;
  127273. private _enablePosition;
  127274. private _enableVelocity;
  127275. private _positionIndex;
  127276. private _velocityIndex;
  127277. protected _effect: Effect;
  127278. protected _cachedDefines: string;
  127279. /**
  127280. * Set the render list (meshes to be rendered) used in the G buffer.
  127281. */
  127282. renderList: Mesh[];
  127283. /**
  127284. * Gets wether or not G buffer are supported by the running hardware.
  127285. * This requires draw buffer supports
  127286. */
  127287. readonly isSupported: boolean;
  127288. /**
  127289. * Returns the index of the given texture type in the G-Buffer textures array
  127290. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127291. * @returns the index of the given texture type in the G-Buffer textures array
  127292. */
  127293. getTextureIndex(textureType: number): number;
  127294. /**
  127295. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127296. */
  127297. /**
  127298. * Sets whether or not objects positions are enabled for the G buffer.
  127299. */
  127300. enablePosition: boolean;
  127301. /**
  127302. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127303. */
  127304. /**
  127305. * Sets wether or not objects velocities are enabled for the G buffer.
  127306. */
  127307. enableVelocity: boolean;
  127308. /**
  127309. * Gets the scene associated with the buffer.
  127310. */
  127311. readonly scene: Scene;
  127312. /**
  127313. * Gets the ratio used by the buffer during its creation.
  127314. * How big is the buffer related to the main canvas.
  127315. */
  127316. readonly ratio: number;
  127317. /** @hidden */
  127318. static _SceneComponentInitialization: (scene: Scene) => void;
  127319. /**
  127320. * Creates a new G Buffer for the scene
  127321. * @param scene The scene the buffer belongs to
  127322. * @param ratio How big is the buffer related to the main canvas.
  127323. */
  127324. constructor(scene: Scene, ratio?: number);
  127325. /**
  127326. * Checks wether everything is ready to render a submesh to the G buffer.
  127327. * @param subMesh the submesh to check readiness for
  127328. * @param useInstances is the mesh drawn using instance or not
  127329. * @returns true if ready otherwise false
  127330. */
  127331. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127332. /**
  127333. * Gets the current underlying G Buffer.
  127334. * @returns the buffer
  127335. */
  127336. getGBuffer(): MultiRenderTarget;
  127337. /**
  127338. * Gets the number of samples used to render the buffer (anti aliasing).
  127339. */
  127340. /**
  127341. * Sets the number of samples used to render the buffer (anti aliasing).
  127342. */
  127343. samples: number;
  127344. /**
  127345. * Disposes the renderer and frees up associated resources.
  127346. */
  127347. dispose(): void;
  127348. protected _createRenderTargets(): void;
  127349. private _copyBonesTransformationMatrices;
  127350. }
  127351. }
  127352. declare module BABYLON {
  127353. interface Scene {
  127354. /** @hidden (Backing field) */
  127355. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127356. /**
  127357. * Gets or Sets the current geometry buffer associated to the scene.
  127358. */
  127359. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  127360. /**
  127361. * Enables a GeometryBufferRender and associates it with the scene
  127362. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  127363. * @returns the GeometryBufferRenderer
  127364. */
  127365. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  127366. /**
  127367. * Disables the GeometryBufferRender associated with the scene
  127368. */
  127369. disableGeometryBufferRenderer(): void;
  127370. }
  127371. /**
  127372. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127373. * in several rendering techniques.
  127374. */
  127375. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  127376. /**
  127377. * The component name helpful to identify the component in the list of scene components.
  127378. */
  127379. readonly name: string;
  127380. /**
  127381. * The scene the component belongs to.
  127382. */
  127383. scene: Scene;
  127384. /**
  127385. * Creates a new instance of the component for the given scene
  127386. * @param scene Defines the scene to register the component in
  127387. */
  127388. constructor(scene: Scene);
  127389. /**
  127390. * Registers the component in a given scene
  127391. */
  127392. register(): void;
  127393. /**
  127394. * Rebuilds the elements related to this component in case of
  127395. * context lost for instance.
  127396. */
  127397. rebuild(): void;
  127398. /**
  127399. * Disposes the component and the associated ressources
  127400. */
  127401. dispose(): void;
  127402. private _gatherRenderTargets;
  127403. }
  127404. }
  127405. declare module BABYLON {
  127406. /** @hidden */
  127407. export var motionBlurPixelShader: {
  127408. name: string;
  127409. shader: string;
  127410. };
  127411. }
  127412. declare module BABYLON {
  127413. /**
  127414. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  127415. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  127416. * As an example, all you have to do is to create the post-process:
  127417. * var mb = new BABYLON.MotionBlurPostProcess(
  127418. * 'mb', // The name of the effect.
  127419. * scene, // The scene containing the objects to blur according to their velocity.
  127420. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  127421. * camera // The camera to apply the render pass to.
  127422. * );
  127423. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  127424. */
  127425. export class MotionBlurPostProcess extends PostProcess {
  127426. /**
  127427. * Defines how much the image is blurred by the movement. Default value is equal to 1
  127428. */
  127429. motionStrength: number;
  127430. /**
  127431. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  127432. */
  127433. /**
  127434. * Sets the number of iterations to be used for motion blur quality
  127435. */
  127436. motionBlurSamples: number;
  127437. private _motionBlurSamples;
  127438. private _geometryBufferRenderer;
  127439. /**
  127440. * Creates a new instance MotionBlurPostProcess
  127441. * @param name The name of the effect.
  127442. * @param scene The scene containing the objects to blur according to their velocity.
  127443. * @param options The required width/height ratio to downsize to before computing the render pass.
  127444. * @param camera The camera to apply the render pass to.
  127445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127446. * @param engine The engine which the post process will be applied. (default: current engine)
  127447. * @param reusable If the post process can be reused on the same frame. (default: false)
  127448. * @param textureType Type of textures used when performing the post process. (default: 0)
  127449. * @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)
  127450. */
  127451. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127452. /**
  127453. * Excludes the given skinned mesh from computing bones velocities.
  127454. * 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.
  127455. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  127456. */
  127457. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127458. /**
  127459. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  127460. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  127461. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  127462. */
  127463. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  127464. /**
  127465. * Disposes the post process.
  127466. * @param camera The camera to dispose the post process on.
  127467. */
  127468. dispose(camera?: Camera): void;
  127469. }
  127470. }
  127471. declare module BABYLON {
  127472. /** @hidden */
  127473. export var refractionPixelShader: {
  127474. name: string;
  127475. shader: string;
  127476. };
  127477. }
  127478. declare module BABYLON {
  127479. /**
  127480. * Post process which applies a refractin texture
  127481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127482. */
  127483. export class RefractionPostProcess extends PostProcess {
  127484. /** the base color of the refraction (used to taint the rendering) */
  127485. color: Color3;
  127486. /** simulated refraction depth */
  127487. depth: number;
  127488. /** the coefficient of the base color (0 to remove base color tainting) */
  127489. colorLevel: number;
  127490. private _refTexture;
  127491. private _ownRefractionTexture;
  127492. /**
  127493. * Gets or sets the refraction texture
  127494. * Please note that you are responsible for disposing the texture if you set it manually
  127495. */
  127496. refractionTexture: Texture;
  127497. /**
  127498. * Initializes the RefractionPostProcess
  127499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  127500. * @param name The name of the effect.
  127501. * @param refractionTextureUrl Url of the refraction texture to use
  127502. * @param color the base color of the refraction (used to taint the rendering)
  127503. * @param depth simulated refraction depth
  127504. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  127505. * @param camera The camera to apply the render pass to.
  127506. * @param options The required width/height ratio to downsize to before computing the render pass.
  127507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127508. * @param engine The engine which the post process will be applied. (default: current engine)
  127509. * @param reusable If the post process can be reused on the same frame. (default: false)
  127510. */
  127511. constructor(name: string, refractionTextureUrl: string,
  127512. /** the base color of the refraction (used to taint the rendering) */
  127513. color: Color3,
  127514. /** simulated refraction depth */
  127515. depth: number,
  127516. /** the coefficient of the base color (0 to remove base color tainting) */
  127517. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127518. /**
  127519. * Disposes of the post process
  127520. * @param camera Camera to dispose post process on
  127521. */
  127522. dispose(camera: Camera): void;
  127523. }
  127524. }
  127525. declare module BABYLON {
  127526. /** @hidden */
  127527. export var sharpenPixelShader: {
  127528. name: string;
  127529. shader: string;
  127530. };
  127531. }
  127532. declare module BABYLON {
  127533. /**
  127534. * The SharpenPostProcess applies a sharpen kernel to every pixel
  127535. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127536. */
  127537. export class SharpenPostProcess extends PostProcess {
  127538. /**
  127539. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  127540. */
  127541. colorAmount: number;
  127542. /**
  127543. * How much sharpness should be applied (default: 0.3)
  127544. */
  127545. edgeAmount: number;
  127546. /**
  127547. * Creates a new instance ConvolutionPostProcess
  127548. * @param name The name of the effect.
  127549. * @param options The required width/height ratio to downsize to before computing the render pass.
  127550. * @param camera The camera to apply the render pass to.
  127551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127552. * @param engine The engine which the post process will be applied. (default: current engine)
  127553. * @param reusable If the post process can be reused on the same frame. (default: false)
  127554. * @param textureType Type of textures used when performing the post process. (default: 0)
  127555. * @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)
  127556. */
  127557. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127558. }
  127559. }
  127560. declare module BABYLON {
  127561. /**
  127562. * PostProcessRenderPipeline
  127563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127564. */
  127565. export class PostProcessRenderPipeline {
  127566. private engine;
  127567. private _renderEffects;
  127568. private _renderEffectsForIsolatedPass;
  127569. /**
  127570. * List of inspectable custom properties (used by the Inspector)
  127571. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  127572. */
  127573. inspectableCustomProperties: IInspectable[];
  127574. /**
  127575. * @hidden
  127576. */
  127577. protected _cameras: Camera[];
  127578. /** @hidden */
  127579. _name: string;
  127580. /**
  127581. * Gets pipeline name
  127582. */
  127583. readonly name: string;
  127584. /**
  127585. * Initializes a PostProcessRenderPipeline
  127586. * @param engine engine to add the pipeline to
  127587. * @param name name of the pipeline
  127588. */
  127589. constructor(engine: Engine, name: string);
  127590. /**
  127591. * Gets the class name
  127592. * @returns "PostProcessRenderPipeline"
  127593. */
  127594. getClassName(): string;
  127595. /**
  127596. * If all the render effects in the pipeline are supported
  127597. */
  127598. readonly isSupported: boolean;
  127599. /**
  127600. * Adds an effect to the pipeline
  127601. * @param renderEffect the effect to add
  127602. */
  127603. addEffect(renderEffect: PostProcessRenderEffect): void;
  127604. /** @hidden */
  127605. _rebuild(): void;
  127606. /** @hidden */
  127607. _enableEffect(renderEffectName: string, cameras: Camera): void;
  127608. /** @hidden */
  127609. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  127610. /** @hidden */
  127611. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127612. /** @hidden */
  127613. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  127614. /** @hidden */
  127615. _attachCameras(cameras: Camera, unique: boolean): void;
  127616. /** @hidden */
  127617. _attachCameras(cameras: Camera[], unique: boolean): void;
  127618. /** @hidden */
  127619. _detachCameras(cameras: Camera): void;
  127620. /** @hidden */
  127621. _detachCameras(cameras: Nullable<Camera[]>): void;
  127622. /** @hidden */
  127623. _update(): void;
  127624. /** @hidden */
  127625. _reset(): void;
  127626. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  127627. /**
  127628. * Disposes of the pipeline
  127629. */
  127630. dispose(): void;
  127631. }
  127632. }
  127633. declare module BABYLON {
  127634. /**
  127635. * PostProcessRenderPipelineManager class
  127636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127637. */
  127638. export class PostProcessRenderPipelineManager {
  127639. private _renderPipelines;
  127640. /**
  127641. * Initializes a PostProcessRenderPipelineManager
  127642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127643. */
  127644. constructor();
  127645. /**
  127646. * Gets the list of supported render pipelines
  127647. */
  127648. readonly supportedPipelines: PostProcessRenderPipeline[];
  127649. /**
  127650. * Adds a pipeline to the manager
  127651. * @param renderPipeline The pipeline to add
  127652. */
  127653. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  127654. /**
  127655. * Attaches a camera to the pipeline
  127656. * @param renderPipelineName The name of the pipeline to attach to
  127657. * @param cameras the camera to attach
  127658. * @param unique if the camera can be attached multiple times to the pipeline
  127659. */
  127660. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  127661. /**
  127662. * Detaches a camera from the pipeline
  127663. * @param renderPipelineName The name of the pipeline to detach from
  127664. * @param cameras the camera to detach
  127665. */
  127666. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  127667. /**
  127668. * Enables an effect by name on a pipeline
  127669. * @param renderPipelineName the name of the pipeline to enable the effect in
  127670. * @param renderEffectName the name of the effect to enable
  127671. * @param cameras the cameras that the effect should be enabled on
  127672. */
  127673. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127674. /**
  127675. * Disables an effect by name on a pipeline
  127676. * @param renderPipelineName the name of the pipeline to disable the effect in
  127677. * @param renderEffectName the name of the effect to disable
  127678. * @param cameras the cameras that the effect should be disabled on
  127679. */
  127680. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  127681. /**
  127682. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  127683. */
  127684. update(): void;
  127685. /** @hidden */
  127686. _rebuild(): void;
  127687. /**
  127688. * Disposes of the manager and pipelines
  127689. */
  127690. dispose(): void;
  127691. }
  127692. }
  127693. declare module BABYLON {
  127694. interface Scene {
  127695. /** @hidden (Backing field) */
  127696. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127697. /**
  127698. * Gets the postprocess render pipeline manager
  127699. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127700. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127701. */
  127702. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  127703. }
  127704. /**
  127705. * Defines the Render Pipeline scene component responsible to rendering pipelines
  127706. */
  127707. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  127708. /**
  127709. * The component name helpfull to identify the component in the list of scene components.
  127710. */
  127711. readonly name: string;
  127712. /**
  127713. * The scene the component belongs to.
  127714. */
  127715. scene: Scene;
  127716. /**
  127717. * Creates a new instance of the component for the given scene
  127718. * @param scene Defines the scene to register the component in
  127719. */
  127720. constructor(scene: Scene);
  127721. /**
  127722. * Registers the component in a given scene
  127723. */
  127724. register(): void;
  127725. /**
  127726. * Rebuilds the elements related to this component in case of
  127727. * context lost for instance.
  127728. */
  127729. rebuild(): void;
  127730. /**
  127731. * Disposes the component and the associated ressources
  127732. */
  127733. dispose(): void;
  127734. private _gatherRenderTargets;
  127735. }
  127736. }
  127737. declare module BABYLON {
  127738. /**
  127739. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  127740. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  127741. */
  127742. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127743. private _scene;
  127744. private _camerasToBeAttached;
  127745. /**
  127746. * ID of the sharpen post process,
  127747. */
  127748. private readonly SharpenPostProcessId;
  127749. /**
  127750. * @ignore
  127751. * ID of the image processing post process;
  127752. */
  127753. readonly ImageProcessingPostProcessId: string;
  127754. /**
  127755. * @ignore
  127756. * ID of the Fast Approximate Anti-Aliasing post process;
  127757. */
  127758. readonly FxaaPostProcessId: string;
  127759. /**
  127760. * ID of the chromatic aberration post process,
  127761. */
  127762. private readonly ChromaticAberrationPostProcessId;
  127763. /**
  127764. * ID of the grain post process
  127765. */
  127766. private readonly GrainPostProcessId;
  127767. /**
  127768. * Sharpen post process which will apply a sharpen convolution to enhance edges
  127769. */
  127770. sharpen: SharpenPostProcess;
  127771. private _sharpenEffect;
  127772. private bloom;
  127773. /**
  127774. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  127775. */
  127776. depthOfField: DepthOfFieldEffect;
  127777. /**
  127778. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127779. */
  127780. fxaa: FxaaPostProcess;
  127781. /**
  127782. * Image post processing pass used to perform operations such as tone mapping or color grading.
  127783. */
  127784. imageProcessing: ImageProcessingPostProcess;
  127785. /**
  127786. * Chromatic aberration post process which will shift rgb colors in the image
  127787. */
  127788. chromaticAberration: ChromaticAberrationPostProcess;
  127789. private _chromaticAberrationEffect;
  127790. /**
  127791. * Grain post process which add noise to the image
  127792. */
  127793. grain: GrainPostProcess;
  127794. private _grainEffect;
  127795. /**
  127796. * Glow post process which adds a glow to emissive areas of the image
  127797. */
  127798. private _glowLayer;
  127799. /**
  127800. * Animations which can be used to tweak settings over a period of time
  127801. */
  127802. animations: Animation[];
  127803. private _imageProcessingConfigurationObserver;
  127804. private _sharpenEnabled;
  127805. private _bloomEnabled;
  127806. private _depthOfFieldEnabled;
  127807. private _depthOfFieldBlurLevel;
  127808. private _fxaaEnabled;
  127809. private _imageProcessingEnabled;
  127810. private _defaultPipelineTextureType;
  127811. private _bloomScale;
  127812. private _chromaticAberrationEnabled;
  127813. private _grainEnabled;
  127814. private _buildAllowed;
  127815. /**
  127816. * Gets active scene
  127817. */
  127818. readonly scene: Scene;
  127819. /**
  127820. * Enable or disable the sharpen process from the pipeline
  127821. */
  127822. sharpenEnabled: boolean;
  127823. private _resizeObserver;
  127824. private _hardwareScaleLevel;
  127825. private _bloomKernel;
  127826. /**
  127827. * Specifies the size of the bloom blur kernel, relative to the final output size
  127828. */
  127829. bloomKernel: number;
  127830. /**
  127831. * Specifies the weight of the bloom in the final rendering
  127832. */
  127833. private _bloomWeight;
  127834. /**
  127835. * Specifies the luma threshold for the area that will be blurred by the bloom
  127836. */
  127837. private _bloomThreshold;
  127838. private _hdr;
  127839. /**
  127840. * The strength of the bloom.
  127841. */
  127842. bloomWeight: number;
  127843. /**
  127844. * The strength of the bloom.
  127845. */
  127846. bloomThreshold: number;
  127847. /**
  127848. * The scale of the bloom, lower value will provide better performance.
  127849. */
  127850. bloomScale: number;
  127851. /**
  127852. * Enable or disable the bloom from the pipeline
  127853. */
  127854. bloomEnabled: boolean;
  127855. private _rebuildBloom;
  127856. /**
  127857. * If the depth of field is enabled.
  127858. */
  127859. depthOfFieldEnabled: boolean;
  127860. /**
  127861. * Blur level of the depth of field effect. (Higher blur will effect performance)
  127862. */
  127863. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  127864. /**
  127865. * If the anti aliasing is enabled.
  127866. */
  127867. fxaaEnabled: boolean;
  127868. private _samples;
  127869. /**
  127870. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127871. */
  127872. samples: number;
  127873. /**
  127874. * If image processing is enabled.
  127875. */
  127876. imageProcessingEnabled: boolean;
  127877. /**
  127878. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  127879. */
  127880. glowLayerEnabled: boolean;
  127881. /**
  127882. * Gets the glow layer (or null if not defined)
  127883. */
  127884. readonly glowLayer: Nullable<GlowLayer>;
  127885. /**
  127886. * Enable or disable the chromaticAberration process from the pipeline
  127887. */
  127888. chromaticAberrationEnabled: boolean;
  127889. /**
  127890. * Enable or disable the grain process from the pipeline
  127891. */
  127892. grainEnabled: boolean;
  127893. /**
  127894. * @constructor
  127895. * @param name - The rendering pipeline name (default: "")
  127896. * @param hdr - If high dynamic range textures should be used (default: true)
  127897. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127898. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127899. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127900. */
  127901. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127902. /**
  127903. * Get the class name
  127904. * @returns "DefaultRenderingPipeline"
  127905. */
  127906. getClassName(): string;
  127907. /**
  127908. * Force the compilation of the entire pipeline.
  127909. */
  127910. prepare(): void;
  127911. private _hasCleared;
  127912. private _prevPostProcess;
  127913. private _prevPrevPostProcess;
  127914. private _setAutoClearAndTextureSharing;
  127915. private _depthOfFieldSceneObserver;
  127916. private _buildPipeline;
  127917. private _disposePostProcesses;
  127918. /**
  127919. * Adds a camera to the pipeline
  127920. * @param camera the camera to be added
  127921. */
  127922. addCamera(camera: Camera): void;
  127923. /**
  127924. * Removes a camera from the pipeline
  127925. * @param camera the camera to remove
  127926. */
  127927. removeCamera(camera: Camera): void;
  127928. /**
  127929. * Dispose of the pipeline and stop all post processes
  127930. */
  127931. dispose(): void;
  127932. /**
  127933. * Serialize the rendering pipeline (Used when exporting)
  127934. * @returns the serialized object
  127935. */
  127936. serialize(): any;
  127937. /**
  127938. * Parse the serialized pipeline
  127939. * @param source Source pipeline.
  127940. * @param scene The scene to load the pipeline to.
  127941. * @param rootUrl The URL of the serialized pipeline.
  127942. * @returns An instantiated pipeline from the serialized object.
  127943. */
  127944. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127945. }
  127946. }
  127947. declare module BABYLON {
  127948. /** @hidden */
  127949. export var lensHighlightsPixelShader: {
  127950. name: string;
  127951. shader: string;
  127952. };
  127953. }
  127954. declare module BABYLON {
  127955. /** @hidden */
  127956. export var depthOfFieldPixelShader: {
  127957. name: string;
  127958. shader: string;
  127959. };
  127960. }
  127961. declare module BABYLON {
  127962. /**
  127963. * BABYLON.JS Chromatic Aberration GLSL Shader
  127964. * Author: Olivier Guyot
  127965. * Separates very slightly R, G and B colors on the edges of the screen
  127966. * Inspired by Francois Tarlier & Martins Upitis
  127967. */
  127968. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127969. /**
  127970. * @ignore
  127971. * The chromatic aberration PostProcess id in the pipeline
  127972. */
  127973. LensChromaticAberrationEffect: string;
  127974. /**
  127975. * @ignore
  127976. * The highlights enhancing PostProcess id in the pipeline
  127977. */
  127978. HighlightsEnhancingEffect: string;
  127979. /**
  127980. * @ignore
  127981. * The depth-of-field PostProcess id in the pipeline
  127982. */
  127983. LensDepthOfFieldEffect: string;
  127984. private _scene;
  127985. private _depthTexture;
  127986. private _grainTexture;
  127987. private _chromaticAberrationPostProcess;
  127988. private _highlightsPostProcess;
  127989. private _depthOfFieldPostProcess;
  127990. private _edgeBlur;
  127991. private _grainAmount;
  127992. private _chromaticAberration;
  127993. private _distortion;
  127994. private _highlightsGain;
  127995. private _highlightsThreshold;
  127996. private _dofDistance;
  127997. private _dofAperture;
  127998. private _dofDarken;
  127999. private _dofPentagon;
  128000. private _blurNoise;
  128001. /**
  128002. * @constructor
  128003. *
  128004. * Effect parameters are as follow:
  128005. * {
  128006. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128007. * edge_blur: number; // from 0 to x (1 for realism)
  128008. * distortion: number; // from 0 to x (1 for realism)
  128009. * grain_amount: number; // from 0 to 1
  128010. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128011. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128012. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128013. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128014. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128015. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128016. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128017. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128018. * }
  128019. * Note: if an effect parameter is unset, effect is disabled
  128020. *
  128021. * @param name The rendering pipeline name
  128022. * @param parameters - An object containing all parameters (see above)
  128023. * @param scene The scene linked to this pipeline
  128024. * @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)
  128025. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128026. */
  128027. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128028. /**
  128029. * Get the class name
  128030. * @returns "LensRenderingPipeline"
  128031. */
  128032. getClassName(): string;
  128033. /**
  128034. * Gets associated scene
  128035. */
  128036. readonly scene: Scene;
  128037. /**
  128038. * Gets or sets the edge blur
  128039. */
  128040. edgeBlur: number;
  128041. /**
  128042. * Gets or sets the grain amount
  128043. */
  128044. grainAmount: number;
  128045. /**
  128046. * Gets or sets the chromatic aberration amount
  128047. */
  128048. chromaticAberration: number;
  128049. /**
  128050. * Gets or sets the depth of field aperture
  128051. */
  128052. dofAperture: number;
  128053. /**
  128054. * Gets or sets the edge distortion
  128055. */
  128056. edgeDistortion: number;
  128057. /**
  128058. * Gets or sets the depth of field distortion
  128059. */
  128060. dofDistortion: number;
  128061. /**
  128062. * Gets or sets the darken out of focus amount
  128063. */
  128064. darkenOutOfFocus: number;
  128065. /**
  128066. * Gets or sets a boolean indicating if blur noise is enabled
  128067. */
  128068. blurNoise: boolean;
  128069. /**
  128070. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128071. */
  128072. pentagonBokeh: boolean;
  128073. /**
  128074. * Gets or sets the highlight grain amount
  128075. */
  128076. highlightsGain: number;
  128077. /**
  128078. * Gets or sets the highlight threshold
  128079. */
  128080. highlightsThreshold: number;
  128081. /**
  128082. * Sets the amount of blur at the edges
  128083. * @param amount blur amount
  128084. */
  128085. setEdgeBlur(amount: number): void;
  128086. /**
  128087. * Sets edge blur to 0
  128088. */
  128089. disableEdgeBlur(): void;
  128090. /**
  128091. * Sets the amout of grain
  128092. * @param amount Amount of grain
  128093. */
  128094. setGrainAmount(amount: number): void;
  128095. /**
  128096. * Set grain amount to 0
  128097. */
  128098. disableGrain(): void;
  128099. /**
  128100. * Sets the chromatic aberration amount
  128101. * @param amount amount of chromatic aberration
  128102. */
  128103. setChromaticAberration(amount: number): void;
  128104. /**
  128105. * Sets chromatic aberration amount to 0
  128106. */
  128107. disableChromaticAberration(): void;
  128108. /**
  128109. * Sets the EdgeDistortion amount
  128110. * @param amount amount of EdgeDistortion
  128111. */
  128112. setEdgeDistortion(amount: number): void;
  128113. /**
  128114. * Sets edge distortion to 0
  128115. */
  128116. disableEdgeDistortion(): void;
  128117. /**
  128118. * Sets the FocusDistance amount
  128119. * @param amount amount of FocusDistance
  128120. */
  128121. setFocusDistance(amount: number): void;
  128122. /**
  128123. * Disables depth of field
  128124. */
  128125. disableDepthOfField(): void;
  128126. /**
  128127. * Sets the Aperture amount
  128128. * @param amount amount of Aperture
  128129. */
  128130. setAperture(amount: number): void;
  128131. /**
  128132. * Sets the DarkenOutOfFocus amount
  128133. * @param amount amount of DarkenOutOfFocus
  128134. */
  128135. setDarkenOutOfFocus(amount: number): void;
  128136. private _pentagonBokehIsEnabled;
  128137. /**
  128138. * Creates a pentagon bokeh effect
  128139. */
  128140. enablePentagonBokeh(): void;
  128141. /**
  128142. * Disables the pentagon bokeh effect
  128143. */
  128144. disablePentagonBokeh(): void;
  128145. /**
  128146. * Enables noise blur
  128147. */
  128148. enableNoiseBlur(): void;
  128149. /**
  128150. * Disables noise blur
  128151. */
  128152. disableNoiseBlur(): void;
  128153. /**
  128154. * Sets the HighlightsGain amount
  128155. * @param amount amount of HighlightsGain
  128156. */
  128157. setHighlightsGain(amount: number): void;
  128158. /**
  128159. * Sets the HighlightsThreshold amount
  128160. * @param amount amount of HighlightsThreshold
  128161. */
  128162. setHighlightsThreshold(amount: number): void;
  128163. /**
  128164. * Disables highlights
  128165. */
  128166. disableHighlights(): void;
  128167. /**
  128168. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128169. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128170. */
  128171. dispose(disableDepthRender?: boolean): void;
  128172. private _createChromaticAberrationPostProcess;
  128173. private _createHighlightsPostProcess;
  128174. private _createDepthOfFieldPostProcess;
  128175. private _createGrainTexture;
  128176. }
  128177. }
  128178. declare module BABYLON {
  128179. /** @hidden */
  128180. export var ssao2PixelShader: {
  128181. name: string;
  128182. shader: string;
  128183. };
  128184. }
  128185. declare module BABYLON {
  128186. /** @hidden */
  128187. export var ssaoCombinePixelShader: {
  128188. name: string;
  128189. shader: string;
  128190. };
  128191. }
  128192. declare module BABYLON {
  128193. /**
  128194. * Render pipeline to produce ssao effect
  128195. */
  128196. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128197. /**
  128198. * @ignore
  128199. * The PassPostProcess id in the pipeline that contains the original scene color
  128200. */
  128201. SSAOOriginalSceneColorEffect: string;
  128202. /**
  128203. * @ignore
  128204. * The SSAO PostProcess id in the pipeline
  128205. */
  128206. SSAORenderEffect: string;
  128207. /**
  128208. * @ignore
  128209. * The horizontal blur PostProcess id in the pipeline
  128210. */
  128211. SSAOBlurHRenderEffect: string;
  128212. /**
  128213. * @ignore
  128214. * The vertical blur PostProcess id in the pipeline
  128215. */
  128216. SSAOBlurVRenderEffect: string;
  128217. /**
  128218. * @ignore
  128219. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128220. */
  128221. SSAOCombineRenderEffect: string;
  128222. /**
  128223. * The output strength of the SSAO post-process. Default value is 1.0.
  128224. */
  128225. totalStrength: number;
  128226. /**
  128227. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128228. */
  128229. maxZ: number;
  128230. /**
  128231. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128232. */
  128233. minZAspect: number;
  128234. private _samples;
  128235. /**
  128236. * Number of samples used for the SSAO calculations. Default value is 8
  128237. */
  128238. samples: number;
  128239. private _textureSamples;
  128240. /**
  128241. * Number of samples to use for antialiasing
  128242. */
  128243. textureSamples: number;
  128244. /**
  128245. * Ratio object used for SSAO ratio and blur ratio
  128246. */
  128247. private _ratio;
  128248. /**
  128249. * Dynamically generated sphere sampler.
  128250. */
  128251. private _sampleSphere;
  128252. /**
  128253. * Blur filter offsets
  128254. */
  128255. private _samplerOffsets;
  128256. private _expensiveBlur;
  128257. /**
  128258. * If bilateral blur should be used
  128259. */
  128260. expensiveBlur: boolean;
  128261. /**
  128262. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128263. */
  128264. radius: number;
  128265. /**
  128266. * The base color of the SSAO post-process
  128267. * The final result is "base + ssao" between [0, 1]
  128268. */
  128269. base: number;
  128270. /**
  128271. * Support test.
  128272. */
  128273. static readonly IsSupported: boolean;
  128274. private _scene;
  128275. private _depthTexture;
  128276. private _normalTexture;
  128277. private _randomTexture;
  128278. private _originalColorPostProcess;
  128279. private _ssaoPostProcess;
  128280. private _blurHPostProcess;
  128281. private _blurVPostProcess;
  128282. private _ssaoCombinePostProcess;
  128283. private _firstUpdate;
  128284. /**
  128285. * Gets active scene
  128286. */
  128287. readonly scene: Scene;
  128288. /**
  128289. * @constructor
  128290. * @param name The rendering pipeline name
  128291. * @param scene The scene linked to this pipeline
  128292. * @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 }
  128293. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128294. */
  128295. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128296. /**
  128297. * Get the class name
  128298. * @returns "SSAO2RenderingPipeline"
  128299. */
  128300. getClassName(): string;
  128301. /**
  128302. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128303. */
  128304. dispose(disableGeometryBufferRenderer?: boolean): void;
  128305. private _createBlurPostProcess;
  128306. /** @hidden */
  128307. _rebuild(): void;
  128308. private _bits;
  128309. private _radicalInverse_VdC;
  128310. private _hammersley;
  128311. private _hemisphereSample_uniform;
  128312. private _generateHemisphere;
  128313. private _createSSAOPostProcess;
  128314. private _createSSAOCombinePostProcess;
  128315. private _createRandomTexture;
  128316. /**
  128317. * Serialize the rendering pipeline (Used when exporting)
  128318. * @returns the serialized object
  128319. */
  128320. serialize(): any;
  128321. /**
  128322. * Parse the serialized pipeline
  128323. * @param source Source pipeline.
  128324. * @param scene The scene to load the pipeline to.
  128325. * @param rootUrl The URL of the serialized pipeline.
  128326. * @returns An instantiated pipeline from the serialized object.
  128327. */
  128328. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  128329. }
  128330. }
  128331. declare module BABYLON {
  128332. /** @hidden */
  128333. export var ssaoPixelShader: {
  128334. name: string;
  128335. shader: string;
  128336. };
  128337. }
  128338. declare module BABYLON {
  128339. /**
  128340. * Render pipeline to produce ssao effect
  128341. */
  128342. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  128343. /**
  128344. * @ignore
  128345. * The PassPostProcess id in the pipeline that contains the original scene color
  128346. */
  128347. SSAOOriginalSceneColorEffect: string;
  128348. /**
  128349. * @ignore
  128350. * The SSAO PostProcess id in the pipeline
  128351. */
  128352. SSAORenderEffect: string;
  128353. /**
  128354. * @ignore
  128355. * The horizontal blur PostProcess id in the pipeline
  128356. */
  128357. SSAOBlurHRenderEffect: string;
  128358. /**
  128359. * @ignore
  128360. * The vertical blur PostProcess id in the pipeline
  128361. */
  128362. SSAOBlurVRenderEffect: string;
  128363. /**
  128364. * @ignore
  128365. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128366. */
  128367. SSAOCombineRenderEffect: string;
  128368. /**
  128369. * The output strength of the SSAO post-process. Default value is 1.0.
  128370. */
  128371. totalStrength: number;
  128372. /**
  128373. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  128374. */
  128375. radius: number;
  128376. /**
  128377. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  128378. * Must not be equal to fallOff and superior to fallOff.
  128379. * Default value is 0.0075
  128380. */
  128381. area: number;
  128382. /**
  128383. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  128384. * Must not be equal to area and inferior to area.
  128385. * Default value is 0.000001
  128386. */
  128387. fallOff: number;
  128388. /**
  128389. * The base color of the SSAO post-process
  128390. * The final result is "base + ssao" between [0, 1]
  128391. */
  128392. base: number;
  128393. private _scene;
  128394. private _depthTexture;
  128395. private _randomTexture;
  128396. private _originalColorPostProcess;
  128397. private _ssaoPostProcess;
  128398. private _blurHPostProcess;
  128399. private _blurVPostProcess;
  128400. private _ssaoCombinePostProcess;
  128401. private _firstUpdate;
  128402. /**
  128403. * Gets active scene
  128404. */
  128405. readonly scene: Scene;
  128406. /**
  128407. * @constructor
  128408. * @param name - The rendering pipeline name
  128409. * @param scene - The scene linked to this pipeline
  128410. * @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 }
  128411. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  128412. */
  128413. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  128414. /**
  128415. * Get the class name
  128416. * @returns "SSAORenderingPipeline"
  128417. */
  128418. getClassName(): string;
  128419. /**
  128420. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  128421. */
  128422. dispose(disableDepthRender?: boolean): void;
  128423. private _createBlurPostProcess;
  128424. /** @hidden */
  128425. _rebuild(): void;
  128426. private _createSSAOPostProcess;
  128427. private _createSSAOCombinePostProcess;
  128428. private _createRandomTexture;
  128429. }
  128430. }
  128431. declare module BABYLON {
  128432. /** @hidden */
  128433. export var standardPixelShader: {
  128434. name: string;
  128435. shader: string;
  128436. };
  128437. }
  128438. declare module BABYLON {
  128439. /**
  128440. * Standard rendering pipeline
  128441. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128442. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  128443. */
  128444. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128445. /**
  128446. * Public members
  128447. */
  128448. /**
  128449. * Post-process which contains the original scene color before the pipeline applies all the effects
  128450. */
  128451. originalPostProcess: Nullable<PostProcess>;
  128452. /**
  128453. * Post-process used to down scale an image x4
  128454. */
  128455. downSampleX4PostProcess: Nullable<PostProcess>;
  128456. /**
  128457. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  128458. */
  128459. brightPassPostProcess: Nullable<PostProcess>;
  128460. /**
  128461. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  128462. */
  128463. blurHPostProcesses: PostProcess[];
  128464. /**
  128465. * Post-process array storing all the vertical blur post-processes used by the pipeline
  128466. */
  128467. blurVPostProcesses: PostProcess[];
  128468. /**
  128469. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  128470. */
  128471. textureAdderPostProcess: Nullable<PostProcess>;
  128472. /**
  128473. * Post-process used to create volumetric lighting effect
  128474. */
  128475. volumetricLightPostProcess: Nullable<PostProcess>;
  128476. /**
  128477. * Post-process used to smooth the previous volumetric light post-process on the X axis
  128478. */
  128479. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  128480. /**
  128481. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  128482. */
  128483. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  128484. /**
  128485. * Post-process used to merge the volumetric light effect and the real scene color
  128486. */
  128487. volumetricLightMergePostProces: Nullable<PostProcess>;
  128488. /**
  128489. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  128490. */
  128491. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  128492. /**
  128493. * Base post-process used to calculate the average luminance of the final image for HDR
  128494. */
  128495. luminancePostProcess: Nullable<PostProcess>;
  128496. /**
  128497. * Post-processes used to create down sample post-processes in order to get
  128498. * the average luminance of the final image for HDR
  128499. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  128500. */
  128501. luminanceDownSamplePostProcesses: PostProcess[];
  128502. /**
  128503. * Post-process used to create a HDR effect (light adaptation)
  128504. */
  128505. hdrPostProcess: Nullable<PostProcess>;
  128506. /**
  128507. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  128508. */
  128509. textureAdderFinalPostProcess: Nullable<PostProcess>;
  128510. /**
  128511. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  128512. */
  128513. lensFlareFinalPostProcess: Nullable<PostProcess>;
  128514. /**
  128515. * Post-process used to merge the final HDR post-process and the real scene color
  128516. */
  128517. hdrFinalPostProcess: Nullable<PostProcess>;
  128518. /**
  128519. * Post-process used to create a lens flare effect
  128520. */
  128521. lensFlarePostProcess: Nullable<PostProcess>;
  128522. /**
  128523. * Post-process that merges the result of the lens flare post-process and the real scene color
  128524. */
  128525. lensFlareComposePostProcess: Nullable<PostProcess>;
  128526. /**
  128527. * Post-process used to create a motion blur effect
  128528. */
  128529. motionBlurPostProcess: Nullable<PostProcess>;
  128530. /**
  128531. * Post-process used to create a depth of field effect
  128532. */
  128533. depthOfFieldPostProcess: Nullable<PostProcess>;
  128534. /**
  128535. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128536. */
  128537. fxaaPostProcess: Nullable<FxaaPostProcess>;
  128538. /**
  128539. * Represents the brightness threshold in order to configure the illuminated surfaces
  128540. */
  128541. brightThreshold: number;
  128542. /**
  128543. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  128544. */
  128545. blurWidth: number;
  128546. /**
  128547. * Sets if the blur for highlighted surfaces must be only horizontal
  128548. */
  128549. horizontalBlur: boolean;
  128550. /**
  128551. * Gets the overall exposure used by the pipeline
  128552. */
  128553. /**
  128554. * Sets the overall exposure used by the pipeline
  128555. */
  128556. exposure: number;
  128557. /**
  128558. * Texture used typically to simulate "dirty" on camera lens
  128559. */
  128560. lensTexture: Nullable<Texture>;
  128561. /**
  128562. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  128563. */
  128564. volumetricLightCoefficient: number;
  128565. /**
  128566. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  128567. */
  128568. volumetricLightPower: number;
  128569. /**
  128570. * Used the set the blur intensity to smooth the volumetric lights
  128571. */
  128572. volumetricLightBlurScale: number;
  128573. /**
  128574. * Light (spot or directional) used to generate the volumetric lights rays
  128575. * The source light must have a shadow generate so the pipeline can get its
  128576. * depth map
  128577. */
  128578. sourceLight: Nullable<SpotLight | DirectionalLight>;
  128579. /**
  128580. * For eye adaptation, represents the minimum luminance the eye can see
  128581. */
  128582. hdrMinimumLuminance: number;
  128583. /**
  128584. * For eye adaptation, represents the decrease luminance speed
  128585. */
  128586. hdrDecreaseRate: number;
  128587. /**
  128588. * For eye adaptation, represents the increase luminance speed
  128589. */
  128590. hdrIncreaseRate: number;
  128591. /**
  128592. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128593. */
  128594. /**
  128595. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  128596. */
  128597. hdrAutoExposure: boolean;
  128598. /**
  128599. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  128600. */
  128601. lensColorTexture: Nullable<Texture>;
  128602. /**
  128603. * The overall strengh for the lens flare effect
  128604. */
  128605. lensFlareStrength: number;
  128606. /**
  128607. * Dispersion coefficient for lens flare ghosts
  128608. */
  128609. lensFlareGhostDispersal: number;
  128610. /**
  128611. * Main lens flare halo width
  128612. */
  128613. lensFlareHaloWidth: number;
  128614. /**
  128615. * Based on the lens distortion effect, defines how much the lens flare result
  128616. * is distorted
  128617. */
  128618. lensFlareDistortionStrength: number;
  128619. /**
  128620. * Configures the blur intensity used for for lens flare (halo)
  128621. */
  128622. lensFlareBlurWidth: number;
  128623. /**
  128624. * Lens star texture must be used to simulate rays on the flares and is available
  128625. * in the documentation
  128626. */
  128627. lensStarTexture: Nullable<Texture>;
  128628. /**
  128629. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  128630. * flare effect by taking account of the dirt texture
  128631. */
  128632. lensFlareDirtTexture: Nullable<Texture>;
  128633. /**
  128634. * Represents the focal length for the depth of field effect
  128635. */
  128636. depthOfFieldDistance: number;
  128637. /**
  128638. * Represents the blur intensity for the blurred part of the depth of field effect
  128639. */
  128640. depthOfFieldBlurWidth: number;
  128641. /**
  128642. * Gets how much the image is blurred by the movement while using the motion blur post-process
  128643. */
  128644. /**
  128645. * Sets how much the image is blurred by the movement while using the motion blur post-process
  128646. */
  128647. motionStrength: number;
  128648. /**
  128649. * Gets wether or not the motion blur post-process is object based or screen based.
  128650. */
  128651. /**
  128652. * Sets wether or not the motion blur post-process should be object based or screen based
  128653. */
  128654. objectBasedMotionBlur: boolean;
  128655. /**
  128656. * List of animations for the pipeline (IAnimatable implementation)
  128657. */
  128658. animations: Animation[];
  128659. /**
  128660. * Private members
  128661. */
  128662. private _scene;
  128663. private _currentDepthOfFieldSource;
  128664. private _basePostProcess;
  128665. private _fixedExposure;
  128666. private _currentExposure;
  128667. private _hdrAutoExposure;
  128668. private _hdrCurrentLuminance;
  128669. private _motionStrength;
  128670. private _isObjectBasedMotionBlur;
  128671. private _floatTextureType;
  128672. private _camerasToBeAttached;
  128673. private _ratio;
  128674. private _bloomEnabled;
  128675. private _depthOfFieldEnabled;
  128676. private _vlsEnabled;
  128677. private _lensFlareEnabled;
  128678. private _hdrEnabled;
  128679. private _motionBlurEnabled;
  128680. private _fxaaEnabled;
  128681. private _motionBlurSamples;
  128682. private _volumetricLightStepsCount;
  128683. private _samples;
  128684. /**
  128685. * @ignore
  128686. * Specifies if the bloom pipeline is enabled
  128687. */
  128688. BloomEnabled: boolean;
  128689. /**
  128690. * @ignore
  128691. * Specifies if the depth of field pipeline is enabed
  128692. */
  128693. DepthOfFieldEnabled: boolean;
  128694. /**
  128695. * @ignore
  128696. * Specifies if the lens flare pipeline is enabed
  128697. */
  128698. LensFlareEnabled: boolean;
  128699. /**
  128700. * @ignore
  128701. * Specifies if the HDR pipeline is enabled
  128702. */
  128703. HDREnabled: boolean;
  128704. /**
  128705. * @ignore
  128706. * Specifies if the volumetric lights scattering effect is enabled
  128707. */
  128708. VLSEnabled: boolean;
  128709. /**
  128710. * @ignore
  128711. * Specifies if the motion blur effect is enabled
  128712. */
  128713. MotionBlurEnabled: boolean;
  128714. /**
  128715. * Specifies if anti-aliasing is enabled
  128716. */
  128717. fxaaEnabled: boolean;
  128718. /**
  128719. * Specifies the number of steps used to calculate the volumetric lights
  128720. * Typically in interval [50, 200]
  128721. */
  128722. volumetricLightStepsCount: number;
  128723. /**
  128724. * Specifies the number of samples used for the motion blur effect
  128725. * Typically in interval [16, 64]
  128726. */
  128727. motionBlurSamples: number;
  128728. /**
  128729. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128730. */
  128731. samples: number;
  128732. /**
  128733. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  128734. * @constructor
  128735. * @param name The rendering pipeline name
  128736. * @param scene The scene linked to this pipeline
  128737. * @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)
  128738. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  128739. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128740. */
  128741. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  128742. private _buildPipeline;
  128743. private _createDownSampleX4PostProcess;
  128744. private _createBrightPassPostProcess;
  128745. private _createBlurPostProcesses;
  128746. private _createTextureAdderPostProcess;
  128747. private _createVolumetricLightPostProcess;
  128748. private _createLuminancePostProcesses;
  128749. private _createHdrPostProcess;
  128750. private _createLensFlarePostProcess;
  128751. private _createDepthOfFieldPostProcess;
  128752. private _createMotionBlurPostProcess;
  128753. private _getDepthTexture;
  128754. private _disposePostProcesses;
  128755. /**
  128756. * Dispose of the pipeline and stop all post processes
  128757. */
  128758. dispose(): void;
  128759. /**
  128760. * Serialize the rendering pipeline (Used when exporting)
  128761. * @returns the serialized object
  128762. */
  128763. serialize(): any;
  128764. /**
  128765. * Parse the serialized pipeline
  128766. * @param source Source pipeline.
  128767. * @param scene The scene to load the pipeline to.
  128768. * @param rootUrl The URL of the serialized pipeline.
  128769. * @returns An instantiated pipeline from the serialized object.
  128770. */
  128771. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  128772. /**
  128773. * Luminance steps
  128774. */
  128775. static LuminanceSteps: number;
  128776. }
  128777. }
  128778. declare module BABYLON {
  128779. /** @hidden */
  128780. export var tonemapPixelShader: {
  128781. name: string;
  128782. shader: string;
  128783. };
  128784. }
  128785. declare module BABYLON {
  128786. /** Defines operator used for tonemapping */
  128787. export enum TonemappingOperator {
  128788. /** Hable */
  128789. Hable = 0,
  128790. /** Reinhard */
  128791. Reinhard = 1,
  128792. /** HejiDawson */
  128793. HejiDawson = 2,
  128794. /** Photographic */
  128795. Photographic = 3
  128796. }
  128797. /**
  128798. * Defines a post process to apply tone mapping
  128799. */
  128800. export class TonemapPostProcess extends PostProcess {
  128801. private _operator;
  128802. /** Defines the required exposure adjustement */
  128803. exposureAdjustment: number;
  128804. /**
  128805. * Creates a new TonemapPostProcess
  128806. * @param name defines the name of the postprocess
  128807. * @param _operator defines the operator to use
  128808. * @param exposureAdjustment defines the required exposure adjustement
  128809. * @param camera defines the camera to use (can be null)
  128810. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  128811. * @param engine defines the hosting engine (can be ignore if camera is set)
  128812. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128813. */
  128814. constructor(name: string, _operator: TonemappingOperator,
  128815. /** Defines the required exposure adjustement */
  128816. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  128817. }
  128818. }
  128819. declare module BABYLON {
  128820. /** @hidden */
  128821. export var depthVertexShader: {
  128822. name: string;
  128823. shader: string;
  128824. };
  128825. }
  128826. declare module BABYLON {
  128827. /** @hidden */
  128828. export var volumetricLightScatteringPixelShader: {
  128829. name: string;
  128830. shader: string;
  128831. };
  128832. }
  128833. declare module BABYLON {
  128834. /** @hidden */
  128835. export var volumetricLightScatteringPassVertexShader: {
  128836. name: string;
  128837. shader: string;
  128838. };
  128839. }
  128840. declare module BABYLON {
  128841. /** @hidden */
  128842. export var volumetricLightScatteringPassPixelShader: {
  128843. name: string;
  128844. shader: string;
  128845. };
  128846. }
  128847. declare module BABYLON {
  128848. /**
  128849. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  128850. */
  128851. export class VolumetricLightScatteringPostProcess extends PostProcess {
  128852. private _volumetricLightScatteringPass;
  128853. private _volumetricLightScatteringRTT;
  128854. private _viewPort;
  128855. private _screenCoordinates;
  128856. private _cachedDefines;
  128857. /**
  128858. * If not undefined, the mesh position is computed from the attached node position
  128859. */
  128860. attachedNode: {
  128861. position: Vector3;
  128862. };
  128863. /**
  128864. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  128865. */
  128866. customMeshPosition: Vector3;
  128867. /**
  128868. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  128869. */
  128870. useCustomMeshPosition: boolean;
  128871. /**
  128872. * If the post-process should inverse the light scattering direction
  128873. */
  128874. invert: boolean;
  128875. /**
  128876. * The internal mesh used by the post-process
  128877. */
  128878. mesh: Mesh;
  128879. /**
  128880. * @hidden
  128881. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  128882. */
  128883. useDiffuseColor: boolean;
  128884. /**
  128885. * Array containing the excluded meshes not rendered in the internal pass
  128886. */
  128887. excludedMeshes: AbstractMesh[];
  128888. /**
  128889. * Controls the overall intensity of the post-process
  128890. */
  128891. exposure: number;
  128892. /**
  128893. * Dissipates each sample's contribution in range [0, 1]
  128894. */
  128895. decay: number;
  128896. /**
  128897. * Controls the overall intensity of each sample
  128898. */
  128899. weight: number;
  128900. /**
  128901. * Controls the density of each sample
  128902. */
  128903. density: number;
  128904. /**
  128905. * @constructor
  128906. * @param name The post-process name
  128907. * @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)
  128908. * @param camera The camera that the post-process will be attached to
  128909. * @param mesh The mesh used to create the light scattering
  128910. * @param samples The post-process quality, default 100
  128911. * @param samplingModeThe post-process filtering mode
  128912. * @param engine The babylon engine
  128913. * @param reusable If the post-process is reusable
  128914. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128915. */
  128916. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128917. /**
  128918. * Returns the string "VolumetricLightScatteringPostProcess"
  128919. * @returns "VolumetricLightScatteringPostProcess"
  128920. */
  128921. getClassName(): string;
  128922. private _isReady;
  128923. /**
  128924. * Sets the new light position for light scattering effect
  128925. * @param position The new custom light position
  128926. */
  128927. setCustomMeshPosition(position: Vector3): void;
  128928. /**
  128929. * Returns the light position for light scattering effect
  128930. * @return Vector3 The custom light position
  128931. */
  128932. getCustomMeshPosition(): Vector3;
  128933. /**
  128934. * Disposes the internal assets and detaches the post-process from the camera
  128935. */
  128936. dispose(camera: Camera): void;
  128937. /**
  128938. * Returns the render target texture used by the post-process
  128939. * @return the render target texture used by the post-process
  128940. */
  128941. getPass(): RenderTargetTexture;
  128942. private _meshExcluded;
  128943. private _createPass;
  128944. private _updateMeshScreenCoordinates;
  128945. /**
  128946. * Creates a default mesh for the Volumeric Light Scattering post-process
  128947. * @param name The mesh name
  128948. * @param scene The scene where to create the mesh
  128949. * @return the default mesh
  128950. */
  128951. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128952. }
  128953. }
  128954. declare module BABYLON {
  128955. interface Scene {
  128956. /** @hidden (Backing field) */
  128957. _boundingBoxRenderer: BoundingBoxRenderer;
  128958. /** @hidden (Backing field) */
  128959. _forceShowBoundingBoxes: boolean;
  128960. /**
  128961. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128962. */
  128963. forceShowBoundingBoxes: boolean;
  128964. /**
  128965. * Gets the bounding box renderer associated with the scene
  128966. * @returns a BoundingBoxRenderer
  128967. */
  128968. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128969. }
  128970. interface AbstractMesh {
  128971. /** @hidden (Backing field) */
  128972. _showBoundingBox: boolean;
  128973. /**
  128974. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128975. */
  128976. showBoundingBox: boolean;
  128977. }
  128978. /**
  128979. * Component responsible of rendering the bounding box of the meshes in a scene.
  128980. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128981. */
  128982. export class BoundingBoxRenderer implements ISceneComponent {
  128983. /**
  128984. * The component name helpfull to identify the component in the list of scene components.
  128985. */
  128986. readonly name: string;
  128987. /**
  128988. * The scene the component belongs to.
  128989. */
  128990. scene: Scene;
  128991. /**
  128992. * Color of the bounding box lines placed in front of an object
  128993. */
  128994. frontColor: Color3;
  128995. /**
  128996. * Color of the bounding box lines placed behind an object
  128997. */
  128998. backColor: Color3;
  128999. /**
  129000. * Defines if the renderer should show the back lines or not
  129001. */
  129002. showBackLines: boolean;
  129003. /**
  129004. * @hidden
  129005. */
  129006. renderList: SmartArray<BoundingBox>;
  129007. private _colorShader;
  129008. private _vertexBuffers;
  129009. private _indexBuffer;
  129010. private _fillIndexBuffer;
  129011. private _fillIndexData;
  129012. /**
  129013. * Instantiates a new bounding box renderer in a scene.
  129014. * @param scene the scene the renderer renders in
  129015. */
  129016. constructor(scene: Scene);
  129017. /**
  129018. * Registers the component in a given scene
  129019. */
  129020. register(): void;
  129021. private _evaluateSubMesh;
  129022. private _activeMesh;
  129023. private _prepareRessources;
  129024. private _createIndexBuffer;
  129025. /**
  129026. * Rebuilds the elements related to this component in case of
  129027. * context lost for instance.
  129028. */
  129029. rebuild(): void;
  129030. /**
  129031. * @hidden
  129032. */
  129033. reset(): void;
  129034. /**
  129035. * Render the bounding boxes of a specific rendering group
  129036. * @param renderingGroupId defines the rendering group to render
  129037. */
  129038. render(renderingGroupId: number): void;
  129039. /**
  129040. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129041. * @param mesh Define the mesh to render the occlusion bounding box for
  129042. */
  129043. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129044. /**
  129045. * Dispose and release the resources attached to this renderer.
  129046. */
  129047. dispose(): void;
  129048. }
  129049. }
  129050. declare module BABYLON {
  129051. /** @hidden */
  129052. export var depthPixelShader: {
  129053. name: string;
  129054. shader: string;
  129055. };
  129056. }
  129057. declare module BABYLON {
  129058. /**
  129059. * This represents a depth renderer in Babylon.
  129060. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129061. */
  129062. export class DepthRenderer {
  129063. private _scene;
  129064. private _depthMap;
  129065. private _effect;
  129066. private readonly _storeNonLinearDepth;
  129067. private readonly _clearColor;
  129068. /** Get if the depth renderer is using packed depth or not */
  129069. readonly isPacked: boolean;
  129070. private _cachedDefines;
  129071. private _camera;
  129072. /**
  129073. * Specifiess that the depth renderer will only be used within
  129074. * the camera it is created for.
  129075. * This can help forcing its rendering during the camera processing.
  129076. */
  129077. useOnlyInActiveCamera: boolean;
  129078. /** @hidden */
  129079. static _SceneComponentInitialization: (scene: Scene) => void;
  129080. /**
  129081. * Instantiates a depth renderer
  129082. * @param scene The scene the renderer belongs to
  129083. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129084. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129085. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129086. */
  129087. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129088. /**
  129089. * Creates the depth rendering effect and checks if the effect is ready.
  129090. * @param subMesh The submesh to be used to render the depth map of
  129091. * @param useInstances If multiple world instances should be used
  129092. * @returns if the depth renderer is ready to render the depth map
  129093. */
  129094. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129095. /**
  129096. * Gets the texture which the depth map will be written to.
  129097. * @returns The depth map texture
  129098. */
  129099. getDepthMap(): RenderTargetTexture;
  129100. /**
  129101. * Disposes of the depth renderer.
  129102. */
  129103. dispose(): void;
  129104. }
  129105. }
  129106. declare module BABYLON {
  129107. interface Scene {
  129108. /** @hidden (Backing field) */
  129109. _depthRenderer: {
  129110. [id: string]: DepthRenderer;
  129111. };
  129112. /**
  129113. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129114. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129115. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129116. * @returns the created depth renderer
  129117. */
  129118. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129119. /**
  129120. * Disables a depth renderer for a given camera
  129121. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129122. */
  129123. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129124. }
  129125. /**
  129126. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129127. * in several rendering techniques.
  129128. */
  129129. export class DepthRendererSceneComponent implements ISceneComponent {
  129130. /**
  129131. * The component name helpfull to identify the component in the list of scene components.
  129132. */
  129133. readonly name: string;
  129134. /**
  129135. * The scene the component belongs to.
  129136. */
  129137. scene: Scene;
  129138. /**
  129139. * Creates a new instance of the component for the given scene
  129140. * @param scene Defines the scene to register the component in
  129141. */
  129142. constructor(scene: Scene);
  129143. /**
  129144. * Registers the component in a given scene
  129145. */
  129146. register(): void;
  129147. /**
  129148. * Rebuilds the elements related to this component in case of
  129149. * context lost for instance.
  129150. */
  129151. rebuild(): void;
  129152. /**
  129153. * Disposes the component and the associated ressources
  129154. */
  129155. dispose(): void;
  129156. private _gatherRenderTargets;
  129157. private _gatherActiveCameraRenderTargets;
  129158. }
  129159. }
  129160. declare module BABYLON {
  129161. /** @hidden */
  129162. export var outlinePixelShader: {
  129163. name: string;
  129164. shader: string;
  129165. };
  129166. }
  129167. declare module BABYLON {
  129168. /** @hidden */
  129169. export var outlineVertexShader: {
  129170. name: string;
  129171. shader: string;
  129172. };
  129173. }
  129174. declare module BABYLON {
  129175. interface Scene {
  129176. /** @hidden */
  129177. _outlineRenderer: OutlineRenderer;
  129178. /**
  129179. * Gets the outline renderer associated with the scene
  129180. * @returns a OutlineRenderer
  129181. */
  129182. getOutlineRenderer(): OutlineRenderer;
  129183. }
  129184. interface AbstractMesh {
  129185. /** @hidden (Backing field) */
  129186. _renderOutline: boolean;
  129187. /**
  129188. * Gets or sets a boolean indicating if the outline must be rendered as well
  129189. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129190. */
  129191. renderOutline: boolean;
  129192. /** @hidden (Backing field) */
  129193. _renderOverlay: boolean;
  129194. /**
  129195. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129196. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129197. */
  129198. renderOverlay: boolean;
  129199. }
  129200. /**
  129201. * This class is responsible to draw bothe outline/overlay of meshes.
  129202. * It should not be used directly but through the available method on mesh.
  129203. */
  129204. export class OutlineRenderer implements ISceneComponent {
  129205. /**
  129206. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129207. */
  129208. private static _StencilReference;
  129209. /**
  129210. * The name of the component. Each component must have a unique name.
  129211. */
  129212. name: string;
  129213. /**
  129214. * The scene the component belongs to.
  129215. */
  129216. scene: Scene;
  129217. /**
  129218. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129219. */
  129220. zOffset: number;
  129221. private _engine;
  129222. private _effect;
  129223. private _cachedDefines;
  129224. private _savedDepthWrite;
  129225. /**
  129226. * Instantiates a new outline renderer. (There could be only one per scene).
  129227. * @param scene Defines the scene it belongs to
  129228. */
  129229. constructor(scene: Scene);
  129230. /**
  129231. * Register the component to one instance of a scene.
  129232. */
  129233. register(): void;
  129234. /**
  129235. * Rebuilds the elements related to this component in case of
  129236. * context lost for instance.
  129237. */
  129238. rebuild(): void;
  129239. /**
  129240. * Disposes the component and the associated ressources.
  129241. */
  129242. dispose(): void;
  129243. /**
  129244. * Renders the outline in the canvas.
  129245. * @param subMesh Defines the sumesh to render
  129246. * @param batch Defines the batch of meshes in case of instances
  129247. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129248. */
  129249. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129250. /**
  129251. * Returns whether or not the outline renderer is ready for a given submesh.
  129252. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129253. * @param subMesh Defines the submesh to check readyness for
  129254. * @param useInstances Defines wheter wee are trying to render instances or not
  129255. * @returns true if ready otherwise false
  129256. */
  129257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129258. private _beforeRenderingMesh;
  129259. private _afterRenderingMesh;
  129260. }
  129261. }
  129262. declare module BABYLON {
  129263. /**
  129264. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129265. * @see http://doc.babylonjs.com/babylon101/sprites
  129266. */
  129267. export class SpritePackedManager extends SpriteManager {
  129268. /** defines the packed manager's name */
  129269. name: string;
  129270. /**
  129271. * Creates a new sprite manager from a packed sprite sheet
  129272. * @param name defines the manager's name
  129273. * @param imgUrl defines the sprite sheet url
  129274. * @param capacity defines the maximum allowed number of sprites
  129275. * @param scene defines the hosting scene
  129276. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129277. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129278. * @param samplingMode defines the smapling mode to use with spritesheet
  129279. * @param fromPacked set to true; do not alter
  129280. */
  129281. constructor(
  129282. /** defines the packed manager's name */
  129283. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129284. }
  129285. }
  129286. declare module BABYLON {
  129287. /**
  129288. * Defines the list of states available for a task inside a AssetsManager
  129289. */
  129290. export enum AssetTaskState {
  129291. /**
  129292. * Initialization
  129293. */
  129294. INIT = 0,
  129295. /**
  129296. * Running
  129297. */
  129298. RUNNING = 1,
  129299. /**
  129300. * Done
  129301. */
  129302. DONE = 2,
  129303. /**
  129304. * Error
  129305. */
  129306. ERROR = 3
  129307. }
  129308. /**
  129309. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  129310. */
  129311. export abstract class AbstractAssetTask {
  129312. /**
  129313. * Task name
  129314. */ name: string;
  129315. /**
  129316. * Callback called when the task is successful
  129317. */
  129318. onSuccess: (task: any) => void;
  129319. /**
  129320. * Callback called when the task is not successful
  129321. */
  129322. onError: (task: any, message?: string, exception?: any) => void;
  129323. /**
  129324. * Creates a new AssetsManager
  129325. * @param name defines the name of the task
  129326. */
  129327. constructor(
  129328. /**
  129329. * Task name
  129330. */ name: string);
  129331. private _isCompleted;
  129332. private _taskState;
  129333. private _errorObject;
  129334. /**
  129335. * Get if the task is completed
  129336. */
  129337. readonly isCompleted: boolean;
  129338. /**
  129339. * Gets the current state of the task
  129340. */
  129341. readonly taskState: AssetTaskState;
  129342. /**
  129343. * Gets the current error object (if task is in error)
  129344. */
  129345. readonly errorObject: {
  129346. message?: string;
  129347. exception?: any;
  129348. };
  129349. /**
  129350. * Internal only
  129351. * @hidden
  129352. */
  129353. _setErrorObject(message?: string, exception?: any): void;
  129354. /**
  129355. * Execute the current task
  129356. * @param scene defines the scene where you want your assets to be loaded
  129357. * @param onSuccess is a callback called when the task is successfully executed
  129358. * @param onError is a callback called if an error occurs
  129359. */
  129360. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129361. /**
  129362. * Execute the current task
  129363. * @param scene defines the scene where you want your assets to be loaded
  129364. * @param onSuccess is a callback called when the task is successfully executed
  129365. * @param onError is a callback called if an error occurs
  129366. */
  129367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129368. /**
  129369. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  129370. * This can be used with failed tasks that have the reason for failure fixed.
  129371. */
  129372. reset(): void;
  129373. private onErrorCallback;
  129374. private onDoneCallback;
  129375. }
  129376. /**
  129377. * Define the interface used by progress events raised during assets loading
  129378. */
  129379. export interface IAssetsProgressEvent {
  129380. /**
  129381. * Defines the number of remaining tasks to process
  129382. */
  129383. remainingCount: number;
  129384. /**
  129385. * Defines the total number of tasks
  129386. */
  129387. totalCount: number;
  129388. /**
  129389. * Defines the task that was just processed
  129390. */
  129391. task: AbstractAssetTask;
  129392. }
  129393. /**
  129394. * Class used to share progress information about assets loading
  129395. */
  129396. export class AssetsProgressEvent implements IAssetsProgressEvent {
  129397. /**
  129398. * Defines the number of remaining tasks to process
  129399. */
  129400. remainingCount: number;
  129401. /**
  129402. * Defines the total number of tasks
  129403. */
  129404. totalCount: number;
  129405. /**
  129406. * Defines the task that was just processed
  129407. */
  129408. task: AbstractAssetTask;
  129409. /**
  129410. * Creates a AssetsProgressEvent
  129411. * @param remainingCount defines the number of remaining tasks to process
  129412. * @param totalCount defines the total number of tasks
  129413. * @param task defines the task that was just processed
  129414. */
  129415. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  129416. }
  129417. /**
  129418. * Define a task used by AssetsManager to load meshes
  129419. */
  129420. export class MeshAssetTask extends AbstractAssetTask {
  129421. /**
  129422. * Defines the name of the task
  129423. */
  129424. name: string;
  129425. /**
  129426. * Defines the list of mesh's names you want to load
  129427. */
  129428. meshesNames: any;
  129429. /**
  129430. * Defines the root url to use as a base to load your meshes and associated resources
  129431. */
  129432. rootUrl: string;
  129433. /**
  129434. * Defines the filename of the scene to load from
  129435. */
  129436. sceneFilename: string;
  129437. /**
  129438. * Gets the list of loaded meshes
  129439. */
  129440. loadedMeshes: Array<AbstractMesh>;
  129441. /**
  129442. * Gets the list of loaded particle systems
  129443. */
  129444. loadedParticleSystems: Array<IParticleSystem>;
  129445. /**
  129446. * Gets the list of loaded skeletons
  129447. */
  129448. loadedSkeletons: Array<Skeleton>;
  129449. /**
  129450. * Gets the list of loaded animation groups
  129451. */
  129452. loadedAnimationGroups: Array<AnimationGroup>;
  129453. /**
  129454. * Callback called when the task is successful
  129455. */
  129456. onSuccess: (task: MeshAssetTask) => void;
  129457. /**
  129458. * Callback called when the task is successful
  129459. */
  129460. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  129461. /**
  129462. * Creates a new MeshAssetTask
  129463. * @param name defines the name of the task
  129464. * @param meshesNames defines the list of mesh's names you want to load
  129465. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  129466. * @param sceneFilename defines the filename of the scene to load from
  129467. */
  129468. constructor(
  129469. /**
  129470. * Defines the name of the task
  129471. */
  129472. name: string,
  129473. /**
  129474. * Defines the list of mesh's names you want to load
  129475. */
  129476. meshesNames: any,
  129477. /**
  129478. * Defines the root url to use as a base to load your meshes and associated resources
  129479. */
  129480. rootUrl: string,
  129481. /**
  129482. * Defines the filename of the scene to load from
  129483. */
  129484. sceneFilename: string);
  129485. /**
  129486. * Execute the current task
  129487. * @param scene defines the scene where you want your assets to be loaded
  129488. * @param onSuccess is a callback called when the task is successfully executed
  129489. * @param onError is a callback called if an error occurs
  129490. */
  129491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129492. }
  129493. /**
  129494. * Define a task used by AssetsManager to load text content
  129495. */
  129496. export class TextFileAssetTask extends AbstractAssetTask {
  129497. /**
  129498. * Defines the name of the task
  129499. */
  129500. name: string;
  129501. /**
  129502. * Defines the location of the file to load
  129503. */
  129504. url: string;
  129505. /**
  129506. * Gets the loaded text string
  129507. */
  129508. text: string;
  129509. /**
  129510. * Callback called when the task is successful
  129511. */
  129512. onSuccess: (task: TextFileAssetTask) => void;
  129513. /**
  129514. * Callback called when the task is successful
  129515. */
  129516. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  129517. /**
  129518. * Creates a new TextFileAssetTask object
  129519. * @param name defines the name of the task
  129520. * @param url defines the location of the file to load
  129521. */
  129522. constructor(
  129523. /**
  129524. * Defines the name of the task
  129525. */
  129526. name: string,
  129527. /**
  129528. * Defines the location of the file to load
  129529. */
  129530. url: string);
  129531. /**
  129532. * Execute the current task
  129533. * @param scene defines the scene where you want your assets to be loaded
  129534. * @param onSuccess is a callback called when the task is successfully executed
  129535. * @param onError is a callback called if an error occurs
  129536. */
  129537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129538. }
  129539. /**
  129540. * Define a task used by AssetsManager to load binary data
  129541. */
  129542. export class BinaryFileAssetTask extends AbstractAssetTask {
  129543. /**
  129544. * Defines the name of the task
  129545. */
  129546. name: string;
  129547. /**
  129548. * Defines the location of the file to load
  129549. */
  129550. url: string;
  129551. /**
  129552. * Gets the lodaded data (as an array buffer)
  129553. */
  129554. data: ArrayBuffer;
  129555. /**
  129556. * Callback called when the task is successful
  129557. */
  129558. onSuccess: (task: BinaryFileAssetTask) => void;
  129559. /**
  129560. * Callback called when the task is successful
  129561. */
  129562. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  129563. /**
  129564. * Creates a new BinaryFileAssetTask object
  129565. * @param name defines the name of the new task
  129566. * @param url defines the location of the file to load
  129567. */
  129568. constructor(
  129569. /**
  129570. * Defines the name of the task
  129571. */
  129572. name: string,
  129573. /**
  129574. * Defines the location of the file to load
  129575. */
  129576. url: string);
  129577. /**
  129578. * Execute the current task
  129579. * @param scene defines the scene where you want your assets to be loaded
  129580. * @param onSuccess is a callback called when the task is successfully executed
  129581. * @param onError is a callback called if an error occurs
  129582. */
  129583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129584. }
  129585. /**
  129586. * Define a task used by AssetsManager to load images
  129587. */
  129588. export class ImageAssetTask extends AbstractAssetTask {
  129589. /**
  129590. * Defines the name of the task
  129591. */
  129592. name: string;
  129593. /**
  129594. * Defines the location of the image to load
  129595. */
  129596. url: string;
  129597. /**
  129598. * Gets the loaded images
  129599. */
  129600. image: HTMLImageElement;
  129601. /**
  129602. * Callback called when the task is successful
  129603. */
  129604. onSuccess: (task: ImageAssetTask) => void;
  129605. /**
  129606. * Callback called when the task is successful
  129607. */
  129608. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  129609. /**
  129610. * Creates a new ImageAssetTask
  129611. * @param name defines the name of the task
  129612. * @param url defines the location of the image to load
  129613. */
  129614. constructor(
  129615. /**
  129616. * Defines the name of the task
  129617. */
  129618. name: string,
  129619. /**
  129620. * Defines the location of the image to load
  129621. */
  129622. url: string);
  129623. /**
  129624. * Execute the current task
  129625. * @param scene defines the scene where you want your assets to be loaded
  129626. * @param onSuccess is a callback called when the task is successfully executed
  129627. * @param onError is a callback called if an error occurs
  129628. */
  129629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129630. }
  129631. /**
  129632. * Defines the interface used by texture loading tasks
  129633. */
  129634. export interface ITextureAssetTask<TEX extends BaseTexture> {
  129635. /**
  129636. * Gets the loaded texture
  129637. */
  129638. texture: TEX;
  129639. }
  129640. /**
  129641. * Define a task used by AssetsManager to load 2D textures
  129642. */
  129643. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  129644. /**
  129645. * Defines the name of the task
  129646. */
  129647. name: string;
  129648. /**
  129649. * Defines the location of the file to load
  129650. */
  129651. url: string;
  129652. /**
  129653. * Defines if mipmap should not be generated (default is false)
  129654. */
  129655. noMipmap?: boolean | undefined;
  129656. /**
  129657. * Defines if texture must be inverted on Y axis (default is false)
  129658. */
  129659. invertY?: boolean | undefined;
  129660. /**
  129661. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129662. */
  129663. samplingMode: number;
  129664. /**
  129665. * Gets the loaded texture
  129666. */
  129667. texture: Texture;
  129668. /**
  129669. * Callback called when the task is successful
  129670. */
  129671. onSuccess: (task: TextureAssetTask) => void;
  129672. /**
  129673. * Callback called when the task is successful
  129674. */
  129675. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  129676. /**
  129677. * Creates a new TextureAssetTask object
  129678. * @param name defines the name of the task
  129679. * @param url defines the location of the file to load
  129680. * @param noMipmap defines if mipmap should not be generated (default is false)
  129681. * @param invertY defines if texture must be inverted on Y axis (default is false)
  129682. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129683. */
  129684. constructor(
  129685. /**
  129686. * Defines the name of the task
  129687. */
  129688. name: string,
  129689. /**
  129690. * Defines the location of the file to load
  129691. */
  129692. url: string,
  129693. /**
  129694. * Defines if mipmap should not be generated (default is false)
  129695. */
  129696. noMipmap?: boolean | undefined,
  129697. /**
  129698. * Defines if texture must be inverted on Y axis (default is false)
  129699. */
  129700. invertY?: boolean | undefined,
  129701. /**
  129702. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  129703. */
  129704. samplingMode?: number);
  129705. /**
  129706. * Execute the current task
  129707. * @param scene defines the scene where you want your assets to be loaded
  129708. * @param onSuccess is a callback called when the task is successfully executed
  129709. * @param onError is a callback called if an error occurs
  129710. */
  129711. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129712. }
  129713. /**
  129714. * Define a task used by AssetsManager to load cube textures
  129715. */
  129716. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  129717. /**
  129718. * Defines the name of the task
  129719. */
  129720. name: string;
  129721. /**
  129722. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129723. */
  129724. url: string;
  129725. /**
  129726. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129727. */
  129728. extensions?: string[] | undefined;
  129729. /**
  129730. * Defines if mipmaps should not be generated (default is false)
  129731. */
  129732. noMipmap?: boolean | undefined;
  129733. /**
  129734. * Defines the explicit list of files (undefined by default)
  129735. */
  129736. files?: string[] | undefined;
  129737. /**
  129738. * Gets the loaded texture
  129739. */
  129740. texture: CubeTexture;
  129741. /**
  129742. * Callback called when the task is successful
  129743. */
  129744. onSuccess: (task: CubeTextureAssetTask) => void;
  129745. /**
  129746. * Callback called when the task is successful
  129747. */
  129748. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  129749. /**
  129750. * Creates a new CubeTextureAssetTask
  129751. * @param name defines the name of the task
  129752. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129753. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129754. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129755. * @param files defines the explicit list of files (undefined by default)
  129756. */
  129757. constructor(
  129758. /**
  129759. * Defines the name of the task
  129760. */
  129761. name: string,
  129762. /**
  129763. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  129764. */
  129765. url: string,
  129766. /**
  129767. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  129768. */
  129769. extensions?: string[] | undefined,
  129770. /**
  129771. * Defines if mipmaps should not be generated (default is false)
  129772. */
  129773. noMipmap?: boolean | undefined,
  129774. /**
  129775. * Defines the explicit list of files (undefined by default)
  129776. */
  129777. files?: string[] | undefined);
  129778. /**
  129779. * Execute the current task
  129780. * @param scene defines the scene where you want your assets to be loaded
  129781. * @param onSuccess is a callback called when the task is successfully executed
  129782. * @param onError is a callback called if an error occurs
  129783. */
  129784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129785. }
  129786. /**
  129787. * Define a task used by AssetsManager to load HDR cube textures
  129788. */
  129789. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  129790. /**
  129791. * Defines the name of the task
  129792. */
  129793. name: string;
  129794. /**
  129795. * Defines the location of the file to load
  129796. */
  129797. url: string;
  129798. /**
  129799. * Defines the desired size (the more it increases the longer the generation will be)
  129800. */
  129801. size: number;
  129802. /**
  129803. * Defines if mipmaps should not be generated (default is false)
  129804. */
  129805. noMipmap: boolean;
  129806. /**
  129807. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129808. */
  129809. generateHarmonics: boolean;
  129810. /**
  129811. * 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)
  129812. */
  129813. gammaSpace: boolean;
  129814. /**
  129815. * Internal Use Only
  129816. */
  129817. reserved: boolean;
  129818. /**
  129819. * Gets the loaded texture
  129820. */
  129821. texture: HDRCubeTexture;
  129822. /**
  129823. * Callback called when the task is successful
  129824. */
  129825. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  129826. /**
  129827. * Callback called when the task is successful
  129828. */
  129829. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  129830. /**
  129831. * Creates a new HDRCubeTextureAssetTask object
  129832. * @param name defines the name of the task
  129833. * @param url defines the location of the file to load
  129834. * @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.
  129835. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129836. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129837. * @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)
  129838. * @param reserved Internal use only
  129839. */
  129840. constructor(
  129841. /**
  129842. * Defines the name of the task
  129843. */
  129844. name: string,
  129845. /**
  129846. * Defines the location of the file to load
  129847. */
  129848. url: string,
  129849. /**
  129850. * Defines the desired size (the more it increases the longer the generation will be)
  129851. */
  129852. size: number,
  129853. /**
  129854. * Defines if mipmaps should not be generated (default is false)
  129855. */
  129856. noMipmap?: boolean,
  129857. /**
  129858. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  129859. */
  129860. generateHarmonics?: boolean,
  129861. /**
  129862. * 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)
  129863. */
  129864. gammaSpace?: boolean,
  129865. /**
  129866. * Internal Use Only
  129867. */
  129868. reserved?: boolean);
  129869. /**
  129870. * Execute the current task
  129871. * @param scene defines the scene where you want your assets to be loaded
  129872. * @param onSuccess is a callback called when the task is successfully executed
  129873. * @param onError is a callback called if an error occurs
  129874. */
  129875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129876. }
  129877. /**
  129878. * Define a task used by AssetsManager to load Equirectangular cube textures
  129879. */
  129880. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  129881. /**
  129882. * Defines the name of the task
  129883. */
  129884. name: string;
  129885. /**
  129886. * Defines the location of the file to load
  129887. */
  129888. url: string;
  129889. /**
  129890. * Defines the desired size (the more it increases the longer the generation will be)
  129891. */
  129892. size: number;
  129893. /**
  129894. * Defines if mipmaps should not be generated (default is false)
  129895. */
  129896. noMipmap: boolean;
  129897. /**
  129898. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129899. * but the standard material would require them in Gamma space) (default is true)
  129900. */
  129901. gammaSpace: boolean;
  129902. /**
  129903. * Gets the loaded texture
  129904. */
  129905. texture: EquiRectangularCubeTexture;
  129906. /**
  129907. * Callback called when the task is successful
  129908. */
  129909. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129910. /**
  129911. * Callback called when the task is successful
  129912. */
  129913. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129914. /**
  129915. * Creates a new EquiRectangularCubeTextureAssetTask object
  129916. * @param name defines the name of the task
  129917. * @param url defines the location of the file to load
  129918. * @param size defines the desired size (the more it increases the longer the generation will be)
  129919. * If the size is omitted this implies you are using a preprocessed cubemap.
  129920. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129921. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129922. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129923. * (default is true)
  129924. */
  129925. constructor(
  129926. /**
  129927. * Defines the name of the task
  129928. */
  129929. name: string,
  129930. /**
  129931. * Defines the location of the file to load
  129932. */
  129933. url: string,
  129934. /**
  129935. * Defines the desired size (the more it increases the longer the generation will be)
  129936. */
  129937. size: number,
  129938. /**
  129939. * Defines if mipmaps should not be generated (default is false)
  129940. */
  129941. noMipmap?: boolean,
  129942. /**
  129943. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129944. * but the standard material would require them in Gamma space) (default is true)
  129945. */
  129946. gammaSpace?: boolean);
  129947. /**
  129948. * Execute the current task
  129949. * @param scene defines the scene where you want your assets to be loaded
  129950. * @param onSuccess is a callback called when the task is successfully executed
  129951. * @param onError is a callback called if an error occurs
  129952. */
  129953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129954. }
  129955. /**
  129956. * This class can be used to easily import assets into a scene
  129957. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129958. */
  129959. export class AssetsManager {
  129960. private _scene;
  129961. private _isLoading;
  129962. protected _tasks: AbstractAssetTask[];
  129963. protected _waitingTasksCount: number;
  129964. protected _totalTasksCount: number;
  129965. /**
  129966. * Callback called when all tasks are processed
  129967. */
  129968. onFinish: (tasks: AbstractAssetTask[]) => void;
  129969. /**
  129970. * Callback called when a task is successful
  129971. */
  129972. onTaskSuccess: (task: AbstractAssetTask) => void;
  129973. /**
  129974. * Callback called when a task had an error
  129975. */
  129976. onTaskError: (task: AbstractAssetTask) => void;
  129977. /**
  129978. * Callback called when a task is done (whatever the result is)
  129979. */
  129980. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129981. /**
  129982. * Observable called when all tasks are processed
  129983. */
  129984. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129985. /**
  129986. * Observable called when a task had an error
  129987. */
  129988. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129989. /**
  129990. * Observable called when all tasks were executed
  129991. */
  129992. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129993. /**
  129994. * Observable called when a task is done (whatever the result is)
  129995. */
  129996. onProgressObservable: Observable<IAssetsProgressEvent>;
  129997. /**
  129998. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129999. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130000. */
  130001. useDefaultLoadingScreen: boolean;
  130002. /**
  130003. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130004. * when all assets have been downloaded.
  130005. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130006. */
  130007. autoHideLoadingUI: boolean;
  130008. /**
  130009. * Creates a new AssetsManager
  130010. * @param scene defines the scene to work on
  130011. */
  130012. constructor(scene: Scene);
  130013. /**
  130014. * Add a MeshAssetTask to the list of active tasks
  130015. * @param taskName defines the name of the new task
  130016. * @param meshesNames defines the name of meshes to load
  130017. * @param rootUrl defines the root url to use to locate files
  130018. * @param sceneFilename defines the filename of the scene file
  130019. * @returns a new MeshAssetTask object
  130020. */
  130021. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130022. /**
  130023. * Add a TextFileAssetTask to the list of active tasks
  130024. * @param taskName defines the name of the new task
  130025. * @param url defines the url of the file to load
  130026. * @returns a new TextFileAssetTask object
  130027. */
  130028. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130029. /**
  130030. * Add a BinaryFileAssetTask to the list of active tasks
  130031. * @param taskName defines the name of the new task
  130032. * @param url defines the url of the file to load
  130033. * @returns a new BinaryFileAssetTask object
  130034. */
  130035. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130036. /**
  130037. * Add a ImageAssetTask to the list of active tasks
  130038. * @param taskName defines the name of the new task
  130039. * @param url defines the url of the file to load
  130040. * @returns a new ImageAssetTask object
  130041. */
  130042. addImageTask(taskName: string, url: string): ImageAssetTask;
  130043. /**
  130044. * Add a TextureAssetTask to the list of active tasks
  130045. * @param taskName defines the name of the new task
  130046. * @param url defines the url of the file to load
  130047. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130048. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130049. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130050. * @returns a new TextureAssetTask object
  130051. */
  130052. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130053. /**
  130054. * Add a CubeTextureAssetTask to the list of active tasks
  130055. * @param taskName defines the name of the new task
  130056. * @param url defines the url of the file to load
  130057. * @param extensions defines the extension to use to load the cube map (can be null)
  130058. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130059. * @param files defines the list of files to load (can be null)
  130060. * @returns a new CubeTextureAssetTask object
  130061. */
  130062. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130063. /**
  130064. *
  130065. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130066. * @param taskName defines the name of the new task
  130067. * @param url defines the url of the file to load
  130068. * @param size defines the size you want for the cubemap (can be null)
  130069. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130070. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130071. * @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)
  130072. * @param reserved Internal use only
  130073. * @returns a new HDRCubeTextureAssetTask object
  130074. */
  130075. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130076. /**
  130077. *
  130078. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130079. * @param taskName defines the name of the new task
  130080. * @param url defines the url of the file to load
  130081. * @param size defines the size you want for the cubemap (can be null)
  130082. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130083. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130084. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130085. * @returns a new EquiRectangularCubeTextureAssetTask object
  130086. */
  130087. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130088. /**
  130089. * Remove a task from the assets manager.
  130090. * @param task the task to remove
  130091. */
  130092. removeTask(task: AbstractAssetTask): void;
  130093. private _decreaseWaitingTasksCount;
  130094. private _runTask;
  130095. /**
  130096. * Reset the AssetsManager and remove all tasks
  130097. * @return the current instance of the AssetsManager
  130098. */
  130099. reset(): AssetsManager;
  130100. /**
  130101. * Start the loading process
  130102. * @return the current instance of the AssetsManager
  130103. */
  130104. load(): AssetsManager;
  130105. /**
  130106. * Start the loading process as an async operation
  130107. * @return a promise returning the list of failed tasks
  130108. */
  130109. loadAsync(): Promise<void>;
  130110. }
  130111. }
  130112. declare module BABYLON {
  130113. /**
  130114. * Wrapper class for promise with external resolve and reject.
  130115. */
  130116. export class Deferred<T> {
  130117. /**
  130118. * The promise associated with this deferred object.
  130119. */
  130120. readonly promise: Promise<T>;
  130121. private _resolve;
  130122. private _reject;
  130123. /**
  130124. * The resolve method of the promise associated with this deferred object.
  130125. */
  130126. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130127. /**
  130128. * The reject method of the promise associated with this deferred object.
  130129. */
  130130. readonly reject: (reason?: any) => void;
  130131. /**
  130132. * Constructor for this deferred object.
  130133. */
  130134. constructor();
  130135. }
  130136. }
  130137. declare module BABYLON {
  130138. /**
  130139. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130140. */
  130141. export class MeshExploder {
  130142. private _centerMesh;
  130143. private _meshes;
  130144. private _meshesOrigins;
  130145. private _toCenterVectors;
  130146. private _scaledDirection;
  130147. private _newPosition;
  130148. private _centerPosition;
  130149. /**
  130150. * Explodes meshes from a center mesh.
  130151. * @param meshes The meshes to explode.
  130152. * @param centerMesh The mesh to be center of explosion.
  130153. */
  130154. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130155. private _setCenterMesh;
  130156. /**
  130157. * Get class name
  130158. * @returns "MeshExploder"
  130159. */
  130160. getClassName(): string;
  130161. /**
  130162. * "Exploded meshes"
  130163. * @returns Array of meshes with the centerMesh at index 0.
  130164. */
  130165. getMeshes(): Array<Mesh>;
  130166. /**
  130167. * Explodes meshes giving a specific direction
  130168. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130169. */
  130170. explode(direction?: number): void;
  130171. }
  130172. }
  130173. declare module BABYLON {
  130174. /**
  130175. * Class used to help managing file picking and drag'n'drop
  130176. */
  130177. export class FilesInput {
  130178. /**
  130179. * List of files ready to be loaded
  130180. */
  130181. static readonly FilesToLoad: {
  130182. [key: string]: File;
  130183. };
  130184. /**
  130185. * Callback called when a file is processed
  130186. */
  130187. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130188. private _engine;
  130189. private _currentScene;
  130190. private _sceneLoadedCallback;
  130191. private _progressCallback;
  130192. private _additionalRenderLoopLogicCallback;
  130193. private _textureLoadingCallback;
  130194. private _startingProcessingFilesCallback;
  130195. private _onReloadCallback;
  130196. private _errorCallback;
  130197. private _elementToMonitor;
  130198. private _sceneFileToLoad;
  130199. private _filesToLoad;
  130200. /**
  130201. * Creates a new FilesInput
  130202. * @param engine defines the rendering engine
  130203. * @param scene defines the hosting scene
  130204. * @param sceneLoadedCallback callback called when scene is loaded
  130205. * @param progressCallback callback called to track progress
  130206. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130207. * @param textureLoadingCallback callback called when a texture is loading
  130208. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130209. * @param onReloadCallback callback called when a reload is requested
  130210. * @param errorCallback callback call if an error occurs
  130211. */
  130212. 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);
  130213. private _dragEnterHandler;
  130214. private _dragOverHandler;
  130215. private _dropHandler;
  130216. /**
  130217. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130218. * @param elementToMonitor defines the DOM element to track
  130219. */
  130220. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130221. /**
  130222. * Release all associated resources
  130223. */
  130224. dispose(): void;
  130225. private renderFunction;
  130226. private drag;
  130227. private drop;
  130228. private _traverseFolder;
  130229. private _processFiles;
  130230. /**
  130231. * Load files from a drop event
  130232. * @param event defines the drop event to use as source
  130233. */
  130234. loadFiles(event: any): void;
  130235. private _processReload;
  130236. /**
  130237. * Reload the current scene from the loaded files
  130238. */
  130239. reload(): void;
  130240. }
  130241. }
  130242. declare module BABYLON {
  130243. /**
  130244. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130245. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130246. */
  130247. export class SceneOptimization {
  130248. /**
  130249. * Defines the priority of this optimization (0 by default which means first in the list)
  130250. */
  130251. priority: number;
  130252. /**
  130253. * Gets a string describing the action executed by the current optimization
  130254. * @returns description string
  130255. */
  130256. getDescription(): string;
  130257. /**
  130258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130259. * @param scene defines the current scene where to apply this optimization
  130260. * @param optimizer defines the current optimizer
  130261. * @returns true if everything that can be done was applied
  130262. */
  130263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130264. /**
  130265. * Creates the SceneOptimization object
  130266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130267. * @param desc defines the description associated with the optimization
  130268. */
  130269. constructor(
  130270. /**
  130271. * Defines the priority of this optimization (0 by default which means first in the list)
  130272. */
  130273. priority?: number);
  130274. }
  130275. /**
  130276. * Defines an optimization used to reduce the size of render target textures
  130277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130278. */
  130279. export class TextureOptimization extends SceneOptimization {
  130280. /**
  130281. * Defines the priority of this optimization (0 by default which means first in the list)
  130282. */
  130283. priority: number;
  130284. /**
  130285. * 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
  130286. */
  130287. maximumSize: number;
  130288. /**
  130289. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130290. */
  130291. step: number;
  130292. /**
  130293. * Gets a string describing the action executed by the current optimization
  130294. * @returns description string
  130295. */
  130296. getDescription(): string;
  130297. /**
  130298. * Creates the TextureOptimization object
  130299. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130300. * @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
  130301. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130302. */
  130303. constructor(
  130304. /**
  130305. * Defines the priority of this optimization (0 by default which means first in the list)
  130306. */
  130307. priority?: number,
  130308. /**
  130309. * 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
  130310. */
  130311. maximumSize?: number,
  130312. /**
  130313. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130314. */
  130315. step?: number);
  130316. /**
  130317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130318. * @param scene defines the current scene where to apply this optimization
  130319. * @param optimizer defines the current optimizer
  130320. * @returns true if everything that can be done was applied
  130321. */
  130322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130323. }
  130324. /**
  130325. * Defines an optimization used to increase or decrease the rendering resolution
  130326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130327. */
  130328. export class HardwareScalingOptimization extends SceneOptimization {
  130329. /**
  130330. * Defines the priority of this optimization (0 by default which means first in the list)
  130331. */
  130332. priority: number;
  130333. /**
  130334. * Defines the maximum scale to use (2 by default)
  130335. */
  130336. maximumScale: number;
  130337. /**
  130338. * Defines the step to use between two passes (0.5 by default)
  130339. */
  130340. step: number;
  130341. private _currentScale;
  130342. private _directionOffset;
  130343. /**
  130344. * Gets a string describing the action executed by the current optimization
  130345. * @return description string
  130346. */
  130347. getDescription(): string;
  130348. /**
  130349. * Creates the HardwareScalingOptimization object
  130350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130351. * @param maximumScale defines the maximum scale to use (2 by default)
  130352. * @param step defines the step to use between two passes (0.5 by default)
  130353. */
  130354. constructor(
  130355. /**
  130356. * Defines the priority of this optimization (0 by default which means first in the list)
  130357. */
  130358. priority?: number,
  130359. /**
  130360. * Defines the maximum scale to use (2 by default)
  130361. */
  130362. maximumScale?: number,
  130363. /**
  130364. * Defines the step to use between two passes (0.5 by default)
  130365. */
  130366. step?: number);
  130367. /**
  130368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130369. * @param scene defines the current scene where to apply this optimization
  130370. * @param optimizer defines the current optimizer
  130371. * @returns true if everything that can be done was applied
  130372. */
  130373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130374. }
  130375. /**
  130376. * Defines an optimization used to remove shadows
  130377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130378. */
  130379. export class ShadowsOptimization extends SceneOptimization {
  130380. /**
  130381. * Gets a string describing the action executed by the current optimization
  130382. * @return description string
  130383. */
  130384. getDescription(): string;
  130385. /**
  130386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130387. * @param scene defines the current scene where to apply this optimization
  130388. * @param optimizer defines the current optimizer
  130389. * @returns true if everything that can be done was applied
  130390. */
  130391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130392. }
  130393. /**
  130394. * Defines an optimization used to turn post-processes off
  130395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130396. */
  130397. export class PostProcessesOptimization extends SceneOptimization {
  130398. /**
  130399. * Gets a string describing the action executed by the current optimization
  130400. * @return description string
  130401. */
  130402. getDescription(): string;
  130403. /**
  130404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130405. * @param scene defines the current scene where to apply this optimization
  130406. * @param optimizer defines the current optimizer
  130407. * @returns true if everything that can be done was applied
  130408. */
  130409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130410. }
  130411. /**
  130412. * Defines an optimization used to turn lens flares off
  130413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130414. */
  130415. export class LensFlaresOptimization extends SceneOptimization {
  130416. /**
  130417. * Gets a string describing the action executed by the current optimization
  130418. * @return description string
  130419. */
  130420. getDescription(): string;
  130421. /**
  130422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130423. * @param scene defines the current scene where to apply this optimization
  130424. * @param optimizer defines the current optimizer
  130425. * @returns true if everything that can be done was applied
  130426. */
  130427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130428. }
  130429. /**
  130430. * Defines an optimization based on user defined callback.
  130431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130432. */
  130433. export class CustomOptimization extends SceneOptimization {
  130434. /**
  130435. * Callback called to apply the custom optimization.
  130436. */
  130437. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  130438. /**
  130439. * Callback called to get custom description
  130440. */
  130441. onGetDescription: () => string;
  130442. /**
  130443. * Gets a string describing the action executed by the current optimization
  130444. * @returns description string
  130445. */
  130446. getDescription(): string;
  130447. /**
  130448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130449. * @param scene defines the current scene where to apply this optimization
  130450. * @param optimizer defines the current optimizer
  130451. * @returns true if everything that can be done was applied
  130452. */
  130453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130454. }
  130455. /**
  130456. * Defines an optimization used to turn particles off
  130457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130458. */
  130459. export class ParticlesOptimization extends SceneOptimization {
  130460. /**
  130461. * Gets a string describing the action executed by the current optimization
  130462. * @return description string
  130463. */
  130464. getDescription(): string;
  130465. /**
  130466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130467. * @param scene defines the current scene where to apply this optimization
  130468. * @param optimizer defines the current optimizer
  130469. * @returns true if everything that can be done was applied
  130470. */
  130471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130472. }
  130473. /**
  130474. * Defines an optimization used to turn render targets off
  130475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130476. */
  130477. export class RenderTargetsOptimization extends SceneOptimization {
  130478. /**
  130479. * Gets a string describing the action executed by the current optimization
  130480. * @return description string
  130481. */
  130482. getDescription(): string;
  130483. /**
  130484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130485. * @param scene defines the current scene where to apply this optimization
  130486. * @param optimizer defines the current optimizer
  130487. * @returns true if everything that can be done was applied
  130488. */
  130489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130490. }
  130491. /**
  130492. * Defines an optimization used to merge meshes with compatible materials
  130493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130494. */
  130495. export class MergeMeshesOptimization extends SceneOptimization {
  130496. private static _UpdateSelectionTree;
  130497. /**
  130498. * Gets or sets a boolean which defines if optimization octree has to be updated
  130499. */
  130500. /**
  130501. * Gets or sets a boolean which defines if optimization octree has to be updated
  130502. */
  130503. static UpdateSelectionTree: boolean;
  130504. /**
  130505. * Gets a string describing the action executed by the current optimization
  130506. * @return description string
  130507. */
  130508. getDescription(): string;
  130509. private _canBeMerged;
  130510. /**
  130511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130512. * @param scene defines the current scene where to apply this optimization
  130513. * @param optimizer defines the current optimizer
  130514. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  130515. * @returns true if everything that can be done was applied
  130516. */
  130517. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  130518. }
  130519. /**
  130520. * Defines a list of options used by SceneOptimizer
  130521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130522. */
  130523. export class SceneOptimizerOptions {
  130524. /**
  130525. * Defines the target frame rate to reach (60 by default)
  130526. */
  130527. targetFrameRate: number;
  130528. /**
  130529. * Defines the interval between two checkes (2000ms by default)
  130530. */
  130531. trackerDuration: number;
  130532. /**
  130533. * Gets the list of optimizations to apply
  130534. */
  130535. optimizations: SceneOptimization[];
  130536. /**
  130537. * Creates a new list of options used by SceneOptimizer
  130538. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  130539. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  130540. */
  130541. constructor(
  130542. /**
  130543. * Defines the target frame rate to reach (60 by default)
  130544. */
  130545. targetFrameRate?: number,
  130546. /**
  130547. * Defines the interval between two checkes (2000ms by default)
  130548. */
  130549. trackerDuration?: number);
  130550. /**
  130551. * Add a new optimization
  130552. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  130553. * @returns the current SceneOptimizerOptions
  130554. */
  130555. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  130556. /**
  130557. * Add a new custom optimization
  130558. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  130559. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  130560. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130561. * @returns the current SceneOptimizerOptions
  130562. */
  130563. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  130564. /**
  130565. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  130566. * @param targetFrameRate defines the target frame rate (60 by default)
  130567. * @returns a SceneOptimizerOptions object
  130568. */
  130569. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130570. /**
  130571. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  130572. * @param targetFrameRate defines the target frame rate (60 by default)
  130573. * @returns a SceneOptimizerOptions object
  130574. */
  130575. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130576. /**
  130577. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  130578. * @param targetFrameRate defines the target frame rate (60 by default)
  130579. * @returns a SceneOptimizerOptions object
  130580. */
  130581. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  130582. }
  130583. /**
  130584. * Class used to run optimizations in order to reach a target frame rate
  130585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130586. */
  130587. export class SceneOptimizer implements IDisposable {
  130588. private _isRunning;
  130589. private _options;
  130590. private _scene;
  130591. private _currentPriorityLevel;
  130592. private _targetFrameRate;
  130593. private _trackerDuration;
  130594. private _currentFrameRate;
  130595. private _sceneDisposeObserver;
  130596. private _improvementMode;
  130597. /**
  130598. * Defines an observable called when the optimizer reaches the target frame rate
  130599. */
  130600. onSuccessObservable: Observable<SceneOptimizer>;
  130601. /**
  130602. * Defines an observable called when the optimizer enables an optimization
  130603. */
  130604. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  130605. /**
  130606. * Defines an observable called when the optimizer is not able to reach the target frame rate
  130607. */
  130608. onFailureObservable: Observable<SceneOptimizer>;
  130609. /**
  130610. * Gets a boolean indicating if the optimizer is in improvement mode
  130611. */
  130612. readonly isInImprovementMode: boolean;
  130613. /**
  130614. * Gets the current priority level (0 at start)
  130615. */
  130616. readonly currentPriorityLevel: number;
  130617. /**
  130618. * Gets the current frame rate checked by the SceneOptimizer
  130619. */
  130620. readonly currentFrameRate: number;
  130621. /**
  130622. * Gets or sets the current target frame rate (60 by default)
  130623. */
  130624. /**
  130625. * Gets or sets the current target frame rate (60 by default)
  130626. */
  130627. targetFrameRate: number;
  130628. /**
  130629. * Gets or sets the current interval between two checks (every 2000ms by default)
  130630. */
  130631. /**
  130632. * Gets or sets the current interval between two checks (every 2000ms by default)
  130633. */
  130634. trackerDuration: number;
  130635. /**
  130636. * Gets the list of active optimizations
  130637. */
  130638. readonly optimizations: SceneOptimization[];
  130639. /**
  130640. * Creates a new SceneOptimizer
  130641. * @param scene defines the scene to work on
  130642. * @param options defines the options to use with the SceneOptimizer
  130643. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  130644. * @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)
  130645. */
  130646. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  130647. /**
  130648. * Stops the current optimizer
  130649. */
  130650. stop(): void;
  130651. /**
  130652. * Reset the optimizer to initial step (current priority level = 0)
  130653. */
  130654. reset(): void;
  130655. /**
  130656. * Start the optimizer. By default it will try to reach a specific framerate
  130657. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  130658. */
  130659. start(): void;
  130660. private _checkCurrentState;
  130661. /**
  130662. * Release all resources
  130663. */
  130664. dispose(): void;
  130665. /**
  130666. * Helper function to create a SceneOptimizer with one single line of code
  130667. * @param scene defines the scene to work on
  130668. * @param options defines the options to use with the SceneOptimizer
  130669. * @param onSuccess defines a callback to call on success
  130670. * @param onFailure defines a callback to call on failure
  130671. * @returns the new SceneOptimizer object
  130672. */
  130673. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  130674. }
  130675. }
  130676. declare module BABYLON {
  130677. /**
  130678. * Class used to serialize a scene into a string
  130679. */
  130680. export class SceneSerializer {
  130681. /**
  130682. * Clear cache used by a previous serialization
  130683. */
  130684. static ClearCache(): void;
  130685. /**
  130686. * Serialize a scene into a JSON compatible object
  130687. * @param scene defines the scene to serialize
  130688. * @returns a JSON compatible object
  130689. */
  130690. static Serialize(scene: Scene): any;
  130691. /**
  130692. * Serialize a mesh into a JSON compatible object
  130693. * @param toSerialize defines the mesh to serialize
  130694. * @param withParents defines if parents must be serialized as well
  130695. * @param withChildren defines if children must be serialized as well
  130696. * @returns a JSON compatible object
  130697. */
  130698. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  130699. }
  130700. }
  130701. declare module BABYLON {
  130702. /**
  130703. * Class used to host texture specific utilities
  130704. */
  130705. export class TextureTools {
  130706. /**
  130707. * Uses the GPU to create a copy texture rescaled at a given size
  130708. * @param texture Texture to copy from
  130709. * @param width defines the desired width
  130710. * @param height defines the desired height
  130711. * @param useBilinearMode defines if bilinear mode has to be used
  130712. * @return the generated texture
  130713. */
  130714. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  130715. }
  130716. }
  130717. declare module BABYLON {
  130718. /**
  130719. * This represents the different options available for the video capture.
  130720. */
  130721. export interface VideoRecorderOptions {
  130722. /** Defines the mime type of the video. */
  130723. mimeType: string;
  130724. /** Defines the FPS the video should be recorded at. */
  130725. fps: number;
  130726. /** Defines the chunk size for the recording data. */
  130727. recordChunckSize: number;
  130728. /** The audio tracks to attach to the recording. */
  130729. audioTracks?: MediaStreamTrack[];
  130730. }
  130731. /**
  130732. * This can help with recording videos from BabylonJS.
  130733. * This is based on the available WebRTC functionalities of the browser.
  130734. *
  130735. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  130736. */
  130737. export class VideoRecorder {
  130738. private static readonly _defaultOptions;
  130739. /**
  130740. * Returns whether or not the VideoRecorder is available in your browser.
  130741. * @param engine Defines the Babylon Engine.
  130742. * @returns true if supported otherwise false.
  130743. */
  130744. static IsSupported(engine: Engine): boolean;
  130745. private readonly _options;
  130746. private _canvas;
  130747. private _mediaRecorder;
  130748. private _recordedChunks;
  130749. private _fileName;
  130750. private _resolve;
  130751. private _reject;
  130752. /**
  130753. * True when a recording is already in progress.
  130754. */
  130755. readonly isRecording: boolean;
  130756. /**
  130757. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  130758. * @param engine Defines the BabylonJS Engine you wish to record.
  130759. * @param options Defines options that can be used to customize the capture.
  130760. */
  130761. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  130762. /**
  130763. * Stops the current recording before the default capture timeout passed in the startRecording function.
  130764. */
  130765. stopRecording(): void;
  130766. /**
  130767. * Starts recording the canvas for a max duration specified in parameters.
  130768. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  130769. * If null no automatic download will start and you can rely on the promise to get the data back.
  130770. * @param maxDuration Defines the maximum recording time in seconds.
  130771. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  130772. * @return A promise callback at the end of the recording with the video data in Blob.
  130773. */
  130774. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  130775. /**
  130776. * Releases internal resources used during the recording.
  130777. */
  130778. dispose(): void;
  130779. private _handleDataAvailable;
  130780. private _handleError;
  130781. private _handleStop;
  130782. }
  130783. }
  130784. declare module BABYLON {
  130785. /**
  130786. * Class containing a set of static utilities functions for screenshots
  130787. */
  130788. export class ScreenshotTools {
  130789. /**
  130790. * Captures a screenshot of the current rendering
  130791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130792. * @param engine defines the rendering engine
  130793. * @param camera defines the source camera
  130794. * @param size This parameter can be set to a single number or to an object with the
  130795. * following (optional) properties: precision, width, height. If a single number is passed,
  130796. * it will be used for both width and height. If an object is passed, the screenshot size
  130797. * will be derived from the parameters. The precision property is a multiplier allowing
  130798. * rendering at a higher or lower resolution
  130799. * @param successCallback defines the callback receives a single parameter which contains the
  130800. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130801. * src parameter of an <img> to display it
  130802. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130803. * Check your browser for supported MIME types
  130804. */
  130805. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  130806. /**
  130807. * Captures a screenshot of the current rendering
  130808. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130809. * @param engine defines the rendering engine
  130810. * @param camera defines the source camera
  130811. * @param size This parameter can be set to a single number or to an object with the
  130812. * following (optional) properties: precision, width, height. If a single number is passed,
  130813. * it will be used for both width and height. If an object is passed, the screenshot size
  130814. * will be derived from the parameters. The precision property is a multiplier allowing
  130815. * rendering at a higher or lower resolution
  130816. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  130817. * Check your browser for supported MIME types
  130818. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  130819. * to the src parameter of an <img> to display it
  130820. */
  130821. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  130822. /**
  130823. * Generates an image screenshot from the specified camera.
  130824. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130825. * @param engine The engine to use for rendering
  130826. * @param camera The camera to use for rendering
  130827. * @param size This parameter can be set to a single number or to an object with the
  130828. * following (optional) properties: precision, width, height. If a single number is passed,
  130829. * it will be used for both width and height. If an object is passed, the screenshot size
  130830. * will be derived from the parameters. The precision property is a multiplier allowing
  130831. * rendering at a higher or lower resolution
  130832. * @param successCallback The callback receives a single parameter which contains the
  130833. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  130834. * src parameter of an <img> to display it
  130835. * @param mimeType The MIME type of the screenshot image (default: image/png).
  130836. * Check your browser for supported MIME types
  130837. * @param samples Texture samples (default: 1)
  130838. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  130839. * @param fileName A name for for the downloaded file.
  130840. */
  130841. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  130842. /**
  130843. * Generates an image screenshot from the specified camera.
  130844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  130845. * @param engine The engine to use for rendering
  130846. * @param camera The camera to use for rendering
  130847. * @param size This parameter can be set to a single number or to an object with the
  130848. * following (optional) properties: precision, width, height. If a single number is passed,
  130849. * it will be used for both width and height. If an object is passed, the screenshot size
  130850. * will be derived from the parameters. The precision property is a multiplier allowing
  130851. * rendering at a higher or lower resolution
  130852. * @param mimeType The MIME type of the screenshot image (default: image/png).
  130853. * Check your browser for supported MIME types
  130854. * @param samples Texture samples (default: 1)
  130855. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  130856. * @param fileName A name for for the downloaded file.
  130857. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  130858. * to the src parameter of an <img> to display it
  130859. */
  130860. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  130861. /**
  130862. * Gets height and width for screenshot size
  130863. * @private
  130864. */
  130865. private static _getScreenshotSize;
  130866. }
  130867. }
  130868. declare module BABYLON {
  130869. /**
  130870. * A cursor which tracks a point on a path
  130871. */
  130872. export class PathCursor {
  130873. private path;
  130874. /**
  130875. * Stores path cursor callbacks for when an onchange event is triggered
  130876. */
  130877. private _onchange;
  130878. /**
  130879. * The value of the path cursor
  130880. */
  130881. value: number;
  130882. /**
  130883. * The animation array of the path cursor
  130884. */
  130885. animations: Animation[];
  130886. /**
  130887. * Initializes the path cursor
  130888. * @param path The path to track
  130889. */
  130890. constructor(path: Path2);
  130891. /**
  130892. * Gets the cursor point on the path
  130893. * @returns A point on the path cursor at the cursor location
  130894. */
  130895. getPoint(): Vector3;
  130896. /**
  130897. * Moves the cursor ahead by the step amount
  130898. * @param step The amount to move the cursor forward
  130899. * @returns This path cursor
  130900. */
  130901. moveAhead(step?: number): PathCursor;
  130902. /**
  130903. * Moves the cursor behind by the step amount
  130904. * @param step The amount to move the cursor back
  130905. * @returns This path cursor
  130906. */
  130907. moveBack(step?: number): PathCursor;
  130908. /**
  130909. * Moves the cursor by the step amount
  130910. * If the step amount is greater than one, an exception is thrown
  130911. * @param step The amount to move the cursor
  130912. * @returns This path cursor
  130913. */
  130914. move(step: number): PathCursor;
  130915. /**
  130916. * Ensures that the value is limited between zero and one
  130917. * @returns This path cursor
  130918. */
  130919. private ensureLimits;
  130920. /**
  130921. * Runs onchange callbacks on change (used by the animation engine)
  130922. * @returns This path cursor
  130923. */
  130924. private raiseOnChange;
  130925. /**
  130926. * Executes a function on change
  130927. * @param f A path cursor onchange callback
  130928. * @returns This path cursor
  130929. */
  130930. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130931. }
  130932. }
  130933. declare module BABYLON {
  130934. /** @hidden */
  130935. export var blurPixelShader: {
  130936. name: string;
  130937. shader: string;
  130938. };
  130939. }
  130940. declare module BABYLON {
  130941. /** @hidden */
  130942. export var pointCloudVertexDeclaration: {
  130943. name: string;
  130944. shader: string;
  130945. };
  130946. }
  130947. // Mixins
  130948. interface Window {
  130949. mozIndexedDB: IDBFactory;
  130950. webkitIndexedDB: IDBFactory;
  130951. msIndexedDB: IDBFactory;
  130952. webkitURL: typeof URL;
  130953. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130954. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130955. WebGLRenderingContext: WebGLRenderingContext;
  130956. MSGesture: MSGesture;
  130957. CANNON: any;
  130958. AudioContext: AudioContext;
  130959. webkitAudioContext: AudioContext;
  130960. PointerEvent: any;
  130961. Math: Math;
  130962. Uint8Array: Uint8ArrayConstructor;
  130963. Float32Array: Float32ArrayConstructor;
  130964. mozURL: typeof URL;
  130965. msURL: typeof URL;
  130966. VRFrameData: any; // WebVR, from specs 1.1
  130967. DracoDecoderModule: any;
  130968. setImmediate(handler: (...args: any[]) => void): number;
  130969. }
  130970. interface HTMLCanvasElement {
  130971. requestPointerLock(): void;
  130972. msRequestPointerLock?(): void;
  130973. mozRequestPointerLock?(): void;
  130974. webkitRequestPointerLock?(): void;
  130975. /** Track wether a record is in progress */
  130976. isRecording: boolean;
  130977. /** Capture Stream method defined by some browsers */
  130978. captureStream(fps?: number): MediaStream;
  130979. }
  130980. interface CanvasRenderingContext2D {
  130981. msImageSmoothingEnabled: boolean;
  130982. }
  130983. interface MouseEvent {
  130984. mozMovementX: number;
  130985. mozMovementY: number;
  130986. webkitMovementX: number;
  130987. webkitMovementY: number;
  130988. msMovementX: number;
  130989. msMovementY: number;
  130990. }
  130991. interface Navigator {
  130992. mozGetVRDevices: (any: any) => any;
  130993. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130994. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130995. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130996. webkitGetGamepads(): Gamepad[];
  130997. msGetGamepads(): Gamepad[];
  130998. webkitGamepads(): Gamepad[];
  130999. }
  131000. interface HTMLVideoElement {
  131001. mozSrcObject: any;
  131002. }
  131003. interface Math {
  131004. fround(x: number): number;
  131005. imul(a: number, b: number): number;
  131006. }
  131007. interface WebGLRenderingContext {
  131008. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131009. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131010. vertexAttribDivisor(index: number, divisor: number): void;
  131011. createVertexArray(): any;
  131012. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131013. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131014. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131015. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131016. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131017. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131018. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131019. // Queries
  131020. createQuery(): WebGLQuery;
  131021. deleteQuery(query: WebGLQuery): void;
  131022. beginQuery(target: number, query: WebGLQuery): void;
  131023. endQuery(target: number): void;
  131024. getQueryParameter(query: WebGLQuery, pname: number): any;
  131025. getQuery(target: number, pname: number): any;
  131026. MAX_SAMPLES: number;
  131027. RGBA8: number;
  131028. READ_FRAMEBUFFER: number;
  131029. DRAW_FRAMEBUFFER: number;
  131030. UNIFORM_BUFFER: number;
  131031. HALF_FLOAT_OES: number;
  131032. RGBA16F: number;
  131033. RGBA32F: number;
  131034. R32F: number;
  131035. RG32F: number;
  131036. RGB32F: number;
  131037. R16F: number;
  131038. RG16F: number;
  131039. RGB16F: number;
  131040. RED: number;
  131041. RG: number;
  131042. R8: number;
  131043. RG8: number;
  131044. UNSIGNED_INT_24_8: number;
  131045. DEPTH24_STENCIL8: number;
  131046. MIN: number;
  131047. MAX: number;
  131048. /* Multiple Render Targets */
  131049. drawBuffers(buffers: number[]): void;
  131050. readBuffer(src: number): void;
  131051. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131052. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131053. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131054. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131055. // Occlusion Query
  131056. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131057. ANY_SAMPLES_PASSED: number;
  131058. QUERY_RESULT_AVAILABLE: number;
  131059. QUERY_RESULT: number;
  131060. }
  131061. interface WebGLProgram {
  131062. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131063. }
  131064. interface EXT_disjoint_timer_query {
  131065. QUERY_COUNTER_BITS_EXT: number;
  131066. TIME_ELAPSED_EXT: number;
  131067. TIMESTAMP_EXT: number;
  131068. GPU_DISJOINT_EXT: number;
  131069. QUERY_RESULT_EXT: number;
  131070. QUERY_RESULT_AVAILABLE_EXT: number;
  131071. queryCounterEXT(query: WebGLQuery, target: number): void;
  131072. createQueryEXT(): WebGLQuery;
  131073. beginQueryEXT(target: number, query: WebGLQuery): void;
  131074. endQueryEXT(target: number): void;
  131075. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131076. deleteQueryEXT(query: WebGLQuery): void;
  131077. }
  131078. interface WebGLUniformLocation {
  131079. _currentState: any;
  131080. }
  131081. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131082. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131083. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131084. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131085. interface WebGLRenderingContext {
  131086. readonly RASTERIZER_DISCARD: number;
  131087. readonly DEPTH_COMPONENT24: number;
  131088. readonly TEXTURE_3D: number;
  131089. readonly TEXTURE_2D_ARRAY: number;
  131090. readonly TEXTURE_COMPARE_FUNC: number;
  131091. readonly TEXTURE_COMPARE_MODE: number;
  131092. readonly COMPARE_REF_TO_TEXTURE: number;
  131093. readonly TEXTURE_WRAP_R: number;
  131094. readonly HALF_FLOAT: number;
  131095. readonly RGB8: number;
  131096. readonly RED_INTEGER: number;
  131097. readonly RG_INTEGER: number;
  131098. readonly RGB_INTEGER: number;
  131099. readonly RGBA_INTEGER: number;
  131100. readonly R8_SNORM: number;
  131101. readonly RG8_SNORM: number;
  131102. readonly RGB8_SNORM: number;
  131103. readonly RGBA8_SNORM: number;
  131104. readonly R8I: number;
  131105. readonly RG8I: number;
  131106. readonly RGB8I: number;
  131107. readonly RGBA8I: number;
  131108. readonly R8UI: number;
  131109. readonly RG8UI: number;
  131110. readonly RGB8UI: number;
  131111. readonly RGBA8UI: number;
  131112. readonly R16I: number;
  131113. readonly RG16I: number;
  131114. readonly RGB16I: number;
  131115. readonly RGBA16I: number;
  131116. readonly R16UI: number;
  131117. readonly RG16UI: number;
  131118. readonly RGB16UI: number;
  131119. readonly RGBA16UI: number;
  131120. readonly R32I: number;
  131121. readonly RG32I: number;
  131122. readonly RGB32I: number;
  131123. readonly RGBA32I: number;
  131124. readonly R32UI: number;
  131125. readonly RG32UI: number;
  131126. readonly RGB32UI: number;
  131127. readonly RGBA32UI: number;
  131128. readonly RGB10_A2UI: number;
  131129. readonly R11F_G11F_B10F: number;
  131130. readonly RGB9_E5: number;
  131131. readonly RGB10_A2: number;
  131132. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131133. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131134. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131135. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131136. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131137. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131138. 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;
  131139. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131140. readonly TRANSFORM_FEEDBACK: number;
  131141. readonly INTERLEAVED_ATTRIBS: number;
  131142. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131143. createTransformFeedback(): WebGLTransformFeedback;
  131144. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131145. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131146. beginTransformFeedback(primitiveMode: number): void;
  131147. endTransformFeedback(): void;
  131148. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131149. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131150. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131151. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131152. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131153. }
  131154. interface ImageBitmap {
  131155. readonly width: number;
  131156. readonly height: number;
  131157. close(): void;
  131158. }
  131159. interface WebGLQuery extends WebGLObject {
  131160. }
  131161. declare var WebGLQuery: {
  131162. prototype: WebGLQuery;
  131163. new(): WebGLQuery;
  131164. };
  131165. interface WebGLSampler extends WebGLObject {
  131166. }
  131167. declare var WebGLSampler: {
  131168. prototype: WebGLSampler;
  131169. new(): WebGLSampler;
  131170. };
  131171. interface WebGLSync extends WebGLObject {
  131172. }
  131173. declare var WebGLSync: {
  131174. prototype: WebGLSync;
  131175. new(): WebGLSync;
  131176. };
  131177. interface WebGLTransformFeedback extends WebGLObject {
  131178. }
  131179. declare var WebGLTransformFeedback: {
  131180. prototype: WebGLTransformFeedback;
  131181. new(): WebGLTransformFeedback;
  131182. };
  131183. interface WebGLVertexArrayObject extends WebGLObject {
  131184. }
  131185. declare var WebGLVertexArrayObject: {
  131186. prototype: WebGLVertexArrayObject;
  131187. new(): WebGLVertexArrayObject;
  131188. };
  131189. // Type definitions for WebVR API
  131190. // Project: https://w3c.github.io/webvr/
  131191. // Definitions by: six a <https://github.com/lostfictions>
  131192. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131193. interface VRDisplay extends EventTarget {
  131194. /**
  131195. * Dictionary of capabilities describing the VRDisplay.
  131196. */
  131197. readonly capabilities: VRDisplayCapabilities;
  131198. /**
  131199. * z-depth defining the far plane of the eye view frustum
  131200. * enables mapping of values in the render target depth
  131201. * attachment to scene coordinates. Initially set to 10000.0.
  131202. */
  131203. depthFar: number;
  131204. /**
  131205. * z-depth defining the near plane of the eye view frustum
  131206. * enables mapping of values in the render target depth
  131207. * attachment to scene coordinates. Initially set to 0.01.
  131208. */
  131209. depthNear: number;
  131210. /**
  131211. * An identifier for this distinct VRDisplay. Used as an
  131212. * association point in the Gamepad API.
  131213. */
  131214. readonly displayId: number;
  131215. /**
  131216. * A display name, a user-readable name identifying it.
  131217. */
  131218. readonly displayName: string;
  131219. readonly isConnected: boolean;
  131220. readonly isPresenting: boolean;
  131221. /**
  131222. * If this VRDisplay supports room-scale experiences, the optional
  131223. * stage attribute contains details on the room-scale parameters.
  131224. */
  131225. readonly stageParameters: VRStageParameters | null;
  131226. /**
  131227. * Passing the value returned by `requestAnimationFrame` to
  131228. * `cancelAnimationFrame` will unregister the callback.
  131229. * @param handle Define the hanle of the request to cancel
  131230. */
  131231. cancelAnimationFrame(handle: number): void;
  131232. /**
  131233. * Stops presenting to the VRDisplay.
  131234. * @returns a promise to know when it stopped
  131235. */
  131236. exitPresent(): Promise<void>;
  131237. /**
  131238. * Return the current VREyeParameters for the given eye.
  131239. * @param whichEye Define the eye we want the parameter for
  131240. * @returns the eye parameters
  131241. */
  131242. getEyeParameters(whichEye: string): VREyeParameters;
  131243. /**
  131244. * Populates the passed VRFrameData with the information required to render
  131245. * the current frame.
  131246. * @param frameData Define the data structure to populate
  131247. * @returns true if ok otherwise false
  131248. */
  131249. getFrameData(frameData: VRFrameData): boolean;
  131250. /**
  131251. * Get the layers currently being presented.
  131252. * @returns the list of VR layers
  131253. */
  131254. getLayers(): VRLayer[];
  131255. /**
  131256. * Return a VRPose containing the future predicted pose of the VRDisplay
  131257. * when the current frame will be presented. The value returned will not
  131258. * change until JavaScript has returned control to the browser.
  131259. *
  131260. * The VRPose will contain the position, orientation, velocity,
  131261. * and acceleration of each of these properties.
  131262. * @returns the pose object
  131263. */
  131264. getPose(): VRPose;
  131265. /**
  131266. * Return the current instantaneous pose of the VRDisplay, with no
  131267. * prediction applied.
  131268. * @returns the current instantaneous pose
  131269. */
  131270. getImmediatePose(): VRPose;
  131271. /**
  131272. * The callback passed to `requestAnimationFrame` will be called
  131273. * any time a new frame should be rendered. When the VRDisplay is
  131274. * presenting the callback will be called at the native refresh
  131275. * rate of the HMD. When not presenting this function acts
  131276. * identically to how window.requestAnimationFrame acts. Content should
  131277. * make no assumptions of frame rate or vsync behavior as the HMD runs
  131278. * asynchronously from other displays and at differing refresh rates.
  131279. * @param callback Define the eaction to run next frame
  131280. * @returns the request handle it
  131281. */
  131282. requestAnimationFrame(callback: FrameRequestCallback): number;
  131283. /**
  131284. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  131285. * Repeat calls while already presenting will update the VRLayers being displayed.
  131286. * @param layers Define the list of layer to present
  131287. * @returns a promise to know when the request has been fulfilled
  131288. */
  131289. requestPresent(layers: VRLayer[]): Promise<void>;
  131290. /**
  131291. * Reset the pose for this display, treating its current position and
  131292. * orientation as the "origin/zero" values. VRPose.position,
  131293. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  131294. * updated when calling resetPose(). This should be called in only
  131295. * sitting-space experiences.
  131296. */
  131297. resetPose(): void;
  131298. /**
  131299. * The VRLayer provided to the VRDisplay will be captured and presented
  131300. * in the HMD. Calling this function has the same effect on the source
  131301. * canvas as any other operation that uses its source image, and canvases
  131302. * created without preserveDrawingBuffer set to true will be cleared.
  131303. * @param pose Define the pose to submit
  131304. */
  131305. submitFrame(pose?: VRPose): void;
  131306. }
  131307. declare var VRDisplay: {
  131308. prototype: VRDisplay;
  131309. new(): VRDisplay;
  131310. };
  131311. interface VRLayer {
  131312. leftBounds?: number[] | Float32Array | null;
  131313. rightBounds?: number[] | Float32Array | null;
  131314. source?: HTMLCanvasElement | null;
  131315. }
  131316. interface VRDisplayCapabilities {
  131317. readonly canPresent: boolean;
  131318. readonly hasExternalDisplay: boolean;
  131319. readonly hasOrientation: boolean;
  131320. readonly hasPosition: boolean;
  131321. readonly maxLayers: number;
  131322. }
  131323. interface VREyeParameters {
  131324. /** @deprecated */
  131325. readonly fieldOfView: VRFieldOfView;
  131326. readonly offset: Float32Array;
  131327. readonly renderHeight: number;
  131328. readonly renderWidth: number;
  131329. }
  131330. interface VRFieldOfView {
  131331. readonly downDegrees: number;
  131332. readonly leftDegrees: number;
  131333. readonly rightDegrees: number;
  131334. readonly upDegrees: number;
  131335. }
  131336. interface VRFrameData {
  131337. readonly leftProjectionMatrix: Float32Array;
  131338. readonly leftViewMatrix: Float32Array;
  131339. readonly pose: VRPose;
  131340. readonly rightProjectionMatrix: Float32Array;
  131341. readonly rightViewMatrix: Float32Array;
  131342. readonly timestamp: number;
  131343. }
  131344. interface VRPose {
  131345. readonly angularAcceleration: Float32Array | null;
  131346. readonly angularVelocity: Float32Array | null;
  131347. readonly linearAcceleration: Float32Array | null;
  131348. readonly linearVelocity: Float32Array | null;
  131349. readonly orientation: Float32Array | null;
  131350. readonly position: Float32Array | null;
  131351. readonly timestamp: number;
  131352. }
  131353. interface VRStageParameters {
  131354. sittingToStandingTransform?: Float32Array;
  131355. sizeX?: number;
  131356. sizeY?: number;
  131357. }
  131358. interface Navigator {
  131359. getVRDisplays(): Promise<VRDisplay[]>;
  131360. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  131361. }
  131362. interface Window {
  131363. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  131364. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  131365. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  131366. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131367. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  131368. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  131369. }
  131370. interface Gamepad {
  131371. readonly displayId: number;
  131372. }
  131373. type XRSessionMode =
  131374. | "inline"
  131375. | "immersive-vr"
  131376. | "immersive-ar";
  131377. type XRReferenceSpaceType =
  131378. | "viewer"
  131379. | "local"
  131380. | "local-floor"
  131381. | "bounded-floor"
  131382. | "unbounded";
  131383. type XREnvironmentBlendMode =
  131384. | "opaque"
  131385. | "additive"
  131386. | "alpha-blend";
  131387. type XRVisibilityState =
  131388. | "visible"
  131389. | "visible-blurred"
  131390. | "hidden";
  131391. type XRHandedness =
  131392. | "none"
  131393. | "left"
  131394. | "right";
  131395. type XRTargetRayMode =
  131396. | "gaze"
  131397. | "tracked-pointer"
  131398. | "screen";
  131399. type XREye =
  131400. | "none"
  131401. | "left"
  131402. | "right";
  131403. interface XRSpace extends EventTarget {
  131404. }
  131405. interface XRRenderState {
  131406. depthNear?: number;
  131407. depthFar?: number;
  131408. inlineVerticalFieldOfView?: number;
  131409. baseLayer?: XRWebGLLayer;
  131410. }
  131411. interface XRInputSource {
  131412. handedness: XRHandedness;
  131413. targetRayMode: XRTargetRayMode;
  131414. targetRaySpace: XRSpace;
  131415. gripSpace: XRSpace | undefined;
  131416. gamepad: Gamepad | undefined;
  131417. profiles: Array<string>;
  131418. }
  131419. interface XRSession {
  131420. addEventListener: Function;
  131421. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131422. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  131423. requestAnimationFrame: Function;
  131424. end(): Promise<void>;
  131425. renderState: XRRenderState;
  131426. inputSources: Array<XRInputSource>;
  131427. }
  131428. interface XRReferenceSpace extends XRSpace {
  131429. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  131430. onreset: any;
  131431. }
  131432. interface XRFrame {
  131433. session: XRSession;
  131434. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  131435. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  131436. }
  131437. interface XRViewerPose extends XRPose {
  131438. views: Array<XRView>;
  131439. }
  131440. interface XRPose {
  131441. transform: XRRigidTransform;
  131442. emulatedPosition: boolean;
  131443. }
  131444. declare var XRWebGLLayer: {
  131445. prototype: XRWebGLLayer;
  131446. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  131447. };
  131448. interface XRWebGLLayer {
  131449. framebuffer: WebGLFramebuffer;
  131450. framebufferWidth: number;
  131451. framebufferHeight: number;
  131452. getViewport: Function;
  131453. }
  131454. interface XRRigidTransform {
  131455. position: DOMPointReadOnly;
  131456. orientation: DOMPointReadOnly;
  131457. matrix: Float32Array;
  131458. inverse: XRRigidTransform;
  131459. }
  131460. interface XRView {
  131461. eye: XREye;
  131462. projectionMatrix: Float32Array;
  131463. transform: XRRigidTransform;
  131464. }
  131465. interface XRInputSourceChangeEvent {
  131466. session: XRSession;
  131467. removed: Array<XRInputSource>;
  131468. added: Array<XRInputSource>;
  131469. }